src-release.sh: Support zstd compression

This commit is contained in:
Mark Wielaard 2024-05-30 12:50:11 +01:00 committed by Nick Clifton
parent 99455afce4
commit 888ef52523

View file

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright (C) 1990-2020 Free Software Foundation # Copyright (C) 1990-2024 Free Software Foundation
# #
# This file is free software; you can redistribute it and/or modify # This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -26,6 +26,7 @@ BZIPPROG=bzip2
GZIPPROG=gzip GZIPPROG=gzip
LZIPPROG=lzip LZIPPROG=lzip
XZPROG=xz XZPROG=xz
ZSTDPROG=zstd
SHA256PROG=sha256sum SHA256PROG=sha256sum
MAKE=make MAKE=make
CC=gcc CC=gcc
@ -241,6 +242,16 @@ do_xz()
$XZPROG -k -v -9 $package-$ver.tar $XZPROG -k -v -9 $package-$ver.tar
} }
# Compress the output with zstd
do_zstd()
{
package=$1
ver=$2
echo "==> Zzipping $package-$ver.tar.zst"
rm -f $package-$ver.tar.zst
$ZSTDPROG -k -v -19 -T0 $package-$ver.tar
}
# Compress the output with all selected compresion methods # Compress the output with all selected compresion methods
do_compress() do_compress()
{ {
@ -257,6 +268,8 @@ do_compress()
do_lz $package $ver;; do_lz $package $ver;;
xz) xz)
do_xz $package $ver;; do_xz $package $ver;;
zstd)
do_zstd $package $ver;;
*) *)
echo "Unknown compression method: $comp" && exit 1;; echo "Unknown compression method: $comp" && exit 1;;
esac esac
@ -352,6 +365,7 @@ usage()
echo " -g: Compress with gzip" echo " -g: Compress with gzip"
echo " -l: Compress with lzip" echo " -l: Compress with lzip"
echo " -x: Compress with xz" echo " -x: Compress with xz"
echo " -z: Compress with zstd"
echo " -r <date>: Create a reproducible tarball using <date> as the mtime" echo " -r <date>: Create a reproducible tarball using <date> as the mtime"
exit 1 exit 1
} }
@ -376,7 +390,7 @@ build_release()
compressors="" compressors=""
while getopts ":bglr:x" opt; do while getopts ":bglr:xz" opt; do
case $opt in case $opt in
b) b)
compressors="$compressors bz2";; compressors="$compressors bz2";;
@ -388,6 +402,8 @@ while getopts ":bglr:x" opt; do
release_date=$OPTARG;; release_date=$OPTARG;;
x) x)
compressors="$compressors xz";; compressors="$compressors xz";;
z)
compressors="$compressors zstd";;
\?) \?)
echo "Invalid option: -$OPTARG" && usage;; echo "Invalid option: -$OPTARG" && usage;;
esac esac