Revert "kiss: tar improvements"

This reverts commit f8256d699d.

libarchive tar prepends 'x ' to verbose output whereas busybox
tar does not. Did not test other implementations though behave
seems to not be standard regardless.
This commit is contained in:
Dylan Araps 2021-07-21 11:18:34 +03:00
parent 94523bd62f
commit d7ca1d9d5b
No known key found for this signature in database
GPG Key ID: 13295DAC2CF13B5C

26
kiss
View File

@ -453,23 +453,26 @@ pkg_source_tar() {
# This is a portable shell implementation of GNU tar's # This is a portable shell implementation of GNU tar's
# '--strip-components 1'. Use of this function denotes a # '--strip-components 1'. Use of this function denotes a
# performance penalty. # performance penalty.
unset _seen tmp_file "$repo_name" tarball
tmp_file "$repo_name" tarball-manifest tmp_file "$repo_name" tarball-manifest
# Decompress the tarball and extract it to the current directory. unset _seen
# Store its verbose output in a file for use below.
decompress "$1" | tar xvf - > "$_tmp_file" || decompress "$1" > "$_tmp_file_pre" ||
die "$repo_name" "Failed to decompress $1"
tar xf "$_tmp_file_pre" ||
die "$repo_name" "Failed to extract $1" die "$repo_name" "Failed to extract $1"
# The sort command filters out all duplicate top-level
# directories from the tarball's manifest. This is an optimization
# as we avoid looping (4000 times for Python(!)).
tar tf "$_tmp_file_pre" | sort -ut / -k1,1 > "$_tmp_file" ||
die "$repo_name" "Failed to extract manifest"
# Iterate over all directories in the first level of the # Iterate over all directories in the first level of the
# tarball's manifest. Each directory is moved up a level. # tarball's manifest. Each directory is moved up a level.
while IFS=/ read -r dir _; do case ${dir#.} in *?*) while IFS=/ read -r dir _; do case ${dir#.} in *?*)
# Skip directories we have seen before. This used to be a
# sort call but with pipe shenanigans and error handling,
# this is the better solution.
! contains "$_seen" "$dir" || continue && _seen="$_seen $dir"
# Move the parent directory to prevent naming conflicts # Move the parent directory to prevent naming conflicts
# with the to-be-moved children. # with the to-be-moved children.
mv -f "$dir" "$KISS_PID-$dir" mv -f "$dir" "$KISS_PID-$dir"
@ -491,6 +494,9 @@ pkg_source_tar() {
# as we may leave files in here if any were copied. # as we may leave files in here if any were copied.
rm -rf "$KISS_PID-$dir" rm -rf "$KISS_PID-$dir"
esac done < "$_tmp_file" esac done < "$_tmp_file"
# Remove the tarball now that we are done with it.
rm -f "$_tmp_file_pre"
} }
pkg_extract() { pkg_extract() {