pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/rc.d-boot Add support for OpenBSD's take on r...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/edbc09bc2d62
branches:  trunk
changeset: 389274:edbc09bc2d62
user:      schmonz <schmonz%pkgsrc.org@localhost>
date:      Wed Dec 26 00:43:55 2018 +0000

description:
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.

diffstat:

 pkgtools/rc.d-boot/DEINSTALL       |  14 +++++++++++++-
 pkgtools/rc.d-boot/INSTALL         |  12 +++++++++++-
 pkgtools/rc.d-boot/Makefile        |  23 +++++++++++++++--------
 pkgtools/rc.d-boot/files/rc.d-boot |  25 +++++++++++++++++++++----
 4 files changed, 60 insertions(+), 14 deletions(-)

diffs (174 lines):

diff -r ce3c36d021ee -r edbc09bc2d62 pkgtools/rc.d-boot/DEINSTALL
--- a/pkgtools/rc.d-boot/DEINSTALL      Wed Dec 26 00:29:45 2018 +0000
+++ b/pkgtools/rc.d-boot/DEINSTALL      Wed Dec 26 00:43:55 2018 +0000
@@ -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 @@
                ;;
        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 -r ce3c36d021ee -r edbc09bc2d62 pkgtools/rc.d-boot/INSTALL
--- a/pkgtools/rc.d-boot/INSTALL        Wed Dec 26 00:29:45 2018 +0000
+++ b/pkgtools/rc.d-boot/INSTALL        Wed Dec 26 00:43:55 2018 +0000
@@ -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 @@
                ;;
        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 -r ce3c36d021ee -r edbc09bc2d62 pkgtools/rc.d-boot/Makefile
--- a/pkgtools/rc.d-boot/Makefile       Wed Dec 26 00:29:45 2018 +0000
+++ b/pkgtools/rc.d-boot/Makefile       Wed Dec 26 00:43:55 2018 +0000
@@ -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@localhost
@@ -15,7 +15,7 @@
 .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_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 @@
 .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-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 -r ce3c36d021ee -r edbc09bc2d62 pkgtools/rc.d-boot/files/rc.d-boot
--- a/pkgtools/rc.d-boot/files/rc.d-boot        Wed Dec 26 00:29:45 2018 +0000
+++ b/pkgtools/rc.d-boot/files/rc.d-boot        Wed Dec 26 00:43:55 2018 +0000
@@ -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
 }
 



Home | Main Index | Thread Index | Old Index