diff options
author | Zac Medico <zmedico@gentoo.org> | 2007-09-26 20:52:25 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2007-09-26 20:52:25 +0000 |
commit | 9016e31b0f17bb7c118edfcf60cf1342958a3fe7 (patch) | |
tree | 0bf97abe089fb7659574771c94fa2a37ca699bd6 /pym/portage.py | |
parent | e9156c77ede4e00eafd2171c8e89f2f0898cc77e (diff) | |
download | portage-9016e31b0f17bb7c118edfcf60cf1342958a3fe7.tar.gz portage-9016e31b0f17bb7c118edfcf60cf1342958a3fe7.tar.bz2 portage-9016e31b0f17bb7c118edfcf60cf1342958a3fe7.zip |
Bug #192341 - When the chflags command does not exit successfully,
try to generate an informative error. First, use stat or lstat to
try and generate an ENOENT error. It the path exists, verify that
the chflags binary exists and raise CommandNotFound if necessary.
Finally, simply generate an EPERM OSError with the output of the
command since we're not sure exactly why it failed or what the
real errno was. (trunk r7834)
svn path=/main/branches/2.1.2/; revision=7836
Diffstat (limited to 'pym/portage.py')
-rw-r--r-- | pym/portage.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/pym/portage.py b/pym/portage.py index c7766e7c0..b2a2e4a2c 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -49,11 +49,20 @@ if os.uname()[0] in ["FreeBSD"]: 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: + if os.WIFEXITED(status) and os.WEXITSTATUS(status) == os.EX_OK: return - e = OSError(retval, output) - e.errno = retval + # Try to generate an ENOENT error if appropriate. + if "h" in opts: + os.lstat(path) + else: + os.stat(path) + # Make sure the binary exists. + if not portage_exec.find_binary("chflags"): + raise portage_exception.CommandNotFound("chflags") + # Now we're not sure exactly why it failed or what + # the real errno was, so just report EPERM. + e = OSError(errno.EPERM, output) + e.errno = errno.EPERM e.filename = path e.message = output raise e |