From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RZAFi-00033Q-Ti for garchives@archives.gentoo.org; Fri, 09 Dec 2011 23:53:19 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 748F621C07A; Fri, 9 Dec 2011 23:53:11 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 3ED5321C07A for ; Fri, 9 Dec 2011 23:53:11 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 7C19B1B4008 for ; Fri, 9 Dec 2011 23:53:08 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id E9A0E80042 for ; Fri, 9 Dec 2011 23:53:07 +0000 (UTC) From: "Arfrever Frehtes Taifersar Arahesis" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Arfrever Frehtes Taifersar Arahesis" Message-ID: Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/util/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/util/movefile.py X-VCS-Directories: pym/portage/util/ X-VCS-Committer: arfrever X-VCS-Committer-Name: Arfrever Frehtes Taifersar Arahesis X-VCS-Revision: b5b277f1c03ceee6b00577a693e8c3f0b42d32aa Date: Fri, 9 Dec 2011 23:53:07 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 45e3c055-b51f-4e0a-8c2a-43bdeed8bd5c X-Archives-Hash: 9031dc3c36690a9be8144541d2ff230b commit: b5b277f1c03ceee6b00577a693e8c3f0b42d32aa Author: Arfrever Frehtes Taifersar Arahesis Gentoo Org> AuthorDate: Fri Dec 9 23:51:31 2011 +0000 Commit: Arfrever Frehtes Taifersar Arahesis gentoo org> CommitDate: Fri Dec 9 23:51:31 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3Db5b277f1 portage.util.movefile._copyxattr(): Support usage of getfattr and setfattr executables. --- pym/portage/util/movefile.py | 27 +++++++++++++++++++++++---- 1 files changed, 23 insertions(+), 4 deletions(-) diff --git a/pym/portage/util/movefile.py b/pym/portage/util/movefile.py index fe41501..9507d83 100644 --- a/pym/portage/util/movefile.py +++ b/pym/portage/util/movefile.py @@ -7,6 +7,7 @@ import errno import os as _os import shutil as _shutil import stat +import subprocess =20 import portage from portage import bsd_chflags, _encodings, _os_overrides, _selinux, \ @@ -22,14 +23,32 @@ def _apply_stat(src_stat, dest): _os.chmod(dest, stat.S_IMODE(src_stat.st_mode)) =20 if hasattr(_os, "getxattr"): - # Python >=3D3.3 + # Python >=3D3.3 and GNU/Linux def _copyxattr(src, dest): for attr in _os.listxattr(src): _os.setxattr(dest, attr, _os.getxattr(src, attr)) else: - def _copyxattr(src, dest): - pass - # Maybe call getfattr and setfattr executables. + _devnull =3D open("/dev/null", "w") + try: + subprocess.call(["getfattr", "--version"], stdout=3D_devnull) + subprocess.call(["setfattr", "--version"], stdout=3D_devnull) + _has_getfattr_and_setfattr =3D True + except OSError: + _has_getfattr_and_setfattr =3D False + _devnull.close() + if _has_getfattr_and_setfattr: + def _copyxattr(src, dest): + getfattr_process =3D subprocess.Popen(["getfattr", "-d", "--absolute-= names", src], stdout=3Dsubprocess.PIPE) + getfattr_process.wait() + extended_attributes =3D getfattr_process.stdout.readlines() + getfattr_process.stdout.close() + if extended_attributes: + extended_attributes[0] =3D b"# file: " + _unicode_encode(dest) + b"\= n" + setfattr_process =3D subprocess.Popen(["setfattr", "--restore=3D-"],= stdin=3Dsubprocess.PIPE) + setfattr_process.communicate(input=3Db"".join(extended_attributes)) + else: + def _copyxattr(src, dest): + pass =20 def movefile(src, dest, newmtime=3DNone, sstat=3DNone, mysettings=3DNone= , hardlink_candidates=3DNone, encoding=3D_encodings['fs']):