summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Mauch <genone@gentoo.org>2006-01-22 21:05:35 +0000
committerMarius Mauch <genone@gentoo.org>2006-01-22 21:05:35 +0000
commit18857e5b06f9405f9f25df66eb00ef9a53ec5b82 (patch)
tree8f8d2c91d891ab4b853c83c0ff3b72f20210c481 /bin/emaint
parentalso catch leading null runpaths (diff)
downloadportage-multirepo-18857e5b06f9405f9f25df66eb00ef9a53ec5b82.tar.gz
portage-multirepo-18857e5b06f9405f9f25df66eb00ef9a53ec5b82.tar.bz2
portage-multirepo-18857e5b06f9405f9f25df66eb00ef9a53ec5b82.zip
store all auxdbkeys in vdb and add a new emaint target to create missing entries
svn path=/main/trunk/; revision=2568
Diffstat (limited to 'bin/emaint')
-rwxr-xr-xbin/emaint61
1 files changed, 59 insertions, 2 deletions
diff --git a/bin/emaint b/bin/emaint
index a3868772..be538033 100755
--- a/bin/emaint
+++ b/bin/emaint
@@ -4,7 +4,7 @@ import sys
from copy import copy
from optparse import OptionParser, OptionValueError
-
+import re
import os, portage, portage_const
class WorldHandler(object):
@@ -44,9 +44,66 @@ class WorldHandler(object):
errors.append(portage_const.WORLD_FILE + " could not be opened for writing")
return errors
+class VdbKeyHandler(object):
+ def name():
+ return "vdbkeys"
+ name = staticmethod(name)
+<<<<<<< .mine
+ def __init__(self):
+ self.list = portage.db["/"]["vartree"].dbapi.cpv_all()
+ self.missing = []
+ self.keys = ["HOMEPAGE", "SRC_URI", "KEYWORDS", "DESCRIPTION"]
+
+ for p in self.list:
+ mydir = "/var/db/pkg/"+p
+ ismissing = True
+ for k in self.keys:
+ if os.path.exists(mydir+"/"+k):
+ ismissing = False
+ break
+ if ismissing:
+ self.missing.append(p)
+
+ def check(self):
+ return ["%s has missing keys" % x for x in self.missing]
+
+ def fix(self):
+
+ 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"))
+ 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")
+ envlines = env.read().split("\n")
+ env.close()
+ for k in self.keys:
+ s = [l for l in envlines if l.strip("\"\'").startswith(k+"=")]
+ if len(s) > 1:
+ errors.append("multiple matches for %s found in %s/environment.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()
+ if s != "":
+ keyfile = open(mydir+"/"+k, "w")
+ keyfile.write(s+"\n")
+ keyfile.close()
+
+ return errors
# this sucks, should track this in a different manner.
-modules = {"world" : WorldHandler}
+modules = {"world" : WorldHandler,
+ "vdbkeys": VdbKeyHandler}
module_names = modules.keys()
module_names.sort()