Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
sulincix authored Jul 11, 2024
2 parents 5f534ec + 917a703 commit 362fd5f
Show file tree
Hide file tree
Showing 14 changed files with 273 additions and 292 deletions.
4 changes: 2 additions & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
test_task:
freebsd_instance:
matrix:
image: freebsd-13-1-release-amd64
image: freebsd-12-4-release-amd64
image: freebsd-13-2-release-amd64
image: freebsd-13-3-release-amd64
env:
OS: FreeBSD
procfs_script: >
Expand Down
14 changes: 14 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ OpenRC NEWS
This file will contain a list of notable changes for each release. Note
the information in this file is in reverse order.

## OpenRC 0.54

This release drops the support for the split-usr build option.
Also, it drops the support for ncurses/termcap and uses ansi codes
directly for color support on terminals that support them.

## OpenRC 0.53

The names of cgroups for services started by OpenRC are now prefixed by
"openrc." This is done because some services, like docker, create their
own cgroups.

It is now possible to override the mount options used to mount the
cgroups filesystems.
## OpenRC 0.52

This release drops the "runscript" and "rc" binaries.
Expand Down
1 change: 0 additions & 1 deletion bash-completion/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
if get_option('bash-completions')
bash_completions = [
'openrc',
'openrc-service-script',
'rc-service',
'rc-status',
'rc-update',
Expand Down
29 changes: 0 additions & 29 deletions bash-completion/openrc-service-script

This file was deleted.

2 changes: 2 additions & 0 deletions conf.d/cgroups
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# override cgroup mount options
#cgroup_opts=nodev,noexec,nosuid
2 changes: 1 addition & 1 deletion init.d/cgroups.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

description="Mount the control groups."

cgroup_opts=nodev,noexec,nosuid
: "${cgroup_opts:="nodev,noexec,nosuid"}"

depend()
{
Expand Down
7 changes: 0 additions & 7 deletions man/einfo.3
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,6 @@ is true.
prefixes the string
.Fa prefix
to the above functions.
.Sh IMPLEMENTATION NOTES
einfo can optionally be linked against the
.Lb libtermcap
so that we can correctly query the connected console for our color and
cursor escape codes.
If not, then we have a hard coded list of terminals we know about that support
the commonly used codes for color and cursor position.
.Sh ENVIRONMENT
.Va EINFO_QUIET
when set to true makes the
Expand Down
20 changes: 2 additions & 18 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project('OpenRC', 'c',
version : '0.51',
version : '0.54',
license: 'BSD-2',
default_options : [
'c_std=c99',
Expand Down Expand Up @@ -83,16 +83,9 @@ else
pkg_prefix = option_pkg_prefix
endif

if get_option('split-usr') == 'auto'
split_usr = run_command('test', '-L', '/bin', check: false).returncode() != 0
else
split_usr = get_option('split-usr') == 'true'
endif

rootprefix = get_option('rootprefix')
rootprefix_default = fs.is_symlink('/bin') ? '/usr' : '/'
if rootprefix == ''
rootprefix = rootprefix_default
rootprefix = '/'
endif

bindir = rootprefix / get_option('bindir')
Expand Down Expand Up @@ -133,15 +126,6 @@ else
cc_selinux_flags = []
endif

termcap = get_option('termcap')
if termcap != ''
termcap_dep = dependency(termcap)
termcap_flags = '-DHAVE_TERMCAP'
else
termcap_dep = []
termcap_flags = []
endif

if get_option('buildtype').startswith('debug')
cc_debug_flags = ['-DRC_DEBUG']
else
Expand Down
7 changes: 0 additions & 7 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,7 @@ option('selinux', type : 'feature', value : 'auto',
description : 'enable SELinux support')
option('shell', type : 'string', value : '/bin/sh',
description : 'Default posix compatible shell')
option('split-usr', type : 'combo',
choices : ['auto', 'true', 'false'],
description : '''/bin, /sbin aren't symlinks into /usr''')
option('sysvinit', type : 'boolean', value : false,
description : 'enable SysVinit compatibility (linux only)')
option('termcap', type : 'combo',
choices :
[ '', 'ncurses', 'termcap' ],
description : 'the termcap library to use')
option('zsh-completions', type : 'boolean',
description : 'install zsh completions')
8 changes: 4 additions & 4 deletions sh/rc-cgroup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ cgroup_get_pids()
cgroup_pids=
cgroup_procs="$(cgroup2_find_path)"
if [ -n "${cgroup_procs}" ]; then
cgroup_procs="${cgroup_procs}/${RC_SVCNAME}/cgroup.procs"
cgroup_procs="${cgroup_procs}/openrc.${RC_SVCNAME}/cgroup.procs"
else
cgroup_procs="/sys/fs/cgroup/openrc/${RC_SVCNAME}/tasks"
fi
Expand Down Expand Up @@ -167,7 +167,7 @@ cgroup2_remove()
local cgroup_path rc_cgroup_path
cgroup_path="$(cgroup2_find_path)"
[ -z "${cgroup_path}" ] && return 0
rc_cgroup_path="${cgroup_path}/${RC_SVCNAME}"
rc_cgroup_path="${cgroup_path}/openrc.${RC_SVCNAME}"
[ ! -d "${rc_cgroup_path}" ] ||
[ ! -e "${rc_cgroup_path}"/cgroup.events ] &&
return 0
Expand All @@ -191,7 +191,7 @@ cgroup2_set_limits()
cgroup_path="$(cgroup2_find_path)"
[ -z "${cgroup_path}" ] && return 0
mountinfo -q "${cgroup_path}"|| return 0
rc_cgroup_path="${cgroup_path}/${RC_SVCNAME}"
rc_cgroup_path="${cgroup_path}/openrc.${RC_SVCNAME}"
[ ! -d "${rc_cgroup_path}" ] && mkdir "${rc_cgroup_path}"
[ -f "${rc_cgroup_path}"/cgroup.procs ] &&
printf 0 > "${rc_cgroup_path}"/cgroup.procs
Expand All @@ -210,7 +210,7 @@ cgroup2_kill_cgroup() {
local cgroup_path
cgroup_path="$(cgroup2_find_path)"
[ -z "${cgroup_path}" ] && return 1
rc_cgroup_path="${cgroup_path}/${RC_SVCNAME}"
rc_cgroup_path="${cgroup_path}/openrc.${RC_SVCNAME}"
if [ -f "${rc_cgroup_path}"/cgroup.kill ]; then
printf "%d" 1 > "${rc_cgroup_path}"/cgroup.kill
fi
Expand Down
87 changes: 20 additions & 67 deletions src/libeinfo/libeinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

/*
* Copyright (c) 2007-2015 The OpenRC Authors.
* Copyright (c) 2007-2024 The OpenRC Authors.
* See the Authors file at the top-level directory of this distribution and
* https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS
*
Expand All @@ -26,9 +26,6 @@
#include <string.h>
#include <strings.h>
#include <syslog.h>
#ifdef HAVE_TERMCAP
# include <termcap.h>
#endif
#include <unistd.h>

#include "einfo.h"
Expand All @@ -53,8 +50,7 @@
#define HILITE 6
#define BRACKET 4

/* We fallback to these escape codes if termcap isn't available
* like say /usr isn't mounted */
/* ANSI escape codes which mimic termcap */
#define AF "\033[3%dm"
#define CE "\033[K"
#define CH "\033[%dC"
Expand Down Expand Up @@ -97,13 +93,7 @@ static char *goto_column = NULL;
static const char *term = NULL;
static bool term_is_cons25 = false;

/* Termcap buffers and pointers
* Static buffers suck hard, but some termcap implementations require them */
#ifdef HAVE_TERMCAP
static char termcapbuf[2048];
static char tcapbuf[512];
#else
/* No curses support, so we hardcode a list of colour capable terms
/* Hardcoded list of colour capable terms
* Only terminals without "color" in the name need to be explicitly listed */
static const char *const color_terms[] = {
"Eterm",
Expand Down Expand Up @@ -142,9 +132,9 @@ static const char *const color_terms[] = {
"wsvt25",
"xterm",
"xterm-debian",
"xterm-kitty",
NULL
};
#endif

#ifndef HAVE_STRLCPY
static size_t
Expand Down Expand Up @@ -236,7 +226,6 @@ is_verbose(void)
}

/* Fake tgoto call - very crapy, but works for our needs */
#ifndef HAVE_TERMCAP
static char *
tgoto(const char *cap, int col, int line)
{
Expand Down Expand Up @@ -299,7 +288,6 @@ tgoto(const char *cap, int col, int line)
*p = '\0';
return buf;
}
#endif

static bool
colour_terminal(FILE * EINFO_RESTRICT f)
Expand All @@ -312,9 +300,6 @@ colour_terminal(FILE * EINFO_RESTRICT f)
const char *bold;
char tmp[100];
unsigned int i = 0;
#ifdef HAVE_TERMCAP
char *bp;
#endif

if (f && !isatty(fileno(f)))
return false;
Expand All @@ -336,65 +321,33 @@ colour_terminal(FILE * EINFO_RESTRICT f)
if (strcmp(term, "cons25") == 0)
term_is_cons25 = true;

#ifdef HAVE_TERMCAP
/* Check termcap to see if we can do colour or not */
if (tgetent(termcapbuf, term) == 1) {
bp = tcapbuf;
_af = tgetstr("AF", &bp);
_ce = tgetstr("ce", &bp);
_ch = tgetstr("ch", &bp);
/* Our ch use also works with RI .... for now */
if (!_ch)
_ch = tgetstr("RI", &bp);
_md = tgetstr("md", &bp);
_me = tgetstr("me", &bp);
_up = tgetstr("up", &bp);
}
if (strstr(term, "color"))
in_colour = 1;

/* Cheat here as vanilla BSD has the whole termcap info in /usr
* which is not available to us when we boot */
if (term_is_cons25 || strcmp(term, "wsvt25") == 0) {
#else
if (strstr(term, "color"))
while (color_terms[i] && in_colour != 1) {
if (strcmp(color_terms[i], term) == 0) {
in_colour = 1;

while (color_terms[i] && in_colour != 1) {
if (strcmp(color_terms[i], term) == 0) {
in_colour = 1;
}
i++;
}

if (in_colour != 1) {
in_colour = 0;
return false;
}
#endif
if (!_af)
_af = AF;
if (!_ce)
_ce = CE;
if (!_ch)
_ch = CH;
if (!_md)
_md = MD;
if (!_me)
_me = ME;
if (!_up)
_up = UP;
#ifdef HAVE_TERMCAP
i++;
}

if (!_af || !_ce || !_me || !_md || !_up) {
if (in_colour != 1) {
in_colour = 0;
return false;
}

/* Many termcap databases don't have ch or RI even though they
* do work */
if (!_af)
_af = AF;
if (!_ce)
_ce = CE;
if (!_ch)
_ch = CH;
#endif
if (!_md)
_md = MD;
if (!_me)
_me = ME;
if (!_up)
_up = UP;

/* Now setup our colours */
p = ebuffer;
Expand Down
2 changes: 0 additions & 2 deletions src/libeinfo/meson.build
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
libeinfo_version = '1'

libeinfo = library('einfo', ['libeinfo.c'],
c_args : termcap_flags,
include_directories : incdir,
dependencies : termcap_dep,
link_depends : 'einfo.map',
version : libeinfo_version,
install : true,
Expand Down
Loading

0 comments on commit 362fd5f

Please sign in to comment.