commit:     23ce89c761c080e7d3163165dded94241a9a9eea
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sat Jul  5 21:06:29 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=23ce89c7

emerge-webrsync: support bsdtar

Presently, emerge-webrsync is incompatible with bsdtar(1) because the
get_snapshot_timestamp() function specifies the --wildcards option.

Address this issue by only specifying this option in the case that the
tar(1) implementation is found to be that of GNU. The BSD implementation
always treats its operands as globs, provided that either the -t or -x
option has been specified.

It should be noted that this renders emerge-webrsync compatible with the
native tar(1) implementations of macOS, FreeBSD and NetBSD, but not
those of OpenBSD, MirBSD and Solaris. This matters little because the
Gentoo Prefix installation script bootstraps GNU tar. Nonetheless, there
is no harm in improving upon the portability of emerge-webrsync.

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

 bin/emerge-webrsync | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync
index 8eb8546aa6..6f32a484ae 100755
--- a/bin/emerge-webrsync
+++ b/bin/emerge-webrsync
@@ -370,9 +370,13 @@ check_file_signature() {
 
 get_snapshot_timestamp() {
        local file=$1
-       local unixtime
+       local unixtime is_gnu
 
-       tar --wildcards -O -xf "${file}" '*/metadata/timestamp.x' |
+       if tar --version 2>/dev/null | grep -q 'GNU tar'; then
+               is_gnu=1
+       fi
+
+       tar ${is_gnu+--wildcards} -O -xf "${file}" '*/metadata/timestamp.x' |
        {
                read -r unixtime _ \
                && is_uint "${unixtime}" \

Reply via email to