commit: e18f0aab473b3bfaa4507bc600dcb27b23125d19 Author: Eli Schwartz <eschwartz <AT> gentoo <DOT> org> AuthorDate: Mon Sep 15 15:38:52 2025 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Tue Sep 16 15:40:22 2025 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=e18f0aab
ensure GNU tar is used in most places Portage makes certain assumptions in various places, such as --xattrs enabling FEATURES=xattr and its lack *unconditionally* disabling it. Or, --wildcard existing. PMS mandates "GNU Tar" be used to extract files in `unpack`, and a recent fix went "all in" and used GNU Tar options to improve the function. All this is quite reasonable, but nowhere have we ever enforced that "gtar" is used. libarchive is a valid app-alternatives/tar, on Gentoo, has been broken subtly in the past, and now breaks src_unpack. emerge-webrsync alone has "is_gnu" support code introduced since commit 23ce89c761c080e7d3163165dded94241a9a9eea, so leave it alone. Fixes: 3e89139fae34c9bd2e2b4c0490512f71d1d78546 Signed-off-by: Eli Schwartz <eschwartz <AT> gentoo.org> Part-of: https://github.com/gentoo/portage/pull/1473 Signed-off-by: Sam James <sam <AT> gentoo.org> bin/misc-functions.sh | 6 +++--- bin/phase-helpers.sh | 6 +++--- lib/_emerge/BinpkgExtractorAsync.py | 4 ++-- lib/portage/dbapi/vartree.py | 2 +- lib/portage/tests/resolver/ResolverPlayground.py | 2 +- misc/emerge-delta-webrsync | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh index abddef9f18..9b2f3b2ad2 100755 --- a/bin/misc-functions.sh +++ b/bin/misc-functions.sh @@ -531,14 +531,14 @@ __dyn_package() { [[ ${PORTAGE_VERBOSE} = 1 ]] && tar_options+=" -v" if contains_word xattr "${FEATURES}" \ - && tar --help 2>/dev/null | grep -q -- --xattrs + && gtar --help 2>/dev/null | grep -q -- --xattrs then tar_options+=" --xattrs" fi [[ -z "${PORTAGE_COMPRESSION_COMMAND}" ]] && die "PORTAGE_COMPRESSION_COMMAND is unset" - tar ${tar_options} -cf - ${PORTAGE_BINPKG_TAR_OPTS} -C "${D}" . | \ + gtar ${tar_options} -cf - ${PORTAGE_BINPKG_TAR_OPTS} -C "${D}" . | \ ${PORTAGE_COMPRESSION_COMMAND} > "${PORTAGE_BINPKG_TMPFILE}" assert "failed to pack binary package: '${PORTAGE_BINPKG_TMPFILE}'" @@ -584,7 +584,7 @@ __dyn_spec() { mkdir -p "${sources_dir}" declare -a tar_args=("${EBUILD}") [[ -d ${FILESDIR} ]] && tar_args=("${EBUILD}" "${FILESDIR}") - tar czf "${sources_dir}/${PF}.tar.gz" \ + gtar czf "${sources_dir}/${PF}.tar.gz" \ "${tar_args[@]}" || \ die "Failed to create base rpm tarball." diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh index 02b1aea4ee..47c6f8167c 100644 --- a/bin/phase-helpers.sh +++ b/bin/phase-helpers.sh @@ -480,17 +480,17 @@ unpack() { unrar x -idq -o+ "${srcdir}${f}" ;; tar.bz|tar.bz2|tbz|tbz2) - tar -I "${bzip2_cmd-bzip2} -c" -xof "${srcdir}${f}" + gtar -I "${bzip2_cmd-bzip2} -c" -xof "${srcdir}${f}" ;; tar|tar.*|tgz) # GNU tar recognises various file suffixes, for # which it is able to execute the appropriate # decompressor. They are documented by the # (info) manual for the -a option. - tar --warning=decompress-program -xof "${srcdir}${f}" + gtar --warning=decompress-program -xof "${srcdir}${f}" ;; txz) - tar -xJof "${srcdir}${f}" + gtar -xJof "${srcdir}${f}" ;; xz) xz -dc -- "${srcdir}${f}" > "${basename%.*}" diff --git a/lib/_emerge/BinpkgExtractorAsync.py b/lib/_emerge/BinpkgExtractorAsync.py index 3a31154120..63b5c616bc 100644 --- a/lib/_emerge/BinpkgExtractorAsync.py +++ b/lib/_emerge/BinpkgExtractorAsync.py @@ -39,7 +39,7 @@ class BinpkgExtractorAsync(SpawnProcess): tar_options = "" if "xattr" in self.features: process = subprocess.Popen( - ["tar", "--help"], stdout=subprocess.PIPE, stderr=subprocess.PIPE + ["gtar", "--help"], stdout=subprocess.PIPE, stderr=subprocess.PIPE ) output = process.communicate()[0] if b"--xattrs" in output: @@ -121,7 +121,7 @@ class BinpkgExtractorAsync(SpawnProcess): f""" cmd0=(head -c {pkg_xpak.filestat.st_size - pkg_xpak.xpaksize} -- {shlex.quote(self.pkg_path)}) cmd1=({decomp_cmd}) - cmd2=(tar -xp {tar_options} -C {shlex.quote(self.image_dir)} -f -); + cmd2=(gtar -xp {tar_options} -C {shlex.quote(self.image_dir)} -f -); """ """ "${cmd0[@]}" | "${cmd1[@]}" | "${cmd2[@]}"; diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py index d17432f5f5..d62c7c2be9 100644 --- a/lib/portage/dbapi/vartree.py +++ b/lib/portage/dbapi/vartree.py @@ -1094,7 +1094,7 @@ class vardbapi(dbapi): "BINPKG_FORMAT", SUPPORTED_GENTOO_BINPKG_FORMATS[0] ) if binpkg_format == "xpak": - tar_cmd = ("tar", "-x", "--xattrs", "--xattrs-include=*", "-C", dest_dir) + tar_cmd = ("gtar", "-x", "--xattrs", "--xattrs-include=*", "-C", dest_dir) pr, pw = multiprocessing.Pipe(duplex=False) proc = await asyncio.create_subprocess_exec(*tar_cmd, stdin=pr) pr.close() diff --git a/lib/portage/tests/resolver/ResolverPlayground.py b/lib/portage/tests/resolver/ResolverPlayground.py index f52a98f8db..a732e55e47 100644 --- a/lib/portage/tests/resolver/ResolverPlayground.py +++ b/lib/portage/tests/resolver/ResolverPlayground.py @@ -179,7 +179,7 @@ class ResolverPlayground: "rm", "sed", "sort", - "tar", + "gtar", "tr", "uname", "uniq", diff --git a/misc/emerge-delta-webrsync b/misc/emerge-delta-webrsync index 43ed6bac7c..11e6bde560 100755 --- a/misc/emerge-delta-webrsync +++ b/misc/emerge-delta-webrsync @@ -278,7 +278,7 @@ do_tar() { *.gz) decompressor="zcat" ;; *) decompressor="cat" ;; esac - ${decompressor} "${file}" | tar "$@" + ${decompressor} "${file}" | gtar "$@" _pipestatus=${PIPESTATUS[*]} [[ ${_pipestatus// /} -eq 0 ]] }
