kiss/contrib/kiss-export
zacanger 65b8332eac chore(kiss-export): remove duplicate string building
Signed-off-by: Dylan Araps <dylan.araps@gmail.com>
2020-11-06 08:37:28 +02:00

34 lines
668 B
Bash
Executable File

#!/bin/sh -ef
# Turn an installed package into a KISS tarball
db=$KISS_ROOT/var/db/kiss/installed
pkg=${1:-"${PWD##*/}"}
kiss list "$pkg" >/dev/null || {
printf 'usage: kiss-export [pkg]\n'
exit 1
}
read -r ver rel 2>/dev/null < "$db/$1/version"
set --
while read -r file; do
[ -d "$KISS_ROOT/$file" ] || set -- "$@" ".$file"
done < "$db/$pkg/manifest"
cd "$KISS_ROOT/"
dest="$OLDPWD/$pkg#$ver-$rel.tar.${KISS_COMPRESS:-gz}"
tar cf - "$@" | case ${KISS_COMPRESS:-gz} in
bz2) bzip2 -z ;;
gz) gzip -6 ;;
lzma) lzma -z ;;
lz) lzip -z ;;
xz) xz -zT 0 ;;
zst) zstd -z ;;
esac > "$dest"
printf 'created %s\n' "$dest"