From db0bcba4665397a30003d7c03af9c7829d298b1a Mon Sep 17 00:00:00 2001 From: Marius Mauch Date: Tue, 24 Jan 2006 15:20:58 +0000 Subject: fix possible path and vdb location issues svn path=/main/trunk/; revision=2581 --- bin/emaint | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'bin/emaint') 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 -- cgit v1.2.3-1-g7c22