From a4400b3ccbc2d6c06a6ccdbb44e4e742afe12ab7 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 11 May 2024 23:02:18 +0200 Subject: [PATCH] tools/mk7z: support debian unstable / ubuntu 22.04 The version of `7z` provided by `p7zip-full` is now the same as `7zip`: - symlinks are dereferenced by default (no support for `-l`) - `7z -ba h` appends a trailing `/` to directories (not present in the output of `7z -slt l`) --- tools/mk7z.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/mk7z.sh b/tools/mk7z.sh index 8dee9bc3f..77584cfb9 100755 --- a/tools/mk7z.sh +++ b/tools/mk7z.sh @@ -34,8 +34,18 @@ trap 'rm -rf "${tmpdir}"' EXIT manifest="${tmpdir}/manifest" -"${sevenzip}" -l -ba h "${patterns[@]}" | - awk '{ if ($3!="") print $3, $2, $1; else print $1 }' | +# Detect if that version of 7z deferences symlinks by default. +sevenzip_manifest_cmd=("${sevenzip}" -ba h) +ln -s /dev/null "${tmpdir}/symlink" +checksum="$("${sevenzip_manifest_cmd[@]}" "${tmpdir}/symlink" | awk '{ print $1 }')" +if [[ "${checksum}" != '00000000' ]]; then + sevenzip_manifest_cmd+=(-l) +fi +rm -f "${tmpdir}/symlink" + +# Note: remove trailing `/` appended to directories in some 7z versions. +"${sevenzip_manifest_cmd[@]}" "${patterns[@]}" | + awk '{ if ($3!="") print $3, $2, $1; else { gsub("/$", "", $1); print $1 } }' | sort >"${manifest}" # cat "${manifest}" | less @@ -78,6 +88,6 @@ cd "${tmpdir}/contents" find . -depth -print0 | xargs -0 touch --date="${epoch}" # And create the final archive. -"${sevenzip}" -l -mqs "${options[@]}" a "${archive}" . +"${sevenzip}" -mqs "${options[@]}" a "${archive}" . # vim: sw=4