diff options
author | jmmv <jmmv@pkgsrc.org> | 2002-12-19 14:47:04 +0000 |
---|---|---|
committer | jmmv <jmmv@pkgsrc.org> | 2002-12-19 14:47:04 +0000 |
commit | e5df6202360eb832d9f096355bcc590b7bd556bd (patch) | |
tree | 5fd6ead60c847633f52f254da06e53e5c113d663 | |
parent | c3229ab897e91c4fac08de78a3694c7c3c4c3d3a (diff) | |
download | pkgsrc-e5df6202360eb832d9f096355bcc590b7bd556bd.tar.gz |
Update pkg_comp to 1.3:
- Added ability to tune LOCALBASE and PKG_SYSCONFBASE.
- Deprecated PTHREAD_TYPE variable, not useful any more.
- Multiple error checking (directory presence) added.
- Several bugfixes (specially in removepkgs target).
- Replaced "echo -n" with "printf" (more portable).
- Replaced "! -z" with "-n" when doing tests.
- Changed my email address to the NetBSD one.
-rw-r--r-- | pkgtools/pkg_comp/Makefile | 4 | ||||
-rw-r--r-- | pkgtools/pkg_comp/files/pkg_comp.8 | 18 | ||||
-rw-r--r-- | pkgtools/pkg_comp/files/pkg_comp.sh | 157 |
3 files changed, 121 insertions, 58 deletions
diff --git a/pkgtools/pkg_comp/Makefile b/pkgtools/pkg_comp/Makefile index a09e073b534..a22f786d623 100644 --- a/pkgtools/pkg_comp/Makefile +++ b/pkgtools/pkg_comp/Makefile @@ -1,6 +1,6 @@ -# $NetBSD: Makefile,v 1.3 2002/12/14 23:27:50 jmmv Exp $ +# $NetBSD: Makefile,v 1.4 2002/12/19 14:47:04 jmmv Exp $ -DISTNAME= pkg_comp-1.2 +DISTNAME= pkg_comp-1.3 CATEGORIES= pkgtools MASTER_SITES= # empty DISTFILES= # empty diff --git a/pkgtools/pkg_comp/files/pkg_comp.8 b/pkgtools/pkg_comp/files/pkg_comp.8 index 614cd44b59f..44a3c7ebc9e 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.3 2002/09/25 18:57:30 wiz Exp $ +.\" $NetBSD: pkg_comp.8,v 1.4 2002/12/19 14:47:05 jmmv Exp $ .\" .\" pkg_comp - Build packages inside a clean chroot environment -.\" Copyright (c) 2002, Julio Merino <jmmv@hispabsd.org> +.\" Copyright (c) 2002, Julio Merino <jmmv@netbsd.org> .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -143,16 +143,20 @@ Each name must be the full package name, including the tgz suffix. Packages are searched inside .Pa $REAL_PACKAGES/All . Defaults to nothing. +.It LOCALBASE +Where binary packages get installed. +Defaults to +.Pa /usr/pkg . .It MAKE_PACKAGES A list of packages to automatically build after the .Sy makeroot target. A package is in the form section/name, like misc/colorls. Defaults to nothing. -.It PTHREAD_TYPE -The threading type to use when building packages. +.It PKG_SYSCONFBASE +Base directory of configuration files. Defaults to -.Ql pth . +.Pa /usr/pkg/etc . .It ROOTSHELL The shell of the root user. Defaults to @@ -318,6 +322,4 @@ chroot environment. .Xr packages 7 , .Xr mount_null 8 .Sh AUTHORS -.An Julio Merino Aq jmmv@hispabsd.org -.Sh BUGS -Probably many, especially error checking. +.An Julio Merino Aq jmmv@netbsd.org diff --git a/pkgtools/pkg_comp/files/pkg_comp.sh b/pkgtools/pkg_comp/files/pkg_comp.sh index 04442c7301d..925416abbd9 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.2 2002/12/14 23:27:51 jmmv Exp $ +# $NetBSD: pkg_comp.sh,v 1.3 2002/12/19 14:47:05 jmmv Exp $ # # pkg_comp - Build packages inside a clean chroot environment -# Copyright (c) 2002, Julio Merino <jmmv@hispabsd.org> +# Copyright (c) 2002, Julio Merino <jmmv@netbsd.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -51,7 +51,7 @@ usage() # ---------------------------------------------------------------------- fsmount() { - echo -n "=> Mounting chroot filesystems:" + printf "PKG_COMP ==> Mounting chroot filesystems:" if [ -f $fsstate ]; then count=`cat $fsstate` count=$(($count + 1)) @@ -62,19 +62,39 @@ fsmount() echo "1" > $fsstate fi - if [ ! -z "$REAL_SRC" ]; then + if [ -n "$REAL_SRC" ]; then + if [ ! -d "$REAL_SRC" ]; then + echo " failed." + fsumount + err "REAL_SRC $REAL_SRC disappeared" + fi mount $REAL_SRC_OPTS $REAL_SRC $DESTDIR/usr/src fi - if [ ! -z "$REAL_PKGSRC" ]; then + if [ -n "$REAL_PKGSRC" ]; then + if [ ! -d "$REAL_PKGSRC" ]; then + echo " failed." + fsumount + err "REAL_PKGSRC $REAL_PKGSRC disappeared" + fi mount $REAL_PKGSRC_OPTS $REAL_PKGSRC $DESTDIR/usr/pkgsrc fi - if [ ! -z "$REAL_DISTFILES" ]; then + if [ -n "$REAL_DISTFILES" ]; then + if [ ! -d "$REAL_DISTFILES" ]; then + echo " failed." + fsumount + err "REAL_DISTFILES $REAL_DISTFILES disappeared" + fi mount $REAL_DISTFILES_OPTS $REAL_DISTFILES $DESTDIR/pkg_comp/distfiles fi - if [ ! -z "$REAL_PACKAGES" ]; then + if [ -n "$REAL_PACKAGES" ]; then + if [ ! -d "$REAL_PACKAGES" ]; then + echo " failed." + fsumount + err "REAL_PACKAGES $REAL_PACKAGES disappeared" + fi mount $REAL_PACKAGES_OPTS $REAL_PACKAGES $DESTDIR/pkg_comp/packages fi @@ -84,7 +104,7 @@ fsmount() fsumount() { - echo -n "=> Unmounting chroot filesystems:" + printf "PKG_COMP ==> Unmounting chroot filesystems:" if [ ! -f $fsstate ]; then echo " none mounted." return @@ -100,33 +120,33 @@ fsumount() fsfailed=no - if [ ! -z "$REAL_SRC" ]; then + if [ -n "$REAL_SRC" -a -d "$REAL_SRC" ]; then umount $DESTDIR/usr/src if [ $? != 0 ]; then fsfailed=yes; fi fi - if [ ! -z "$REAL_PKGSRC" ]; then + if [ -n "$REAL_PKGSRC" -a -d "$REAL_PKGSRC" ]; then umount $DESTDIR/usr/pkgsrc if [ $? != 0 ]; then fsfailed=yes; fi fi - if [ ! -z "$REAL_DISTFILES" ]; then + if [ -n "$REAL_DISTFILES" -a -d "$REAL_DISTFILES" ]; then umount $DESTDIR/pkg_comp/distfiles if [ $? != 0 ]; then fsfailed=yes; fi fi - if [ ! -z "$REAL_PACKAGES" ]; then + if [ -n "$REAL_PACKAGES" -a -d "$REAL_PACKAGES" ]; then umount $DESTDIR/pkg_comp/packages if [ $? != 0 ]; then fsfailed=yes; fi fi echo " done." - echo -n "Syncing: 1" + printf "Syncing: 1" sync ; sleep 1 - echo -n " 2" + printf " 2" sync ; sleep 1 - echo -n " 3" + printf " 3" sync ; sleep 1 echo " done." if [ "$fsfailed" = "yes" ]; then @@ -172,8 +192,9 @@ SETS_X11="xbase.tgz xcomp.tgz xcontrib.tgz xfont.tgz xmisc.tgz xserver.tgz" USE_XPKGWEDGE="yes" USE_XF86_4="yes" -# Threading library to use. -PTHREAD_TYPE="pth" +# 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. @@ -201,6 +222,24 @@ EOF # ---------------------------------------------------------------------- pkg_makeroot() { + # Check for directories that will be null mounted. + if [ -n "$REAL_SRC" -a ! -d "$REAL_SRC" ]; then + err "REAL_SRC $REAL_SRC does not exist" + fi + + if [ -n "$REAL_PKGSRC" -a ! -d "$REAL_PKGSRC" ]; then + err "REAL_PKGSRC $REAL_PKGSRC does not exist" + fi + + if [ -n "$REAL_DISTFILES" -a ! -d "$REAL_DISTFILES" ]; then + err "REAL_DISTFILES $REAL_DISTFILES does not exist" + fi + + if [ -n "$REAL_PACKAGES" -a ! -d "$REAL_PACKAGES" ]; then + err "REAL_PACKAGES $REAL_PACKAGES does not exist" + fi + + # Check for required directories. if [ ! -d $DISTRIBDIR ]; then err "DISTRIBDIR $DISTRIBDIR does not exist" fi @@ -211,28 +250,28 @@ pkg_makeroot() mkdir -p $DESTDIR cd $DESTDIR - echo -n "Unpacking sets:" + printf "Unpacking sets:" allsets="$SETS $SETS_X11" for s in $allsets; do - echo -n " $s" + printf " $s" tar xzpf $DISTRIBDIR/binary/sets/$s done echo - echo -n "Making device nodes:" + printf "Making device nodes:" cd $DESTDIR/dev ./MAKEDEV all cd $DESTDIR echo " done." - echo -n "Setting root's environment:" + printf "Setting root's environment:" chroot $DESTDIR chpass -s $ROOTSHELL if [ "$COPYROOTCFG" = "yes" ]; then cp /root/.* $DESTDIR/root 2>&1 | > /dev/null fi echo " done." - echo -n "Setting up initial configuration:" + printf "Setting up initial configuration:" mkdir -p $DESTDIR/usr/src mkdir -p $DESTDIR/usr/pkgsrc @@ -259,11 +298,11 @@ pkg_makeroot() makeroot_xpkgwedge - if [ ! -z "$MAKE_PACKAGES" ]; then + if [ -n "$MAKE_PACKAGES" ]; then pkg_build $MAKE_PACKAGES fi - if [ ! -z "$INSTALL_PACKAGES" ]; then + if [ -n "$INSTALL_PACKAGES" ]; then pkg_install $INSTALL_PACKAGES fi } @@ -282,17 +321,19 @@ makeroot_mkconf() echo "CLEANDEPENDS?=yes" >> $file echo "COPTS=$COPTS" >> $file - echo "PTHREAD_TYPE=$PTHREAD_TYPE" >> $file echo "USE_XF86_4=$USE_XF86_4" >> $file + + echo "LOCALBASE=$LOCALBASE" >> $file + echo "PKG_SYSCONFBASE=$PKG_SYSCONFBASE" >> $file } makeroot_xpkgwedge() { - if [ ! -z "$SETS_X11" ]; then + if [ -n "$SETS_X11" ]; then if [ $USE_XPKGWEDGE = "yes" ]; then pkg_build "pkgtools/xpkgwedge" - echo "export XAPPLRESDIR=/usr/pkg/lib/X11/app-defaults" >> $DESTDIR/etc/profile - echo "setenv XAPPLRESDIR /usr/pkg/lib/X11/app-defaults" >> $DESTDIR/etc/csh.login + echo "export XAPPLRESDIR=${LOCALBASE}/lib/X11/app-defaults" >> $DESTDIR/etc/profile + echo "setenv XAPPLRESDIR ${LOCALBASE}/lib/X11/app-defaults" >> $DESTDIR/etc/csh.login fi fi } @@ -311,7 +352,7 @@ pkg_build() invalid="$invalid $p" fi done - if [ ! -z "$invalid" ]; then + if [ -n "$invalid" ]; then err "invalid packages:$invalid" fi @@ -319,7 +360,7 @@ pkg_build() fsmount failed="" for p in $pkgs; do - echo "=> Building and installing $p" + echo "PKG_COMP ==> Building and installing $p" prefix=`mktemp $DESTDIR/pkg_comp/tmp/pkg_comp-XXXX` rm $prefix script="$prefix.sh" @@ -342,8 +383,12 @@ EOF fi done fsumount - if [ ! -z "$failed" ]; then - echo "Build failed for:$failed" + if [ -n "$failed" ]; then + echo "PKG_COMP ==> Build error summary" + echo "Build failed for:" + for p in $failed; do + echo " $p" + done fi } @@ -362,7 +407,7 @@ pkg_install() failed="" for p in $pkgs; do if [ -f $DESTDIR/pkg_comp/packages/All/$p ]; then - echo "=> Installing binary package: $p" + echo "PKG_COMP ==> Installing binary package: $p" stat=$DESTDIR/pkg_comp/tmp/install.sh cat >> $stat <<EOF #!/bin/sh @@ -377,7 +422,7 @@ EOF fi done fsumount - if [ ! -z "$failed" ]; then + if [ -n "$failed" ]; then echo "Installation failed for:$failed" fi } @@ -392,7 +437,7 @@ pkg_chroot() fi fsmount - echo "=> Entering chroot: $DESTDIR" + echo "PKG_COMP ==> Entering chroot: $DESTDIR" chroot $DESTDIR $ROOTSHELL echo fsumount @@ -406,7 +451,7 @@ pkg_removeroot() if [ -f $fsstate ]; then err "filesystems may still be mounted; cannot remove" fi - echo -n "=> Removing:" + printf "PKG_COMP ==> Removing chroot:" rm -rf $DESTDIR echo " done." } @@ -416,35 +461,43 @@ pkg_removeroot() # ---------------------------------------------------------------------- pkg_removepkgs() { - echo "=> Removing packages" + fsmount + echo "PKG_COMP ==> Removing packages" cat > $DESTDIR/pkg_comp/tmp/removeall.sh <<EOF #!/bin/sh -list="`pkg_info`" -while [ ! -z "$list" ]; do +list="\`pkg_info\`" +while [ -n "\$list" ]; do echo "Deleting all (non-recursive)" pkg_delete "*" - list="`pkg_info`" + 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 - echo -n "Cleaning pkg tree:" - rm -rf $DESTDIR/usr/pkg + printf "Cleaning pkg tree ($LOCALBASE):" + rm -rf $DESTDIR$LOCALBASE echo " done." - echo -n "Cleaning pkg database:" + 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 [ ! -z "$MAKE_PACKAGES" ]; then + if [ -n "$MAKE_PACKAGES" ]; then pkg_build $MAKE_PACKAGES fi - if [ ! -z "$INSTALL_PACKAGES" ]; then + if [ -n "$INSTALL_PACKAGES" ]; then pkg_install $INSTALL_PACKAGES fi + fsumount } # ---------------------------------------------------------------------- @@ -494,9 +547,17 @@ readconf() 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 [ ! -z "$SETS_X11" ]; then + if [ -n "$SETS_X11" ]; then MAKE_PACKAGES="$MAKE_PACKAGES pkgtools/x11-links" fi } @@ -507,7 +568,7 @@ checkroot() err "chroot not initialized; use makeroot first." fi if [ "$DESTDIR" = "/" ]; then - err "DESTDIR can't be /" + err "DESTDIR cannot be /" fi # From now on, filesystems may be mounted, so we need to trap @@ -564,7 +625,7 @@ case "$target" in fi pkg_makeroot checkroot - if [ ! -z "$pkgnames" ]; then + if [ -n "$pkgnames" ]; then pkg_build $pkgnames fi pkg_removeroot |