[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Quilt-dev] [PATCH] Add support for zst archives
From: |
Jean Delvare |
Subject: |
Re: [Quilt-dev] [PATCH] Add support for zst archives |
Date: |
Wed, 24 Jan 2024 13:49:02 +0100 |
User-agent: |
Evolution 3.42.4 |
Hallo Andreas,
On Tue, 2024-01-23 at 12:47 +0100, Andreas Schwab wrote:
> Add support for zstd compressed archives (*.tar.zst) and patches.
Out of curiosity, are there projects actually releasing their work as
tar.zst archives?
> ---
> quilt/push.in | 3 +++
> quilt/scripts/patchfns.in | 8 ++++++--
> quilt/setup.in | 8 +++++++-
> 3 files changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/quilt/push.in b/quilt/push.in
> index 2a30a9a..ef39978 100644
> --- a/quilt/push.in
> +++ b/quilt/push.in
> @@ -125,6 +125,9 @@ apply_patch()
> elif [ "${patch_file:(-3)}" = ".lz" ]
> then
> lzip -cd "$patch_file" | "$@" 2>&1
> + elif [ "${patch_file:(-4)}" = ".zst" ]
> + then
> + zstd -cd "$patch_file" | "$@" 2>&1
> else
> "$@" -i "$patch_file" 2>&1
> fi
> diff --git a/quilt/scripts/patchfns.in b/quilt/scripts/patchfns.in
> index b03644b..276c27e 100644
> --- a/quilt/scripts/patchfns.in
> +++ b/quilt/scripts/patchfns.in
> @@ -527,7 +527,7 @@ find_patch()
>
> local patch=${1#$SUBDIR_DOWN$QUILT_PATCHES/}
> local bre=$(quote_sed_re "$patch")
> - set -- $(sed -e
> "/^$bre\(\|\.patch\|\.diff\?\)\(\|\.gz\|\.bz2\|\.xz\|\.lzma\|\.lz\)\([
> "$'\t'"]\|$\)/!d" \
> + set -- $(sed -e
> "/^$bre\(\|\.patch\|\.diff\?\)\(\|\.gz\|\.bz2\|\.xz\|\.lzma\|\.lz\|\.zst\)\([
> "$'\t'"]\|$\)/!d" \
> -e 's/[ '$'\t''].*//' "$SERIES")
> if [ $# -eq 1 ]
> then
> @@ -795,6 +795,8 @@ cat_file()
> lzma -cd "$filename" ;;
> *.lz)
> lzip -cd "$filename" ;;
> + *.zst)
> + zstd -cd "$filename" ;;
> *)
> cat "$filename" ;;
> esac
> @@ -837,6 +839,8 @@ cat_to_new_file()
> lzma -c ;;
> *.lz)
> lzip -c ;;
> + *.zst)
> + zstd -c ;;
> *)
> cat ;;
> esac \
> @@ -999,7 +1003,7 @@ next_filename()
> {
> local patch=$1 base num
> base=$(echo "$patch" \
> - | sed -r -e 's:(\.gz|\.bz2|\.xz|\.lzma|\.lz)$::' -e
> 's:(\.diff?|\.patch)$::')
> + | sed -r -e 's:(\.gz|\.bz2|\.xz|\.lzma|\.lz|\.zst)$::' -e
> 's:(\.diff?|\.patch)$::')
> num=$(echo "$base" | sed -nre 's:.*-([0-9]+)$:\1:'p)
> [ -n "$num" ] || num=1
> echo "${base%-$num}-$((num+1))${patch#$base}"
> diff --git a/quilt/setup.in b/quilt/setup.in
> index ac24722..8e157d7 100644
> --- a/quilt/setup.in
> +++ b/quilt/setup.in
> @@ -126,7 +126,7 @@ create_md5sums()
> ;;
> # In fast mode, we are only interested in patches, so
> filter out
> # archives
> -
> *.tar|*.tar.Z|*.tar.gz|*.tgz|*.tar.bz2|*.tar.xz|*.tar.lz|*.zip|*.7z)
> +
> *.tar|*.tar.Z|*.tar.gz|*.tgz|*.tar.bz2|*.tar.xz|*.tar.lz|*.tar.zst|*.zip|*.7z)
> [ -n "$QUILT_SETUP_FAST" ] && continue
> ;;
> esac
> @@ -182,6 +182,12 @@ create_md5sums()
> set -- $(lzip -cd "$file" | md5sum)
> echo "$1 $basename"
> ;;
> + zst*|Zst*)
I checked the file(1) source code, the returned string for zstd-
compressed file is "Zstandard compressed data", and has always been
(since support was added in September 2016). But the command would also
return "Zstandard dictionary" for zstd dictionary files. So, the "zst*"
part will never match, and the Zst* part may match file types it
shouldn't. I would therefore recommend changing the pattern to:
"Zstandard compressed data"*)
to be on the safe side.
> + echo -n "z" >&4
> + echo "zstd -cd $file | md5sum" >&5
> + set -- $(zstd -cd "$file" | md5sum)
> + echo "$1 $basename"
> + ;;
> esac
> done > $output
> echo >&4
Everything else looks good.
--
Jean Delvare
SUSE L3 Support