Subject: sysconfdir in bootstrap?
To: None <tech-pkg@NetBSD.org>
From: Julio M. Merino Vidal <jmmv@menta.net>
List: tech-pkg
Date: 04/07/2004 00:09:01
Hi all,
I just started playing with bootstrap, and I don't like that mk.conf is
searched in /etc, with a hardcoded path; specially when wanting to use
pkgsrc as non-root. Yeah, there is the MAKECONF variable, which can be
set in the environment, but I would like to be able to configure the
default path during the bootstrap process.
I've modified the script to add the --sysconfdir flag, changing the default
to ${prefix}/etc, to match the default PKG_SYSCONFDIR value used by pkgsrc.
Then, this value is used in the *own.mk files to open the mk.conf file, if
found in that location, falling back to /etc/mk.conf in other cases (to not
break existing installations and documentation that points to it).
It seems that OpenBSD.bsd.own.mk and IRIX.own.mk should be renamed to end
in a '.in' suffix, as the default bsd.own.mk.in, because it needs to be
processed from the bootstrap script. (Not that matters much, but for
consistency).
Objections/comments to the patch below? Thanks.
Index: bootstrap
===================================================================
RCS file: /cvsroot/pkgsrc/bootstrap/bootstrap,v
retrieving revision 1.10
diff -u -r1.10 bootstrap
--- bootstrap 29 Mar 2004 02:20:04 -0000 1.10
+++ bootstrap 6 Apr 2004 21:58:17 -0000
@@ -41,6 +41,7 @@
prefix=/usr/pkg
pkgdbdir=/var/db/pkg
pkgsrcdir=/usr/pkgsrc
+sysconfdir=${prefix}/etc
ignorecasecheck=no
ignoreusercheck=no
@@ -54,6 +55,7 @@
[ --prefix=<prefix> ]
[ --pkgdbdir=<pkgdbdir> ]
[ --pkgsrcdir=<pkgsrcdir> ]
+ [ --sysconfdir=<sysconfdir> ]
[ --ignore-case-check ]
[ --ignore-user-check ]
[ --help ]'
@@ -341,9 +343,11 @@
while [ $# -gt 0 ]; do
case $1 in
--workdir=*) wrkdir=`echo $1 | $sedprog -e 's|--workdir=||'` ;;
- --prefix=*) prefix=`echo $1 | $sedprog -e 's|--prefix=||'` ;;
+ --prefix=*) prefix=`echo $1 | $sedprog -e 's|--prefix=||'`
+ sysconfdir=${prefix}/etc ;;
--pkgdbdir=*) pkgdbdir=`echo $1 | $sedprog -e 's|--pkgdbdir=||'` ;;
--pkgsrcdir=*) pkgsrcdir=`echo $1 | $sedprog -e 's|--pkgsrcdir=||'` ;;
+ --sysconfdir=*) sysconfdir=`echo $1 | $sedprog -e 's|--sysconfdir=||'`;;
--ignore-case-check) ignorecasecheck=yes ;;
--ignore-user-check) ignoreusercheck=yes ;;
--help) echo "$usage"; exit ;;
@@ -422,7 +426,7 @@
MKCONF_EXAMPLE=${wrkdir}/mk.conf.example
export MKCONF_EXAMPLE
echo_msg "Creating mk.conf.example in ${wrkdir}"
-echo "# Example /etc/mk.conf file produced by bootstrap-pkgsrc" > ${MKCONF_EXAMPLE}
+echo "# Example ${sysconfdir}/mk.conf file produced by bootstrap-pkgsrc" > ${MKCONF_EXAMPLE}
echo "# `date`" >> ${MKCONF_EXAMPLE}
echo "" >> ${MKCONF_EXAMPLE}
echo ".ifdef BSD_PKG_MK # begin pkgsrc settings" >> ${MKCONF_EXAMPLE}
@@ -470,9 +474,9 @@
fi
if [ -f mods/mk/$opsys.bsd.own.mk ] ; then
- run_cmd "$cpprog mods/mk/$opsys.bsd.own.mk $prefix/share/mk/bsd.own.mk"
+ run_cmd "$sedprog -e 's|@ROOT_GROUP@|'$root_group'|g;s|@ROOT_USER@|'$root_user'|g;s|@SYSCONFDIR@|'$sysconfdir'|g' mods/mk/$opsys.bsd.own.mk > $prefix/share/mk/bsd.own.mk"
else
- run_cmd "$sedprog -e 's|@ROOT_GROUP@|'$root_group'|g;s|@ROOT_USER@|'$root_user'|g' mods/mk/bsd.own.mk.in > $prefix/share/mk/bsd.own.mk"
+ run_cmd "$sedprog -e 's|@ROOT_GROUP@|'$root_group'|g;s|@ROOT_USER@|'$root_user'|g;s|@SYSCONFDIR@|'$sysconfdir'|g' mods/mk/bsd.own.mk.in > $prefix/share/mk/bsd.own.mk"
fi
if [ -f mods/mk/$opsys.bsd.prog.mk ] ; then
@@ -505,7 +509,7 @@
# build libnbcompat
echo_msg "Building libnbcompat"
copy_src ../pkgtools/libnbcompat/files libnbcompat
-run_cmd "(cd $wrkdir/libnbcompat; $shprog ./configure -C --prefix=$prefix && $prefix/bin/bmake)"
+run_cmd "(cd $wrkdir/libnbcompat; $shprog ./configure -C --prefix=$prefix --sysconfdir=$sysconfdir && $prefix/bin/bmake)"
# bootstrap tnftp
case "$DEBIAN" in
@@ -515,7 +519,7 @@
esac
echo_msg "Installing tnftp"
copy_src ../net/tnftp/files tnftp
-run_cmd "(cd $wrkdir/tnftp; env $BSTRAP_ENV $shprog ./configure --prefix=$prefix && make && (cd src && make install))"
+run_cmd "(cd $wrkdir/tnftp; env $BSTRAP_ENV $shprog ./configure --prefix=$prefix --sysconfdir=$sysconfdir && make && (cd src && make install))"
pkg_install_args="$pkg_install_args --with-ftp=$prefix/bin/ftp"
FETCH_CMD=$prefix/bin/ftp
@@ -525,7 +529,7 @@
# bootstrap digest
echo_msg "Installing digest"
copy_src ../pkgtools/digest/files digest
-run_cmd "(cd $wrkdir/digest; env $BSTRAP_ENV $shprog ./configure -C --prefix=$prefix && make && make install)"
+run_cmd "(cd $wrkdir/digest; env $BSTRAP_ENV $shprog ./configure -C --prefix=$prefix --sysconfdir=$sysconfdir && make && make install)"
# create the digest package's meta files
digestversion=digest-`$awkprog -F "'" '/^PACKAGE_VERSION=/ {print $2}' $wrkdir/digest/configure`
@@ -539,7 +543,7 @@
case "$need_pax" in
yes) echo_msg "Installing pax"
copy_src ../archivers/pax/files pax
- run_cmd "(cd $wrkdir/pax; env $BSTRAP_ENV CPPFLAGS='-I../libnbcompat' LDFLAGS='-L../libnbcompat' LIBS='-lnbcompat' $shprog ./configure -C --prefix=$prefix && $prefix/bin/bmake && $prefix/bin/bmake install)"
+ run_cmd "(cd $wrkdir/pax; env $BSTRAP_ENV CPPFLAGS='-I../libnbcompat' LDFLAGS='-L../libnbcompat' LIBS='-lnbcompat' $shprog ./configure -C --prefix=$prefix --sysconfdir=$sysconfdir && $prefix/bin/bmake && $prefix/bin/bmake install)"
echo "PAX=$prefix/bin/pax" >> ${MKCONF_EXAMPLE}
pkg_install_args="$pkg_install_args --with-pax=$prefix/bin/pax --with-tar=$prefix/bin/tar"
;;
@@ -552,7 +556,7 @@
case "$need_mtree" in
yes) echo_msg "Installing mtree"
copy_src ../pkgtools/mtree/files mtree
- run_cmd "(cd $wrkdir/mtree; env $BSTRAP_ENV CPPFLAGS='-I../libnbcompat' LDFLAGS='-L../libnbcompat' LIBS='-lnbcompat' $shprog ./configure -C --prefix=$prefix && $prefix/bin/bmake && $prefix/bin/bmake install)"
+ run_cmd "(cd $wrkdir/mtree; env $BSTRAP_ENV CPPFLAGS='-I../libnbcompat' LDFLAGS='-L../libnbcompat' LIBS='-lnbcompat' $shprog ./configure -C --prefix=$prefix --sysconfdir=$sysconfdir && $prefix/bin/bmake && $prefix/bin/bmake install)"
pkg_install_args="$pkg_install_args --with-mtree=$prefix/sbin/mtree"
;;
*) pkg_install_args="$pkg_install_args --with-mtree=$mtreeprog"
@@ -563,7 +567,7 @@
case "$need_sed" in
yes) echo_msg "Installing sed"
copy_src ../textproc/nbsed/files sed
- run_cmd "(cd $wrkdir/sed; env $BSTRAP_ENV $shprog ./configure -C --prefix=$prefix && make && make install)"
+ run_cmd "(cd $wrkdir/sed; env $BSTRAP_ENV $shprog ./configure -C --prefix=$prefix --sysconfdir=$sysconfdir && make && make install)"
echo "SED=$prefix/bin/nbsed" >> ${MKCONF_EXAMPLE}
;;
esac
@@ -575,7 +579,7 @@
if [ "$prefix" = "/usr" ]; then
pkg_install_mandir="$prefix/share/man"
fi
-run_cmd "(cd $wrkdir/pkg_install; env $BSTRAP_ENV CPPFLAGS='-I../libnbcompat -I../../libnbcompat' LDFLAGS='-L../libnbcompat -L../../libnbcompat' LIBS='-lnbcompat' $shprog ./configure -C --prefix=$prefix --with-pkgdbdir=$pkgdbdir --mandir=$pkg_install_mandir $pkg_install_args && $prefix/bin/bmake && $prefix/bin/bmake install)"
+run_cmd "(cd $wrkdir/pkg_install; env $BSTRAP_ENV CPPFLAGS='-I../libnbcompat -I../../libnbcompat' LDFLAGS='-L../libnbcompat -L../../libnbcompat' LIBS='-lnbcompat' $shprog ./configure -C --prefix=$prefix --sysconfdir=$sysconfdir --with-pkgdbdir=$pkgdbdir --mandir=$pkg_install_mandir $pkg_install_args && $prefix/bin/bmake && $prefix/bin/bmake install)"
# all's ready, install the man page
echo_msg "Installing packages(7) man page"
@@ -593,7 +597,7 @@
echo ""
echo "An example mk.conf file \"${MKCONF_EXAMPLE}\" with the settings you"
echo "provided to \"bootstrap\" has been created for you."
-echo "Please copy ${MKCONF_EXAMPLE} to /etc/mk.conf."
+echo "Please copy ${MKCONF_EXAMPLE} to ${sysconfdir}/mk.conf."
echo ""
echo "You can find extensive documentation of the NetBSD Packages Collection"
echo "in $pkgsrcdir/Packages.txt and packages(7)."
Index: mods/mk/IRIX.own.mk
===================================================================
RCS file: /cvsroot/pkgsrc/bootstrap/mods/mk/IRIX.own.mk,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 IRIX.own.mk
--- mods/mk/IRIX.own.mk 11 Mar 2004 13:04:00 -0000 1.1.1.1
+++ mods/mk/IRIX.own.mk 6 Apr 2004 21:58:17 -0000
@@ -5,6 +5,8 @@
.if defined(MAKECONF) && exists(${MAKECONF})
.include "${MAKECONF}"
+.elif exists(@SYSCONFDIR@/mk.conf)
+.include "@SYSCONFDIR@/mk.conf"
.elif exists(/etc/mk.conf)
.include "/etc/mk.conf"
.endif
Index: mods/mk/OpenBSD.bsd.own.mk
===================================================================
RCS file: /cvsroot/pkgsrc/bootstrap/mods/mk/OpenBSD.bsd.own.mk,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 OpenBSD.bsd.own.mk
--- mods/mk/OpenBSD.bsd.own.mk 11 Mar 2004 13:04:00 -0000 1.1.1.1
+++ mods/mk/OpenBSD.bsd.own.mk 6 Apr 2004 21:58:17 -0000
@@ -8,6 +8,8 @@
.if defined(MAKECONF) && exists(${MAKECONF})
.include "${MAKECONF}"
+.elif exists(@SYSCONFDIR@/mk.conf)
+.include "@SYSCONFDIR@/mk.conf"
.elif exists(/etc/mk.conf)
.include "/etc/mk.conf"
.endif
Index: mods/mk/bsd.own.mk.in
===================================================================
RCS file: /cvsroot/pkgsrc/bootstrap/mods/mk/bsd.own.mk.in,v
retrieving revision 1.2
diff -u -r1.2 bsd.own.mk.in
--- mods/mk/bsd.own.mk.in 11 Mar 2004 17:29:11 -0000 1.2
+++ mods/mk/bsd.own.mk.in 6 Apr 2004 21:58:17 -0000
@@ -5,6 +5,8 @@
.if defined(MAKECONF) && exists(${MAKECONF})
.include "${MAKECONF}"
+.elif exists(@SYSCONFDIR@/mk.conf)
+.include "@SYSCONFDIR@/mk.conf"
.elif exists(/etc/mk.conf)
.include "/etc/mk.conf"
.endif
--
Julio M. Merino Vidal <jmmv@menta.net>
The NetBSD Project - http://www.NetBSD.org/