kiss: Better tar compatibility

This commit is contained in:
Dylan Araps 2020-05-13 14:10:28 +03:00
parent 985068abe7
commit 6620f5c674
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E
1 changed files with 14 additions and 4 deletions

18
kiss
View File

@ -75,6 +75,16 @@ pop() {
for i do [ "$i" = "$del" ] || printf %s " $i "; done for i do [ "$i" = "$del" ] || printf %s " $i "; done
} }
_tar() {
# Some tar implementations support '-args' and some
# simply support 'args'. This will try '-args' and
# fallback to 'args'.
tar_cmd=$1
shift
tar "-$tar_cmd" "$@" || tar "$tar_cmd" "$@"
}
run_hook() { run_hook() {
# Provide a default post-build hook to remove files # Provide a default post-build hook to remove files
# and directories for things we don't support out of # and directories for things we don't support out of
@ -327,10 +337,10 @@ pkg_extract() {
*://*.tar|*://*.tar.??|*://*.tar.???|*://*.tar.????|*://*.t?z) *://*.tar|*://*.tar.??|*://*.tar.???|*://*.tar.????|*://*.t?z)
decompress "$src_dir/$1/${src##*/}" > .ktar decompress "$src_dir/$1/${src##*/}" > .ktar
tar xf .ktar || _tar xf .ktar ||
die "$1" "Couldn't extract ${src##*/}" die "$1" "Couldn't extract ${src##*/}"
tar tf .ktar | while IFS=/ read -r dir _; do _tar tf .ktar | while IFS=/ read -r dir _; do
# Some tarballs contain './' as the top-level directory, # Some tarballs contain './' as the top-level directory,
# we need to skip these occurances. # we need to skip these occurances.
[ -d "${dir#.}" ] || continue [ -d "${dir#.}" ] || continue
@ -600,7 +610,7 @@ pkg_tar() (
cd "$pkg_dir/$1" cd "$pkg_dir/$1"
# Create a tarball from the contents of the built package. # Create a tarball from the contents of the built package.
tar cf - . | case ${KISS_COMPRESS:=gz} in _tar cf - . | case ${KISS_COMPRESS:=gz} in
bz2) bzip2 -z ;; bz2) bzip2 -z ;;
gz) gzip -6 ;; gz) gzip -6 ;;
lzma) lzma -z ;; lzma) lzma -z ;;
@ -1171,7 +1181,7 @@ pkg_install() {
( (
cd "$tar_dir/$pkg_name" cd "$tar_dir/$pkg_name"
decompress "$tar_file" | tar xf - decompress "$tar_file" | _tar xf -
) )
# Naively assume that the existence of a manifest file is all # Naively assume that the existence of a manifest file is all