diff mbox

[pacman-dev] Append architecture information to 'installed' elements in .BUILDINFO

Message ID b59046d6-4f1f-c8a2-c0a4-5ac299990232@broda.me
State Accepted, archived
Headers show

Commit Message

Robin Broda May 3, 2018, 7:27 a.m. UTC
This is a revised version of https://patchwork.archlinux.org/patch/476/,
without the performance penalty.

Signed-off-by: Robin Broda <robin@broda.me>
---
 doc/BUILDINFO.5.txt   |  2 +-
 scripts/makepkg.sh.in | 11 +++++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

Comments

Allan McRae May 12, 2018, 11:20 a.m. UTC | #1
On 03/05/18 17:27, Robin Broda wrote:
> This is a revised version of https://patchwork.archlinux.org/patch/476/,
> without the performance penalty.
> 

I'll accept this, but it really needs an informative commit message. I
used this:

Adding the architecture to the 'installed' elements of the .BUILDINFO
file makes it easier to retrieve the packages needed to reconstruct
the build environment.



> Signed-off-by: Robin Broda <robin@broda.me>
> ---
>  doc/BUILDINFO.5.txt   |  2 +-
>  scripts/makepkg.sh.in | 11 +++++++++--
>  2 files changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/doc/BUILDINFO.5.txt b/doc/BUILDINFO.5.txt
> index b7a72831..bac6d49f 100644
> --- a/doc/BUILDINFO.5.txt
> +++ b/doc/BUILDINFO.5.txt
> @@ -58,7 +58,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 eee8a56c..c9111078 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -697,8 +697,15 @@ 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 pkginfos="$(LC_ALL=C run_pacman -Qi ${pkglist[@]})"
> + local pkginfos_parsed=($(awk -F': ' '\
> +   /^Name .*/ {printf $2} \
> +   /^Version .*/ {printf "-"$2} \
> +   /^Architecture .*/ {print "-"$2} \
> + ' <<< "${pkginfos}"))
> +
> + write_kv_pair "installed" "${pkginfos_parsed[@]}"
>  }
>  
>  # build a sorted NUL-separated list of the full contents of the current
>
diff mbox

Patch

diff --git a/doc/BUILDINFO.5.txt b/doc/BUILDINFO.5.txt
index b7a72831..bac6d49f 100644
--- a/doc/BUILDINFO.5.txt
+++ b/doc/BUILDINFO.5.txt
@@ -58,7 +58,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 eee8a56c..c9111078 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -697,8 +697,15 @@  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 pkginfos="$(LC_ALL=C run_pacman -Qi ${pkglist[@]})"
+ local pkginfos_parsed=($(awk -F': ' '\
+   /^Name .*/ {printf $2} \
+   /^Version .*/ {printf "-"$2} \
+   /^Architecture .*/ {print "-"$2} \
+ ' <<< "${pkginfos}"))
+
+ write_kv_pair "installed" "${pkginfos_parsed[@]}"
 }
 
 # build a sorted NUL-separated list of the full contents of the current