Skip to content

Commit 2b885a4

Browse files
committed
rc.h.in: drop PREFIX macro, and add gentooprefix argument
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]>
1 parent a10cf7c commit 2b885a4

File tree

7 files changed

+12
-9
lines changed

7 files changed

+12
-9
lines changed

man/openrc-run.8

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,9 @@ Default runlevel chosen. Default is default.
563563
.It Va RC_SYS
564564
A special variable to describe the system more.
565565
Possible values are OPENVZ, XENU, XEN0, UML and VSERVER.
566+
.It Va RC_PREFIX
567+
In a Gentoo Prefix installation, this variable contains the prefix
568+
offset. Otherwise it is an empty string.
566569
.It Va RC_UNAME
567570
The result of `uname -s`.
568571
.It Va RC_CMD

meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ project('OpenRC', 'c',
66
'c_std=c99',
77
'prefix=/usr',
88
'sbindir=/sbin',
9+
'gentooprefix=',
910
'warning_level=3',
1011
],
1112
meson_version : '>=0.62.0'

meson_options.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ option('pkg_prefix', type : 'string',
1818
description : 'default location where packages are installed')
1919
option('pkgconfig', type : 'boolean',
2020
description : 'build PKGConfig files')
21+
option('gentooprefix', type : 'string',
22+
description : 'the Gentoo prefix')
2123
option('selinux', type : 'feature', value : 'auto',
2224
description : 'enable SELinux support')
2325
option('shell', type : 'string', value : '/bin/sh',

src/librc/librc.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,6 @@ get_systype(void)
235235
static const char *
236236
detect_prefix(const char *systype)
237237
{
238-
#ifdef PREFIX
239-
return RC_SYS_PREFIX;
240-
#else
241238
if (systype) {
242239
if (strcmp(systype, RC_SYS_NONE) == 0)
243240
return NULL;
@@ -246,7 +243,6 @@ detect_prefix(const char *systype)
246243
}
247244

248245
return NULL;
249-
#endif
250246
}
251247

252248
static const char *

src/librc/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ rc_h_conf_data.set('RC_PLUGINDIR', pluginsdir)
44
rc_h_conf_data.set('LOCAL_PREFIX', local_prefix)
55
rc_h_conf_data.set('PKG_PREFIX', pkg_prefix)
66
rc_h_conf_data.set('SYSCONFDIR', get_option('sysconfdir'))
7+
rc_h_conf_data.set('GENTOOPREFIX', get_option('gentooprefix'))
78

89
librc_version = '1'
910

src/librc/rc.h.in

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@
2222
extern "C" {
2323
#endif
2424

25-
#define RC_PREFIX "@PREFIX@"
25+
#define RC_PREFIX "@GENTOOPREFIX@"
2626
#define RC_SYSCONFDIR "@SYSCONFDIR@"
2727
#define RC_LIBEXECDIR "@RC_LIBEXECDIR@"
28-
#if defined(PREFIX)
29-
#define RC_SVCDIR RC_LIBEXECDIR "/init.d"
30-
#elif defined(__linux__) || (defined(__FreeBSD_kernel__) && \
28+
#if defined(__linux__) || (defined(__FreeBSD_kernel__) && \
3129
defined(__GLIBC__)) || defined(__GNU__)
32-
#define RC_SVCDIR "/run/openrc"
30+
#define RC_SVCDIR RC_PREFIX "/run/openrc"
3331
#else
3432
#define RC_SVCDIR RC_LIBEXECDIR "/init.d"
3533
#endif

src/shared/misc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ env_config(void)
215215
if (sys)
216216
setenv("RC_SYS", sys, 1);
217217

218+
setenv("RC_PREFIX", RC_PREFIX, 1);
219+
218220
/* Some scripts may need to take a different code path if
219221
Linux/FreeBSD, etc
220222
To save on calling uname, we store it in an environment variable */

0 commit comments

Comments
 (0)