diff options
author | Marius Mauch <genone@gentoo.org> | 2006-01-24 15:20:58 +0000 |
---|---|---|
committer | Marius Mauch <genone@gentoo.org> | 2006-01-24 15:20:58 +0000 |
commit | db0bcba4665397a30003d7c03af9c7829d298b1a (patch) | |
tree | c395ac35e6fdee175842a22569e51db0ea0ef256 | |
parent | db991ec37388ea6c8a5d3871ef10a690ffa41347 (diff) | |
download | portage-db0bcba4665397a30003d7c03af9c7829d298b1a.tar.gz portage-db0bcba4665397a30003d7c03af9c7829d298b1a.tar.bz2 portage-db0bcba4665397a30003d7c03af9c7829d298b1a.zip |
fix possible path and vdb location issues
svn path=/main/trunk/; revision=2581
-rwxr-xr-x | bin/emaint | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/bin/emaint b/bin/emaint index 803b5a726..4ea4e73b8 100755 --- a/bin/emaint +++ b/bin/emaint @@ -55,10 +55,10 @@ class VdbKeyHandler(object): self.keys = ["HOMEPAGE", "SRC_URI", "KEYWORDS", "DESCRIPTION"] for p in self.list: - mydir = "/var/db/pkg/"+p + mydir = os.path.join(os.sep, portage.settings["ROOT"], portage_const.VDB_PATH, p)+os.sep ismissing = True for k in self.keys: - if os.path.exists(mydir+"/"+k): + if os.path.exists(mydir+k): ismissing = False break if ismissing: @@ -72,32 +72,33 @@ class VdbKeyHandler(object): errors = [] for p in self.missing: - mydir = "/var/db/pkg/"+p - if not os.access(mydir+"/environment.bz2", os.R_OK): - errors.append("Can't access %s" % (mydir+"/environment.bz2")) + mydir = os.path.join(os.sep, portage.settings["ROOT"], portage_const.VDB_PATH, p)+os.sep + if not os.access(mydir+"environment.bz2", os.R_OK): + errors.append("Can't access %s" % (mydir+"environment.bz2")) elif not os.access(mydir, os.W_OK): errors.append("Can't create files in %s" % mydir) else: - env = os.popen("bzip2 -dcq "+mydir+"/environment.bz2", "r") + env = os.popen("bzip2 -dcq "+mydir+"environment.bz2", "r") envlines = env.read().split("\n") env.close() for k in self.keys: - s = [l for l in envlines if l.strip("\"\'").startswith(k+"=")] + s = [l for l in envlines if l.startswith(k+"=")] if len(s) > 1: - errors.append("multiple matches for %s found in %s/environment.bz2" % (k, mydir)) + errors.append("multiple matches for %s found in %senvironment.bz2" % (k, mydir)) elif len(s) == 0: s = "" else: s = s[0].split("=",1)[1] s = s.lstrip("$").strip("\'\"") s = re.sub("(\\\\[nrt])+", " ", s) - s = re.sub("[\n\r\t]+"," ",s) - s = re.sub(" +"," ",s) - s = s.strip() + s = " ".join(s.split()).strip() if s != "": - keyfile = open(mydir+"/"+k, "w") - keyfile.write(s+"\n") - keyfile.close() + try: + keyfile = open(mydir+os.sep+k, "w") + keyfile.write(s+"\n") + keyfile.close() + except (IOError, OSError), e: + errors.append("Could not write %s, reason was: %s" % (mydir+k, e)) return errors |