Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/makechrootpkg
diff options
context:
space:
mode:
authorTravis Willard <travis@archlinux.org>2007-12-15 20:57:39 -0500
committerAaron Griffin <aaronmgriffin@gmail.com>2008-01-23 16:11:37 -0600
commitfc7f570aad19ef7d426d0c925d6bf1cdc05b1e1a (patch)
tree76b3a4165a81f577e77d5c3e0517dd94fa037847 /makechrootpkg
parent5eb176f4711f57dc2adf2f9804727c1571ae3bb8 (diff)
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 <travis@archlinux.org> Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
Diffstat (limited to 'makechrootpkg')
-rwxr-xr-xmakechrootpkg40
1 files changed, 39 insertions, 1 deletions
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