From fc7f570aad19ef7d426d0c925d6bf1cdc05b1e1a Mon Sep 17 00:00:00 2001 From: Travis Willard Date: Sat, 15 Dec 2007 20:57:39 -0500 Subject: Added support for makepkg's PKGDEST and SRCDEST params. This ensures that sources and packages built inside makechrootpkg go where the user expects them to, as defined in their /etc/makepkg.conf and ~/.makepkg.conf files. Signed-off-by: Travis Willard Signed-off-by: Aaron Griffin --- makechrootpkg | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/makechrootpkg b/makechrootpkg index 55daea9..cd11141 100755 --- a/makechrootpkg +++ b/makechrootpkg @@ -53,6 +53,9 @@ while getopts ':c:h' arg; do esac done +#Get rid of trailing / in chrootdir +[ "$chrootdir" != "/" ] && chrootdir=$(echo $chrootdir | sed 's#/$##') + # Pass all arguments after -- right to makepkg MAKEPKG_ARGS="$MAKEPKG_ARGS ${*:$OPTIND}" @@ -85,6 +88,8 @@ fi cleanup () { echo "cleaning up unioned mounts" + umount "$chrootdir/union/pkgdest" 2>/dev/null + umount "$chrootdir/union/srcdest" 2>/dev/null umount "$chrootdir/union" } @@ -96,8 +101,34 @@ trap 'cleanup' 0 1 2 15 echo "moving build files to chroot" [ -d "$uniondir/build" ] || mkdir "$uniondir/build" + +# Source makepkg.conf and ~/makepkg.conf +if [ -r "/etc/makepkg.conf" ]; then + source "/etc/makepkg.conf" +fi +if [ -r ~/.makepkg.conf ]; then + source ~/.makepkg.conf +fi + +# Set up src and pkg dirs +[ -d "$uniondir/srcdest" ] || mkdir "$uniondir/srcdest" +[ -d "$uniondir/pkgdest" ] || mkdir "$uniondir/pkgdest" +[ ! -z "$PKGDEST" ] && mount --bind "$PKGDEST" "$uniondir/pkgdest" +[ ! -z "$SRCDEST" ] && mount --bind "$SRCDEST" "$uniondir/srcdest" + +if ! grep "PKGDEST=/pkgdest" "$uniondir/etc/makepkg.conf" >/dev/null 2>&1; then + echo "Setting PKGDEST in makepkg.conf" + echo "PKGDEST=/pkgdest" >> "$uniondir/etc/makepkg.conf" +fi + +if ! grep "SRCDEST=/srcdest" "$uniondir/etc/makepkg.conf" >/dev/null 2>&1; then + echo "Setting SRCDEST in makepkg.conf" + echo "SRCDEST=/srcdest" >> "$uniondir/etc/makepkg.conf" +fi + chown -R nobody "$uniondir/build" +# Copy PKGBUILD and sources source PKGBUILD cp PKGBUILD "$uniondir/build/" for f in ${source[@]}; do @@ -134,7 +165,14 @@ if [ -e ${chrootdir}/rw/build/BUILD_FAILED ]; then exit 1 else source ${WORKDIR}/PKGBUILD - mv ${chrootdir}/rw/build/${pkgname}-${pkgver}-*.pkg.tar.gz ${WORKDIR} + if [ -z "$(mount | grep ${chrootdir}/union/pkgdest)" ]; then + echo "Moving completed package file to ${WORKDIR}" + mv ${chrootdir}/union/pkgdest/${pkgname}-${pkgver}-*.pkg.tar.gz ${WORKDIR} + fi + if [ -z "$(mount | grep ${chrootdir}/union/srcdest)" ]; then + echo "Moving downloaded source files to ${WORKDIR}" + mv ${chrootdir}/union/srcdest/* ${WORKDIR} + fi rm -rf ${chrootdir}/rw/build/* echo "Build complete" fi -- cgit v1.2.3-70-g09d2