[pacman-dev] [PATCH 2/2] Append '-$arch' to 'installed' array in .BUILDINFO

Allan McRae allan at archlinux.org
Sun Mar 18 01:40:53 UTC 2018


On 18/03/18 07:24, Robin Broda wrote:
> This patch incurs a **severe** performance degradation when generating
> the .BUILDINFO file, likely due to frequent usage of `pacman -Qi`
> and `grep -E`. I haven't found a faster way to gather this information.
> 
> Signed-off-by: Robin Broda <robin at broda.me>

I will comment on the utility of this patch in another email.   This is
just pointing out that it is broken...

> ---
>  doc/BUILDINFO.5.txt   |  2 +-
>  scripts/makepkg.sh.in | 12 ++++++++++--
>  2 files changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/doc/BUILDINFO.5.txt b/doc/BUILDINFO.5.txt
> index 4734301e..2c74f9ff 100644
> --- a/doc/BUILDINFO.5.txt
> +++ b/doc/BUILDINFO.5.txt
> @@ -61,7 +61,7 @@ BUILDINFO file format.
>  
>  *installed (array)*::
>  	The installed packages at build time including the version information of
> -	the package. Formatted as "$pkgname-$pkgver-$pkgrel".
> +	the package. Formatted as "$pkgname-$pkgver-$pkgrel-$pkgarch".
>  
>  See Also
>  --------
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index ece53dca..10303417 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -694,8 +694,16 @@ write_buildinfo() {
>  	write_kv_pair "buildenv" "${BUILDENV[@]}"
>  	write_kv_pair "options" "${OPTIONS[@]}"
>  
> -	local pkglist=($(run_pacman -Q | sed "s# #-#"))
> -	write_kv_pair "installed" "${pkglist[@]}"
> +	local pkglist=($(run_pacman -Qq))
> +	local installed=()
> +	for pkg in "${pkglist[@]}"
> +	do
> +		pkginfo="$(pacman -Qi "${pkg}")"

What makes this call to pacman not need to use run_pacman like the others?

> +		pkgver="$(grep -E '^Version' <<< "${pkginfo}" | tr -d ' ' | cut -d':' -f2-)"
> +		pkgarch="$(grep -E '^Architecture' <<< "${pkginfo}" | tr -d ' ' | cut -d':' -f2-)"

Not every system runs in English...

> +		installed+=("${pkg}-${pkgver}-${pkgarch}")
> +	done
> +	write_kv_pair "installed" "${installed[@]}"
>  }
>  
>  # build a sorted NUL-separated list of the full contents of the current
> 


More information about the pacman-dev mailing list