From ca99683972942fd75ad25eb498ea7d5aec0da2e3 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Tue, 24 Feb 2009 10:02:25 -0800 Subject: makechrootpkg: Add -d to add to local repo When a package build is complete, it is automatically added to a local db in /rw/repo/ Signed-off-by: Aaron Griffin --- makechrootpkg | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/makechrootpkg b/makechrootpkg index c4f47ef..8c3910f 100755 --- a/makechrootpkg +++ b/makechrootpkg @@ -17,6 +17,7 @@ WORKDIR=$PWD update_first="0" clean_first="0" install_pkg="" +add_to_db=0 chrootdir="" @@ -24,7 +25,7 @@ APPNAME=$(basename "${0}") usage () { - echo "usage ${APPNAME} [-hcu] -r [--] [makepkg args]" + echo "usage ${APPNAME} [-hcud] -r [--] [makepkg args]" echo " ${APPNAME} -r -I " echo " Run this script in a PKGBUILD dir to build a package inside a" echo " clean chroot. All unrecognized arguments passed to this script" @@ -46,16 +47,18 @@ usage () 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" exit 1 } -while getopts 'hcur:I:' arg; do +while getopts 'hcudr:I:' arg; do case "${arg}" in h) usage ;; c) clean_first=1 ;; u) update_first=1 ;; + d) add_to_db=1 ;; r) chrootdir="$OPTARG" ;; I) install_pkg="$OPTARG" ;; *) MAKEPKG_ARGS="$MAKEPKG_ARGS -$arg $OPTARG" ;; @@ -218,6 +221,15 @@ chmod +x "$uniondir/chrootbuild" mkarchroot -r "/chrootbuild" "$uniondir" source ${WORKDIR}/PKGBUILD + +if [ -n "$add_to_db" ]; then + [ -d "${chrootdir}/union/repo" ] || mkdir -p "${chrootdir}/union/repo" + pushd "${chrootdir}/union/repo" >/dev/null + cp ${chrootdir}/union/pkgdest/${pkgname}-${pkgver}-${pkgrel}-*.pkg.tar.gz . + repo-add repo.db.tar.gz *.pkg.tar.gz + popd >/dev/null +fi + if [ -z "$(mount | grep ${chrootdir}/union/pkgdest)" ]; then echo "Moving completed package file to ${WORKDIR}" mv ${chrootdir}/union/pkgdest/${pkgname}-${pkgver}-${pkgrel}-*.pkg.tar.gz ${WORKDIR} -- cgit v1.2.3-70-g09d2