pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc Introduce a new SYSCONFBASE variable (defaults to /etc)



details:   https://anonhg.NetBSD.org/pkgsrc/rev/5591ff640b7f
branches:  trunk
changeset: 453526:5591ff640b7f
user:      khorben <khorben%pkgsrc.org@localhost>
date:      Sun May 30 23:41:05 2021 +0000

description:
Introduce a new SYSCONFBASE variable (defaults to /etc)

This is part 1 to support additional platforms with the RC scripts provided in
pkgsrc, in privileged as well as in unprivileged mode, including on NetBSD
(with part 2 in pkgtools/rc.subr).

This variable is meant to point to the configuration directory of the base
system (as opposed to pkgsrc's own prefix) when it should be used by pkgsrc in
special cases (e.g. installing RC scripts), or to point to the existing
PKG_SYSCONFBASE directory otherwise (e.g. for any unprivileged bootstrap).
This teaches pkgsrc where the RC scripts should be installed, and more
importantly, where the local copy of rc.subr can be expected. Part 3 will
progressively update each and every RC script to substitute this path as
expected.

No functional changes are intended in privileged mode without a bootstrap. The
only variable affected by this change directly is RCD_SCRIPTS_DIR, which
currently remains with the same default of /etc/rc.d, and can be overridden as
before.

When bootstrapping, SYSCONFBASE also remains with the existing default when no
prefix is set or is "/usr/pkg" or "/usr"; it is set to $prefix/etc otherwise. It
can be specified specifically with --sysconfbase if necessary.

Existing installations or bootstraps are not affected, as this change needs
setting SYSCONFBASE in the corresponding $sysconfdir/mk.conf to have an impact.

Tested in privileged and unprivileged modes on NetBSD/amd64, and unprivileged
mode on Darwin/amd64; submitted for review on tech-pkg@.

diffstat:

 bootstrap/bootstrap             |  13 ++++++++++++-
 mk/defaults/mk.conf             |  12 +++++++++---
 mk/pkginstall/bsd.pkginstall.mk |   3 ++-
 3 files changed, 23 insertions(+), 5 deletions(-)

diffs (128 lines):

diff -r 05c52e211154 -r 5591ff640b7f bootstrap/bootstrap
--- a/bootstrap/bootstrap       Sun May 30 21:53:48 2021 +0000
+++ b/bootstrap/bootstrap       Sun May 30 23:41:05 2021 +0000
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-# $NetBSD: bootstrap,v 1.299 2021/04/28 11:14:51 maya Exp $
+# $NetBSD: bootstrap,v 1.300 2021/05/30 23:41:05 khorben Exp $
 #
 # Copyright (c) 2001-2011 Alistair Crooks <agc%NetBSD.org@localhost>
 # All rights reserved.
@@ -74,6 +74,7 @@
     [ --prefix <prefix> ]
     [ --preserve-path ]
     [ --quiet ]
+    [ --sysconfbase <sysconfbase> ]
     [ --sysconfdir <sysconfdir> ]
     [ --unprivileged | --ignore-user-check ]
     [ --varbase <varbase> ]
@@ -413,6 +414,7 @@
 pkgdbdir=
 pkginfodir=
 pkgmandir=
+sysconfbase=
 sysconfdir=
 varbase=
 
@@ -440,6 +442,8 @@
        --pkginfodir)   pkginfodir="$2"; shift ;;
        --pkgmandir=*)  pkgmandir=`get_optarg "$1"` ;;
        --pkgmandir)    pkgmandir="$2"; shift ;;
+       --sysconfbase=*)sysconfbase=`get_optarg "$1"` ;;
+       --sysconfbase)  sysconfbase="$2"; shift ;;
        --sysconfdir=*) sysconfdir=`get_optarg "$1"` ;;
        --sysconfdir)   sysconfdir="$2"; shift ;;
        --varbase=*)    varbase=`get_optarg "$1"` ;;
@@ -485,6 +489,7 @@
 done
 
 checkarg_sane_absolute_path "$pkgdbdir" "--pkgdbdir"
+checkarg_sane_absolute_path "$sysconfbase" "--sysconfbase"
 checkarg_sane_absolute_path "$sysconfdir" "--sysconfdir"
 checkarg_sane_absolute_path "$varbase" "--varbase"
 checkarg_sane_relative_path "$pkginfodir" "--pkginfodir"
@@ -500,6 +505,7 @@
        [ -z "$prefix" ] && prefix=${HOME}/pkg
 elif [ -z "$prefix" -o "$prefix" = "/usr/pkg" ]; then
        prefix=/usr/pkg
+       [ -z "$sysconfbase" ] && sysconfbase=/etc
        [ -z "$varbase" ] && varbase=/var
 fi
 checkarg_sane_absolute_path "$prefix" "--prefix"
@@ -510,9 +516,11 @@
 if [ "$prefix" = "/usr" ]; then
        [ -z "$pkginfodir" ] && pkginfodir=share/info
        [ -z "$pkgmandir" ] && pkgmandir=share/man
+       [ -z "$sysconfbase" ] && sysconfbase=/etc
 else
        [ -z "$pkginfodir" ] && pkginfodir=info
        [ -z "$pkgmandir" ] && pkgmandir=man
+       [ -z "$sysconfbase" ] && sysconfbase=${prefix}/etc
 fi
 infodir=${prefix}/${pkginfodir}
 mandir=${prefix}/${pkgmandir}
@@ -1087,6 +1095,9 @@
 # save environment in example mk.conf
 echo "PKG_DBDIR=               $pkgdbdir" >> ${TARGET_MKCONF}
 echo "LOCALBASE=               $prefix" >> ${TARGET_MKCONF}
+if [ "${sysconfbase}" != "/etc" ]; then
+echo "SYSCONFBASE=             $sysconfbase" >> ${TARGET_MKCONF}
+fi
 echo "VARBASE=         $varbase" >> ${TARGET_MKCONF}
 if [ "${sysconfdir}" != "${prefix}/etc" ]; then
        echo "PKG_SYSCONFBASE=  $sysconfdir" >> ${TARGET_MKCONF}
diff -r 05c52e211154 -r 5591ff640b7f mk/defaults/mk.conf
--- a/mk/defaults/mk.conf       Sun May 30 21:53:48 2021 +0000
+++ b/mk/defaults/mk.conf       Sun May 30 23:41:05 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mk.conf,v 1.317 2021/01/15 19:47:33 schmonz Exp $
+# $NetBSD: mk.conf,v 1.318 2021/05/30 23:41:05 khorben Exp $
 #
 
 # This file provides default values for variables that may be overridden
@@ -489,6 +489,12 @@
 # Possible: yes or no.
 # Default: no.
 
+SYSCONFBASE?= /etc
+# This is the config directory under which system configuration files are
+# expected.
+# Possible: any path you like
+# Default: /etc
+
 PKG_SYSCONFBASE?= ${PREFIX}/etc
 # This is the main config directory under which all package configuration
 # files should be found.
@@ -500,12 +506,12 @@
 # Possible: any of: rc.d, smf
 # Default: Platform-dependent, otherwise rc.d
 
-RCD_SCRIPTS_DIR?= /etc/rc.d
+RCD_SCRIPTS_DIR?= ${SYSCONFBASE}/rc.d
 # This is the system rc.d script directory in which all rc.d scripts
 # expected to be executed at boot-time should be found.  Package views
 # users may want to set this to "${PKG_SYSCONFBASEDIR}/rc.d".
 # Possible: any path you like
-# Default: /etc/rc.d
+# Default: ${SYSCONFBASE}/rc.d
 
 PACKAGES?=     ${PKGSRCDIR}/packages
 # Stores generated packages
diff -r 05c52e211154 -r 5591ff640b7f mk/pkginstall/bsd.pkginstall.mk
--- a/mk/pkginstall/bsd.pkginstall.mk   Sun May 30 21:53:48 2021 +0000
+++ b/mk/pkginstall/bsd.pkginstall.mk   Sun May 30 23:41:05 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkginstall.mk,v 1.74 2020/05/09 16:48:57 rillig Exp $
+# $NetBSD: bsd.pkginstall.mk,v 1.75 2021/05/30 23:41:05 khorben Exp $
 #
 # This Makefile fragment is included by bsd.pkg.mk and implements the
 # common INSTALL/DEINSTALL scripts framework.  To use the pkginstall
@@ -146,6 +146,7 @@
 #
 FILES_SUBST+=          PREFIX=${PREFIX:Q}
 FILES_SUBST+=          LOCALBASE=${LOCALBASE:Q}
+FILES_SUBST+=          SYSCONFBASE=${SYSCONFBASE:Q}
 FILES_SUBST+=          X11BASE=${X11BASE:Q}
 FILES_SUBST+=          VARBASE=${VARBASE:Q}
 FILES_SUBST+=          PKG_SYSCONFBASE=${PKG_SYSCONFBASE:Q}



Home | Main Index | Thread Index | Old Index