From 5092595835461e889fbac14d4cfc6c06b5f55019 Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Sun, 9 Sep 2012 22:22:15 -0500 Subject: add RC_PREFIX environment variable This will be used by init scripts which want to be able to run in a Gentoo Prefix installation. RC_PREFIX will contain the prefix offset. --- man/runscript.8 | 3 +++ src/librc/rc.h.in | 1 + src/rc/rc-misc.c | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/man/runscript.8 b/man/runscript.8 index ef55de35..b87f8ef3 100644 --- a/man/runscript.8 +++ b/man/runscript.8 @@ -352,6 +352,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 undefined. .It Va RC_UNAME The result of `uname -s`. .El diff --git a/src/librc/rc.h.in b/src/librc/rc.h.in index e4cb60dd..32dbef08 100644 --- a/src/librc/rc.h.in +++ b/src/librc/rc.h.in @@ -33,6 +33,7 @@ __BEGIN_DECLS +#define RC_PREFIX "@PREFIX@" #define RC_SYSCONFDIR "@SYSCONFDIR@" #define RC_LIBDIR "@PREFIX@/@LIB@/rc" #define RC_LIBEXECDIR "@LIBEXECDIR@" diff --git a/src/rc/rc-misc.c b/src/rc/rc-misc.c index 27397d71..e8f6ca6e 100644 --- a/src/rc/rc-misc.c +++ b/src/rc/rc-misc.c @@ -191,6 +191,10 @@ env_config(void) if (sys) setenv("RC_SYS", sys, 1); +#ifdef PREFIX + setenv("RC_PREFIX", RC_PREFIX, 1); +#endif + /* 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 */ -- cgit v1.2.3