summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmmv <jmmv@pkgsrc.org>2003-07-18 12:21:38 +0000
committerjmmv <jmmv@pkgsrc.org>2003-07-18 12:21:38 +0000
commit53663d364d6b18e253c8e7cde3a94c850cb76591 (patch)
tree97bd78aa7890ce28209fbaf93f7d8e214bb88138
parentcae1f39ea587fe23c3d35d2697fed88e20ed7137 (diff)
downloadpkgsrc-53663d364d6b18e253c8e7cde3a94c850cb76591.tar.gz
Update to 1.7:
- Added support for audit-packages. pkg_comp will now automatically setup the vulnerabilities file inside the chroot so that pkgsrc can check for security flaws before building packages. See the USE_AUDIT_PACKAGES variable in the manpage. - Added support for gcc3. pkg_comp will now automatically install the gcc3 compiler inside the chroot and build all packages using it. See the USE_GCC3 variable in the manpage. - The new MKCONF_VARS variable lets you add any variable to the generated mk.conf file from the configuration file (no need for EXTRAMK in most cases). - Deprecated the removepkgs target. It was buggy and difficult to adapt to the new changes. removeroot+makeroot should produce the same effect. - Some code cleanup, specially regarding to template file generation and default values for variables. (See next change item) - Configuration file semantics have changed. Variables are now set to their default value if they are NOT set in the configuration file. This changes the behaviour of SETS_X11 specially, which needs to be explicitly set to "no" to disable X11. - Fixed shell profile configuration. Now PS1 is properly set when using the "chroot" target.
-rw-r--r--pkgtools/pkg_comp/Makefile6
-rw-r--r--pkgtools/pkg_comp/files/pkg_comp.867
-rw-r--r--pkgtools/pkg_comp/files/pkg_comp.sh333
3 files changed, 244 insertions, 162 deletions
diff --git a/pkgtools/pkg_comp/Makefile b/pkgtools/pkg_comp/Makefile
index 51dede54f5e..748dbe9b150 100644
--- a/pkgtools/pkg_comp/Makefile
+++ b/pkgtools/pkg_comp/Makefile
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.10 2003/07/17 22:52:14 grant Exp $
+# $NetBSD: Makefile,v 1.11 2003/07/18 12:21:38 jmmv Exp $
-DISTNAME= pkg_comp-1.6
+DISTNAME= pkg_comp-1.7
WRKSRC= ${WRKDIR}
CATEGORIES= pkgtools
MASTER_SITES= # empty
@@ -14,8 +14,6 @@ NO_CHECKSUM= YES
NO_CONFIGURE= YES
NO_BUILD= YES
-.include "../../mk/bsd.prefs.mk"
-
do-install:
${INSTALL_SCRIPT} ${FILESDIR}/pkg_comp.sh ${PREFIX}/sbin/pkg_comp
${INSTALL_MAN} ${FILESDIR}/pkg_comp.8 ${PREFIX}/man/man8/pkg_comp.8
diff --git a/pkgtools/pkg_comp/files/pkg_comp.8 b/pkgtools/pkg_comp/files/pkg_comp.8
index 91b0658939b..5cddb04d53d 100644
--- a/pkgtools/pkg_comp/files/pkg_comp.8
+++ b/pkgtools/pkg_comp/files/pkg_comp.8
@@ -1,7 +1,7 @@
-.\" $NetBSD: pkg_comp.8,v 1.7 2003/07/15 16:46:09 jmmv Exp $
+.\" $NetBSD: pkg_comp.8,v 1.8 2003/07/18 12:21:39 jmmv Exp $
.\"
.\" pkg_comp - Build packages inside a clean chroot environment
-.\" Copyright (c) 2002, Julio Merino <jmmv@netbsd.org>
+.\" Copyright (c) 2002, 2003, Julio Merino <jmmv@netbsd.org>
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd December 24, 2002
+.Dd July 18, 2003
.Dt PKG_COMP 8
.Os
.Sh NAME
@@ -158,14 +158,31 @@ A list of packages to automatically build after the
target.
A package is in the form section/name, like misc/colorls.
Defaults to nothing.
+.It MKCONF_VARS
+A list of variable names that will be appended to the generated
+.Pa /etc/mk.conf
+file, together with their values set in the configuration file.
+Its default value contains all variables listed here.
.It PKG_SYSCONFBASE
Base directory of configuration files.
Defaults to
.Pa /usr/pkg/etc .
+.It PKGVULNDIR
+Directory where the
+.Pa vulnerabilities
+file will be installed (inside the chroot).
+Defaults to
+.Pa /usr/pkg/share .
+.It REAL_PKGVULNDIR
+Directory where the system-wide
+.Pa vulnerabilities
+file resides (outside the chroot).
+Defaults to
+.Pa /usr/pkgsrc/distfiles .
.It ROOTSHELL
The shell of the root user.
Defaults to
-.Pa /bin/sh .
+.Pa /bin/ksh .
.It SETS
A list of binary sets to be extracted inside
.Sy DESTDIR .
@@ -176,17 +193,36 @@ A list of binary sets of the X Window system.
This has the same behavior
as
.Sy SETS .
-If this variable is empty, no X Window is configured inside the chroot
+If this variable is set to
+.Ql no ,
+no X Window is configured inside the chroot
jail and no other X variables take effect.
Defaults to
.Ql xbase.tgz xcomp.tgz xcontrib.tgz xfont.tgz xmisc.tgz xserver.tgz .
-.It USE_XF86_4
+.It USE_AUDIT_PACKAGES
If set to
.Ql yes ,
-sets specified in SETS_X11 contain X Window version 4.
-Has no effect if X is unconfigured.
+install the
+.Pa security/audit-packages
+package inside the chroot and let
+.Nm
+handle the
+.Pa vulnerabilities
+file automatically.
+This means that it will install the system-wide
+.Pa vulnerabilities
+file inside the chroot when needed, keeping both in sync.
Defaults to
.Ql yes .
+.It USE_GCC3
+If set to
+.Ql yes ,
+the GNU C Compiler version 3 will be installed inside the chroot
+environment and used to build all packages, using the
+.Pa lang/gcc3
+package.
+Defaults to
+.Ql no .
.It USE_XPKGWEDGE
If set to
.Ql yes ,
@@ -295,16 +331,6 @@ Enters the chroot environment.
If no arguments are given,
.Va ROOTSHELL
is executed, otherwise whatever you typed.
-.It removepkgs
-Remove all the packages in the chroot environment.
-It starts deleting packages with
-.Xr pkg_delete 1
-and then cleans the package tree and the database.
-This will rebuild
-.Sy MAKE_PACKAGES ,
-reinstall
-.Sy INSTALL_PACKAGES
-and xpkgwedge if they are specified in the configuration file.
.It removeroot
Remove the entire chroot tree.
You should do it with this target because it
@@ -325,6 +351,11 @@ or pass package names through the command line.
.Sh NOTES
This program uses nullfs to create virtual copies of real trees inside the
chroot environment.
+.Pp
+You need to install the
+.Pa security/audit-packages
+package in the host system if you want security checks to work inside the
+chroot environment.
.Sh SEE ALSO
.Xr pkg_delete 1 ,
.Xr packages 7 ,
diff --git a/pkgtools/pkg_comp/files/pkg_comp.sh b/pkgtools/pkg_comp/files/pkg_comp.sh
index 4a426742ab5..b96250bd9ca 100644
--- a/pkgtools/pkg_comp/files/pkg_comp.sh
+++ b/pkgtools/pkg_comp/files/pkg_comp.sh
@@ -1,9 +1,9 @@
#!/bin/sh
#
-# $NetBSD: pkg_comp.sh,v 1.6 2003/01/24 09:41:28 jmmv Exp $
+# $NetBSD: pkg_comp.sh,v 1.7 2003/07/18 12:21:39 jmmv Exp $
#
# pkg_comp - Build packages inside a clean chroot environment
-# Copyright (c) 2002, Julio Merino <jmmv@netbsd.org>
+# Copyright (c) 2002, 2003, Julio Merino <jmmv@netbsd.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -31,24 +31,108 @@
# POSSIBILITY OF SUCH DAMAGE.
#
+ProgName="`basename $0`"
+
+# ----------------------------------------------------------------------
+# Default environment values and functions
+# ----------------------------------------------------------------------
+
+# USE_GCC3, CFLAGS, CPPFLAGS and CXXFLAGS are ommited from _MKCONF_VARS
+# as they require special handling.
+_MKCONF_VARS="OBJMACHINE MKOBJDIRS BSDSRCDIR WRKOBJDIR DISTDIR PACKAGES \
+ PKG_DEVELOPER CLEANDEPENDS LOCALBASE PKG_SYSCONFBASE \
+ CFLAGS CPPFLAGS CXXFLAGS USE_AUDIT_PACKAGES PKGVULNDIR"
+
+_TEMPLATE_VARS="DESTDIR ROOTSHELL COPYROOTCFG BUILD_TARGET DISTRIBDIR SETS \
+ SETS_X11 USE_XPKGWEDGE REAL_SRC REAL_SRC_OPTS REAL_PKGSRC \
+ REAL_PKGSRC_OPTS REAL_DISTFILES REAL_DISTFILES_OPTS \
+ REAL_PACKAGES REAL_PACKAGES_OPTS REAL_PKGVULNDIR"
+
+env_clean()
+{
+ MKCONF_VARS=""
+ TEMPLATE_VARS=""
+ for var in ${_MKCONF_VARS} ${_TEMPLATE_VARS}; do
+ eval $var=\"\"
+ done
+}
+
+env_setdefaults()
+{
+ MKCONF_VARS="$MKCONF_VARS ${_MKCONF_VARS}"
+ TEMPLATE_VARS="$TEMPLATE_VARS ${_TEMPLATE_VARS}"
+
+ # Default values for variables that will be written to mk.conf.
+ : ${OBJMACHINE:=yes}
+ : ${MKOBJDIRS:=yes}
+ : ${BSDSRCDIR:=/usr/src}
+ : ${WRKOBJDIR:=/pkg_comp/obj/pkgsrc}
+ : ${DISTDIR:=/pkg_comp/distfiles}
+ : ${PACKAGES:=/pkg_comp/packages}
+ : ${PKG_DEVELOPER:=yes}
+ : ${CLEANDEPENDS:=yes}
+ : ${LOCALBASE:=/usr/pkg}
+ : ${PKG_SYSCONFDIR:=/usr/pkg/etc}
+ : ${CFLAGS:=}
+ : ${CPPFLAGS:=}
+ : ${CXXFLAGS:=}
+ : ${USE_GCC3:=no}
+ : ${USE_AUDIT_PACKAGES:=yes}
+ : ${PKGVULNDIR:=/usr/pkg/share}
+
+ # Default values for global variables used in the script.
+ : ${DESTDIR:=/var/chroot/pkg_comp/default}
+ : ${ROOTSHELL:=/bin/ksh}
+ : ${COPYROOTCFG:=no}
+ : ${BUILD_TARGET:=package}
+ : ${DISTRIBDIR:=/var/pub/NetBSD}
+ : ${SETS:=base.tgz comp.tgz etc.tgz text.tgz}
+ : ${SETS_X11:=xbase.tgz xcomp.tgz xcontrib.tgz xfont.tgz xmisc.tgz xserver.tgz}
+ : ${USE_XPKGWEDGE:=yes}
+ : ${REAL_SRC:=/usr/src}
+ : ${REAL_SRC_OPTS:=-t null -o ro}
+ : ${REAL_PKGSRC:=/usr/pkgsrc}
+ : ${REAL_PKGSRC_OPTS:=-t null -o ro}
+ : ${REAL_DISTFILES:=/usr/pkgsrc/distfiles}
+ : ${REAL_DISTFILES_OPTS:=-t null -o rw}
+ : ${REAL_PACKAGES:=/usr/pkgsrc/packages}
+ : ${REAL_PACKAGES_OPTS:=-t null -o rw}
+ : ${REAL_PKGVULNDIR:=/usr/pkgsrc/distfiles}
+}
+
# ----------------------------------------------------------------------
# Misc functions
# ----------------------------------------------------------------------
+
err()
{
- echo "$progname: $1"
+ echo "$ProgName: $1"
exit 1
}
usage()
{
- echo "usage: $progname [-c conf_file] target [pkg_names]"
+ echo "usage: $ProgName [-c conf_file] target [pkg_names]"
exit 1
}
+copy_vulnerabilities()
+{
+ if [ "$USE_AUDIT_PACKAGES" = "yes" ]; then
+ echo "PKG_COMP ==> Installing new \`vulnerabilities' file"
+ if [ ! -f "$REAL_PKGVULNDIR/vulnerabilities" ]; then
+ echo "$REAL_PKGVULNDIR/vulnerabilities not found."
+ else
+ mkdir -p $DESTDIR/$PKGVULNDIR
+ cp $REAL_PKGVULNDIR/vulnerabilities $DESTDIR/$PKGVULNDIR
+ fi
+ fi
+}
+
# ----------------------------------------------------------------------
# Filesystem functions
# ----------------------------------------------------------------------
+
fsmount()
{
printf "PKG_COMP ==> Mounting chroot filesystems:"
@@ -159,69 +243,43 @@ fsumount()
# ----------------------------------------------------------------------
# maketemplate target
# ----------------------------------------------------------------------
+
pkg_maketemplate()
{
if [ -f "$conffile" ]; then
err "$conffile already exists"
fi
- echo "Creating template: $conffile"
mkdir -p $confdir
cat > $conffile <<EOF
# -*- sh -*-
#
-# pkg_comp configuration file
+# pkg_comp - configuration file
+# See pkg_comp(8) for a detailed description of each variable.
#
-DESTDIR="/var/chroot/pkg_comp/default"
-ROOTSHELL="/bin/sh"
-COPYROOTCFG="no"
-COPTS="-pipe"
-
-# Target used to build packages.
-BUILD_TARGET="package"
-
-# Binary sets (tgz) are found in \$DISTRIBDIR/binary/sets
-DISTRIBDIR="/var/pub/NetBSD"
-
-# These sets are unpacked to setup the initial chroot.
-SETS="base.tgz comp.tgz etc.tgz text.tgz"
-
-# X configuration. Leave SETS_X11 empty to disable X11.
-SETS_X11="xbase.tgz xcomp.tgz xcontrib.tgz xfont.tgz xmisc.tgz xserver.tgz"
-USE_XPKGWEDGE="yes"
-USE_XF86_4="yes"
-
-# pkgsrc configuration.
-LOCALBASE="/usr/pkg"
-PKG_SYSCONFBASE="\${LOCALBASE}/etc"
-
-# Special directories. They are mounted inside the chroot jail using
-# mount_null. Leave empty to avoid mounting.
-REAL_SRC="/usr/src"
-REAL_SRC_OPTS="-t null -o ro"
-REAL_PKGSRC="/usr/pkgsrc"
-REAL_PKGSRC_OPTS="-t null -o ro"
-REAL_DISTFILES="/usr/pkgsrc/distfiles"
-REAL_DISTFILES_OPTS="-t null -o rw"
-REAL_PACKAGES="/usr/pkgsrc/packages"
-REAL_PACKAGES_OPTS="-t null -o rw"
-
-# Specify which packages to build automatically after building the chroot.
-MAKE_PACKAGES=""
-
-# Install these packages after building the chroot. They must be present in
-# inside REAL_PACKAGES. You must specify the complete name.
-INSTALL_PACKAGES=""
-
-# Append this file to the generated mk.conf.
-EXTRAMK=
EOF
+
+ echo "# Variables used internally by pkg_comp." >> $conffile
+ for var in $TEMPLATE_VARS; do
+ eval val=\""\$$var"\"
+ echo "$var=\"$val\"" >> $conffile
+ done
+
+ echo >> $conffile
+ echo "# Default variables written to the generated mk.conf." >> $conffile
+ for var in $MKCONF_VARS; do
+ eval val=\""\$$var"\"
+ echo "$var=\"$val\"" >> $conffile
+ done
+
+ echo "pkg_comp: $conffile created. Edit the file by hand now."
}
# ----------------------------------------------------------------------
# makeroot target
# ----------------------------------------------------------------------
+
pkg_makeroot()
{
# Check for directories that will be null mounted.
@@ -250,7 +308,11 @@ pkg_makeroot()
err "DESTDIR $DESTDIR already exists"
fi
- allsets="$SETS $SETS_X11"
+ if [ "$SETS_X11" = "no" ]; then
+ allsets="$SETS"
+ else
+ allsets="$SETS $SETS_X11"
+ fi
for s in $allsets; do
if [ ! -f $DISTRIBDIR/binary/sets/$s ]; then
@@ -305,36 +367,53 @@ pkg_makeroot()
makeroot_mkconf
echo " done."
+
+ # From now on, filesystems may be mounted, so we need to trap
+ # signals to umount them.
+ trap "echo \"*** Process aborted ***\" ; fsumount ; exit 1" INT QUIT
- makeroot_xpkgwedge
+ if [ "$USE_AUDIT_PACKAGES" = "yes" ]; then
+ pkg_build security/audit-packages
+ fi
- if [ -n "$MAKE_PACKAGES" ]; then
- pkg_build $MAKE_PACKAGES
+ if [ "$USE_GCC3" = "yes" ]; then
+ if [ -z "`echo $MAKE_PACKAGES $INSTALL_PACKAGES | grep gcc3`" ]; then
+ AVOID_GCC3=yes pkg_build lang/gcc3
+ fi
+ fi
+
+ if [ "$SETS_X11" != "no" ]; then
+ makeroot_xpkgwedge
+ pkg_build pkgtools/x11-links
fi
if [ -n "$INSTALL_PACKAGES" ]; then
pkg_install $INSTALL_PACKAGES
fi
+
+ if [ -n "$MAKE_PACKAGES" ]; then
+ pkg_build $MAKE_PACKAGES
+ fi
}
makeroot_mkconf()
{
file="$DESTDIR/etc/mk.conf"
- echo "OBJMACHINE=yes" >> $file
- echo "MKOBJDIRS=yes" >> $file
- echo "BSDSRCDIR=/usr/src" >> $file
- echo "WRKOBJDIR=/pkg_comp/obj/pkgsrc" >> $file
- echo "DISTDIR=/pkg_comp/distfiles" >> $file
- echo "PACKAGES=/pkg_comp/packages" >> $file
- echo "PKG_DEVELOPER?=yes" >> $file
- echo "CLEANDEPENDS?=yes" >> $file
+ cat >> $file <<EOF
+#
+# /etc/mk.conf
+# File automatically generated by pkg_comp on `date`
+#
- echo "COPTS=$COPTS" >> $file
- echo "USE_XF86_4=$USE_XF86_4" >> $file
+EOF
- echo "LOCALBASE=$LOCALBASE" >> $file
- echo "PKG_SYSCONFBASE=$PKG_SYSCONFBASE" >> $file
+ for var in $MKCONF_VARS; do
+ eval val=\""\$$var"\"
+ if [ -n "$val" ]; then
+ echo "$var ?= $val" >> $file
+ fi
+ done
if [ -n "$EXTRAMK" ]; then
if [ ! -f "$EXTRAMK" ]; then
@@ -343,6 +422,28 @@ makeroot_mkconf()
cat $EXTRAMK >> $file
fi
fi
+
+ if [ "$USE_AUDIT_PACKAGES" != "yes" ]; then
+ echo "ALLOW_VULNERABLE_PACKAGES ?= YES" >> $file
+ fi
+
+ if [ "$USE_GCC3" = "yes" ]; then
+ cat >>$file <<EOF
+.if !defined(AVOID_GCC3) && exists(/usr/pkg/share/examples/gcc-3.3/mk.conf)
+USE_GCC3 = yes
+CFLAGS += $CFLAGS
+CPPFLAGS += $CPPFLAGS
+CXXFLAGS += $CXXFLAGS
+.include "/usr/pkg/share/examples/gcc-3.3/mk.conf"
+.endif
+EOF
+ else
+ cat >>$file <<EOF
+CFLAGS += $CFLAGS
+CPPFLAGS += $CPPFLAGS
+CXXFLAGS += $CXXFLAGS
+EOF
+ fi
}
makeroot_xpkgwedge()
@@ -359,6 +460,7 @@ makeroot_xpkgwedge()
# ----------------------------------------------------------------------
# build target
# ----------------------------------------------------------------------
+
pkg_build()
{
pkgs="$*"
@@ -374,6 +476,8 @@ pkg_build()
err "invalid packages:$invalid"
fi
+ copy_vulnerabilities
+
# Build them
fsmount
failed=""
@@ -413,6 +517,7 @@ EOF
# ----------------------------------------------------------------------
# install target
# ----------------------------------------------------------------------
+
pkg_install()
{
pkgs="$*"
@@ -421,6 +526,8 @@ pkg_install()
err "REAL_PACKAGES is not set"
fi
+ copy_vulnerabilities
+
fsmount
failed=""
for p in $pkgs; do
@@ -448,18 +555,21 @@ EOF
# ----------------------------------------------------------------------
# chroot target
# ----------------------------------------------------------------------
+
pkg_chroot()
{
if [ ! -d $DESTDIR ]; then
err "$DESTDIR does not exist"
fi
+ copy_vulnerabilities
+
fsmount
echo "PKG_COMP ==> Entering chroot: $DESTDIR"
if [ $# -eq 0 ]; then
- chroot $DESTDIR $ROOTSHELL
+ ENV=/etc/shrc chroot $DESTDIR $ROOTSHELL
else
- chroot $DESTDIR $*
+ ENV=/etc/shrc chroot $DESTDIR $*
fi
echo
fsumount
@@ -468,6 +578,7 @@ pkg_chroot()
# ----------------------------------------------------------------------
# removeroot target
# ----------------------------------------------------------------------
+
pkg_removeroot()
{
if [ -f $fsstate ]; then
@@ -479,54 +590,9 @@ pkg_removeroot()
}
# ----------------------------------------------------------------------
-# removepkgs target
-# ----------------------------------------------------------------------
-pkg_removepkgs()
-{
- fsmount
- echo "PKG_COMP ==> Removing packages"
- cat > $DESTDIR/pkg_comp/tmp/removeall.sh <<EOF
-#!/bin/sh
-list="\`pkg_info\`"
-while [ -n "\$list" ]; do
- echo "Deleting all (non-recursive)"
- pkg_delete "*"
- list="\`pkg_info\`"
-done
-EOF
- chmod +x $DESTDIR/pkg_comp/tmp/removeall.sh
- chroot $DESTDIR /pkg_comp/tmp/removeall.sh
- rm $DESTDIR/pkg_comp/tmp/removeall.sh
-
- printf "Cleaning pkg tree ($LOCALBASE):"
- rm -rf $DESTDIR$LOCALBASE
- echo " done."
-
- if [ -d "$PKG_SYSCONFBASE" ]; then
- printf "Cleaning pkg configuration ($PKG_SYSCONFBASE):"
- rm -rf $DESTDIR$PKG_SYSCONFBASE
- echo " done."
- fi
-
- printf "Cleaning pkg database:"
- rm -rf $DESTDIR/var/db/pkg
- mkdir -p $DESTDIR/var/db/pkg
- echo " done."
- makeroot_xpkgwedge
- if [ -n "$MAKE_PACKAGES" ]; then
- pkg_build $MAKE_PACKAGES
- fi
- if [ -n "$INSTALL_PACKAGES" ]; then
- pkg_install $INSTALL_PACKAGES
- fi
- fsumount
-}
-
-# ----------------------------------------------------------------------
# Main program
# ----------------------------------------------------------------------
-progname="`basename $0`"
confdir="$HOME/pkg_comp"
# Parse options
@@ -564,42 +630,34 @@ readconf()
err "must be run as root"
fi
echo "Reading config file: $conffile"
+ env_clean
. $conffile
+ env_setdefaults
else
err "$conffile does not exist"
fi
- if [ -z "$LOCALBASE" ]; then
- LOCALBASE="/usr/pkg"
- fi
-
- if [ -z "$PKG_SYSCONFBASE" ]; then
- PKG_SYSCONFBASE="/usr/pkg/etc"
- fi
-
fsstate="$DESTDIR/pkg_comp/tmp/mount.stat"
-
- if [ -n "$SETS_X11" ]; then
- MAKE_PACKAGES="$MAKE_PACKAGES pkgtools/x11-links"
- fi
}
checkroot()
{
- if [ ! -d "$DESTDIR" ]; then
- err "chroot not initialized; use makeroot first."
- fi
- if [ "$DESTDIR" = "/" ]; then
- err "DESTDIR cannot be /"
- fi
-
- # From now on, filesystems may be mounted, so we need to trap
- # signals to umount them.
- trap "echo \"*** Process aborted ***\" ; fsumount ; exit 1" INT QUIT
+ if [ ! -d "$DESTDIR" ]; then
+ err "chroot not initialized; use makeroot first."
+ fi
+ if [ "$DESTDIR" = "/" ]; then
+ err "DESTDIR cannot be /"
+ fi
+
+ # From now on, filesystems may be mounted, so we need to trap
+ # signals to umount them.
+ trap "echo \"*** Process aborted ***\" ; fsumount ; exit 1" INT QUIT
}
case "$target" in
maketemplate)
+ env_clean
+ env_setdefaults
pkg_maketemplate
exit 0
;;
@@ -626,11 +684,6 @@ case "$target" in
pkg_chroot $args
exit 0
;;
- removepkgs)
- readconf
- checkroot
- pkg_removepkgs
- ;;
removeroot)
readconf
checkroot
@@ -653,7 +706,7 @@ case "$target" in
pkg_removeroot
;;
*)
- err "unknown target '$target'"
+ err "unknown target \`$target'"
;;
esac