summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-09-26 03:30:54 +0000
committerZac Medico <zmedico@gentoo.org>2007-09-26 03:30:54 +0000
commitc90c13bbbb1f6a4d7262c922b1413dadbf09eb5b (patch)
treef63c19dba4dbebe45fc1daf45353323ce5ea2dd9
parentfabc613fbacc9dddbc765a30d6e49431b8726ba9 (diff)
downloadportage-c90c13bbbb1f6a4d7262c922b1413dadbf09eb5b.tar.gz
portage-c90c13bbbb1f6a4d7262c922b1413dadbf09eb5b.tar.bz2
portage-c90c13bbbb1f6a4d7262c922b1413dadbf09eb5b.zip
Bug #192341 - Eliminate the dependency on py-freebsd by implementing
it's chflags() and lchflags() functions as wrappers around the chflags command (which should always be available in any case). The functions are only called when merging/unmerging files that actually have flags set so the performance difference should be negligible. svn path=/main/trunk/; revision=7808
-rw-r--r--pym/portage/__init__.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index f9ef92c12..db377fda5 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -42,10 +42,23 @@ except ImportError, e:
bsd_chflags = None
if os.uname()[0] in ["FreeBSD"]:
- try:
- import freebsd as bsd_chflags
- except ImportError:
+ def bsd_chflags():
pass
+ def _chflags(path, flags, opts=""):
+ cmd = "chflags %s %o '%s'" % (opts, flags, path)
+ status, output = commands.getstatusoutput(cmd)
+ retval = os.WEXITSTATUS(status)
+ if os.WIFEXITED(status) and retval == os.EX_OK:
+ return
+ e = OSError(retval, output)
+ e.errno = retval
+ e.filename = path
+ e.message = output
+ raise e
+ def _lchflags(path, flags):
+ return _chflags(path, flags, opts="-h")
+ bsd_chflags.chflags = _chflags
+ bsd_chflags.lchflags = _lchflags
try:
from portage.cache.cache_errors import CacheError