Commit 486375ba authored by Aaron Griffin's avatar Aaron Griffin
Browse files

makechrootpkg: Don't mount-bind srcdest/pkgdest



Do actual copying to and from PKGDEST and SRCDEST rather than
mounting via --bind, as the chown and other operations can cause
issues here

Original-work-by: default avatarPhil Dillon-Thiselton <dibblethewrecker@gmail.com>
Signed-off-by: default avatarAaron Griffin <aaronmgriffin@gmail.com>
parent 3a78a877
Loading
Loading
Loading
Loading
+17 −10
Original line number Diff line number Diff line
@@ -164,18 +164,13 @@ fi

source $uniondir/etc/makepkg.conf

# Magic trickery with PKGDEST and SRCDEST, so that the built
# files end up where they're expected in the _real_ filesystem
[ -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

[ -d "$uniondir/srcdest" ] || mkdir "$uniondir/srcdest"
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"
@@ -192,6 +187,8 @@ for f in ${source[@]}; do
    basef=$(echo $f | sed 's|::.*||' | sed 's|^.*://.*/||g')
    if [ -f "$basef" ]; then
        cp "$basef" "$uniondir/srcdest/"
    elif [ -f "$SRCDEST/$basef" ]; then
        cp "$SRCDEST/$basef" "$uniondir/srcdest/"
    fi
done
if [ "$install" != "" -a -f "$install" ]; then
@@ -236,15 +233,25 @@ if mkarchroot -r "/chrootbuild" "$uniondir"; then
    local pkgfile=${chrootdir}/union/pkgdest/${pkgname}-${pkgver}-${pkgrel}-*.pkg.tar.gz
    if [ -z "$(mount | grep ${chrootdir}/union/pkgdest)" ]; then
        if [ -e "$pkgfile" ]; then
            if [ -n "$PKGDEST" ]; then
                echo "Moving completed package file to ${PKGDEST}"
                mv "$pkgfile" "${PKGDEST}"
            else
                echo "Moving completed package file to ${WORKDIR}"
                mv "$pkgfile" "${WORKDIR}"
            fi
        fi
    fi
    if [ -z "$(mount | grep ${chrootdir}/union/srcdest)" ]; then
        for f in ${chrootdir}/union/srcdest/*; do
            [ -e "$f" ] || continue
            if [ -n "$SRCDEST" ]; then
                echo "Moving downloaded source file ($(basename $f) to ${SRCDEST}"
                mv "$f" "${SRCDEST}"
            else
                echo "Moving downloaded source file ($(basename $f) to ${WORKDIR}"
                mv "$f" "${WORKDIR}"
            fi
        done
    fi
else