Bug #496134: Preserve extended attributes in binary packages.
authorArfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Fri, 27 Dec 2013 18:06:10 +0000 (19:06 +0100)
committerArfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Fri, 27 Dec 2013 18:06:10 +0000 (19:06 +0100)
bin/misc-functions.sh
pym/_emerge/Binpkg.py
pym/_emerge/BinpkgExtractorAsync.py

index 2c4d2489a24446aa7767e2a298f6f87642cd465f..5ccf7c2245fe547a8c0c66bf41109530f2f1be4a 100755 (executable)
@@ -1166,6 +1166,7 @@ __dyn_package() {
 
        local tar_options=""
        [[ $PORTAGE_VERBOSE = 1 ]] && tar_options+=" -v"
+       has xattr ${FEATURES} && [[ $(tar --help 2> /dev/null) == *--xattrs* ]] && tar_options+=" --xattrs"
        # Sandbox is disabled in case the user wants to use a symlink
        # for $PKGDIR and/or $PKGDIR/All.
        export SANDBOX_ON="0"
index 36f851609f78c1db50e465eeaec2ef3db06a63ab..a740efdb901579959f1f36fa87e20c44cffa9ed4 100644 (file)
@@ -298,6 +298,7 @@ class Binpkg(CompositeTask):
 
                extractor = BinpkgExtractorAsync(background=self.background,
                        env=self.settings.environ(),
+                       features=self.settings.features,
                        image_dir=self._image_dir,
                        pkg=self.pkg, pkg_path=self._pkg_path,
                        logfile=self.settings.get("PORTAGE_LOG_FILE"),
index f25cbf93386ae7827774d820e863eb910157f1b0..be74c2fb798d89e287f93924d6117e2c21cdbf6b 100644 (file)
@@ -1,23 +1,31 @@
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from _emerge.SpawnProcess import SpawnProcess
 import portage
 import signal
+import subprocess
 
 class BinpkgExtractorAsync(SpawnProcess):
 
-       __slots__ = ("image_dir", "pkg", "pkg_path")
+       __slots__ = ("features", "image_dir", "pkg", "pkg_path")
 
        _shell_binary = portage.const.BASH_BINARY
 
        def _start(self):
+               tar_options = ""
+               if "xattr" in self.features:
+                       process = subprocess.Popen(["tar", "--help"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+                       output = process.communicate()[0]
+                       if b"--xattrs" in output:
+                               tar_options = "--xattrs"
+
                # Add -q to bzip2 opts, in order to avoid "trailing garbage after
                # EOF ignored" warning messages due to xpak trailer.
                # SIGPIPE handling (128 + SIGPIPE) should be compatible with
                # assert_sigpipe_ok() that's used by the ebuild unpack() helper.
                self.args = [self._shell_binary, "-c",
-                       ("${PORTAGE_BUNZIP2_COMMAND:-${PORTAGE_BZIP2_COMMAND} -d} -cq -- %s | tar -xp -C %s -f - ; " + \
+                       ("${PORTAGE_BUNZIP2_COMMAND:-${PORTAGE_BZIP2_COMMAND} -d} -cq -- %s | tar -xp %s -C %s -f - ; " + \
                        "p=(${PIPESTATUS[@]}) ; " + \
                        "if [[ ${p[0]} != 0 && ${p[0]} != %d ]] ; then " % (128 + signal.SIGPIPE) + \
                        "echo bzip2 failed with status ${p[0]} ; exit ${p[0]} ; fi ; " + \
@@ -25,6 +33,7 @@ class BinpkgExtractorAsync(SpawnProcess):
                        "echo tar failed with status ${p[1]} ; exit ${p[1]} ; fi ; " + \
                        "exit 0 ;") % \
                        (portage._shell_quote(self.pkg_path),
+                       tar_options,
                        portage._shell_quote(self.image_dir))]
 
                SpawnProcess._start(self)