pkgsrc-Changes archive

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

CVS commit: pkgsrc/pkgtools/rc.d-boot



Module Name:    pkgsrc
Committed By:   schmonz
Date:           Wed Dec 26 00:43:55 UTC 2018

Modified Files:
        pkgsrc/pkgtools/rc.d-boot: DEINSTALL INSTALL Makefile
        pkgsrc/pkgtools/rc.d-boot/files: rc.d-boot

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 pkgsrc/pkgtools/rc.d-boot/DEINSTALL
cvs rdiff -u -r1.4 -r1.5 pkgsrc/pkgtools/rc.d-boot/INSTALL
cvs rdiff -u -r1.5 -r1.6 pkgsrc/pkgtools/rc.d-boot/Makefile
cvs rdiff -u -r1.2 -r1.3 pkgsrc/pkgtools/rc.d-boot/files/rc.d-boot

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/pkgtools/rc.d-boot/DEINSTALL
diff -u pkgsrc/pkgtools/rc.d-boot/DEINSTALL:1.2 pkgsrc/pkgtools/rc.d-boot/DEINSTALL:1.3
--- pkgsrc/pkgtools/rc.d-boot/DEINSTALL:1.2     Sun Dec 16 05:41:01 2018
+++ pkgsrc/pkgtools/rc.d-boot/DEINSTALL Wed Dec 26 00:43:55 2018
@@ -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

Index: pkgsrc/pkgtools/rc.d-boot/INSTALL
diff -u pkgsrc/pkgtools/rc.d-boot/INSTALL:1.4 pkgsrc/pkgtools/rc.d-boot/INSTALL:1.5
--- pkgsrc/pkgtools/rc.d-boot/INSTALL:1.4       Sun Dec 16 05:41:01 2018
+++ pkgsrc/pkgtools/rc.d-boot/INSTALL   Wed Dec 26 00:43:55 2018
@@ -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
 
        ;;

Index: pkgsrc/pkgtools/rc.d-boot/Makefile
diff -u pkgsrc/pkgtools/rc.d-boot/Makefile:1.5 pkgsrc/pkgtools/rc.d-boot/Makefile:1.6
--- pkgsrc/pkgtools/rc.d-boot/Makefile:1.5      Mon Dec 17 03:03:47 2018
+++ pkgsrc/pkgtools/rc.d-boot/Makefile  Wed Dec 26 00:43:55 2018
@@ -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 @@ 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/
 

Index: pkgsrc/pkgtools/rc.d-boot/files/rc.d-boot
diff -u pkgsrc/pkgtools/rc.d-boot/files/rc.d-boot:1.2 pkgsrc/pkgtools/rc.d-boot/files/rc.d-boot:1.3
--- pkgsrc/pkgtools/rc.d-boot/files/rc.d-boot:1.2       Wed Dec  5 19:49:26 2018
+++ pkgsrc/pkgtools/rc.d-boot/files/rc.d-boot   Wed Dec 26 00:43:55 2018
@@ -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