Gentoo Archives: gentoo-commits

From: Arfrever Frehtes Taifersar Arahesis <arfrever@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/util/
Date: Tue, 29 Nov 2011 01:27:02
Message-Id: ddc9dbc832b3424da722f7442cf33327423735a6.arfrever@gentoo
1 commit: ddc9dbc832b3424da722f7442cf33327423735a6
2 Author: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Gentoo <DOT> Org>
3 AuthorDate: Tue Nov 29 01:26:04 2011 +0000
4 Commit: Arfrever Frehtes Taifersar Arahesis <arfrever <AT> gentoo <DOT> org>
5 CommitDate: Tue Nov 29 01:26:04 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=ddc9dbc8
7
8 Preserve extended attributes on regular files when using Python >=3.3.
9
10 ---
11 pym/portage/util/movefile.py | 16 ++++++++++++++--
12 1 files changed, 14 insertions(+), 2 deletions(-)
13
14 diff --git a/pym/portage/util/movefile.py b/pym/portage/util/movefile.py
15 index 30cb6f1..995f6e7 100644
16 --- a/pym/portage/util/movefile.py
17 +++ b/pym/portage/util/movefile.py
18 @@ -16,6 +16,16 @@ from portage.localization import _
19 from portage.process import spawn
20 from portage.util import writemsg
21
22 +if hasattr(_os, "getxattr"):
23 + # Python >=3.3
24 + def _copyxattr(src, dest):
25 + for attr in _os.listxattr(src):
26 + _os.setxattr(dest, attr, _os.getxattr(src, attr))
27 +else:
28 + def _copyxattr(src, dest):
29 + pass
30 + # Maybe call getfattr and setfattr executables.
31 +
32 def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
33 hardlink_candidates=None, encoding=_encodings['fs']):
34 """moves a file from src to dest, preserving all permissions and attributes; mtime will
35 @@ -162,10 +172,12 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
36 try: # For safety copy then move it over.
37 if selinux_enabled:
38 selinux.copyfile(src, dest + "#new")
39 + _copyxattr(src, dest + "#new")
40 selinux.rename(dest + "#new", dest)
41 else:
42 - shutil.copyfile(src,dest+"#new")
43 - os.rename(dest+"#new",dest)
44 + shutil.copyfile(src, dest + "#new")
45 + _copyxattr(src, dest + "#new")
46 + os.rename(dest + "#new", dest)
47 didcopy=1
48 except SystemExit as e:
49 raise