makechrootpkg: Move makepkg-as-root check to main()

download_sources(), while the first invocation of makepkg, is a rather
odd place for this kind of guard.
This commit is contained in:
Jan Alexander Steffens (heftig) 2017-07-13 19:37:15 +02:00
parent 086ff8b9e7
commit a8f512a665
No known key found for this signature in database
GPG Key ID: A5E9288C4FA415FA
1 changed files with 8 additions and 8 deletions

View File

@ -271,14 +271,9 @@ download_sources() {
chmod 1777 "$builddir" chmod 1777 "$builddir"
# Ensure sources are downloaded # Ensure sources are downloaded
if [[ "$(id -u "$makepkg_user")" != 0 ]]; then sudo -u "$makepkg_user" env SRCDEST="$SRCDEST" BUILDDIR="$builddir" \
sudo -u "$makepkg_user" env SRCDEST="$SRCDEST" BUILDDIR="$builddir" \ makepkg --config="$copydir/etc/makepkg.conf" --verifysource -o ||
makepkg --config="$copydir/etc/makepkg.conf" --verifysource -o || die "Could not download sources."
die "Could not download sources."
else
error "Running makepkg as root is not allowed."
exit 1
fi
# Clean up garbage from verifysource # Clean up garbage from verifysource
rm -rf "$builddir" rm -rf "$builddir"
@ -406,6 +401,11 @@ main() {
[[ -f PKGBUILD ]] || return $ret [[ -f PKGBUILD ]] || return $ret
fi fi
if [[ "$(id -u "$makepkg_user")" == 0 ]]; then
error "Running makepkg as root is not allowed."
exit 1
fi
download_sources "$copydir" "$makepkg_user" download_sources "$copydir" "$makepkg_user"
prepare_chroot "$copydir" "$USER_HOME" "$repack" prepare_chroot "$copydir" "$USER_HOME" "$repack"