Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions man/openrc-run.8
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,9 @@ Default runlevel chosen. Default is default.
.It Va RC_SYS
A special variable to describe the system more.
Possible values are OPENVZ, XENU, XEN0, UML and VSERVER.
.It Va RC_PREFIX
In a Gentoo Prefix installation, this variable contains the prefix
offset. Otherwise it is an empty string.
.It Va RC_UNAME
The result of `uname -s`.
.It Va RC_CMD
Expand Down
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ project('OpenRC', 'c',
'c_std=c99',
'prefix=/usr',
'sbindir=/sbin',
'gentooprefix=',
'warning_level=3',
],
meson_version : '>=0.62.0'
Expand Down
2 changes: 2 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ option('pkg_prefix', type : 'string',
description : 'default location where packages are installed')
option('pkgconfig', type : 'boolean',
description : 'build PKGConfig files')
option('gentooprefix', type : 'string',
description : 'the Gentoo prefix')
option('selinux', type : 'feature', value : 'auto',
description : 'enable SELinux support')
option('shell', type : 'string', value : '/bin/sh',
Expand Down
20 changes: 18 additions & 2 deletions src/librc/librc.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,19 @@ get_systype(void)
return systype;
}

static const char *
detect_prefix(const char *systype)
{
if (systype) {
if (strcmp(systype, RC_SYS_NONE) == 0)
return NULL;
if (strcmp(systype, RC_SYS_PREFIX) == 0)
return RC_SYS_PREFIX;
}

return NULL;
}

static const char *
detect_container(const char *systype RC_UNUSED)
{
Expand Down Expand Up @@ -349,9 +362,12 @@ rc_sys(void)
const char *sys;

systype = get_systype();
sys = detect_container(systype);
sys = detect_prefix(systype);
if (!sys) {
sys = detect_vm(systype);
sys = detect_container(systype);
if (!sys) {
sys = detect_vm(systype);
}
}

return sys;
Expand Down
1 change: 1 addition & 0 deletions src/librc/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ rc_h_conf_data.set('RC_PLUGINDIR', pluginsdir)
rc_h_conf_data.set('LOCAL_PREFIX', local_prefix)
rc_h_conf_data.set('PKG_PREFIX', pkg_prefix)
rc_h_conf_data.set('SYSCONFDIR', get_option('sysconfdir'))
rc_h_conf_data.set('GENTOOPREFIX', get_option('gentooprefix'))

librc_version = '1'

Expand Down
4 changes: 3 additions & 1 deletion src/librc/rc.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
extern "C" {
#endif

#define RC_PREFIX "@GENTOOPREFIX@"
#define RC_SYSCONFDIR "@SYSCONFDIR@"
#define RC_LIBEXECDIR "@RC_LIBEXECDIR@"
#if defined(__linux__) || (defined(__FreeBSD_kernel__) && \
defined(__GLIBC__)) || defined(__GNU__)
#define RC_SVCDIR "/run/openrc"
#define RC_SVCDIR RC_PREFIX "/run/openrc"
#else
#define RC_SVCDIR RC_LIBEXECDIR "/init.d"
#endif
Expand Down Expand Up @@ -353,6 +354,7 @@ bool rc_service_daemons_crashed(const char *);
#define RC_SYS_NONE ""
#define RC_SYS_OPENVZ "OPENVZ"
#define RC_SYS_LXC "LXC"
#define RC_SYS_PREFIX "PREFIX"
#define RC_SYS_RKT "RKT"
#define RC_SYS_SYSTEMD_NSPAWN "SYSTEMD-NSPAWN"
#define RC_SYS_UML "UML"
Expand Down
2 changes: 2 additions & 0 deletions src/shared/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ env_config(void)
if (sys)
setenv("RC_SYS", sys, 1);

setenv("RC_PREFIX", RC_PREFIX, 1);

/* Some scripts may need to take a different code path if
Linux/FreeBSD, etc
To save on calling uname, we store it in an environment variable */
Expand Down