summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-06-12 21:50:56 +0000
committerZac Medico <zmedico@gentoo.org>2007-06-12 21:50:56 +0000
commit5e79d767fea11fde435af56d579c81f30fcea12f (patch)
tree1cde73341cd49ec13c1748dd9752993c6e137072 /pym
parent20850d4640b7fa8f6ac12473717f9f750d92e7f9 (diff)
downloadportage-5e79d767fea11fde435af56d579c81f30fcea12f.tar.gz
portage-5e79d767fea11fde435af56d579c81f30fcea12f.tar.bz2
portage-5e79d767fea11fde435af56d579c81f30fcea12f.zip
For bug #153109, replace our old chflags module with the one provided by the py-freebsd package. Thanks to Flameeyes for the initial patch. (trunk r5870)
svn path=/main/branches/2.1.2/; revision=6820
Diffstat (limited to 'pym')
-rw-r--r--pym/portage.py41
1 files changed, 13 insertions, 28 deletions
diff --git a/pym/portage.py b/pym/portage.py
index 2bb76a2bc..64867b926 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -42,12 +42,12 @@ except ImportError, e:
sys.stderr.write(" "+str(e)+"\n\n");
raise
-try:
- # XXX: This should get renamed to bsd_chflags, I think.
- import chflags
- bsd_chflags = chflags
-except ImportError:
- bsd_chflags = None
+bsd_chflags = None
+if os.uname()[0] in ["FreeBSD"]:
+ try:
+ import freebsd as bsd_chflags
+ except ImportError:
+ pass
try:
from cache.cache_errors import CacheError
@@ -3892,24 +3892,12 @@ def movefile(src,dest,newmtime=None,sstat=None,mysettings=None):
destexists=0
if bsd_chflags:
- # Check that we can actually unset schg etc flags...
- # Clear the flags on source and destination; we'll reinstate them after merging
if destexists and dstat.st_flags != 0:
- if bsd_chflags.lchflags(dest, 0) < 0:
- writemsg("!!! Couldn't clear flags on file being merged: \n ",
- noiselevel=-1)
- # We might have an immutable flag on the parent dir; save and clear.
- pflags=bsd_chflags.lgetflags(os.path.dirname(dest))
+ bsd_chflags.lchflags(dest, 0)
+ pflags = os.stat(os.path.dirname(dest)).st_flags
if pflags != 0:
bsd_chflags.lchflags(os.path.dirname(dest), 0)
- if (destexists and bsd_chflags.lhasproblems(dest) > 0) or \
- bsd_chflags.lhasproblems(os.path.dirname(dest)) > 0:
- # This is bad: we can't merge the file with these flags set.
- writemsg("!!! Can't merge file "+dest+" because of flags set\n",
- noiselevel=-1)
- return None
-
if destexists:
if stat.S_ISLNK(dstat[stat.ST_MODE]):
try:
@@ -4014,10 +4002,8 @@ def movefile(src,dest,newmtime=None,sstat=None,mysettings=None):
if bsd_chflags:
# Restore the flags we saved before moving
- if pflags and bsd_chflags.lchflags(os.path.dirname(dest), pflags) < 0:
- writemsg("!!! Couldn't restore flags (%s) on '%s'\n" % \
- (str(pflags), os.path.dirname(dest)), noiselevel=-1)
- return None
+ if pflags:
+ bsd_chflags.lchflags(os.path.dirname(dest), pflags)
return newmtime
@@ -7837,10 +7823,9 @@ class dblink:
if bsd_chflags:
# Save then clear flags on dest.
- dflags=bsd_chflags.lgetflags(mydest)
- if dflags != 0 and bsd_chflags.lchflags(mydest, 0) < 0:
- writemsg("!!! Couldn't clear flags on '"+mydest+"'.\n",
- noiselevel=-1)
+ dflags = os.lstat(mydest).st_flags
+ if dflags != 0:
+ bsd_chflags.lchflags(mydest, 0)
if not os.access(mydest, os.W_OK):
pkgstuff = pkgsplit(self.pkg)