[arch-projects] [devtools] [PATCH 2/2] makechrootpkg: use the chroot database to find checkpkg packages

2020-01-02 Thread Eli Schwartz via arch-projects
We don't want to check against the current version known to the host
system, because that will be incorrect in a wide variety of situations,
including:
- the build host hasn't done a full system upgrade yet
- we're building against staging, and want to see the delta between
  different staging versions
- we're building against extra, but the host runs testing which carries
  changes we don't want to visualize right now
- the chroot has a configured database not available to the host, and
  the package is only available there

Essentially, it's rarely 100% correct to run checkpkg on the host, but
we already have a database we *know* is correct, and that is the one we
just built the package against. So let's use that.

This also fixes a bug in the current logic, where in order to try
downloading fresh databases, we work in a non-cached temporary working
database to download the package files, but then let checkpkg default to
comparing packages in the system database. Since we are explicitly
trying to compare against packages that differ from the host's pacman
database, we need to pass the package files as options to checkpkg,
using the additional modes added in commit 
c14338c0fe71a74f5e56b4f3af7c548fe0928e15

Signed-off-by: Eli Schwartz 
---
 makechrootpkg.in | 32 ++--
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/makechrootpkg.in b/makechrootpkg.in
index dfea18c..bfa69be 100644
--- a/makechrootpkg.in
+++ b/makechrootpkg.in
@@ -366,11 +366,7 @@ if arch-nspawn "$copydir" \
"${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
/chrootbuild "${makepkg_args[@]}"
 then
-   pkgnames=()
-   for pkgfile in "$copydir"/pkgdest/*; do
-   pkgfile=${pkgfile##*/};
-   pkgnames+=("${pkgfile%-*-*-*}");
-   done
+   mapfile -t pkgnames < <(sudo -u "$makepkg_user" bash -c 'source 
PKGBUILD; printf "%s\n" "${pkgname[@]}"')
move_products
 else
(( ret += 1 ))
@@ -388,29 +384,29 @@ else
if (( run_checkpkg )); then
msg "Running checkpkg"
 
-   # sync off-site databases for up-to-date queries
-   trap 'rm -rf $dbpath; cleanup' EXIT INT TERM QUIT
-   dbpath=$(mktemp -d --tmpdir makechrootpkg-database.XX)
-   mkdir -p "$dbpath"
-   pacman -Sy --dbpath "$dbpath" --logfile /dev/null
+   mapfile -t remotepkgs < <(pacman --config 
"$copydir"/etc/pacman.conf \
+   --dbpath "$copydir"/var/lib/pacman \
+   -Sddp "${pkgnames[@]}")
 
-   # query current package locations
-   remotepkgs=($(pacman -Sddp --dbpath "$dbpath" --logfile 
/dev/null "${pkgnames[@]}"))
-   if (( $? )); then
+   if ! wait $!; then
warning "Skipped checkpkg due to missing repo packages"
exit 0
fi
 
# download package files if any non-local location exists
for remotepkg in "${remotepkgs[@]}"; do
-   [[ $remotepkg == file://* ]] && continue
-   msg2 "Downloading current versions"
-   pacman --noconfirm -Swdd --dbpath "$dbpath" --logfile 
/dev/null "${pkgnames[@]}"
-   break
+   if [[ $remotepkg != file://* ]]; then
+   msg2 "Downloading current versions"
+   arch-nspawn "$copydir" pacman --noconfirm -Swdd 
"${pkgnames[@]}"
+   mapfile -t remotepkgs < <(pacman --config 
"$copydir"/etc/pacman.conf \
+   --dbpath "$copydir"/var/lib/pacman \
+   -Sddp "${pkgnames[@]}")
+   break
+   fi
done
 
msg2 "Checking packages"
-   sudo -u "$makepkg_user" checkpkg --rmdir --warn
+   sudo -u "$makepkg_user" checkpkg --rmdir --warn 
"${remotepkgs[@]/#file:\/\//}"
fi
true
 fi
-- 
2.24.1


[arch-projects] [devtools] [PATCH 1/2] checkpkg: fix support for http:// url comparisons

2020-01-02 Thread Eli Schwartz via arch-projects
Broken in commit c14338c0fe71a74f5e56b4f3af7c548fe0928e15.

Signed-off-by: Eli Schwartz 
---
 checkpkg.in | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/checkpkg.in b/checkpkg.in
index 374c004..d7c0948 100644
--- a/checkpkg.in
+++ b/checkpkg.in
@@ -95,8 +95,10 @@ for _pkgname in "${pkgname[@]}"; do
 
if (( $# )); then
case $1 in
+   *://*)
+   pkgurl=$1 ;;
/*|*/*)
-   pkgurl=file://$(readlink -m "$1") ;;
+   pkgurl=$(readlink -m "$1") ;;
*.pkg.tar*)
pkgurl=$1 ;;
'')
-- 
2.24.1


[arch-projects] [devtools] [PATCH 4/4] zsh-completion: update for new makerepropkg options

2020-01-02 Thread Eli Schwartz via arch-projects
Thanks to anthraxx for the guidance.

Original-patch-by: Levente Polyak 
Signed-off-by: Eli Schwartz 
---
 zsh_completion.in | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/zsh_completion.in b/zsh_completion.in
index a1225aa..e59bc3a 100644
--- a/zsh_completion.in
+++ b/zsh_completion.in
@@ -94,10 +94,11 @@ _offload_build_args=(
 )
 
 _makerepropkg_args=(
+   '-d[Run diffoscope if the package is unreproducible]'
'-c[Set pacman cache]:pacman_cache:_files -/'
'-M[Location of a makepkg config file]:makepkg_config:_files -g 
"*.conf(.)"'
'-h[Display usage]'
-   '1:working_dir:_files -g "*.pkg.tar.*(.)"'
+   '*:working_dir:_files -g "*.pkg.tar.*(.)"'
 )
 
 _devtools_completions_all_packages() {
-- 
2.24.1