Lines 28-33
Link Here
|
28 |
_os.chmod(dest, stat.S_IMODE(src_stat.st_mode)) |
28 |
_os.chmod(dest, stat.S_IMODE(src_stat.st_mode)) |
29 |
|
29 |
|
30 |
if hasattr(_os, "getxattr"): |
30 |
if hasattr(_os, "getxattr"): |
|
|
31 |
print 'Fea, has attr' |
31 |
# Python >=3.3 and GNU/Linux |
32 |
# Python >=3.3 and GNU/Linux |
32 |
def _copyxattr(src, dest): |
33 |
def _copyxattr(src, dest): |
33 |
for attr in _os.listxattr(src): |
34 |
for attr in _os.listxattr(src): |
Lines 39-55
Link Here
|
39 |
if raise_exception: |
40 |
if raise_exception: |
40 |
raise OperationNotSupported("Filesystem containing file '%s' does not support extended attributes" % dest) |
41 |
raise OperationNotSupported("Filesystem containing file '%s' does not support extended attributes" % dest) |
41 |
else: |
42 |
else: |
|
|
43 |
print 'Fea, has not attr' |
42 |
try: |
44 |
try: |
43 |
import xattr |
45 |
import xattr |
44 |
except ImportError: |
46 |
except ImportError: |
45 |
xattr = None |
47 |
xattr = None |
46 |
if xattr is not None: |
48 |
if xattr is not None: |
47 |
def _copyxattr(src, dest): |
49 |
def _copyxattr(src, dest): |
|
|
50 |
print 'Fea, case 1' |
48 |
for attr in xattr.list(src): |
51 |
for attr in xattr.list(src): |
49 |
try: |
52 |
try: |
50 |
xattr.set(dest, attr, xattr.get(src, attr)) |
53 |
xattr.set(dest, attr, xattr.get(src, attr)) |
51 |
raise_exception = False |
54 |
raise_exception = False |
52 |
except IOError: |
55 |
except IOError as e: |
|
|
56 |
print 'IOERROR copyxattr: {0}'.format(e) |
53 |
raise_exception = True |
57 |
raise_exception = True |
54 |
if raise_exception: |
58 |
if raise_exception: |
55 |
raise OperationNotSupported("Filesystem containing file '%s' does not support extended attributes" % dest) |
59 |
raise OperationNotSupported("Filesystem containing file '%s' does not support extended attributes" % dest) |
Lines 64-69
Link Here
|
64 |
_devnull.close() |
68 |
_devnull.close() |
65 |
if _has_getfattr_and_setfattr: |
69 |
if _has_getfattr_and_setfattr: |
66 |
def _copyxattr(src, dest): |
70 |
def _copyxattr(src, dest): |
|
|
71 |
print 'Fea, case 2' |
67 |
getfattr_process = subprocess.Popen(["getfattr", "-d", "--absolute-names", src], stdout=subprocess.PIPE) |
72 |
getfattr_process = subprocess.Popen(["getfattr", "-d", "--absolute-names", src], stdout=subprocess.PIPE) |
68 |
getfattr_process.wait() |
73 |
getfattr_process.wait() |
69 |
extended_attributes = getfattr_process.stdout.readlines() |
74 |
extended_attributes = getfattr_process.stdout.readlines() |
Lines 76-81
Link Here
|
76 |
raise OperationNotSupported("Filesystem containing file '%s' does not support extended attributes" % dest) |
81 |
raise OperationNotSupported("Filesystem containing file '%s' does not support extended attributes" % dest) |
77 |
else: |
82 |
else: |
78 |
def _copyxattr(src, dest): |
83 |
def _copyxattr(src, dest): |
|
|
84 |
print 'Fea, case 3 O_o' |
79 |
pass |
85 |
pass |
80 |
|
86 |
|
81 |
def movefile(src, dest, newmtime=None, sstat=None, mysettings=None, |
87 |
def movefile(src, dest, newmtime=None, sstat=None, mysettings=None, |
Lines 191-196
Link Here
|
191 |
# For atomic replacement, first create the link as a temp file |
197 |
# For atomic replacement, first create the link as a temp file |
192 |
# and them use os.rename() to replace the destination. |
198 |
# and them use os.rename() to replace the destination. |
193 |
if hardlink_candidates: |
199 |
if hardlink_candidates: |
|
|
200 |
print 'Fea, hard' |
194 |
head, tail = os.path.split(dest) |
201 |
head, tail = os.path.split(dest) |
195 |
hardlink_tmp = os.path.join(head, ".%s._portage_merge_.%s" % \ |
202 |
hardlink_tmp = os.path.join(head, ".%s._portage_merge_.%s" % \ |
196 |
(tail, os.getpid())) |
203 |
(tail, os.getpid())) |
Lines 218-227
Link Here
|
218 |
return None |
225 |
return None |
219 |
hardlinked = True |
226 |
hardlinked = True |
220 |
break |
227 |
break |
|
|
228 |
else: |
229 |
print 'Fea, not hard' |
221 |
|
230 |
|
222 |
renamefailed=1 |
231 |
renamefailed=1 |
223 |
if hardlinked: |
232 |
if hardlinked: |
224 |
renamefailed = False |
233 |
renamefailed = False |
|
|
234 |
print '{0} {1} {2}=={3}'.format(hardlinked, selinux_enabled, sstat.st_dev, dstat.st_dev) |
225 |
if not hardlinked and (selinux_enabled or sstat.st_dev == dstat.st_dev): |
235 |
if not hardlinked and (selinux_enabled or sstat.st_dev == dstat.st_dev): |
226 |
try: |
236 |
try: |
227 |
if selinux_enabled: |
237 |
if selinux_enabled: |
Lines 230-235
Link Here
|
230 |
os.rename(src,dest) |
240 |
os.rename(src,dest) |
231 |
renamefailed=0 |
241 |
renamefailed=0 |
232 |
except OSError as e: |
242 |
except OSError as e: |
|
|
243 |
print 'renamefailed, err {0}'.format(e) |
233 |
if e.errno != errno.EXDEV: |
244 |
if e.errno != errno.EXDEV: |
234 |
# Some random error. |
245 |
# Some random error. |
235 |
writemsg("!!! %s\n" % _("Failed to move %(src)s to %(dest)s") % |
246 |
writemsg("!!! %s\n" % _("Failed to move %(src)s to %(dest)s") % |
Lines 238-262
Link Here
|
238 |
return None |
249 |
return None |
239 |
# Invalid cross-device-link 'bind' mounted or actually Cross-Device |
250 |
# Invalid cross-device-link 'bind' mounted or actually Cross-Device |
240 |
if renamefailed: |
251 |
if renamefailed: |
|
|
252 |
print 'Fea, renamefailed' |
253 |
|
254 |
print '{0}, then {1}, then {2}'.format(stat.ST_MODE, sstat[stat.ST_MODE], stat.S_ISREG(sstat[stat.ST_MODE])) |
241 |
if stat.S_ISREG(sstat[stat.ST_MODE]): |
255 |
if stat.S_ISREG(sstat[stat.ST_MODE]): |
|
|
256 |
print 'Fea, stat.S_ISREG(sstat[stat.ST_MODE])' |
242 |
dest_tmp = dest + "#new" |
257 |
dest_tmp = dest + "#new" |
243 |
dest_tmp_bytes = _unicode_encode(dest_tmp, encoding=encoding, |
258 |
dest_tmp_bytes = _unicode_encode(dest_tmp, encoding=encoding, |
244 |
errors='strict') |
259 |
errors='strict') |
245 |
try: # For safety copy then move it over. |
260 |
try: # For safety copy then move it over. |
|
|
261 |
print '{0} -> {1}'.format(src_bytes, dest_tmp_bytes) |
246 |
_copyfile(src_bytes, dest_tmp_bytes) |
262 |
_copyfile(src_bytes, dest_tmp_bytes) |
247 |
if xattr_enabled: |
263 |
if xattr_enabled: |
248 |
try: |
264 |
try: |
249 |
_copyxattr(src_bytes, dest_tmp_bytes) |
265 |
_copyxattr(src_bytes, dest_tmp_bytes) |
250 |
except SystemExit: |
266 |
except SystemExit: |
251 |
raise |
267 |
raise |
252 |
except: |
268 |
except Exception as e: |
|
|
269 |
print 'Fea, l263: {0}'.format(e) |
253 |
msg = _("Failed to copy extended attributes. " |
270 |
msg = _("Failed to copy extended attributes. " |
254 |
"In order to avoid this error, set " |
271 |
"In order to avoid this error, set " |
255 |
"FEATURES=\"-xattr\" in make.conf.") |
272 |
"FEATURES=\"-xattr\" in make.conf.") |
256 |
msg = textwrap.wrap(msg, 65) |
273 |
msg = textwrap.wrap(msg, 65) |
257 |
for line in msg: |
274 |
for line in msg: |
258 |
writemsg("!!! %s\n" % (line,), noiselevel=-1) |
275 |
writemsg("!!! %s\n" % (line,), noiselevel=-1) |
259 |
raise |
276 |
raise e |
260 |
_apply_stat(sstat, dest_tmp_bytes) |
277 |
_apply_stat(sstat, dest_tmp_bytes) |
261 |
_rename(dest_tmp_bytes, dest_bytes) |
278 |
_rename(dest_tmp_bytes, dest_bytes) |
262 |
_os.unlink(src_bytes) |
279 |
_os.unlink(src_bytes) |
Lines 268-273
Link Here
|
268 |
writemsg("!!! %s\n" % (e,), noiselevel=-1) |
285 |
writemsg("!!! %s\n" % (e,), noiselevel=-1) |
269 |
return None |
286 |
return None |
270 |
else: |
287 |
else: |
|
|
288 |
print 'Fea, falback mv' |
289 |
|
271 |
#we don't yet handle special, so we need to fall back to /bin/mv |
290 |
#we don't yet handle special, so we need to fall back to /bin/mv |
272 |
a = spawn([MOVE_BINARY, '-f', src, dest], env=os.environ) |
291 |
a = spawn([MOVE_BINARY, '-f', src, dest], env=os.environ) |
273 |
if a != os.EX_OK: |
292 |
if a != os.EX_OK: |