/[secure-testing]/bin/list-queue
ViewVC logotype

Diff of /bin/list-queue

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 16580 by fw, Sun Apr 24 15:27:54 2011 UTC revision 16581 by fw, Sun Apr 24 15:35:27 2011 UTC
# Line 33  DIRECTORIES = ('/org/security-master.deb Line 33  DIRECTORIES = ('/org/security-master.deb
33  # End Configuration  # End Configuration
34  ######################################################################  ######################################################################
35    
36  import sys  import json
37  import os.path  import os.path
38  def setup_path():  import re
     dirname = os.path.dirname  
     base = dirname(dirname(os.path.realpath(sys.argv[0])))  
     sys.path.insert(0, os.path.join(base, "lib", "python"))  
 setup_path()  
   
39  import sqlite3  import sqlite3
40  import json  import sys
41    
 from debian.debfile import DebFile  
42  from debian.deb822 import Changes  from debian.deb822 import Changes
43  import debian_support  from debian.debfile import DebFile
44    
45  def createdb():  def createdb():
46      cache = os.path.expanduser("~/.cache")      cache = os.path.expanduser("~/.cache")
# Line 100  def readpackages(db): Line 94  def readpackages(db):
94      result = {}      result = {}
95      for row in db.execute("SELECT * FROM package"):      for row in db.execute("SELECT * FROM package"):
96          name, size, mtime = row[0:3]          name, size, mtime = row[0:3]
97          pkg = debian_support.BinaryPackage(row[3:])          pkg = tuple(row[3:])
98          result[name] = (size, mtime, pkg)          result[name] = (size, mtime, pkg)
99      return result      return result
100    
# Line 131  def stripstat(data): Line 125  def stripstat(data):
125      for (key, value) in data.items():      for (key, value) in data.items():
126          data[key] = value[2:]          data[key] = value[2:]
127    
128    # See debian_support.BinaryPackage.loadtuple().
129    def deb822totuple(data, re_source=re.compile(
130            r'^([a-zA-Z0-9.+-]+)(?:\s+\(([a-zA-Z0-9.+:~-]+)\))?$')):
131        """Turns an Deb822-like object into a 5-tuple.
132    
133        Returns (PACKAGE-NAME, VERSION, ARCHITECTURE, SOURCE,
134        SOURCE-VERSION)."""
135    
136        pkg = data["Package"]
137        version = data["Version"]
138        if "Source" in data:
139            source = data.get("Source", None)
140            match = re_source.match(source)
141            if match is None:
142                raise ValueError("invalid Source field: " + repr(source))
143            src, src_version = match.groups()
144            if src_version is None:
145                src_version = version
146        else:
147            src = pkg
148            src_version = version
149        return (pkg, version, data["Architecture"], src, src_version)
150    
151  def updatepackages(db, ondisk):  def updatepackages(db, ondisk):
152      "Updates the package table from the file system."      "Updates the package table from the file system."
153      indb = readpackages(db)      indb = readpackages(db)
# Line 141  def updatepackages(db, ondisk): Line 158  def updatepackages(db, ondisk):
158      def do_update():      def do_update():
159          for (path, stat) in need_update:          for (path, stat) in need_update:
160              deb = DebFile(path)              deb = DebFile(path)
161              pkg = debian_support.BinaryPackage()              pkg = deb822totuple(deb.debcontrol())
             pkg.load822(deb.debcontrol())  
162              indb[path] = stat + (pkg,)              indb[path] = stat + (pkg,)
163              yield (path,) + stat + pkg.astuple()              yield (path,) + stat + pkg
164      db.executemany("INSERT INTO package VALUES (?, ?, ?, ?, ?, ?, ?, ?)",      db.executemany("INSERT INTO package VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
165                     do_update())                     do_update())
166    
# Line 194  def pkgwithdist(debs, dists): Line 210  def pkgwithdist(debs, dists):
210      Returns a list of tuples (PACKAGE-NAME, VERSION, ARCHITECTURE,      Returns a list of tuples (PACKAGE-NAME, VERSION, ARCHITECTURE,
211      SOURCE-NAME, SOURCE-VERSION, TUPLE-OF-DISTRIBUTIONS).      SOURCE-NAME, SOURCE-VERSION, TUPLE-OF-DISTRIBUTIONS).
212      """      """
213      return [pkg.astuple() + (sorted(dists.get(path, ())),)      return [pkg + (sorted(dists.get(path, ())),)
214              for (path, (pkg,)) in debs.items()]              for (path, (pkg,)) in debs.items()]
215    
216  def main():  def main():

Legend:
Removed from v.16580  
changed lines
  Added in v.16581

  ViewVC Help
Powered by ViewVC 1.1.5