summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschmonz <schmonz@pkgsrc.org>2018-12-26 00:43:55 +0000
committerschmonz <schmonz@pkgsrc.org>2018-12-26 00:43:55 +0000
commita7c0c3f97f245f029d4f5ded5edbde9c7091359b (patch)
treee9f294701129fd221e564dc0bc302638001e57a8
parent5af8de3a241cd65db98061bb6dea966a48f40069 (diff)
downloadpkgsrc-a7c0c3f97f245f029d4f5ded5edbde9c7091359b.tar.gz
Add support for OpenBSD's take on rc.d. There's no boot-time dynamic
dependency ordering, so we compute the order of such rc.d scripts as are present at install time (via a new "list" action in sbin/rc.d-boot). Anything added or removed later is the sysadmin's job. I guess this is what OpenBSD sysadmins expect. While here, make "stop" run the commands in reverse order, like NetBSD does on shutdown. Bump version.
-rw-r--r--pkgtools/rc.d-boot/DEINSTALL14
-rw-r--r--pkgtools/rc.d-boot/INSTALL12
-rw-r--r--pkgtools/rc.d-boot/Makefile23
-rw-r--r--pkgtools/rc.d-boot/files/rc.d-boot25
4 files changed, 60 insertions, 14 deletions
diff --git a/pkgtools/rc.d-boot/DEINSTALL b/pkgtools/rc.d-boot/DEINSTALL
index 5fb170bf5cb..bb633bba023 100644
--- a/pkgtools/rc.d-boot/DEINSTALL
+++ b/pkgtools/rc.d-boot/DEINSTALL
@@ -1,6 +1,7 @@
-# $NetBSD: DEINSTALL,v 1.2 2018/12/16 05:41:01 schmonz Exp $
+# $NetBSD: DEINSTALL,v 1.3 2018/12/26 00:43:55 schmonz Exp $
RCDBOOT_STYLE=@RCDBOOT_STYLE@
+RCD_SCRIPTS_DIR=@RCD_SCRIPTS_DIR@
case "${STAGE}" in
@@ -15,6 +16,17 @@ DEINSTALL)
;;
netbsd-native)
;;
+ openbsd-rcd)
+ short_order=$(rc.d-boot list | ${SED} -e "s|^${RCD_SCRIPTS_DIR}/||" | ${GREP} -v '^[A-Z]*$')
+ for _svc in ${short_order}; do
+ # lifted from OpenBSD 6.4 /usr/sbin/rcctl
+ ${SED} "/^pkg_scripts[[:>:]]/{s/[[:<:]]${_svc}[[:>:]]//g
+ s/['\"]//g;s/ *= */=/;s/ */ /g;s/ $//;/=$/d;}" \
+ < /etc/rc.conf.local \
+ > /etc/rc.conf.local.tmp \
+ && ${MV} /etc/rc.conf.local.tmp /etc/rc.conf.local
+ done
+ ;;
esac
case "${RCDBOOT_STYLE}" in
diff --git a/pkgtools/rc.d-boot/INSTALL b/pkgtools/rc.d-boot/INSTALL
index 82c828db3f5..0d25ecff17b 100644
--- a/pkgtools/rc.d-boot/INSTALL
+++ b/pkgtools/rc.d-boot/INSTALL
@@ -1,6 +1,7 @@
-# $NetBSD: INSTALL,v 1.4 2018/12/16 05:41:01 schmonz Exp $
+# $NetBSD: INSTALL,v 1.5 2018/12/26 00:43:55 schmonz Exp $
RCDBOOT_STYLE=@RCDBOOT_STYLE@
+RCD_SCRIPTS_DIR=@RCD_SCRIPTS_DIR@
case "${STAGE}" in
@@ -16,6 +17,15 @@ POST-INSTALL)
;;
netbsd-native)
;;
+ openbsd-rcd)
+ short_order=$(rc.d-boot list | ${SED} -e "s|^${RCD_SCRIPTS_DIR}/||" | ${GREP} -v '^[A-Z]*$')
+ rcctl enable ${short_order}
+ rcctl order ${short_order}
+ ${SED} -e 's|^pkg_scripts=\([a-z]*.*\)$|pkg_scripts="\1"|' \
+ < /etc/rc.conf.local \
+ > /etc/rc.conf.local.tmp \
+ && ${MV} /etc/rc.conf.local.tmp /etc/rc.conf.local
+ ;;
esac
;;
diff --git a/pkgtools/rc.d-boot/Makefile b/pkgtools/rc.d-boot/Makefile
index 3d4eaabbf9e..a4732d7b951 100644
--- a/pkgtools/rc.d-boot/Makefile
+++ b/pkgtools/rc.d-boot/Makefile
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.5 2018/12/17 03:03:47 schmonz Exp $
+# $NetBSD: Makefile,v 1.6 2018/12/26 00:43:55 schmonz Exp $
#
-PKGNAME= rc.d-boot-20181211
+PKGNAME= rc.d-boot-20181226
CATEGORIES= pkgtools
MAINTAINER= schmonz@NetBSD.org
@@ -15,7 +15,7 @@ ONLY_FOR_PLATFORM= # empty by default
.if exists(/sbin/rcorder)
RCORDER= /sbin/rcorder
.else
-DEPENDS+= rc.subr-[0-9]*:../../pkgtools/rc.subr
+DEPENDS+= rc.subr>=20181226:../../pkgtools/rc.subr
DEPENDS+= rcorder-[0-9]*:../../pkgtools/rcorder
RCORDER= ${PREFIX}/sbin/rcorder
.endif
@@ -28,14 +28,17 @@ SUBST_STAGE.paths= pre-configure
SUBST_FILES.paths= rc.d-boot
SUBST_FILES.paths+= org.pkgsrc.rc.d-boot.plist \
pkgsrc-rc.d-boot.service
-SUBST_VARS.paths= PREFIX RCD_SCRIPTS_DIR RCORDER
+SUBST_VARS.paths= GREP PREFIX RCD_SCRIPTS_DIR RCORDER
FILES_SUBST+= RCDBOOT_STYLE=${RCDBOOT_STYLE:Q}
+FILES_SUBST+= RCD_SCRIPTS_DIR=${RCD_SCRIPTS_DIR:Q}
+
+EGDIR= share/examples/${PKGBASE}
.if ${OPSYS} == "Darwin" && exists (/Library/LaunchDaemons)
ONLY_FOR_PLATFORM+= ${OPSYS}-*-*
RCDBOOT_STYLE= darwin-launchd
-CONF_FILES+= ${PREFIX}/share/examples/${PKGBASE}/org.pkgsrc.rc.d-boot.plist \
+CONF_FILES+= ${PREFIX}/${EGDIR}/org.pkgsrc.rc.d-boot.plist \
/Library/LaunchDaemons/org.pkgsrc.rc.d-boot.plist
.elif ${OPSYS} == "FreeBSD" && exists(/etc/rc.d)
ONLY_FOR_PLATFORM+= ${OPSYS}-*-*
@@ -43,16 +46,20 @@ RCDBOOT_STYLE= freebsd-native
.elif ${OPSYS} == "Linux" && exists(/etc/systemd/system)
ONLY_FOR_PLATFORM+= ${OPSYS}-*-*
RCDBOOT_STYLE= linux-systemd
-CONF_FILES+= ${PREFIX}/share/examples/${PKGBASE}/pkgsrc-rc.d-boot.service \
+CONF_FILES+= ${PREFIX}/${EGDIR}/pkgsrc-rc.d-boot.service \
/etc/systemd/system/pkgsrc-rc.d-boot.service
.elif ${OPSYS} == "NetBSD" && exists(/etc/rc.d)
ONLY_FOR_PLATFORM+= ${OPSYS}-*-*
RCDBOOT_STYLE= netbsd-native
+.elif ${OPSYS} == "OpenBSD" && exists(/etc/rc.d/rc.subr)
+ONLY_FOR_PLATFORM+= ${OPSYS}-*-*
+RCDBOOT_STYLE= openbsd-rcd
.else
NOT_FOR_PLATFORM+= ${OPSYS}-*-*
.endif
-INSTALLATION_DIRS= sbin share/examples/${PKGBASE}
+BUILD_DEFS+= RCD_SCRIPTS_DIR
+INSTALLATION_DIRS= sbin ${EGDIR}
do-extract:
${CP} -R ${FILESDIR} ${WRKSRC}
@@ -60,7 +67,7 @@ do-extract:
do-install:
. for i in org.pkgsrc.rc.d-boot.plist \
pkgsrc-rc.d-boot.service
- ${INSTALL_DATA} ${WRKSRC}/${i} ${DESTDIR}${PREFIX}/share/examples/${PKGBASE}/
+ ${INSTALL_DATA} ${WRKSRC}/${i} ${DESTDIR}${PREFIX}/${EGDIR}/
. endfor
${INSTALL_SCRIPT} ${WRKSRC}/rc.d-boot ${DESTDIR}${PREFIX}/sbin/
diff --git a/pkgtools/rc.d-boot/files/rc.d-boot b/pkgtools/rc.d-boot/files/rc.d-boot
index 536c324ce68..4c8a4c417c4 100644
--- a/pkgtools/rc.d-boot/files/rc.d-boot
+++ b/pkgtools/rc.d-boot/files/rc.d-boot
@@ -1,17 +1,34 @@
#!/bin/sh
+. /etc/rc.subr
+
run_all_rcd_scripts() {
action="$1"; shift
- # from NetBSD /etc/rc
- scripts=$(for rcd in @RCD_SCRIPTS_DIR@; do
+ # mostly from NetBSD /etc/rc
+ contents=$(for rcd in @RCD_SCRIPTS_DIR@; do
test -d ${rcd} && echo ${rcd}/*;
done)
- files=$(@RCORDER@ -s nostart ${scripts})
+ scripts=$(for rcd in ${contents}; do
+ test -f ${rcd} && echo ${rcd};
+ done)
+
+ rcd_scripts=$(for s in ${scripts}; do
+ @GREP@ -q '^# PROVIDE: ' ${s} && echo ${s};
+ done)
+
+ files=$(@RCORDER@ -s nostart ${rcd_scripts})
+ if [ "${action}" = stop ]; then
+ files=$(reverse_list ${files})
+ fi
for _rc_elem in $files; do
- $_rc_elem ${action}
+ if [ "${action}" = list ]; then
+ echo $_rc_elem
+ else
+ $_rc_elem ${action}
+ fi
done
}