store all auxdbkeys in vdb and add a new emaint target to create missing entries
authorMarius Mauch <genone@gentoo.org>
Sun, 22 Jan 2006 21:05:35 +0000 (21:05 -0000)
committerMarius Mauch <genone@gentoo.org>
Sun, 22 Jan 2006 21:05:35 +0000 (21:05 -0000)
svn path=/main/trunk/; revision=2568

bin/ebuild.sh
bin/emaint

index 0ccd616c45ccafe8f41706775fe2b6341d84bc34..afd0343c2c2aa1def337b13975e02fb008be39f5 100755 (executable)
@@ -914,7 +914,8 @@ dyn_compile() {
        for f in ASFLAGS CATEGORY CBUILD CC CFLAGS CHOST CTARGET CXX \
                CXXFLAGS DEPEND EXTRA_ECONF EXTRA_EINSTALL EXTRA_MAKE \
                FEATURES INHERITED IUSE LDFLAGS LIBCFLAGS LIBCXXFLAGS \
-               LICENSE PDEPEND PF PKGUSE PROVIDE RDEPEND RESTRICT SLOT; do
+               LICENSE PDEPEND PF PKGUSE PROVIDE RDEPEND RESTRICT SLOT \
+               KEYWORDS HOMEPAGE SRC_URI DESCRIPTION; do
                [ -n "${!f}" ] && echo $(echo "${!f}" | tr '\n,\r,\t' ' , , ' | sed s/'  \+'/' '/g) > ${f}
        done
        echo "${USE}"           > USE
index a3868772fcd97fca3f11a46f3a7a4e7b903c0a6b..be538033dde61bd64aa9765b063fbd73e10e371d 100755 (executable)
@@ -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()