summaryrefslogtreecommitdiff
path: root/makechrootpkg.in
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2019-02-13 02:23:51 -0500
committerLevente Polyak <anthraxx@archlinux.org>2019-08-09 19:41:51 +0200
commit46d614d91a90a60839280060f736dc3be8445502 (patch)
treea36f73472e6e56c0ee689616535aad22bc174563 /makechrootpkg.in
parentdf0d6b867b289ed98c4b9e7ced817dee155feb4f (diff)
downloaddevtools-46d614d91a90a60839280060f736dc3be8445502.tar.xz
Revert "makechrootpkg: Have functions be more function-y."
This reverts (the bulk of) commit 2fd5931a8c67289a8a4acd327b3ce99a5d64c8c7. Reducing globals makes little sense in in a oneshot bash script, but reduces code clarity and in fact resulted in bugs because even the commit author couldn't keep track of the script state. An exit was changed to a return, even though that made no sense outside of a function, and has been duly returned to being an exit. This was never tested and later papered over by wrapping the entire script in a main() function and then calling the function for hysterical raisins. The functiony nature of sync_chroot/delete_chroot is preserved, as those functions demonstrate meaningfully standalone functionality -- who knows? we may want to reuse this. Everything else is tightly bound to the internal logic of makechrootpkg. Completely separate functionality that was silently implemented in the original commit is also preserved: - declare a couple of variables as locals - move the abort-on-no-PKGBUILD outside the install_packages function Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
Diffstat (limited to 'makechrootpkg.in')
-rw-r--r--makechrootpkg.in39
1 files changed, 6 insertions, 33 deletions
diff --git a/makechrootpkg.in b/makechrootpkg.in
index 6718d13..0d24ac2 100644
--- a/makechrootpkg.in
+++ b/makechrootpkg.in
@@ -151,11 +151,7 @@ delete_chroot() {
stat_done
}
-# Usage: install_packages $copydir $pkgs...
install_packages() {
- local copydir=$1
- local install_pkgs=("${@:2}")
-
local -a pkgnames
local ret
@@ -170,16 +166,7 @@ install_packages() {
return $ret
}
-# Usage: prepare_chroot $copydir $HOME $keepbuilddir $run_namcap
-# Globals:
-# - MAKEFLAGS
-# - PACKAGER
prepare_chroot() {
- local copydir=$1
- local USER_HOME=$2
- local keepbuilddir=$3
- local run_namcap=$4
-
[[ $keepbuilddir = true ]] || rm -rf "$copydir/build"
local builduser_uid builduser_gid
@@ -258,13 +245,7 @@ _chrootnamcap() {
done
}
-# Usage: download_sources $copydir $makepkg_user
-# Globals:
-# - SRCDEST
download_sources() {
- local copydir=$1
- local makepkg_user=$2
-
setup_workdir
chown "$makepkg_user:" "$WORKDIR"
@@ -275,15 +256,7 @@ download_sources() {
die "Could not download sources."
}
-# Usage: move_products $copydir $owner
-# Globals:
-# - PKGDEST
-# - LOGDEST
-# - SRCPKGDEST
move_products() {
- local copydir=$1
- local src_owner=$2
-
local pkgfile
for pkgfile in "$copydir"/pkgdest/*; do
chown "$src_owner" "$pkgfile"
@@ -389,10 +362,10 @@ $update_first && arch-nspawn "$copydir" \
pacman -Syu --noconfirm
if [[ -n ${install_pkgs[*]:-} ]]; then
- install_packages "$copydir" "${install_pkgs[@]}"
+ install_packages
ret=$?
- # If there is no PKGBUILD we have done
- [[ -f PKGBUILD ]] || return $ret
+ # If there is no PKGBUILD we are done
+ [[ -f PKGBUILD ]] || exit $ret
fi
if [[ "$(id -u "$makepkg_user")" == 0 ]]; then
@@ -400,9 +373,9 @@ if [[ "$(id -u "$makepkg_user")" == 0 ]]; then
exit 1
fi
-download_sources "$copydir" "$makepkg_user"
+download_sources
-prepare_chroot "$copydir" "$USER_HOME" "$keepbuilddir" "$run_namcap"
+prepare_chroot
if arch-nspawn "$copydir" \
--bind="$PWD:/startdir" \
@@ -410,7 +383,7 @@ if arch-nspawn "$copydir" \
"${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
/chrootbuild "${makepkg_args[@]}"
then
- move_products "$copydir" "$src_owner"
+ move_products
else
(( ret += 1 ))
fi