Add 'update first' flag and fix help

Add -u to update the chroot before building. This should update the
unionfs rw layer only, leaving the chroot clean. Useful for rebuilds
and a local repo.

Also fix the docs and document the -i flag

Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
This commit is contained in:
Aaron Griffin 2009-02-23 14:30:28 -08:00
parent c67729af98
commit dd45bbcaf3
1 changed files with 17 additions and 5 deletions

View File

@ -13,6 +13,7 @@ RUN=""
MAKEPKG_ARGS="-sr" MAKEPKG_ARGS="-sr"
REPACK="" REPACK=""
WORKDIR=$PWD WORKDIR=$PWD
update_first="0"
clean_first="0" clean_first="0"
install_pkg="" install_pkg=""
@ -22,7 +23,7 @@ APPNAME=$(basename "${0}")
usage () usage ()
{ {
echo "usage ${APPNAME} [-h] [-c] [-r CHROOT_SHELL] [--] [makepkg args]" echo "usage ${APPNAME} [-hcui] [-r CHROOT_SHELL] [--] [makepkg args]"
echo " Run this script in a PKGBUILD dir to build a package inside a" 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 " clean chroot. All unrecognized arguments passed to this script"
echo " will be passed to makepkg." echo " will be passed to makepkg."
@ -32,9 +33,6 @@ usage ()
echo " directories: \$CHROOT_SHELL/{root, rw, union} but only 'root' is" echo " directories: \$CHROOT_SHELL/{root, rw, union} but only 'root' is"
echo " required by default. The rest will be created as needed" echo " required by default. The rest will be created as needed"
echo "" echo ""
echo "The -c flag, if specified, will remove all files created by previous"
echo "builds using makechrootpkg. This will ensure a clean chroot is used."
echo ""
echo "The chroot shell 'root' directory must be created via the following" echo "The chroot shell 'root' directory must be created via the following"
echo "command:" echo "command:"
echo " mkarchroot \$CHROOT_SHELL/root base base-devel sudo" echo " mkarchroot \$CHROOT_SHELL/root base base-devel sudo"
@ -43,13 +41,22 @@ usage ()
echo "options, put -- between the makechrootpkg args and the makepkg args" echo "options, put -- between the makechrootpkg args and the makepkg args"
echo "" echo ""
echo "Default makepkg args: $MAKEPKG_ARGS" 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 "-i <pkg> Install a package into the rw layer of the chroot"
exit 1 exit 1
} }
while getopts ':r:i:h:c' arg; do while getopts ':r:i:h:cu' arg; do
case "${arg}" in case "${arg}" in
r) chrootdir="$OPTARG" ;; r) chrootdir="$OPTARG" ;;
i) install_pkg="$OPTARG" ;; i) install_pkg="$OPTARG" ;;
u) update_first=1 ;;
c) clean_first=1 ;; c) clean_first=1 ;;
h|?) usage ;; h|?) usage ;;
*) MAKEPKG_ARGS="$MAKEPKG_ARGS -$arg $OPTARG" ;; *) MAKEPKG_ARGS="$MAKEPKG_ARGS -$arg $OPTARG" ;;
@ -127,6 +134,11 @@ if [ -n "$install_pkg" ]; then
exit $ret exit $ret
fi fi
if [ $update_first -eq 1 ]; then
echo "updating chroot"
mkarchroot -u "$uniondir"
fi
echo "moving build files to chroot" echo "moving build files to chroot"
[ -d "$uniondir/build" ] || mkdir "$uniondir/build" [ -d "$uniondir/build" ] || mkdir "$uniondir/build"