From 9009a5fec52c5820fc90a68317bcc29cdbb42da1 Mon Sep 17 00:00:00 2001
From: Erich Eckner <git@eckner.net>
Date: Fri, 3 Jan 2020 13:26:28 +0100
Subject: learn to handle zst, too

---
 bin/clean-cache                   |  4 +++-
 bin/copy-to-build-support         |  5 +++--
 bin/create-build-support-package  |  2 +-
 bin/filter-build-logs             |  7 +++++--
 bin/interpret-mail                |  4 ++--
 bin/local-build-package           | 14 +++++++++-----
 bin/modify-package-state          |  4 ++--
 bin/put-upstream-packages-into-db |  2 +-
 bin/seed-build-list               |  6 +++---
 9 files changed, 29 insertions(+), 19 deletions(-)

(limited to 'bin')

diff --git a/bin/clean-cache b/bin/clean-cache
index 41d0df8..2ed8c58 100755
--- a/bin/clean-cache
+++ b/bin/clean-cache
@@ -56,7 +56,9 @@ find "${tmp_dir}" -type f -name desc \
   while read -r s; do
     printf '%s%s\n' \
       "${s}" '-i686.pkg.tar.xz' \
-      "${s}" '-any.pkg.tar.xz'
+      "${s}" '-any.pkg.tar.xz' \
+      "${s}" '-i686.pkg.tar.zst' \
+      "${s}" '-any.pkg.tar.zst'
   done | \
   sha256sum -c --ignore-missing --quiet 2> /dev/null | \
   sed 's|: FAILED$||' | \
diff --git a/bin/copy-to-build-support b/bin/copy-to-build-support
index abf11cb..0b3eaf7 100755
--- a/bin/copy-to-build-support
+++ b/bin/copy-to-build-support
@@ -83,7 +83,8 @@ export TMPDIR="${tmp_dir}"
 sed -n '
   s/ \S\+/\0 \0/
   T
-  s/\.pkg\.tar\.xz$//
+  s/\.pkg\.tar\.zst$//
+  T
   s/\(-[0-9]\+\)\(-[^- ]\+\)$/\1.0\2/
   s/-\([^-: ]\+\)\(\(-[^- ]\+\)\{2\}\)$/-0:\1\2/
   s/-\([^-: ]\+\):\([^-: ]\+\)-\([^-. ]\+\).\([^-. ]\+\)-\([^- ]\+\)$/ \1 \2 \3 \4 \5/
@@ -189,7 +190,7 @@ if [ -s "${tmp_dir}/to-copy" ]; then
       $(sed -n 's,^'"$(str_to_regex "${repo_arch}")"' ,,;T;p' "${tmp_dir}/to-copy") \
       "${tmp_dir}/transit/${repo_arch}/"
     repo-add "${tmp_dir}/${repo_arch}/build-support.db.tar.gz" \
-      "${tmp_dir}/transit/${repo_arch}/"*".pkg.tar.xz"
+      "${tmp_dir}/transit/${repo_arch}/"*".pkg.tar.zst"
   done < \
     "${tmp_dir}/repo-archs"
 fi
diff --git a/bin/create-build-support-package b/bin/create-build-support-package
index 3e9dd8d..dc7b7bd 100755
--- a/bin/create-build-support-package
+++ b/bin/create-build-support-package
@@ -214,7 +214,7 @@ if [ -n "${source_package}" ]; then
 
   list_package_files \
     | LANG=C bsdtar -C "${tmp_dir}/content" -cnf - --null --files-from - \
-    | xz -c -z - \
+    | zstd -c -z - \
     > "${tmp_dir}/${new_pkg}"
 
   rm -rf --one-file-system "${tmp_dir:?}/content"
diff --git a/bin/filter-build-logs b/bin/filter-build-logs
index 0a2cbe3..263054a 100755
--- a/bin/filter-build-logs
+++ b/bin/filter-build-logs
@@ -25,9 +25,12 @@
     'type' \
     'message'
   printf '</tr>\n'
-  find "${build_log_directory}/success" -maxdepth 1 -name '*.pkg.tar.xz-namcap.log.gz' -execdir zcat {} \; | \
+  find "${build_log_directory}/success" -maxdepth 1 \( \
+    -name '*.pkg.tar.xz-namcap.log.gz' \
+    -o -name '*.pkg.tar.zst-namcap.log.gz' \
+  \) -execdir zcat {} \; | \
     sed '
-      /^Checking \(PKGBUILD\|\S\+\(-[^-]\+\)\{3\}\.pkg\.tar\.xz\)$/d
+      /^Checking \(PKGBUILD\|\S\+\(-[^-]\+\)\{3\}\.pkg\.tar\.\(xz\|zst\)\)$/d
       / on your system is a testing release$/d
       s/^PKGBUILD\s\+(\([^) ]\+\))\s\+/\1 /
       s/^./\0 /
diff --git a/bin/interpret-mail b/bin/interpret-mail
index ee218e7..cc7690e 100755
--- a/bin/interpret-mail
+++ b/bin/interpret-mail
@@ -275,7 +275,7 @@ fi
 
 if [ -s "${tmp_dir}/copy-to-build-support" ]; then
   sed -i '
-    /\.pkg\.tar\.xz$/!s/$/.pkg.tar.xz/
+    /\.pkg\.tar\.\(xz\|zst\)$/!s/$/.pkg.tar.zst/
   ' "${tmp_dir}/copy-to-build-support"
   if run_and_log_on_error 'copy-to-build-support' "${base_dir}/bin/copy-to-build-support" --wait "${tmp_dir}/copy-to-build-support"; then
     log 1 'copy-to-build-support' "$(wc -l < "${tmp_dir}/copy-to-build-support")"
@@ -324,7 +324,7 @@ fi
 
 if [ -s "${tmp_dir}/stabilize" ]; then
   sed -i '
-    /\.pkg\.tar\.xz$/!s/$/.pkg.tar.xz/
+    /\.pkg\.tar\.\(xz\|zst\)$/!s/$/.pkg.tar.zst/
   ' "${tmp_dir}/stabilize"
   if run_and_log_on_error 'stabilize' "${base_dir}/bin/modify-package-state" --wait --tested "${tmp_dir}/stabilize"; then
     log 1 'stabilize' "$(wc -l < "${tmp_dir}/stabilize")"
diff --git a/bin/local-build-package b/bin/local-build-package
index 7c88b3f..fd4fdab 100755
--- a/bin/local-build-package
+++ b/bin/local-build-package
@@ -173,7 +173,9 @@ if ! ${nobuild}; then
 
   extract_source_directory "${git_repo}" "${git_revision}" "${mod_git_revision}" "${tmp_dir}"
 
-  rm -f ./*"-${arch}.pkg.tar.xz" ./*"-${arch}.pkg.tar.xz.sig"
+  rm -f \
+    ./*"-${arch}.pkg.tar.xz" ./*"-${arch}.pkg.tar.xz.sig" \
+    ./*"-${arch}.pkg.tar.zst" ./*"-${arch}.pkg.tar.zst.sig"
 
   cd "${tmp_dir}" || exit 1
 
@@ -190,9 +192,11 @@ else
 fi
 
 if ${bootstrap}; then
-  rm -f ./*"-${arch}.pkg.tar.xz.sig"
+  rm -f \
+    ./*"-${arch}.pkg.tar.xz.sig" \
+    ./*"-${arch}.pkg.tar.zst.sig"
 
-  find . -maxdepth 1 -type f -name "*${arch}.pkg.tar.xz" \
+  find . -maxdepth 1 -type f -name "*${arch}.pkg.tar.zst" \
     -execdir gpg --local-user="${signkey}" --detach-sign '{}' \;
 
   case "$repository" in
@@ -207,8 +211,8 @@ if ${bootstrap}; then
       ;;
   esac
 
-  scp -P "${bootstrap_port}" -rC "${tmp_dir}/"*"-${arch}.pkg.tar.xz" "${tmp_dir}/"*"-${arch}.pkg.tar.xz.sig" "${bootstrap_host}:${bootstrap_dir}/${staging_repo}/."
-  ssh -p "${bootstrap_port}" "${bootstrap_host}" bash -l -c "'cd ${bootstrap_dir}/${staging_repo} && repo-add -n bootstrap-${staging_repo}.db.tar.gz *-${arch}.pkg.tar.xz'"
+  scp -P "${bootstrap_port}" -rC "${tmp_dir}/"*"-${arch}.pkg.tar.zst" "${tmp_dir}/"*"-${arch}.pkg.tar.zst.sig" "${bootstrap_host}:${bootstrap_dir}/${staging_repo}/."
+  ssh -p "${bootstrap_port}" "${bootstrap_host}" bash -l -c "'cd ${bootstrap_dir}/${staging_repo} && repo-add -n bootstrap-${staging_repo}.db.tar.gz *-${arch}.pkg.tar.zst'"
 fi
 
 # do not delete build reports, why might actually to want to have a look for things
diff --git a/bin/modify-package-state b/bin/modify-package-state
index 0a394d7..eb1558b 100755
--- a/bin/modify-package-state
+++ b/bin/modify-package-state
@@ -23,7 +23,7 @@ usage() {
   >&2 echo 'Exactly one of -b|-f|-t|-u is needed for actual operation.'
   >&2 echo 'packages-file contains one line for each target.'
   >&2 echo 'for --faulty and --tested, the format is:'
-  >&2 echo ' sha512sum pkgname-epoch:pkgver-pkgrel.sub_pkgrel-arch[".pkg.tar.xz"]'
+  >&2 echo ' sha512sum pkgname-epoch:pkgver-pkgrel.sub_pkgrel-arch[".pkg.tar.zst"]'
   >&2 echo 'for --block and --unblock, the format is:'
   >&2 echo ' pkgbase.git_revision.mod_git_revision.repository.architecture'
   [ -z "$1" ] && exit 1 || exit "$1"
@@ -149,7 +149,7 @@ while read -r a b; do
   case "${action}" in
     'faulty'|'tested')
       # we expect a sha512sum and binary package identifier
-      # (pkgname-epoch:pkgver-pkgrel.sub_pkgrel-arch[".pkg.tar.xz"])
+      # (pkgname-epoch:pkgver-pkgrel.sub_pkgrel-arch[".pkg.tar.zst"])
       # and we will only operate on packages in "testing" repositories
       # shellcheck disable=SC2016
       combiner=$(
diff --git a/bin/put-upstream-packages-into-db b/bin/put-upstream-packages-into-db
index 219e146..68629a0 100755
--- a/bin/put-upstream-packages-into-db
+++ b/bin/put-upstream-packages-into-db
@@ -20,7 +20,7 @@ trap 'rm "${upstream_packages}"' EXIT
         /^%FILENAME%$/ {
           N
           s/.*\n//
-          s/\.pkg\.tar\.xz$//
+          s/\.pkg\.tar\.\(xz\|zst\)$//
           s/-\(\([^-:]\+\):\)\?\([^-:]\+\)-\([^-]\+\)-\([^-]\+\)$/\t\2\t\3\t\4\t\5/
           s/\s\s/\t0\t/
           s/^/'"${repo}"'\t/
diff --git a/bin/seed-build-list b/bin/seed-build-list
index d083487..32bd6df 100755
--- a/bin/seed-build-list
+++ b/bin/seed-build-list
@@ -223,8 +223,8 @@ if [ -s "${tmp_dir}/mirrors" ]; then
             N
             s/^.*\n//
             /^lib32-/d
-            s/^\(.*-\)x86_64\.pkg\.tar\.xz$/\1i486\n\1i686\n\1pentium4/
-            s/^\(.*-any\)\.pkg\.tar\.xz$/\1/
+            s/^\(.*-\)x86_64\.pkg\.tar\.\(xz\|zst\)$/\1i486\n\1i686\n\1pentium4/
+            s/^\(.*-any\)\.pkg\.tar\.\(xz\|zst\)$/\1/
           ' | \
           sed '
             s/^\(.*\)-\([^-]\+-[^-]\+\)-\([^-]\+\)$/theirs \2 \3 \1/
@@ -248,7 +248,7 @@ if [ -s "${tmp_dir}/mirrors" ]; then
     } | \
       mysql_run_query | \
       sed '
-        s/^\(.*\)-\([^-]\+-[^-.]\+\)\(\.[^-.]\+\)\?-\([^-]\+\)\.pkg\.tar\.xz$/ours \2 \4 \1/
+        s/^\(.*\)-\([^-]\+-[^-.]\+\)\(\.[^-.]\+\)\?-\([^-]\+\)\.pkg\.tar\.\(xz\|zst\)$/ours \2 \4 \1/
         s/^\(.* \)any\( \S\+\)$/\0\n\1i486\2\n\1i686\2\n\1pentium4\2/
       '
   } | \
-- 
cgit v1.2.3-70-g09d2