[arch-projects] [devtools] [PATCH 2/4] use libmakepkg to find and use variables in makepkg.conf

Eli Schwartz eschwartz at archlinux.org
Tue Nov 5 23:38:51 UTC 2019


- drop homebrew function in makechrootpkg
- use better mock to find invoking user's $HOME
- make offload-build respect makepkg.conf to determine where to sync
  files, matching the behavior of makechrootpkg

Signed-off-by: Eli Schwartz <eschwartz at archlinux.org>
---
 makechrootpkg.in | 34 ++++++----------------------------
 offload-build    |  9 ++++++++-
 2 files changed, 14 insertions(+), 29 deletions(-)

diff --git a/makechrootpkg.in b/makechrootpkg.in
index f5a0e51..b3a1854 100644
--- a/makechrootpkg.in
+++ b/makechrootpkg.in
@@ -13,6 +13,8 @@
 m4_include(lib/common.sh)
 m4_include(lib/archroot.sh)
 
+source /usr/share/makepkg/util/config.sh
+
 shopt -s nullglob
 
 default_makepkg_args=(--syncdeps --noconfirm --log --holdver --skipinteg)
@@ -80,26 +82,6 @@ usage() {
 }
 
 # {{{ functions
-# Usage: load_vars $makepkg_conf
-# Globals:
-#  - SRCDEST
-#  - SRCPKGDEST
-#  - PKGDEST
-#  - LOGDEST
-#  - MAKEFLAGS
-#  - PACKAGER
-load_vars() {
-	local makepkg_conf="$1" var
-
-	[[ -f $makepkg_conf ]] || return 1
-
-	for var in {SRC,SRCPKG,PKG,LOG}DEST MAKEFLAGS PACKAGER; do
-		[[ -z ${!var:-} ]] && eval "$(source "$makepkg_conf"; printf "%s='%s'" "$var" "${!var}")"
-	done
-
-	return 0
-}
-
 # Usage: sync_chroot $chrootdir $copydir [$copy]
 sync_chroot() {
 	local chrootdir=$1
@@ -338,16 +320,12 @@ for arg in "${@:$OPTIND}"; do
 	esac
 done
 
-if [[ -n $SUDO_USER ]]; then
-	eval "USER_HOME=~$SUDO_USER"
-else
-	USER_HOME=$HOME
-fi
-
 umask 0022
 
-load_vars "${XDG_CONFIG_HOME:-$USER_HOME/.config}/pacman/makepkg.conf" || load_vars "$USER_HOME/.makepkg.conf"
-load_vars /etc/makepkg.conf
+ORIG_HOME=$HOME
+IFS=: read -r _ _ _ _ _ HOME _ < <(getent passwd "${SUDO_USER:-$USER}")
+load_makepkg_config
+HOME=$ORIG_HOME
 
 # Use PKGBUILD directory if these don't exist
 [[ -d $PKGDEST ]]    || PKGDEST=$PWD
diff --git a/offload-build b/offload-build
index 7a07b15..078796a 100755
--- a/offload-build
+++ b/offload-build
@@ -18,6 +18,8 @@
 #   along with this program.  If not, see <https://www.gnu.org/licenses/>.
 #
 
+source /usr/share/makepkg/util/config.sh
+
 
 # global defaults suitable for use by Arch staff
 repo=extra
@@ -105,4 +107,9 @@ mapfile -t files < <(
             makepkg --packagelist
 ')
 
-(( ${#files[@]} )) && printf '%s\n' '' '-> copying files...' && scp "${files[@]/#/$server:}" .
+
+if (( ${#files[@]} )); then
+    printf '%s\n' '' '-> copying files...'
+    load_makepkg_config
+    scp "${files[@]/#/$server:}" "${PKGDEST:-${PWD}}/"
+fi
-- 
2.24.0


More information about the arch-projects mailing list