From c0fd1b49e49cec28c1f5a3a76f9db11c62e550dc Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Sat, 23 May 2009 20:38:12 +0100 Subject: Move non compiled libraries from /lib/rc to /libexec/rc OpenRC version is now stored as plaintext in /libexec/rc/version Plugins (cursplash, splashutils) will have to be re-compiled to pickup the new directories. State data needs to be moved from /lib/rc/init.d to /libexec/rc/init.d as well. --- Makefile | 6 ++++-- init.d/bootmisc.in | 2 +- init.d/consolefont.in | 12 ++++++------ init.d/keymaps.in | 6 +++--- init.d/localmount.in | 2 +- init.d/mount-ro.in | 2 +- init.d/net.lo.in | 2 +- init.d/netmount.in | 2 +- init.d/savecache.in | 8 ++++---- mk/git.mk | 8 ++++++++ mk/scripts.mk | 2 +- mk/sys.mk | 2 ++ net/Makefile | 2 +- net/ifwatchd.sh | 12 ++++++------ net/udhcpc.sh | 2 +- sh/Makefile | 7 +++---- sh/functions.sh.in | 6 +++--- sh/init-common-post.sh.in | 9 +++++---- sh/init-early.sh.Linux.in | 13 +++++++------ sh/init.sh.BSD.in | 4 ++-- sh/init.sh.Linux.in | 4 ++-- sh/rc-functions.sh.in | 10 +++++----- sh/runscript.sh.in | 2 +- src/librc/Makefile | 1 + src/librc/librc-depend.c | 9 +++++---- src/librc/rc.h.in | 5 +++-- src/rc/Makefile | 12 ++---------- src/rc/rc-misc.c | 8 +++++--- src/rc/rc.c | 4 ++-- src/rc/runscript.c | 6 +++--- src/rc/start-stop-daemon.c | 4 ++-- 31 files changed, 92 insertions(+), 82 deletions(-) create mode 100644 mk/git.mk diff --git a/Makefile b/Makefile index d9460e0..0cf32e2 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,9 @@ include ${MK}/sys.mk include ${MK}/os.mk include ${MK}/subdir.mk include ${MK}/dist.mk +include ${MK}/git.mk _installafter: - ${INSTALL} -d ${DESTDIR}/${PREFIX}/${RC_LIB}/init.d - ${INSTALL} -d ${DESTDIR}/${PREFIX}/${RC_LIB}/tmp + ${INSTALL} -d ${DESTDIR}/${LIBEXECDIR}/init.d + ${INSTALL} -d ${DESTDIR}/${LIBEXECDIR}/tmp + ${ECHO} "${VERSION}${GITVER}" > ${DESTDIR}/${LIBEXECDIR}/version diff --git a/init.d/bootmisc.in b/init.d/bootmisc.in index b2356c8..aa14a75 100644 --- a/init.d/bootmisc.in +++ b/init.d/bootmisc.in @@ -74,7 +74,7 @@ mkutmp() start() { # Remove any added console dirs - rm -rf "$RC_LIBDIR"/console + rm -rf "$RC_LIBEXECDIR"/console local logw=false runw=false # Ensure that our basic dirs exist diff --git a/init.d/consolefont.in b/init.d/consolefont.in index 5900ef7..ecd3666 100644 --- a/init.d/consolefont.in +++ b/init.d/consolefont.in @@ -52,17 +52,17 @@ start() eend $retval # Store the last font so we can use it ASAP on boot - if [ $retval -eq 0 -a -w "$RC_LIBDIR" ]; then - mkdir -p "$RC_LIBDIR"/console + if [ $retval -eq 0 -a -w "$RC_LIBEXECDIR" ]; then + mkdir -p "$RC_LIBEXECDIR"/console for font in /usr/share/consolefonts/"$consolefont".*; do : done - cp "$font" "$RC_LIBDIR"/console - echo "${font##*/}" >"$RC_LIBDIR"/console/font + cp "$font" "$RC_LIBEXECDIR"/console + echo "${font##*/}" >"$RC_LIBEXECDIR"/console/font if yesno ${unicode:-${UNICODE}}; then - echo "" > "$RC_LIBDIR"/console/unicode + echo "" > "$RC_LIBEXECDIR"/console/unicode else - rm -f "$RC_LIBDIR"/console/unicode + rm -f "$RC_LIBEXECDIR"/console/unicode fi fi diff --git a/init.d/keymaps.in b/init.d/keymaps.in index 1eff061..4af5f94 100644 --- a/init.d/keymaps.in +++ b/init.d/keymaps.in @@ -67,8 +67,8 @@ start() eend 0 # Save the keymapping for use immediately at boot - if [ -w "$RC_LIBDIR" ]; then - mkdir -p "$RC_LIBDIR"/console - dumpkeys >"$RC_LIBDIR"/console/keymap + if [ -w "$RC_LIBEXECDIR" ]; then + mkdir -p "$RC_LIBEXECDIR"/console + dumpkeys >"$RC_LIBEXECDIR"/console/keymap fi } diff --git a/init.d/localmount.in b/init.d/localmount.in index ff82ed4..0226822 100644 --- a/init.d/localmount.in +++ b/init.d/localmount.in @@ -52,7 +52,7 @@ stop() # Flush all pending disk writes now sync; sync - . "$RC_LIBDIR"/sh/rc-mount.sh + . "$RC_LIBEXECDIR"/sh/rc-mount.sh # Umount loopback devices einfo "Unmounting loopback devices" diff --git a/init.d/mount-ro.in b/init.d/mount-ro.in index 6b237c3..c6275bb 100644 --- a/init.d/mount-ro.in +++ b/init.d/mount-ro.in @@ -17,7 +17,7 @@ start() ebegin "Remounting remaining filesystems read-only" # We need the do_unmount function - . "$RC_LIBDIR"/sh/rc-mount.sh + . "$RC_LIBEXECDIR"/sh/rc-mount.sh eindent local m="/dev|/dev/.*|/proc|/proc.*|/sys|/sys/.*|${RC_SVCDIR}" x= fs= m="$m|/bin|/sbin|/lib|/libexec" diff --git a/init.d/net.lo.in b/init.d/net.lo.in index 845b32c..5c7f43a 100644 --- a/init.d/net.lo.in +++ b/init.d/net.lo.in @@ -2,7 +2,7 @@ # Copyright (c) 2007-2008 Roy Marples # All rights reserved. Released under the 2-clause BSD license. -MODULESDIR="${RC_LIBDIR}/net" +MODULESDIR="${RC_LIBEXECDIR}/net" MODULESLIST="${RC_SVCDIR}/nettree" _config_vars="config routes" diff --git a/init.d/netmount.in b/init.d/netmount.in index 1b88a27..39f542a 100644 --- a/init.d/netmount.in +++ b/init.d/netmount.in @@ -74,7 +74,7 @@ stop() local x= fs= ebegin "Unmounting network filesystems" - . "$RC_LIBDIR"/sh/rc-mount.sh + . "$RC_LIBEXECDIR"/sh/rc-mount.sh for x in $net_fs_list; do fs="$fs${fs:+,}$x" diff --git a/init.d/savecache.in b/init.d/savecache.in index ea011c1..799b8bc 100644 --- a/init.d/savecache.in +++ b/init.d/savecache.in @@ -14,9 +14,9 @@ start() fi fi ebegin "Saving dependency cache" - if [ ! -d "$RC_LIBDIR"/cache ]; then - rm -rf "$RC_LIBDIR"/cache - if ! mkdir "$RC_LIBDIR"/cache; then + if [ ! -d "$RC_LIBEXECDIR"/cache ]; then + rm -rf "$RC_LIBEXECDIR"/cache + if ! mkdir "$RC_LIBEXECDIR"/cache; then eend $? return $? fi @@ -26,7 +26,7 @@ start() [ -e "$RC_SVCDIR/$x" ] && save="$save $RC_SVCDIR/$x" done if [ -n "$save" ]; then - cp -p $save "$RC_LIBDIR"/cache 2>/dev/null + cp -p $save "$RC_LIBEXECDIR"/cache 2>/dev/null fi eend $? } diff --git a/mk/git.mk b/mk/git.mk new file mode 100644 index 0000000..54a98ef --- /dev/null +++ b/mk/git.mk @@ -0,0 +1,8 @@ +_GITVER_SH= if git rev-parse --short HEAD >/dev/null 2>&1; then \ + printf "."; \ + git rev-parse --short HEAD; \ + else \ + echo ""; \ + fi +_GITVER!= ${_GITVER_SH} +GITVER= ${_GITVER}$(shell ${_GITVER_SH}) diff --git a/mk/scripts.mk b/mk/scripts.mk index f311acf..bd7ec6b 100644 --- a/mk/scripts.mk +++ b/mk/scripts.mk @@ -12,7 +12,7 @@ _PKG_SED!= ${_PKG_SED_SH} _LCL_SED_SH= if test "${PREFIX}" = "${LOCAL_PREFIX}"; then echo "-e 's:@LOCAL_PREFIX@::g'"; else echo "-e 's:@LOCAL_PREFIX@:${LOCAL_PREFIX}:g'"; fi _LCL_SED!= ${_LCL_SED_SH} -SED_REPLACE= -e 's:@SHELL@:${SH}:g' -e 's:@LIB@:${LIBNAME}:g' -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g' -e 's:@PREFIX@:${PREFIX}:g' ${_PKG_SED}$(shell ${_PKG_SED_SH}) ${_LCL_SED}$(shell ${_LCL_SED_SH}) +SED_REPLACE= -e 's:@SHELL@:${SH}:g' -e 's:@LIB@:${LIBNAME}:g' -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g' -e 's:@LIBEXECDIR@:${LIBEXECDIR}:g' -e 's:@PREFIX@:${PREFIX}:g' ${_PKG_SED}$(shell ${_PKG_SED_SH}) ${_LCL_SED}$(shell ${_LCL_SED_SH}) # Tweak our shell scripts .SUFFIXES: .sh.in .in diff --git a/mk/sys.mk b/mk/sys.mk index 42a24fb..e22731b 100644 --- a/mk/sys.mk +++ b/mk/sys.mk @@ -35,6 +35,8 @@ LIBDIR?= ${UPREFIX}/${LIBNAME} LIBMODE?= 0444 SHLIBDIR?= ${PREFIX}/${LIBNAME} +LIBEXECDIR?= ${PREFIX}/libexec/rc + MANPREFIX?= ${UPREFIX}/share MANDIR?= ${MANPREFIX}/man MANMODE?= 0444 diff --git a/net/Makefile b/net/Makefile index bde659e..5cba7eb 100644 --- a/net/Makefile +++ b/net/Makefile @@ -1,4 +1,4 @@ -DIR= ${PREFIX}/${RC_LIB}/net +DIR= ${LIBEXECDIR}/net SRCS= ifconfig.sh.in INC= dhclient.sh dhcpcd.sh ifconfig.sh macchanger.sh macnet.sh \ ssidnet.sh system.sh wpa_supplicant.sh diff --git a/net/ifwatchd.sh b/net/ifwatchd.sh index e8c5e2b..d9da15e 100644 --- a/net/ifwatchd.sh +++ b/net/ifwatchd.sh @@ -33,8 +33,8 @@ ifwatchd_pre_start() # Start ifwatchd export IN_BACKGROUND=yes start-stop-daemon --start --exec /usr/sbin/ifwatchd \ - -- -c "${RC_LIBDIR}/sh/ifwatchd-carrier.sh" \ - -n "${RC_LIBDIR}/sh/ifwatchd-nocarrier.sh" "${IFACE}" + -- -c "${RC_LIBEXECDIR}/sh/ifwatchd-carrier.sh" \ + -n "${RC_LIBEXECDIR}/sh/ifwatchd-nocarrier.sh" "${IFACE}" unset IN_BACKGROUND eend "$?" || return 1 @@ -47,13 +47,13 @@ ifwatchd_stop() yesno ${IN_BACKGROUND} && return 0 start-stop-daemon --test --quiet --stop --exec /usr/sbin/ifwatchd \ - -- -c "${RC_LIBDIR}/sh/ifwatchd-carrier.sh" \ - -n "${RC_LIBDIR}/sh/ifwatchd-nocarrier.sh" "${IFACE}" \ + -- -c "${RC_LIBEXECDIR}/sh/ifwatchd-carrier.sh" \ + -n "${RC_LIBEXECDIR}/sh/ifwatchd-nocarrier.sh" "${IFACE}" \ || return 0 ebegin "Stopping ifwatchd on" "${IFACE}" start-stop-daemon --stop --exec /usr/sbin/ifwatchd \ - -- -c "${RC_LIBDIR}/sh/ifwatchd-carrier.sh" \ - -n "${RC_LIBDIR}/sh/ifwatchd-nocarrier.sh" "${IFACE}" + -- -c "${RC_LIBEXECDIR}/sh/ifwatchd-carrier.sh" \ + -n "${RC_LIBEXECDIR}/sh/ifwatchd-nocarrier.sh" "${IFACE}" eend $? } diff --git a/net/udhcpc.sh b/net/udhcpc.sh index 7efdf42..75cbf09 100644 --- a/net/udhcpc.sh +++ b/net/udhcpc.sh @@ -68,7 +68,7 @@ udhcpc_start() ;; esac - local script="${RC_LIBDIR}"/sh/udhcpc.sh + local script="${RC_LIBEXECDIR}"/sh/udhcpc.h [ -x "${script}" ] || script=/lib/rcscripts/sh/udhcpc.sh eval "${x}" "${args}" --interface="${IFACE}" --now \ diff --git a/sh/Makefile b/sh/Makefile index 7ee0433..73d4641 100644 --- a/sh/Makefile +++ b/sh/Makefile @@ -1,4 +1,4 @@ -DIR= ${PREFIX}/${RC_LIB}/sh +DIR= ${LIBEXECDIR}/sh SRCS= functions.sh.in gendepends.sh.in init-common-post.sh.in \ rc-functions.sh.in runscript.sh.in INC= init-common-post.sh rc-mount.sh functions.sh rc-functions.sh @@ -13,9 +13,8 @@ include ${MK}/scripts.mk _installafter: ${INSTALL} -d ${DESTDIR}/${INITDIR} - @# Put functions.sh into the init.d dir so 3rd party apps don't have to - @# be multilib aware - ln -snf ${PREFIX}/${RC_LIB}/sh/functions.sh ${DESTDIR}/${INITDIR} || exit $$? + @# Put functions.sh into init for backwards compat + ln -snf ${LIBEXECDIR}/sh/functions.sh ${DESTDIR}/${INITDIR} || exit $$? check test:: ./runtests.sh diff --git a/sh/functions.sh.in b/sh/functions.sh.in index 3f4a15a..da2e51a 100644 --- a/sh/functions.sh.in +++ b/sh/functions.sh.in @@ -47,7 +47,7 @@ _sanitize_path() local IFS=":" p= path= for p in $PATH; do case "$p" in - @PREFIX@/@LIB@/rc/bin|@PREFIX@/@LIB@/rc/sbin);; + @LIBEXECDIR@/bin|@LIBEXECDIR@/sbin);; @PREFIX@/bin|@PREFIX@/sbin|/usr/bin|/usr/sbin);; @PKG_PREFIX@/bin|@PKG_PREFIX@/sbin);; @LOCAL_PREFIX@/bin|@LOCAL_PREFIX@/sbin);; @@ -70,7 +70,7 @@ _PREFIX=@PREFIX@ _PKG_PREFIX=@PKG_PREFIX@ _LOCAL_PREFIX=@LOCAL_PREFIX@ _LOCAL_PREFIX=${_LOCAL_PREFIX:-/usr/local} -_PATH=@PREFIX@/@LIB@/rc/bin +_PATH=@LIBEXECDIR@/bin case "$_PREFIX" in "$_PKG_PREFIX"|"$_LOCAL_PREFIX") ;; *) _PATH="$_PATH:$_PREFIX/bin:$_PREFIX/sbin";; @@ -104,7 +104,7 @@ else # the last ecmd for _e in ebegin eend error errorn einfo einfon ewarn ewarnn ewend \ vebegin veend veinfo vewarn vewend; do - eval "$_e() { local _r; @PREFIX@/@LIB@/rc/bin/$_e \"\$@\"; _r=$?; \ + eval "$_e() { local _r; @LIBEXECDIR@/bin/$_e \"\$@\"; _r=$?; \ export EINFO_LASTCMD=$_e; return \$_r; }" done unset _e diff --git a/sh/init-common-post.sh.in b/sh/init-common-post.sh.in index 10ec954..0649cb3 100644 --- a/sh/init-common-post.sh.in +++ b/sh/init-common-post.sh.in @@ -1,10 +1,11 @@ -# Copyright (c) 2007-2008 Roy Marples +# Copyright (c) 2007-2009 Roy Marples # All rights reserved. Released under the 2-clause BSD license. # mount $RC_SVCDIR as something we can write to if it's not rw # On vservers, / is always rw at this point, so we need to clean out # the old service state data -: ${RC_SVCDIR:=/@LIB@/rc/init.d} +: ${RC_LIBEXECDIR:=@LIBEXECDIR@} +: ${RC_SVCDIR:=@LIBEXECDIR@/init.d} case "$(rc --sys)" in OPENVZ|VSERVER) rm -rf "$RC_SVCDIR"/*;; *) if mountinfo --quiet "$RC_SVCDIR"; then @@ -16,8 +17,8 @@ case "$(rc --sys)" in esac retval=$? -if [ -e "$RC_LIBDIR"/cache/deptree ]; then - cp -p "$RC_LIBDIR"/cache/* "$RC_SVCDIR" 2>/dev/null +if [ -e "$RC_LIBEXECDIR"/cache/deptree ]; then + cp -p "$RC_LIBEXECDIR"/cache/* "$RC_SVCDIR" 2>/dev/null fi echo sysinit >"$RC_SVCDIR"/softlevel diff --git a/sh/init-early.sh.Linux.in b/sh/init-early.sh.Linux.in index a533d52..e13af13 100644 --- a/sh/init-early.sh.Linux.in +++ b/sh/init-early.sh.Linux.in @@ -3,8 +3,9 @@ # All rights reserved. Released under the 2-clause BSD license. : ${CONSOLE:=/dev/console} +: ${RC_LIBEXECDIR:=@LIBEXECDIR@} -if [ -e "$RC_LIBDIR"/console/unicode ]; then +if [ -e "$RC_LIBEXECDIR"/console/unicode ]; then termencoding="%G" kmode="-u" else @@ -16,10 +17,10 @@ fi if [ -e /etc/runlevels/"$RC_DEFAULTLEVEL"/consolefont \ -o -e /etc/runlevels/"$RC_BOOTLEVEL"/consolefont ]; then printf "\033%s" "$termencoding" >"$CONSOLE" 2>/dev/null - if [ -r "$RC_LIBDIR"/console/font -a -x /bin/setfont ]; then - font="$(cat "$RC_LIBDIR"/console/font)" + if [ -r "$RC_LIBEXECDIR"/console/font -a -x /bin/setfont ]; then + font="$(cat "$RC_LIBEXECDIR"/console/font)" [ -c "$CONSOLE" ] && cons="-C $CONSOLE" - setfont $cons "$RC_LIBDIR"/console/"$font" 2>/dev/null + setfont $cons "$RC_LIBEXECDIR"/console/"$font" 2>/dev/null fi fi @@ -27,8 +28,8 @@ fi if [ -e /etc/runlevels/"$RC_DEFAULTLEVEL"/keymaps \ -o -e /etc/runlevels/"$RC_BOOTLEVEL"/keymaps ]; then kbd_mode $kmode -C "$CONSOLE" 2>/dev/null - if [ -r "$RC_LIBDIR"/console/keymap ]; then - loadkeys "$RC_LIBDIR"/console/keymap 2>/dev/null + if [ -r "$RC_LIBEXECDIR"/console/keymap ]; then + loadkeys "$RC_LIBEXECDIR"/console/keymap 2>/dev/null fi fi diff --git a/sh/init.sh.BSD.in b/sh/init.sh.BSD.in index 2472825..de3b436 100644 --- a/sh/init.sh.BSD.in +++ b/sh/init.sh.BSD.in @@ -21,7 +21,7 @@ mount_svcdir() fi } -. "$RC_LIBDIR"/sh/functions.sh +. "$RC_LIBEXECDIR"/sh/functions.sh [ -r /etc/rc.conf ] && . /etc/rc.conf # Disable devd until we need it @@ -29,4 +29,4 @@ if [ -z "$RC_SYS" -a "$RC_UNAME" = "FreeBSD" ]; then sysctl hw.bus.devctl_disable=1 >/dev/null fi -. "$RC_LIBDIR"/sh/init-common-post.sh +. "$RC_LIBEXECDIR"/sh/init-common-post.sh diff --git a/sh/init.sh.Linux.in b/sh/init.sh.Linux.in index b98a570..23be195 100644 --- a/sh/init.sh.Linux.in +++ b/sh/init.sh.Linux.in @@ -38,7 +38,7 @@ mount_svcdir() fi } -. /etc/init.d/functions.sh +. "$RC_LIBEXECDIR"/sh/functions.sh [ -r /etc/rc.conf ] && . /etc/rc.conf # By default VServer already has /proc mounted, but OpenVZ does not! @@ -68,4 +68,4 @@ if $mountproc; then eend $? fi -. "$RC_LIBDIR"/sh/init-common-post.sh +. "$RC_LIBEXECDIR"/sh/init-common-post.sh diff --git a/sh/rc-functions.sh.in b/sh/rc-functions.sh.in index 6e1ef01..2a656bc 100644 --- a/sh/rc-functions.sh.in +++ b/sh/rc-functions.sh.in @@ -4,7 +4,7 @@ has_addon() { - [ -e "$RC_LIBDIR/addons/$1.sh" -o -e /@LIB@/rcscripts/addons/"$1".sh ] + [ -e /@LIB@/rc/addons/"$1".sh -o -e /@LIB@/rcscripts/addons/"$1".sh ] } _addon_warn() @@ -17,9 +17,9 @@ _addon_warn() import_addon() { - if [ -e "$RC_LIBDIR/addons/$1.sh" ]; then + if [ -e /@LIB@/rc/addons/"$1".sh ]; then _addon_warn - . "$RC_LIBDIR/addons/$1.sh" + . /@LIB@/rc/addons/"$1".sh elif [ -e /@LIB@/rcscripts/addons/"$1".sh ]; then _addon_warn . /@LIB@/rcscripts/addons/"$1".sh @@ -86,6 +86,6 @@ get_bootparam() # Add our sbin to $PATH case "$PATH" in - "$RC_LIBDIR"/sbin|"$RC_LIBDIR"/sbin:*);; - *) export PATH="$RC_LIBDIR/sbin:$PATH";; + "$RC_LIBEXECDIR"/sbin|"$RC_LIBEXECDIR"/sbin:*);; + *) export PATH="$RC_LIBEXECDIR/sbin:$PATH";; esac diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in index a8172dc..f39ed0a 100644 --- a/sh/runscript.sh.in +++ b/sh/runscript.sh.in @@ -5,7 +5,7 @@ # All rights reserved. Released under the 2-clause BSD license. . @SYSCONFDIR@/init.d/functions.sh -. "$RC_LIBDIR"/sh/rc-functions.sh +. @LIBEXECDIR@/sh/rc-functions.sh # Support LiveCD foo if [ -r /sbin/livecd-functions.sh ]; then diff --git a/src/librc/Makefile b/src/librc/Makefile index 902b14e..d3f9cc4 100644 --- a/src/librc/Makefile +++ b/src/librc/Makefile @@ -18,6 +18,7 @@ include ${MK}/debug.mk SED_CMD= -e 's:@PREFIX@:${PREFIX}:g' SED_CMD+= -e 's:@LIB@:${LIBNAME}:g' SED_CMD+= -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g' +SED_CMD+= -e 's:@LIBEXECDIR@:${LIBEXECDIR}:g' _PKG_PREFIX_SH= if test -n "${PKG_PREFIX}" && test "${PKG_PREFIX}" != "/" && test "${PKG_PREFIX}" != "${PREFIX}"; then \ echo "-e 's:@PKG_PREFIX@:${PKG_PREFIX}:g'"; \ else \ diff --git a/src/librc/librc-depend.c b/src/librc/librc-depend.c index 36d8782..97421fa 100644 --- a/src/librc/librc-depend.c +++ b/src/librc/librc-depend.c @@ -31,7 +31,7 @@ #include "librc.h" -#define GENDEP RC_LIBDIR "/sh/gendepends.sh" +#define GENDEP RC_LIBEXECDIR "/sh/gendepends.sh" #define RC_DEPCONFIG RC_SVCDIR "/depconfig" @@ -647,6 +647,7 @@ static const DEPPAIR deppairs[] = { static const char *const depdirs[] = { + RC_SVCDIR, RC_SVCDIR "/starting", RC_SVCDIR "/started", RC_SVCDIR "/stopping", @@ -742,10 +743,10 @@ rc_deptree_update(void) bool retval = true; const char *sys = rc_sys(); - /* Some init scripts need RC_LIBDIR to source stuff + /* Some init scripts need RC_LIBEXECDIR to source stuff Ideally we should be setting our full env instead */ - if (!getenv("RC_LIBDIR")) - setenv("RC_LIBDIR", RC_LIBDIR, 0); + if (!getenv("RC_LIBEXECDIR")) + setenv("RC_LIBEXECDIR", RC_LIBEXECDIR, 0); /* Phase 1 - source all init scripts and print dependencies */ if (!(fp = popen(GENDEP, "r"))) diff --git a/src/librc/rc.h.in b/src/librc/rc.h.in index cb5258c..89ebfed 100644 --- a/src/librc/rc.h.in +++ b/src/librc/rc.h.in @@ -36,11 +36,12 @@ __BEGIN_DECLS #define RC_SYSCONFDIR "@SYSCONFDIR@" #define RC_LIBDIR "@PREFIX@/@LIB@/rc" -#define RC_SVCDIR RC_LIBDIR "/init.d" -#define RC_PLUGINDIR RC_LIBDIR "/plugins" +#define RC_LIBEXECDIR "@LIBEXECDIR@" +#define RC_SVCDIR RC_LIBEXECDIR "/init.d" #define RC_RUNLEVELDIR RC_SYSCONFDIR "/runlevels" #define RC_INITDIR RC_SYSCONFDIR "/init.d" #define RC_CONFDIR RC_SYSCONFDIR "/conf.d" +#define RC_PLUGINDIR RC_LIBDIR "/plugins" /* PKG_PREFIX is where packages are installed if different from the base OS * On Gentoo this is normally unset, on FreeBSD /usr/local and on NetBSD diff --git a/src/rc/Makefile b/src/rc/Makefile index 378f8e9..b5fc189 100644 --- a/src/rc/Makefile +++ b/src/rc/Makefile @@ -8,7 +8,7 @@ CLEANFILES= version.h BINDIR= ${PREFIX}/bin SBINDIR= ${PREFIX}/sbin -LINKDIR= ${PREFIX}/${LIBNAME}/${PROG} +LINKDIR= ${LIBEXECDIR} BINLINKS= rc-status SBINLINKS= rc-service rc-update runscript start-stop-daemon @@ -37,21 +37,13 @@ LDADD+= -lutil -lrc -leinfo MK= ../../mk include ${MK}/debug.mk include ${MK}/prog.mk +include ${MK}/git.mk include ${MK}/cc.mk include ${MK}/${MKTERMCAP}.mk LDADD+= ${LIBDL} ${LIBKVM} include ${MK}/${MKPAM}.mk -_GITVER_SH= if git rev-parse --short HEAD >/dev/null 2>&1; then \ - printf "."; \ - git rev-parse --short HEAD; \ - else \ - echo ""; \ - fi -_GITVER!= ${_GITVER_SH} -GITVER= ${_GITVER}$(shell ${_GITVER_SH}) - ${SRCS}: version.h version.h: sed -n -e 's/^VERSION=[[:space:]]*\([^[:space:]]*\).*/#define VERSION "\1${GITVER}\"/p' ../../Makefile > version.h diff --git a/src/rc/rc-misc.c b/src/rc/rc-misc.c index 1cc3dd4..0239f9d 100644 --- a/src/rc/rc-misc.c +++ b/src/rc/rc-misc.c @@ -50,14 +50,15 @@ #include "einfo.h" #include "rc.h" #include "rc-misc.h" +#include "version.h" #define PROFILE_ENV RC_SYSCONFDIR "/profile.env" -#define SYS_WHITELIST RC_LIBDIR "/conf.d/env_whitelist" +#define SYS_WHITELIST RC_LIBEXECDIR "/conf.d/env_whitelist" #define USR_WHITELIST RC_SYSCONFDIR "/conf.d/env_whitelist" #define RC_CONF RC_SYSCONFDIR "/rc.conf" #define RC_CONF_OLD RC_SYSCONFDIR "/conf.d/rc" -#define PATH_PREFIX RC_LIBDIR "/bin:/bin:/sbin:/usr/bin:/usr/sbin" +#define PATH_PREFIX RC_LIBEXECDIR "/bin:/bin:/sbin:/usr/bin:/usr/sbin" static RC_STRINGLIST *rc_conf = NULL; @@ -221,7 +222,8 @@ env_config(void) free(e); } - setenv("RC_LIBDIR", RC_LIBDIR, 1); + setenv("RC_VERSION", VERSION, 1); + setenv("RC_LIBEXECDIR", RC_LIBEXECDIR, 1); setenv("RC_SVCDIR", RC_SVCDIR, 1); setenv("RC_TMPDIR", RC_SVCDIR "/tmp", 1); setenv("RC_BOOTLEVEL", RC_LEVEL_BOOT, 1); diff --git a/src/rc/rc.c b/src/rc/rc.c index 8e40e1d..915dc18 100644 --- a/src/rc/rc.c +++ b/src/rc/rc.c @@ -72,8 +72,8 @@ const char rc_copyright[] = "Copyright (c) 2007-2008 Roy Marples"; #include "version.h" -#define INITSH RC_LIBDIR "/sh/init.sh" -#define INITEARLYSH RC_LIBDIR "/sh/init-early.sh" +#define INITSH RC_LIBEXECDIR "/sh/init.sh" +#define INITEARLYSH RC_LIBEXECDIR "/sh/init-early.sh" #define SHUTDOWN "/sbin/shutdown" #define SULOGIN "/sbin/sulogin" diff --git a/src/rc/runscript.c b/src/rc/runscript.c index c82e55f..44da58c 100644 --- a/src/rc/runscript.c +++ b/src/rc/runscript.c @@ -398,10 +398,10 @@ svc_exec(const char *arg1, const char *arg2) service, strerror(errno)); _exit(EXIT_FAILURE); } else { - execl(RC_LIBDIR "/sh/runscript.sh", - RC_LIBDIR "/sh/runscript.sh", + execl(RC_LIBEXECDIR "/sh/runscript.sh", + RC_LIBEXECDIR "/sh/runscript.sh", service, arg1, arg2, (char *) NULL); - eerror("%s: exec `" RC_LIBDIR "/sh/runscript.sh': %s", + eerror("%s: exec `" RC_LIBEXECDIR "/sh/runscript.sh': %s", service, strerror(errno)); _exit(EXIT_FAILURE); } diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c index bede39b..58bc23e 100644 --- a/src/rc/start-stop-daemon.c +++ b/src/rc/start-stop-daemon.c @@ -1188,8 +1188,8 @@ start_stop_daemon(int argc, char **argv) while (*p == ':') p++; } - if (strcmp(token, RC_LIBDIR "/bin") != 0 && - strcmp(token, RC_LIBDIR "/sbin") != 0) + if (strcmp(token, RC_LIBEXECDIR "/bin") != 0 && + strcmp(token, RC_LIBEXECDIR "/sbin") != 0) { len = strlen(token); if (np != newpath) -- cgit v1.2.3