Skip to content

Commit

Permalink
rc.h.in: drop PREFIX macro, and add gentooprefix argument
Browse files Browse the repository at this point in the history
This will place the RC_SVCDIR to ${gentooprefix}/run/openrc. In Gentoo
Prefix, user may not have root permission to use /run/openrc, and can
only access directories inside ${gentooprefix}

RC_PREFIX is now always set to ${gentooprefix}

Signed-off-by: Yiyang Wu <[email protected]>
  • Loading branch information
littlewu2508 committed Jan 25, 2025
1 parent a10cf7c commit 2b885a4
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 9 deletions.
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
4 changes: 0 additions & 4 deletions src/librc/librc.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,6 @@ get_systype(void)
static const char *
detect_prefix(const char *systype)
{
#ifdef PREFIX
return RC_SYS_PREFIX;
#else
if (systype) {
if (strcmp(systype, RC_SYS_NONE) == 0)
return NULL;
Expand All @@ -246,7 +243,6 @@ detect_prefix(const char *systype)
}

return NULL;
#endif
}

static const char *
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
8 changes: 3 additions & 5 deletions src/librc/rc.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@
extern "C" {
#endif

#define RC_PREFIX "@PREFIX@"
#define RC_PREFIX "@GENTOOPREFIX@"
#define RC_SYSCONFDIR "@SYSCONFDIR@"
#define RC_LIBEXECDIR "@RC_LIBEXECDIR@"
#if defined(PREFIX)
#define RC_SVCDIR RC_LIBEXECDIR "/init.d"
#elif defined(__linux__) || (defined(__FreeBSD_kernel__) && \
#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
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

0 comments on commit 2b885a4

Please sign in to comment.