[arch-projects] [DEVTOOLS][PATCH 2/3] archbuild: install packages in one call to pacman

Dave Reisner d at falconindy.com
Fri Aug 14 14:06:52 UTC 2015


On Thu, Aug 13, 2015 at 10:56:41PM +0200, seblu at archlinux.org wrote:
> From: Sébastien Luttringer <seblu at seblu.net>
> 
> In order to install/downgrade packages with dependencies (e.g gcc-multilib),
> pass all packages to install in a row to pacman.
> 
> As a side improvement, when a package installation fails, build fails.
> ---
>  makechrootpkg.in | 30 ++++++++++++++++++------------
>  1 file changed, 18 insertions(+), 12 deletions(-)
> 
> diff --git a/makechrootpkg.in b/makechrootpkg.in
> index 3c8a20f..447157d 100644
> --- a/makechrootpkg.in
> +++ b/makechrootpkg.in
> @@ -126,23 +126,26 @@ clean_temporary() {
>  	stat_done
>  }
>  
> +# install packages in one call to pacman to let it manage correctly
> +# dependencies between packages
>  install_packages() {
> -	local pkgname
> +	(( ${#install_pkgs[*]} == 0 )) && return 0
>  
> -	for install_pkg in "${install_pkgs[@]}"; do
> -		pkgname="${install_pkg##*/}"
> -		cp "$install_pkg" "$copydir/$pkgname"
> +	local src dst
> +	local -a dsts

These aren't "destinations", they're packages. Please call the variable
as such.

>  
> -		arch-nspawn "$copydir" \
> -			"${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
> -			pacman -U /$pkgname --noconfirm
> -		(( ret += !! $? ))
> -
> -		rm "$copydir/$pkgname"
> +	for src in "${install_pkgs[@]}"; do
> +		dst=/"${src##*/}"
> +		dsts+=("$dst")
> +		cp "$src" "$copydir$dst"
>  	done
>  
> -	# If there is no PKGBUILD we are done
> -	[[ -f PKGBUILD ]] || exit $ret
> +	arch-nspawn "$copydir" "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
> +		pacman -U "${dsts[@]}" --noconfirm || exit $?

exit $? is redundant, you only need 'exit'. Better still, use 'die' with
an appropriate error message?

> +
> +	for dst in "${dsts[@]}"; do
> +		rm "$copydir$dst"
> +	done

rm "${dsts[@]}"

>  }
>  
>  prepare_chroot() {
> @@ -384,6 +387,9 @@ $update_first && arch-nspawn "$copydir" \
>  
>  [[ -n ${install_pkgs[*]} ]] && install_packages
>  
> +# If there is no PKGBUILD we are done
> +[[ -f PKGBUILD ]] || exit 0
> +

Seems like an unrelated change... And, shouldn't lack of a PKGBUILD be a
failure?

>  download_sources
>  
>  prepare_chroot
> -- 
> Sébastien "Seblu" Luttringer


More information about the arch-projects mailing list