From e641b4384977011b93c3c2a90222d459bc4c5ca6 Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Mon, 2 Jul 2012 22:04:22 -0500 Subject: Bring Back prefix support We now have a team member who is interested in OpenRC on prefix, so I am bringing it back to the main tree. --- etc/rc.conf.FreeBSD | 1 + etc/rc.conf.Linux | 1 + etc/rc.conf.NetBSD | 1 + init.d/adjkerntz.in | 2 +- init.d/bootmisc.in | 2 +- init.d/consolefont.in | 2 +- init.d/devd.in | 2 +- init.d/devfs.in | 2 +- init.d/dumpon.in | 2 +- init.d/fsck.in | 2 +- init.d/hostid.in | 2 +- init.d/hostname.in | 2 +- init.d/hwclock.in | 2 +- init.d/keymaps.in | 2 +- init.d/killprocs.in | 5 +++++ init.d/localmount.in | 2 +- init.d/mixer.in | 2 +- init.d/modules.in | 2 +- init.d/mount-ro.in | 2 +- init.d/moused.in | 2 +- init.d/mtab.in | 1 + init.d/net.lo.in | 2 +- init.d/netmount.in | 2 +- init.d/network.in | 2 +- init.d/newsyslog.in | 1 + init.d/numlock.in | 2 +- init.d/pf.in | 2 +- init.d/powerd.in | 2 +- init.d/procfs.in | 2 +- init.d/rc-enabled.in | 1 + init.d/root.in | 2 +- init.d/savecore.in | 2 +- init.d/staticroute.in | 2 +- init.d/swap-blk.in | 2 +- init.d/swap.in | 2 +- init.d/swclock.in | 2 +- init.d/syscons.in | 2 +- init.d/sysctl.BSD.in | 1 + init.d/sysctl.Linux.in | 2 +- init.d/sysfs.in | 2 +- init.d/syslogd.in | 1 + init.d/termencoding.in | 2 +- init.d/ttys.in | 1 + init.d/urandom.in | 2 +- init.d/wscons.in | 1 + man/runscript.8 | 7 +++++-- runlevels/Makefile | 18 ++++++++++++++---- src/librc/librc.c | 6 ++++++ src/librc/rc.h.in | 1 + 49 files changed, 75 insertions(+), 40 deletions(-) diff --git a/etc/rc.conf.FreeBSD b/etc/rc.conf.FreeBSD index 92640e81..cb16b83a 100644 --- a/etc/rc.conf.FreeBSD +++ b/etc/rc.conf.FreeBSD @@ -4,6 +4,7 @@ # This is the subsystem type. Valid options on FreeBSD: # "" - nothing special # "jail" - FreeBSD jails +# "prefix" - Prefix # If this is commented out, automatic detection will be used. # # This should be set to the value representing the environment this file is diff --git a/etc/rc.conf.Linux b/etc/rc.conf.Linux index 6cc9bef1..909e6a94 100644 --- a/etc/rc.conf.Linux +++ b/etc/rc.conf.Linux @@ -5,6 +5,7 @@ # "" - nothing special # "lxc" - Linux Containers # "openvz" - Linux OpenVZ +# "prefix" - Prefix # "uml" - Usermode Linux # "vserver" - Linux vserver # "xen0" - Xen0 Domain diff --git a/etc/rc.conf.NetBSD b/etc/rc.conf.NetBSD index 633e2a14..43f8b886 100644 --- a/etc/rc.conf.NetBSD +++ b/etc/rc.conf.NetBSD @@ -3,6 +3,7 @@ # This is the subsystem type. Valid options on NetBSD: # "" - nothing special +# "prefix" - Prefix # "xen0" - Xen0 Domain # "xenU" - XenU Domain # If this is commented out, automatic detection will be used. diff --git a/init.d/adjkerntz.in b/init.d/adjkerntz.in index 21fc1df0..76ad175f 100644 --- a/init.d/adjkerntz.in +++ b/init.d/adjkerntz.in @@ -22,7 +22,7 @@ depend() [ "$clock" != "UTC" -a ! -e /etc/wall_cmos_clock ]; then need root fi - keyword -jail + keyword -jail -prefix } start() diff --git a/init.d/bootmisc.in b/init.d/bootmisc.in index 31448757..a2afbf9f 100644 --- a/init.d/bootmisc.in +++ b/init.d/bootmisc.in @@ -7,7 +7,7 @@ depend() need localmount before logger after clock sysctl - keyword -timeout + keyword -prefix -timeout } : ${wipe_tmp:=${WIPE_TMP:-yes}} diff --git a/init.d/consolefont.in b/init.d/consolefont.in index 53c43af2..66b780d1 100644 --- a/init.d/consolefont.in +++ b/init.d/consolefont.in @@ -8,7 +8,7 @@ depend() { need localmount termencoding after hotplug bootmisc - keyword -openvz -uml -vserver -xenu -lxc + keyword -openvz -prefix -uml -vserver -xenu -lxc } start() diff --git a/init.d/devd.in b/init.d/devd.in index 7943e0d0..b474b759 100644 --- a/init.d/devd.in +++ b/init.d/devd.in @@ -10,7 +10,7 @@ depend() { need localmount after bootmisc before net.lo0 - keyword -jail + keyword -jail -prefix } start_pre() { diff --git a/init.d/devfs.in b/init.d/devfs.in index ff43f1e6..6a41354f 100644 --- a/init.d/devfs.in +++ b/init.d/devfs.in @@ -6,7 +6,7 @@ description="Mount system critical filesystems in /dev." depend() { use dev - keyword -vserver + keyword -prefix -vserver } start() { diff --git a/init.d/dumpon.in b/init.d/dumpon.in index 282e2361..4450bf94 100644 --- a/init.d/dumpon.in +++ b/init.d/dumpon.in @@ -6,7 +6,7 @@ description="Configures a specific kernel dump device." depend() { need swap - keyword -jail + keyword -jail -prefix } start() { diff --git a/init.d/fsck.in b/init.d/fsck.in index 0e93d21a..fcc334c5 100644 --- a/init.d/fsck.in +++ b/init.d/fsck.in @@ -9,7 +9,7 @@ _IFS=" depend() { use dev clock modules - keyword -jail -openvz -timeout -vserver -lxc + keyword -jail -openvz -prefix -timeout -vserver -lxc } _abort() { diff --git a/init.d/hostid.in b/init.d/hostid.in index a028c904..b682b3de 100644 --- a/init.d/hostid.in +++ b/init.d/hostid.in @@ -9,7 +9,7 @@ depend() { use root before devd net - keyword -jail + keyword -jail -prefix } _set() diff --git a/init.d/hostname.in b/init.d/hostname.in index f5b6fc80..2b0ec810 100644 --- a/init.d/hostname.in +++ b/init.d/hostname.in @@ -5,7 +5,7 @@ description="Sets the hostname of the machine." depend() { - keyword -lxc + keyword -prefix -lxc } start() diff --git a/init.d/hwclock.in b/init.d/hwclock.in index de6e8699..eb44f62a 100644 --- a/init.d/hwclock.in +++ b/init.d/hwclock.in @@ -28,7 +28,7 @@ depend() else before * fi - keyword -openvz -uml -vserver -xenu -lxc + keyword -openvz -prefix -uml -vserver -xenu -lxc } setupopts() diff --git a/init.d/keymaps.in b/init.d/keymaps.in index 86aed3ea..a55a0e06 100644 --- a/init.d/keymaps.in +++ b/init.d/keymaps.in @@ -8,7 +8,7 @@ depend() { need localmount termencoding after bootmisc - keyword -openvz -uml -vserver -xenu -lxc + keyword -openvz -prefix -uml -vserver -xenu -lxc } start() diff --git a/init.d/killprocs.in b/init.d/killprocs.in index ea1e84b3..7f1cf917 100644 --- a/init.d/killprocs.in +++ b/init.d/killprocs.in @@ -4,6 +4,11 @@ description="Kill all processes so we can unmount disks cleanly." +depend() +{ + keyword -prefix +} + start() { ebegin "Terminating remaining processes" diff --git a/init.d/localmount.in b/init.d/localmount.in index c432a121..8e67c38a 100644 --- a/init.d/localmount.in +++ b/init.d/localmount.in @@ -9,7 +9,7 @@ depend() need fsck use lvm modules mtab after lvm modules - keyword -jail -openvz -vserver -lxc + keyword -jail -openvz -prefix -vserver -lxc } start() diff --git a/init.d/mixer.in b/init.d/mixer.in index 7163f860..a08aea13 100644 --- a/init.d/mixer.in +++ b/init.d/mixer.in @@ -7,7 +7,7 @@ extra_commands="restore" depend() { need localmount - keyword -jail + keyword -jail -prefix } restore() diff --git a/init.d/modules.in b/init.d/modules.in index 11006802..72f14e76 100644 --- a/init.d/modules.in +++ b/init.d/modules.in @@ -7,7 +7,7 @@ description="Loads a user defined list of kernel modules." depend() { use isapnp - keyword -openvz -vserver -lxc + keyword -openvz -prefix -vserver -lxc } start() diff --git a/init.d/mount-ro.in b/init.d/mount-ro.in index 369d5440..881bf846 100644 --- a/init.d/mount-ro.in +++ b/init.d/mount-ro.in @@ -7,7 +7,7 @@ description="Re-mount filesytems read-only for a clean reboot." depend() { need killprocs savecache - keyword -openvz -vserver -lxc + keyword -openvz -prefix -vserver -lxc } start() diff --git a/init.d/moused.in b/init.d/moused.in index 8ce8ffa9..cdcf36ad 100644 --- a/init.d/moused.in +++ b/init.d/moused.in @@ -16,7 +16,7 @@ depend() { need localmount after bootmisc - keyword -jail + keyword -jail -prefix } start() diff --git a/init.d/mtab.in b/init.d/mtab.in index 69b3b495..0be5adbc 100644 --- a/init.d/mtab.in +++ b/init.d/mtab.in @@ -7,6 +7,7 @@ description="Update /etc/mtab to match what the kernel knows about" depend() { need root + keyword -prefix } start() diff --git a/init.d/net.lo.in b/init.d/net.lo.in index 6bf49b5d..088398b1 100644 --- a/init.d/net.lo.in +++ b/init.d/net.lo.in @@ -23,7 +23,7 @@ depend() need sysfs fi after bootmisc - keyword -jail -vserver + keyword -jail -prefix -vserver case "${IFACE}" in lo|lo0) provide lo;; diff --git a/init.d/netmount.in b/init.d/netmount.in index cf5971c0..963ad26d 100644 --- a/init.d/netmount.in +++ b/init.d/netmount.in @@ -35,7 +35,7 @@ depend() need net $pmap use afc-client amd autofs openvpn use dns nfs nfsmount portmap rpcbind rpc.statd rpc.lockd - keyword -jail -vserver + keyword -jail -prefix -vserver } start() diff --git a/init.d/network.in b/init.d/network.in index 20d46f4a..f0403b4f 100644 --- a/init.d/network.in +++ b/init.d/network.in @@ -13,7 +13,7 @@ depend() need localmount after bootmisc provide net - keyword -jail -vserver + keyword -jail -prefix -vserver } uniqify() diff --git a/init.d/newsyslog.in b/init.d/newsyslog.in index 878bf4da..6cf72e65 100644 --- a/init.d/newsyslog.in +++ b/init.d/newsyslog.in @@ -7,6 +7,7 @@ required_files="/etc/newsyslog.conf" depend() { need localmount + keyword -prefix } start() diff --git a/init.d/numlock.in b/init.d/numlock.in index 7f795380..3cb8bee3 100644 --- a/init.d/numlock.in +++ b/init.d/numlock.in @@ -9,7 +9,7 @@ ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}} depend() { need localmount - keyword -openvz -vserver -lxc + keyword -openvz -prefix -vserver -lxc } _setleds() diff --git a/init.d/pf.in b/init.d/pf.in index 804c3a0b..1097ac85 100644 --- a/init.d/pf.in +++ b/init.d/pf.in @@ -11,7 +11,7 @@ extra_started_commands="reload" depend() { need localmount - keyword -jail + keyword -jail -prefix } start() diff --git a/init.d/powerd.in b/init.d/powerd.in index 17e53751..10ffeccb 100644 --- a/init.d/powerd.in +++ b/init.d/powerd.in @@ -12,7 +12,7 @@ depend() need localmount use logger after bootmisc - keyword -jail + keyword -jail -prefix } start_pre() diff --git a/init.d/procfs.in b/init.d/procfs.in index a167ed7e..992567e7 100644 --- a/init.d/procfs.in +++ b/init.d/procfs.in @@ -8,7 +8,7 @@ depend() { use modules devfs need localmount - keyword -openvz -vserver -lxc + keyword -openvz -prefix -vserver -lxc } start() diff --git a/init.d/rc-enabled.in b/init.d/rc-enabled.in index c2d38d79..9ba73b0a 100644 --- a/init.d/rc-enabled.in +++ b/init.d/rc-enabled.in @@ -7,6 +7,7 @@ depend() need localmount net after * before local + keyword -prefix } start() diff --git a/init.d/root.in b/init.d/root.in index fd95ab7b..c8ae4f12 100644 --- a/init.d/root.in +++ b/init.d/root.in @@ -7,7 +7,7 @@ description="Mount the root fs read/write" depend() { need fsck - keyword -jail -openvz -vserver -lxc + keyword -jail -openvz -prefix -vserver -lxc } start() diff --git a/init.d/savecore.in b/init.d/savecore.in index b04d1be9..c55a0ab6 100644 --- a/init.d/savecore.in +++ b/init.d/savecore.in @@ -8,7 +8,7 @@ depend() { need dumpon localmount before encswap - keyword -jail + keyword -jail -prefix } start() diff --git a/init.d/staticroute.in b/init.d/staticroute.in index 91b61a40..213dddf6 100644 --- a/init.d/staticroute.in +++ b/init.d/staticroute.in @@ -12,7 +12,7 @@ depend() { provide net use network - keyword -jail -vserver + keyword -jail -prefix -vserver } pre_flight_checks() diff --git a/init.d/swap-blk.in b/init.d/swap-blk.in index 6f28e217..a7862ee2 100644 --- a/init.d/swap-blk.in +++ b/init.d/swap-blk.in @@ -5,7 +5,7 @@ depend() { before fsck - keyword -jail + keyword -jail -prefix } start() diff --git a/init.d/swap.in b/init.d/swap.in index 9e8ddbd9..fa08b4d0 100644 --- a/init.d/swap.in +++ b/init.d/swap.in @@ -5,7 +5,7 @@ depend() { before localmount - keyword -jail -openvz -vserver -lxc + keyword -jail -openvz -prefix -vserver -lxc } start() diff --git a/init.d/swclock.in b/init.d/swclock.in index f10689b1..077f258d 100644 --- a/init.d/swclock.in +++ b/init.d/swclock.in @@ -8,7 +8,7 @@ depend() { before * provide clock - keyword -openvz -uml -vserver -xenu -lxc + keyword -openvz -prefix -uml -vserver -xenu -lxc } # swclock is an OpenRC built in diff --git a/init.d/syscons.in b/init.d/syscons.in index c49799a1..06669471 100644 --- a/init.d/syscons.in +++ b/init.d/syscons.in @@ -4,7 +4,7 @@ depend() { need localmount - keyword -jail + keyword -jail -prefix } start() { diff --git a/init.d/sysctl.BSD.in b/init.d/sysctl.BSD.in index fe69ab2e..c7d2028f 100644 --- a/init.d/sysctl.BSD.in +++ b/init.d/sysctl.BSD.in @@ -5,6 +5,7 @@ depend() { before bootmisc logger + keyword -prefix } start() diff --git a/init.d/sysctl.Linux.in b/init.d/sysctl.Linux.in index a64060f2..119f6ee9 100644 --- a/init.d/sysctl.Linux.in +++ b/init.d/sysctl.Linux.in @@ -5,7 +5,7 @@ depend() { before bootmisc logger - keyword -lxc -vserver + keyword -lxc -prefix -vserver } start() diff --git a/init.d/sysfs.in b/init.d/sysfs.in index 5bc5c717..a90dab24 100644 --- a/init.d/sysfs.in +++ b/init.d/sysfs.in @@ -6,7 +6,7 @@ description="Mount the sys filesystem." depend() { - keyword -vserver + keyword -prefix -vserver } mount_sys() diff --git a/init.d/syslogd.in b/init.d/syslogd.in index 809ac891..817afa1a 100644 --- a/init.d/syslogd.in +++ b/init.d/syslogd.in @@ -16,4 +16,5 @@ depend() use net newsyslog need localmount after bootmisc + keyword -prefix } diff --git a/init.d/termencoding.in b/init.d/termencoding.in index 0f243e20..a8a96e56 100644 --- a/init.d/termencoding.in +++ b/init.d/termencoding.in @@ -9,7 +9,7 @@ ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}} depend() { - keyword -lxc -openvz -uml -vserver -xenu + keyword -lxc -openvz -prefix -uml -vserver -xenu use root after bootmisc } diff --git a/init.d/ttys.in b/init.d/ttys.in index 2ac524b5..2adbe812 100644 --- a/init.d/ttys.in +++ b/init.d/ttys.in @@ -5,6 +5,7 @@ depend() { after fsck + keyword -prefix } start() diff --git a/init.d/urandom.in b/init.d/urandom.in index 8ee32517..bc48066b 100644 --- a/init.d/urandom.in +++ b/init.d/urandom.in @@ -8,7 +8,7 @@ description="Initializes the random number generator." depend() { need localmount - keyword -jail -openvz + keyword -jail -openvz -prefix } save_seed() diff --git a/init.d/wscons.in b/init.d/wscons.in index 9416b3b6..5d94eff1 100644 --- a/init.d/wscons.in +++ b/init.d/wscons.in @@ -5,6 +5,7 @@ depend() { need localmount + keyword -prefix } start() diff --git a/man/runscript.8 b/man/runscript.8 index 6d425e4a..ef55de35 100644 --- a/man/runscript.8 +++ b/man/runscript.8 @@ -180,6 +180,8 @@ in Same as -jail, but for Linux Resource Containers (LXC). .It Dv -openvz Same as -jail, but for OpenVZ systems. +.It Dv -prefix +Same as -jail, but for Prefix systems. .It Dv -uml Same as -jail, but for UML systems. .It Dv -vserver @@ -388,8 +390,9 @@ rc_provide_tap1="!net" # To put in in /etc/rc.conf you would do it like this rc_net_tap1_provide="!net" -# It's also possible to negate keywords. -rc_keyword="-keyword" +# It's also possible to negate keywords. This is mainly useful for prefix +# users testing OpenRC. +rc_keyword="!-prefix" .Ed .Sh EXAMPLES .Pp diff --git a/runlevels/Makefile b/runlevels/Makefile index 25fa029f..c42b307a 100644 --- a/runlevels/Makefile +++ b/runlevels/Makefile @@ -53,24 +53,34 @@ install: if ! test -d "${SYSINITDIR}"; then \ ${INSTALL} -d ${SYSINITDIR} || exit $$?; \ for x in ${SYSINIT}; do \ - ln -snf ${PREFIX}/etc/init.d/"$$x" ${SYSINITDIR}/"$$x" || exit $$?; \ - done \ + if test -n "${PREFIX}"; then \ + grep -q "keyword .*-prefix" ${INITDIR}/"$$x" && continue; \ + fi; \ + ln -snf ${PREFIX}/etc/init.d/"$$x" ${SYSINITDIR}/"$$x" || exit $$?; done \ fi if ! test -d "${BOOTDIR}"; then \ ${INSTALL} -d ${BOOTDIR} || exit $$?; \ for x in ${BOOT}; do \ + if test -n "${PREFIX}"; then \ + grep -q "keyword .*-prefix" ${INITDIR}/"$$x" && continue; \ + fi; \ ln -snf ${PREFIX}/etc/init.d/"$$x" ${BOOTDIR}/"$$x" || exit $$?; \ done \ fi if ! test -d "${DEFAULTDIR}"; then \ ${INSTALL} -d ${DEFAULTDIR} || exit $$?; \ for x in ${DEFAULT}; do \ - ln -snf ${PREFIX}/etc/init.d/"$$x" ${DEFAULTDIR}/"$$x" || exit $$?; \ - done \ + if test -n "${PREFIX}"; then \ + grep -q "keyword .*-prefix" ${INITDIR}/"$$x" && continue; \ + fi; \ + ln -snf ${PREFIX}/etc/init.d/"$$x" ${DEFAULTDIR}/"$$x" || exit $$?; done \ fi if ! test -d "${SHUTDOWNDIR}"; then \ ${INSTALL} -d ${SHUTDOWNDIR} || exit $$?; \ for x in ${SHUTDOWN}; do \ + if test -n "${PREFIX}"; then \ + grep -q "keyword .*-prefix" ${INITDIR}/"$$x" && continue; \ + fi; \ ln -snf ${PREFIX}/etc/init.d/"$$x" ${SHUTDOWNDIR}/"$$x" || exit $$?; done \ fi diff --git a/src/librc/librc.c b/src/librc/librc.c index ed601964..d82880fb 100644 --- a/src/librc/librc.c +++ b/src/librc/librc.c @@ -216,6 +216,7 @@ rc_sys_v2(void) } /* Now do detection */ __STRING_SWITCH(systype) + __STRING_CASE(RC_SYS_PREFIX) { return RC_SYS_PREFIX; } #ifdef __FreeBSD__ __STRING_CASE(RC_SYS_JAIL) { return RC_SYS_JAIL; } #endif /* __FreeBSD__ */ @@ -245,6 +246,10 @@ librc_hidden_def(rc_sys_v2) const char * rc_sys_v1(void) { +#ifdef PREFIX + return RC_SYS_PREFIX; +#else + #ifdef __FreeBSD__ int jailed = 0; size_t len = sizeof(jailed); @@ -281,6 +286,7 @@ rc_sys_v1(void) #endif return NULL; +#endif /* PREFIX */ } librc_hidden_def(rc_sys_v1) diff --git a/src/librc/rc.h.in b/src/librc/rc.h.in index 96926a5a..e4cb60dd 100644 --- a/src/librc/rc.h.in +++ b/src/librc/rc.h.in @@ -280,6 +280,7 @@ bool rc_service_daemons_crashed(const char *); #define RC_SYS_JAIL "JAIL" #define RC_SYS_OPENVZ "OPENVZ" #define RC_SYS_LXC "LXC" +#define RC_SYS_PREFIX "PREFIX" #define RC_SYS_UML "UML" #define RC_SYS_VSERVER "VSERVER" #define RC_SYS_XEN0 "XEN0" -- cgit v1.2.3