aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-02-28 11:08:49 +0000
committerRoy Marples <roy@marples.name>2008-02-28 11:08:49 +0000
commitf092045650faad778d25d000d80b3128664d2e2a (patch)
tree89188e92a4d01423ee59e33e5eaf5355fa14d103
parentaabf3976db5ffb41f8f8bbd47f5015b4158e095a (diff)
Support the use of PREFIX and PKG_PREFIX.
-rw-r--r--README7
-rw-r--r--mk/os.mk8
-rw-r--r--mk/scripts.mk18
-rw-r--r--mk/sys.mk15
-rw-r--r--sh/Makefile4
-rw-r--r--sh/functions.sh.in4
-rw-r--r--sh/rc-functions.sh.in4
-rw-r--r--src/includes/rc-misc.h25
-rw-r--r--src/libeinfo/Makefile2
-rw-r--r--src/librc/Makefile2
-rw-r--r--src/librc/librc-depend.c8
-rw-r--r--src/librc/librc.c12
-rw-r--r--src/rc/Makefile23
13 files changed, 82 insertions, 50 deletions
diff --git a/README b/README
index 41e4beb8..c0f5b244 100644
--- a/README
+++ b/README
@@ -13,6 +13,8 @@ DESTDIR=/tmp/openrc-image
MKPAM=pam
MKTERMCAP=ncurses
MKTERMCAP=termcap
+PKG_PREFIX=/usr/pkg
+PREFIX=/usr/local
We don't support building a static OpenRC with PAM.
You may need to use PROGLDFLAGS=-Wl,-Bstatic on glibc instead of just -static.
@@ -20,6 +22,9 @@ You may need to use PROGLDFLAGS=-Wl,-Bstatic on glibc instead of just -static.
You can also brand OpenRC if you so wish like so
BRANDING=\"Gentoo/$(uname -s)\"
+PKG_PREFIX should be set to where packages install to by default.
+PREFIX should be set when OpenRC is not installed to /.
+
If any of the following files exist then we do not overwrite them
/etc/devd.conf
/etc/rc
@@ -40,7 +45,6 @@ tweaking on a per distro basis. They are also non essential to the operation
of the system.
-
Reporting Bugs
-------------
If you installed OpenRC from your chosen distribution, you should report
@@ -50,7 +54,6 @@ then you should reports bugs to http://bugs.gentoo.org.
Otherwise, you can report them directly to me at http://bugs.marples.name
-
History - by Roy Marples
------------------------
I became a Gentoo/Linux developer in 2004 and wrote the modular network
diff --git a/mk/os.mk b/mk/os.mk
index c99f8b6e..e4f3c76f 100644
--- a/mk/os.mk
+++ b/mk/os.mk
@@ -29,3 +29,11 @@ LIBDL?= ${_LIBDL}$(shell ${_LIBDL_SH})
_LIBKVM_SH= case `uname -s` in *BSD) echo "-lkvm";; *) echo;; esac
_LIBKVM!= ${_LIBKVM_SH}
LIBKVM?= ${_LIBKVM}$(shell ${_LIBKVM_SH})
+
+_PREFIX_SH= if test -n "${PREFIX}" && test "${PREFIX}" != "/"; then echo "-DPREFIX=\\\"${PREFIX}\\\""; else echo ""; fi
+_PREFIX!= ${_PREFIX_SH}
+CFLAGS+= ${_PREFIX}$(shell ${_PREFIX_SH})
+
+_PKG_PREFIX_SH= if test -n "${PKG_PREFIX}" && test "${PKG_PREFIX}" != "/"; then echo "-DPKG_PREFIX=\\\"${PKG_PREFIX}\\\""; else echo ""; fi
+_PKG_PREFIX!= ${_PKG_PREFIX_SH}
+CFLAGS+= ${_PKG_PREFIX}$(shell ${_PKG_PREFIX_SH})
diff --git a/mk/scripts.mk b/mk/scripts.mk
index 114d5e2b..561545de 100644
--- a/mk/scripts.mk
+++ b/mk/scripts.mk
@@ -16,24 +16,24 @@ include ${MK}/os.mk
# Tweak our shell scripts
.SUFFIXES: .sh.in
.sh.in.sh:
- sed -e 's:@SHELL@:${SH}:g' -e 's:@LIB@:${LIBNAME}:g' $< > $@
+ sed -e 's:@SHELL@:${SH}:g' -e 's:@LIB@:${LIBNAME}:g' -e 's:@PREFIX@:${PREFIX}:g' -e 's:@PKG_PREFIX@:${PKG_PREFIX}:g' $< > $@
all: ${OBJS}
realinstall: ${BIN} ${CONF} ${CONF_APPEND}
- if test -n "${DIR}"; then ${INSTALL} -d ${DESTDIR}${DIR} || exit $$?; fi
- if test -n "${BIN}"; then ${INSTALL} -m ${BINMODE} ${BIN} ${DESTDIR}${DIR} || exit $$?; fi
- if test -n "${INC}"; then ${INSTALL} -m ${INCMODE} ${INC} ${DESTDIR}${DIR} || exit $$?; fi
+ if test -n "${DIR}"; then ${INSTALL} -d ${DESTDIR}/${PREFIX}${DIR} || exit $$?; fi
+ if test -n "${BIN}"; then ${INSTALL} -m ${BINMODE} ${BIN} ${DESTDIR}/${PREFIX}${DIR} || exit $$?; fi
+ if test -n "${INC}"; then ${INSTALL} -m ${INCMODE} ${INC} ${DESTDIR}/${PREFIX}${DIR} || exit $$?; fi
for x in ${CONF}; do \
- if ! test -e ${DESTDIR}${DIR}/$$x; then \
- ${INSTALL} -m ${CONFMODE} $$x ${DESTDIR}${DIR} || exit $$?; \
+ if ! test -e ${DESTDIR}/${PREFIX}${DIR}/$$x; then \
+ ${INSTALL} -m ${CONFMODE} $$x ${DESTDIR}/${PREFIX}${DIR} || exit $$?; \
fi; \
done
for x in ${CONF_APPEND}; do \
- if test -e ${DESTDIR}${DIR}/$$x; then \
- cat $$x >> ${DESTDIR}${DIR}/$$x || exit $$?; \
+ if test -e ${DESTDIR}/${PREFIX}${DIR}/$$x; then \
+ cat $$x >> ${DESTDIR}/${PREFIX}${DIR}/$$x || exit $$?; \
else \
- ${INSTALL} -m ${CONFMODE} $$x ${DESTDIR}${DIR} || exit $$?; \
+ ${INSTALL} -m ${CONFMODE} $$x ${DESTDIR}/${PREFIX}${DIR} || exit $$?; \
fi; \
done
diff --git a/mk/sys.mk b/mk/sys.mk
index 7be86426..e3111e37 100644
--- a/mk/sys.mk
+++ b/mk/sys.mk
@@ -7,23 +7,26 @@ INSTALL?= install
RANLIB?= ranlib
SH= /bin/sh
+PREFIX=
+PKG_PREFIX= /usr/local
+
PICFLAG?= -fPIC
-BINDIR?= /sbin
+BINDIR?= ${PREFIX}/sbin
BINMODE?= 0755
-INCDIR?= /usr/include
+INCDIR?= ${PREFIX}/usr/include
INCMODE?= 0444
LIBNAME?= lib
-LIBDIR?= /usr/${LIBNAME}
+LIBDIR?= ${PREFIX}/usr/${LIBNAME}
LIBMODE?= 0444
-SHLIBDIR?= /${LIBNAME}
+SHLIBDIR?= ${PREFIX}/${LIBNAME}
-MANDIR?= /usr/share/man/man
+MANDIR?= ${PREFIX}/usr/share/man/man
MANMODE?= 0444
-DOCDIR?= /usr/share/doc
+DOCDIR?= ${PREFIX}/usr/share/doc
DOCMODE?= 0644
CONFMODE?= 0644
diff --git a/sh/Makefile b/sh/Makefile
index 364a59bc..bda82a03 100644
--- a/sh/Makefile
+++ b/sh/Makefile
@@ -13,7 +13,7 @@ include ${MK}/scripts.mk
_installafter:
${INSTALL} -d ${DESTDIR}/etc/init.d
@# Provide an init script for the loopback interface
- ln -snf ${RC_LIB}/sh/net.sh ${DESTDIR}/etc/init.d/${NET_LO} || exit $$?
+ ln -snf ${RC_LIB}/sh/net.sh ${DESTDIR}/${PREFIX}/etc/init.d/${NET_LO} || exit $$?
@# Put functions.sh into the init.d dir so 3rd party apps don't have to
@# be multilib aware
- ln -snf ${RC_LIB}/sh/functions.sh ${DESTDIR}/etc/init.d || exit $$?
+ ln -snf ${RC_LIB}/sh/functions.sh ${DESTDIR}/${PREFIX}/etc/init.d || exit $$?
diff --git a/sh/functions.sh.in b/sh/functions.sh.in
index effce67d..a68f65f3 100644
--- a/sh/functions.sh.in
+++ b/sh/functions.sh.in
@@ -43,7 +43,7 @@ _sanitize_path()
local IFS=":" p= path=
for p in ${PATH}; do
case "${p}" in
- /lib/rc/sbin|/bin|/sbin|/usr/bin|/usr/sbin|/usr/pkg/bin|/usr/pkg/sbin|/usr/local/bin|/usr/local/sbin);;
+ @PREFIX@/lib/rc/sbin|/bin|/sbin|/usr/bin|/usr/sbin|@PKG_PREFIX@/bin|@PKG_PREFIX/sbin);;
*) path="${path}:${p}";;
esac
done
@@ -60,7 +60,7 @@ if [ -n "${ZSH_VERSION}" ]; then
fi
# Add our bin to $PATH
-export PATH="/lib/rc/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/pkg/bin:/usr/pkg/sbin:/usr/local/bin:/usr/local/sbin$(_sanitize_path "${PATH}")"
+export PATH="@PREFIX@/lib/rc/bin:/bin:/sbin:/usr/bin:/usr/sbin:@PKG_PREFIX@/bin:@PKG_PREFIX@/sbin:$(_sanitize_path "${PATH}")"
unset _sanitize_path
for arg; do
diff --git a/sh/rc-functions.sh.in b/sh/rc-functions.sh.in
index 2a57709c..74db71ef 100644
--- a/sh/rc-functions.sh.in
+++ b/sh/rc-functions.sh.in
@@ -75,6 +75,6 @@ get_bootparam()
# Add our sbin to $PATH
case "${PATH}" in
- /lib/rc/sbin|/lib/rc/sbin:*);;
- *) export PATH="/lib/rc/sbin:${PATH}";;
+ @PREFIX@/lib/rc/sbin|@PREFIX@/lib/rc/sbin:*);;
+ *) export PATH="@PREFIX@/lib/rc/sbin:${PATH}";;
esac
diff --git a/src/includes/rc-misc.h b/src/includes/rc-misc.h
index f80684b0..4ba0f839 100644
--- a/src/includes/rc-misc.h
+++ b/src/includes/rc-misc.h
@@ -38,21 +38,30 @@
#include <string.h>
#ifndef LIB
-# define LIB "lib"
+# define LIB "lib"
+#endif
+
+#ifndef PREFIX
+# define PREFIX ""
#endif
#define RC_LEVEL_BOOT "boot"
#define RC_LEVEL_DEFAULT "default"
-#define RC_LIBDIR "/" LIB "/rc"
+#define RC_LIBDIR PREFIX "/" LIB "/rc"
#define RC_SVCDIR RC_LIBDIR "/init.d"
#define RC_DEPTREE RC_SVCDIR "/deptree"
-#define RC_RUNLEVELDIR "/etc/runlevels"
-#define RC_INITDIR "/etc/init.d"
-#define RC_CONFDIR "/etc/conf.d"
-
-#define RC_INITDIR_LOCAL "/usr/local/etc/init.d"
-#define RC_CONFDIR_LOCAL "/usr/local/etc/conf.d"
+#define RC_RUNLEVELDIR PREFIX "/etc/runlevels"
+#define RC_INITDIR PREFIX "/etc/init.d"
+#define RC_CONFDIR PREFIX "/etc/conf.d"
+
+/* 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
+ * /usr/pkg. */
+#ifdef PKG_PREFIX
+# define RC_PKG_INITDIR PKG_PREFIX "/etc/init.d"
+# define RC_PKG_CONFDIR PKG_PREFIX "/usr/local/etc/conf.d"
+#endif
#define RC_KSOFTLEVEL RC_SVCDIR "/ksoftlevel"
#define RC_STARTING RC_SVCDIR "/rc.starting"
diff --git a/src/libeinfo/Makefile b/src/libeinfo/Makefile
index bf3a0f61..b40266f5 100644
--- a/src/libeinfo/Makefile
+++ b/src/libeinfo/Makefile
@@ -7,8 +7,6 @@ SRCS= libeinfo.c
INCS= einfo.h
VERSION_MAP= einfo.map
-SHLIBDIR= /${LIBNAME}
-
CFLAGS+= -I../includes
include ${MK}/cc.mk
diff --git a/src/librc/Makefile b/src/librc/Makefile
index 888155b8..880a56e7 100644
--- a/src/librc/Makefile
+++ b/src/librc/Makefile
@@ -13,7 +13,5 @@ LDADD+= ${LIBKVM}
CFLAGS+= -I../includes
-SHLIBDIR= /${LIBNAME}
-
include ${MK}/cc.mk
include ${MK}/lib.mk
diff --git a/src/librc/librc-depend.c b/src/librc/librc-depend.c
index cf978d63..1ab2b604 100644
--- a/src/librc/librc-depend.c
+++ b/src/librc/librc-depend.c
@@ -696,8 +696,12 @@ bool rc_deptree_update_needed (void)
if (! existss (RC_DEPTREE) ||
! rc_newer_than (RC_DEPTREE, RC_INITDIR) ||
! rc_newer_than (RC_DEPTREE, RC_CONFDIR) ||
- ! rc_newer_than (RC_DEPTREE, RC_INITDIR_LOCAL) ||
- ! rc_newer_than (RC_DEPTREE, RC_CONFDIR_LOCAL) ||
+#ifdef RC_PKG_INITDIR
+ ! rc_newer_than (RC_DEPTREE, RC_PKG_INITDIR) ||
+#endif
+#ifdef RC_PKG_CONFDIR
+ ! rc_newer_than (RC_DEPTREE, RC_PKG_CONFDIR) ||
+#endif
! rc_newer_than (RC_DEPTREE, "/etc/rc.conf"))
return (true);
diff --git a/src/librc/librc.c b/src/librc/librc.c
index 12d31348..552e083d 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -328,11 +328,13 @@ char *rc_service_resolve (const char *service)
snprintf (buffer, sizeof (buffer), RC_INITDIR "/%s", service);
/* So we don't exist in /etc/init.d - check /usr/local/etc/init.d */
+#ifdef RC_PKG_INITDIR
if (stat (buffer, &buf) != 0) {
- snprintf (buffer, sizeof (buffer), RC_INITDIR_LOCAL "/%s", service);
+ snprintf (buffer, sizeof (buffer), RC_PKG_INITDIR "/%s", service);
if (stat (buffer, &buf) != 0)
return (NULL);
}
+#endif
return (xstrdup (buffer));
}
@@ -781,12 +783,18 @@ char **rc_services_in_runlevel (const char *runlevel)
if (! runlevel) {
int i;
- char **local = ls_dir (RC_INITDIR_LOCAL, LS_INITD);
+#ifdef RC_PKG_INITDIR
+ char **local = ls_dir (RC_PKG_INITDIR, LS_INITD);
+#endif
list = ls_dir (RC_INITDIR, LS_INITD);
+
+#ifdef RC_PKG_INITDIR
STRLIST_FOREACH (local, dir, i)
rc_strlist_addsortu (&list, dir);
rc_strlist_free (local);
+#endif
+
return (list);
}
diff --git a/src/rc/Makefile b/src/rc/Makefile
index d87e728b..fea22214 100644
--- a/src/rc/Makefile
+++ b/src/rc/Makefile
@@ -6,9 +6,10 @@ SRCS= checkpath.c fstabinfo.c mountinfo.c \
CLEANFILES= version.h
-BINDIR?= /sbin
+BINDIR= ${PREFIX}/bin
+SBINDIR= ${PREFIX}/sbin
+LINKDIR= ${PREFIX}/${LIBNAME}/${PROG}
-LINKDIR= ${LIBNAME}/${PROG}
BINLINKS= rc-status
SBINLINKS= rc-update runscript start-stop-daemon
RC_BINLINKS= einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
@@ -50,16 +51,16 @@ version.h:
fi
install: all
+ ${INSTALL} -d ${DESTDIR}${SBINDIR}
+ ${INSTALL} -m ${BINMODE} ${PROG} ${DESTDIR}${SBINDIR}
${INSTALL} -d ${DESTDIR}${BINDIR}
- ${INSTALL} -m ${BINMODE} ${PROG} ${DESTDIR}${BINDIR}
- ${INSTALL} -d ${DESTDIR}/bin
- for x in ${BINLINKS}; do ln -fs ${BINDIR}/${PROG} ${DESTDIR}/bin/$$x; done
- ${INSTALL} -d ${DESTDIR}/bin
- for x in ${SBINLINKS}; do ln -fs ${PROG} ${DESTDIR}${BINDIR}/$$x; done
- ${INSTALL} -d ${DESTDIR}/${LIBNAME}/${PROG}/bin
- for x in $(RC_BINLINKS); do ln -fs ${BINDIR}/${PROG} $(DESTDIR)/${LIBNAME}/${PROG}/bin/$$x; done
- ${INSTALL} -d ${DESTDIR}/${LIBNAME}/${PROG}/sbin
- for x in ${RC_SBINLINKS}; do ln -fs ${BINDIR}/${PROG} ${DESTDIR}/${LIBNAME}/${PROG}/sbin/$$x; done
+ for x in ${BINLINKS}; do ln -fs ${DESTDIR}${SBINDIR}/${PROG} ${DESTDIR}${BINDIR}/$$x; done
+ ${INSTALL} -d ${DESTDIR}${SBINDIR}
+ for x in ${SBINLINKS}; do ln -fs ${PROG} ${DESTDIR}${SBINDIR}/$$x; done
+ ${INSTALL} -d ${DESTDIR}${LINKDIR}/bin
+ for x in $(RC_BINLINKS); do ln -fs ${DESTDIR}${SBINDIR}/${PROG} ${DESTDIR}${LINKDIR}/bin/$$x; done
+ ${INSTALL} -d ${DESTDIR}${LINKDIR}/sbin
+ for x in ${RC_SBINLINKS}; do ln -fs ${DESTDIR}${SBINDIR}/${PROG} ${DESTDIR}${LINKDIR}/sbin/$$x; done
if test "${MKPAM}" = pam; then \
${INSTALL} -d ${DESTDIR}${PAMDIR}; \
${INSTALL} -m ${PAMMODE} start-stop-daemon.pam ${DESTDIR}${PAMDIR}/start-stop-daemon; \