makechrootpkg: Add -d to add to local repo

When a package build is complete, it is automatically
added to a local db in <chrootdir>/rw/repo/

Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
This commit is contained in:
Aaron Griffin 2009-02-24 10:02:25 -08:00
parent 1d1eef1959
commit ca99683972
1 changed files with 14 additions and 2 deletions

View File

@ -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 <chrootdir> [--] [makepkg args]"
echo "usage ${APPNAME} [-hcud] -r <chrootdir> [--] [makepkg args]"
echo " ${APPNAME} -r <chrootdir> -I <package-file>"
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 <dir> The chroot shell to use"
echo "-I <pkg> 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}