[arch-projects] [devtools][PATCH 05/13] makechroot: download_sources: Accept makepkg_owner as an argument

Luke Shumaker lukeshu at parabola.nu
Fri May 5 22:41:02 UTC 2017


What this is really doing is fixing a conflict that I had incorrectly
resolved when rebasing what became 2fd5931 onto cda9cf4.  Of course,
because of dynamic scoping, everything worked out, and everything worked as
intended.

Before cda9cf4, it was appropriate for download_sources to take src_owner
as an argument, but after cda9cf4, it is now appropriate to take
makepkg_user as an argument.  However, it still takes src_owner as an
argument, but pays 0 attention to it; instead looking at makepkg_user which
it happily inherited because of dynamic scoping.

So change it to take makepkg_user as the argument.
---
 makechrootpkg.in | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/makechrootpkg.in b/makechrootpkg.in
index cc3c738..d922fa0 100644
--- a/makechrootpkg.in
+++ b/makechrootpkg.in
@@ -252,20 +252,19 @@ _chrootnamcap() {
 	done
 }
 
-# Usage: download_sources $copydir $src_owner
+# Usage: download_sources $copydir $makepkg_user
 # Globals:
 #  - SRCDEST
 #  - USER
 download_sources() {
 	local copydir=$1
-	local src_owner=$2
+	local makepkg_user=$2
 
 	local builddir="$(mktemp -d)"
 	chmod 1777 "$builddir"
 
 	# Ensure sources are downloaded
-	makepkg_user=${makepkg_user:-$SUDO_USER}
-	if [[ -n $makepkg_user ]]; then
+	if [[ "$(id -u "$makepkg_user")" != 0 ]]; then
 		sudo -u "$makepkg_user" env SRCDEST="$SRCDEST" BUILDDIR="$builddir" \
 			makepkg --config="$copydir/etc/makepkg.conf" --verifysource -o
 	else
@@ -332,6 +331,7 @@ main() {
 
 	[[ ! -f PKGBUILD && -z "${install_pkgs[*]}" ]] && die 'This must be run in a directory containing a PKGBUILD.'
 	[[ -n $makepkg_user && -z $(id -u "$makepkg_user") ]] && die 'Invalid makepkg user.'
+	makepkg_user=${makepkg_user:-${SUDO_USER:-$USER}}
 
 	check_root
 
@@ -394,7 +394,7 @@ main() {
 		[[ -f PKGBUILD ]] || return $ret
 	fi
 
-	download_sources "$copydir" "$src_owner"
+	download_sources "$copydir" "$makepkg_user"
 
 	prepare_chroot "$copydir" "$USER_HOME" "$repack"
 
-- 
2.12.2


More information about the arch-projects mailing list