libmakepkg: Support zstd decompression for sources

This enables us to extract files in the source array and ensures that we
can decompress files if the uncompressed signature is served.

Signed-off-by: Morten Linderud <morten@linderud.pw>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Morten Linderud 2021-02-21 22:36:31 +01:00 committed by Allan McRae
parent 17d3da4777
commit 7587153a44
2 changed files with 7 additions and 1 deletions

View file

@ -134,7 +134,7 @@ verify_file_signature() {
fi fi
found=0 found=0
for ext in "" gz bz2 xz lrz lzo Z; do for ext in "" gz bz2 xz lrz lzo Z zst; do
if sourcefile="$(get_filepath "${file%.*}${ext:+.$ext}")"; then if sourcefile="$(get_filepath "${file%.*}${ext:+.$ext}")"; then
found=1 found=1
break break
@ -152,6 +152,7 @@ verify_file_signature() {
xz) decompress="xz -c -d" ;; xz) decompress="xz -c -d" ;;
lrz) decompress="lrzip -q -d" ;; lrz) decompress="lrzip -q -d" ;;
lzo) decompress="lzop -c -d -q" ;; lzo) decompress="lzop -c -d -q" ;;
zst) decompress="zstd -d -q -f" ;;
Z) decompress="uncompress -c -f" ;; Z) decompress="uncompress -c -f" ;;
"") decompress="cat" ;; "") decompress="cat" ;;
esac esac

View file

@ -118,6 +118,11 @@ extract_file() {
xz) cmd="xz" ;; xz) cmd="xz" ;;
*) return;; *) return;;
esac ;; esac ;;
*application/zstd*)
case "$ext" in
zst) cmd="zstd" ;;
*) return;;
esac ;;
*) *)
# See if bsdtar can recognize the file # See if bsdtar can recognize the file
if bsdtar -tf "$file" -q '*' &>/dev/null; then if bsdtar -tf "$file" -q '*' &>/dev/null; then