commit:     bdb75c6a4baa76d3e05334d1089f92286d670051
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sat Jul  5 20:54:48 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jul 13 04:19:02 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=bdb75c6a

emerge-webrsync: jettison the do_tar() function

GNU tar(1) is perfectly capable of determining whether its input needs
to be decompressed as a bzip2 or xz stream. So is bsdtar(1), provided
that libarchive has been built accordingly; both "bzip2" and "zstd" are
default-enabled by IUSE in app-arch/libarchive. As such, the do_tar()
function serves no purpose. Get rid of it.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 bin/emerge-webrsync | 33 +++------------------------------
 1 file changed, 3 insertions(+), 30 deletions(-)

diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync
index 107613fbaf..8eb8546aa6 100755
--- a/bin/emerge-webrsync
+++ b/bin/emerge-webrsync
@@ -149,21 +149,6 @@ handle_pgp_setup() {
        fi
 }
 
-do_tar() {
-       local -
-
-       shopt -o -s pipefail
-       case $1 in
-               *.xz)   xzcat -- "$1" ;;
-               *.bz2)  bzcat -- "$1" ;;
-               *.gz)   zcat  -- "$1" ;;
-               *)      cat   -- "$1" ;;
-       esac | {
-               shift
-               tar "$@"
-       }
-}
-
 get_unixtime_by_date() {
        local date=$1
 
@@ -387,7 +372,7 @@ get_snapshot_timestamp() {
        local file=$1
        local unixtime
 
-       do_tar "${file}" --to-stdout -f - --wildcards -x 
'*/metadata/timestamp.x' |
+       tar --wildcards -O -xf "${file}" '*/metadata/timestamp.x' |
        {
                read -r unixtime _ \
                && is_uint "${unixtime}" \
@@ -430,7 +415,7 @@ sync_local() {
                snapshot_dir=${tmpdir:?}/snapshot
                mkdir -- "${snapshot_dir}" && cd -- "${snapshot_dir}" || exit
 
-               if ! do_tar "${file}" -x --strip-components=1 -f -; then
+               if ! tar --strip-components=1 -xf "${file}"; then
                        eerror "Failed to extract the contents of ${tarball@Q}"
                        return 1
                fi
@@ -469,21 +454,9 @@ do_snapshot() {
        local ignore_timestamp=$1 date=$2
        local have_files mirror file
        local -a tarballs mirrors
-       local -A suffix_by
-
-       suffix_by=([xzcat]=xz [bzcat]=bz2 [zcat]=gz)
-
-       for file in xzcat bzcat zcat; do
-               if hash "${file}" 2>/dev/null; then
-                       tarballs+=( 
{"$repo_name","portage"}-"${date}.tar.${suffix_by[$file]}" )
-               fi
-       done
-
-       if (( ! ${#tarballs[@]} )); then
-               die "unable to locate any decompressors (xzcat, bzcat or zcat)"
-       fi
 
        read -rd '' -a mirrors <<<"${GENTOO_MIRRORS}"
+       tarballs=( {"$repo_name","portage"}-"${date}.tar."{"xz","bz2"} )
 
        for mirror in "${mirrors[@]/%\/}"; do
                einfo "Trying to retrieve ${date} snapshot from ${mirror} ..."

Reply via email to