From 9ec1e72e65332931dd16300cb09c81b273e0dbde Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Thu, 26 Feb 2009 10:51:35 -0800 Subject: makechrootpkg: Allow setting rw layer dir name Make the name of the rw layer (default /rw) configurable with a command line switch. Useful for maintaining multipl chroots on top of a clean base. i.e. /root #clean chroot /rw #default RW layer /gnome #a RW layer with all of gnome installed /kde #a RW layer with all of KDE installed Signed-off-by: Aaron Griffin --- makechrootpkg | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/makechrootpkg b/makechrootpkg index 209f571..e25a975 100755 --- a/makechrootpkg +++ b/makechrootpkg @@ -12,6 +12,7 @@ FORCE="n" RUN="" MAKEPKG_ARGS="-sr" REPACK="" +LAYER="rw" WORKDIR=$PWD update_first="0" @@ -25,8 +26,7 @@ APPNAME=$(basename "${0}") usage () { - echo "usage ${APPNAME} [-hcud] -r [--] [makepkg args]" - echo " ${APPNAME} -r -I " + echo "usage ${APPNAME} [options] -r [--] [makepkg args]" echo " Run this script in a PKGBUILD dir to build a package inside a" echo " clean chroot. All unrecognized arguments passed to this script" echo " will be passed to makepkg." @@ -42,18 +42,20 @@ usage () echo "Default makepkg args: $MAKEPKG_ARGS" echo "" echo "Flags:" - echo "-h This help" - echo "-c Clean the chroot before building" - echo "-u Update the rw layer of the chroot before building" - echo " This is useful for rebuilds without dirtying the pristine" - echo " chroot" - echo "-d Add the package to a local db at /repo after building" - echo "-r The chroot shell to use" - echo "-I Install a package into the rw layer of the chroot" + echo "-h This help" + echo "-c Clean the chroot before building" + echo "-u Update the rw layer of the chroot before building" + echo " This is useful for rebuilds without dirtying the pristine" + echo " chroot" + echo "-d Add the package to a local db at /repo after building" + echo "-r The chroot shell to use" + echo "-I Install a package into the rw layer of the chroot" + echo "-l The directory to use as the rw layer of the unionfs" + echo " Useful for maintain multiple layers. Default: rw" exit 1 } -while getopts 'hcudr:I:' arg; do +while getopts 'hcudr:I:l:' arg; do case "${arg}" in h) usage ;; c) clean_first=1 ;; @@ -61,6 +63,7 @@ while getopts 'hcudr:I:' arg; do d) add_to_db=1 ;; r) chrootdir="$OPTARG" ;; I) install_pkg="$OPTARG" ;; + l) LAYER="$OPTARG" ;; *) MAKEPKG_ARGS="$MAKEPKG_ARGS -$arg $OPTARG" ;; esac done @@ -101,8 +104,8 @@ if [ ! -d "$chrootdir/root" ]; then usage fi -[ -d "$chrootdir/rw" -a "$clean_first" -eq "1" ] && rm -rf "$chrootdir/rw/" -[ -d "$chrootdir/rw" ] || mkdir "$chrootdir/rw" +[ -d "$chrootdir/$LAYER" -a "$clean_first" -eq "1" ] && rm -rf "$chrootdir/$LAYER/" +[ -d "$chrootdir/$LAYER" ] || mkdir "$chrootdir/$LAYER" [ -d "$chrootdir/union" ] || mkdir "$chrootdir/union" cleanup () @@ -122,7 +125,7 @@ if [ $? -ne 0 ]; then echo "ERROR: No unionfs available. Abandon ship!" && exit 1 fi fi -mount -t unionfs none -o "dirs=$chrootdir/rw=rw:$chrootdir/root=ro" "$uniondir" +mount -t unionfs none -o "dirs=$chrootdir/$LAYER=rw:$chrootdir/root=ro" "$uniondir" trap 'cleanup' 0 1 2 15 if [ -n "$install_pkg" ]; then @@ -214,6 +217,7 @@ export LANG=$LOCALE cd /build export HOME=/build sudo -u nobody makepkg $MAKEPKG_ARGS || touch BUILD_FAILED +namcap *.pkg.tar.gz > /pkgdest/namcap.log EOF ) > "$uniondir/chrootbuild" chmod +x "$uniondir/chrootbuild" @@ -239,14 +243,14 @@ if mkarchroot -r "/chrootbuild" "$uniondir"; then fi else #just in case. We returned 1, make sure we fail - touch ${chrootdir}/rw/build/BUILD_FAILED + touch ${chrootdir}/union/build/BUILD_FAILED fi -if [ -e ${chrootdir}/rw/build/BUILD_FAILED ]; then - echo "Build failed, check $chrootdir/rw/build" - rm ${chrootdir}/rw/build/BUILD_FAILED +if [ -e ${chrootdir}/union/build/BUILD_FAILED ]; then + echo "Build failed, check $chrootdir/$LAYER/build" + rm ${chrootdir}/union/build/BUILD_FAILED else - rm -rf ${chrootdir}/rw/build/* + rm -rf ${chrootdir}/union/build/* echo "Build complete" fi -- cgit v1.2.3-70-g09d2