[arch-projects] [devtools] [PATCH v2 1/2] makechrootpkg: explain load_vars
The way in which makechrootpkg reads variables from makepkg.conf(5) is different from makepkg, in that it reads a subset of defined variables, and only if the were not set in the environment before. Mention this in the usage text. Fixes FS#44827 --- makechrootpkg.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/makechrootpkg.in b/makechrootpkg.in index cd9efce..0b13f0b 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -46,6 +46,10 @@ usage() { echo 'command:' echo ' mkarchroot <chrootdir>/root base-devel' echo '' + echo 'This script reads {SRC,SRCPKG,PKG,LOG}DEST, MAKEFLAGS and PACKAGER' + echo 'from makepkg.conf(5), if those variables are not part of the' + echo 'environment.' + echo '' echo "Default makepkg args: ${makepkg_args[*]}" echo '' echo 'Flags:' -- 2.9.0
makepkg --asroot was removed with pacman 4.2. Allow to specify a separate makepkg user from the command line instead. Fixes FS#43432 --- makechrootpkg.in | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index 0b13f0b..bfc2b6d 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -21,6 +21,7 @@ run_namcap=false temp_chroot=false chrootdir= passeddir= +makepkg_user= declare -a install_pkgs declare -i ret=0 @@ -67,6 +68,7 @@ usage() { echo " Default: $copy" echo '-n Run namcap on the package' echo '-T Build in a temporary directory' + echo '-U Run makepkg as a specified user' exit 1 } @@ -221,13 +223,13 @@ download_sources() { chmod 1777 "$builddir" # Ensure sources are downloaded - if [[ -n $SUDO_USER ]]; then - sudo -u $SUDO_USER env SRCDEST="$SRCDEST" BUILDDIR="$builddir" \ + makepkg_user=${makepkg_user:-$SUDO_USER} + if [[ -n $makepkg_user ]]; then + sudo -u "$makepkg_user" env SRCDEST="$SRCDEST" BUILDDIR="$builddir" \ makepkg --config="$copydir/etc/makepkg.conf" --verifysource -o else - ( export SRCDEST BUILDDIR="$builddir" - makepkg --asroot --config="$copydir/etc/makepkg.conf" --verifysource -o - ) + error "Running makepkg as root is not allowed." + exit 1 fi (( $? != 0 )) && die "Could not download sources." @@ -256,7 +258,7 @@ move_products() { orig_argv=("$@") -while getopts 'hcur:I:l:nTD:d:' arg; do +while getopts 'hcur:I:l:nTD:d:U:' arg; do case "$arg" in c) clean_first=true ;; D) bindmounts_ro+=(--bind-ro="$OPTARG") ;; @@ -267,11 +269,13 @@ while getopts 'hcur:I:l:nTD:d:' arg; do l) copy="$OPTARG" ;; n) run_namcap=true; makepkg_args+=(-i) ;; T) temp_chroot=true; copy+="-$$" ;; + U) makepkg_user="$OPTARG" ;; h|*) usage ;; esac done [[ ! -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.' check_root "$0" "${orig_argv[@]}" -- 2.9.0
participants (1)
-
Alad Wenter