diff options
author | Sean Finney <seanius@seanius.net> | 2009-12-02 20:24:48 +0100 |
---|---|---|
committer | Sean Finney <seanius@seanius.net> | 2009-12-02 20:24:48 +0100 |
commit | e5fd3dd111d34276aa705f8eac09494cda178c98 (patch) | |
tree | b36476974d180210253237f8968803bc0f717780 | |
parent | 11db52a1fedf54f728a9c7f6a890c1bc6d28bd7c (diff) | |
download | patch-tracker-e5fd3dd111d34276aa705f8eac09494cda178c98.tar.gz |
initial support for source package format 3.0 (quilt)
the changes aren't as pretty as i'd like them to be, but i don't want
to hold things up on mere aesthetic grounds and it seems to work anyway :)
-rw-r--r-- | db.sql | 3 | ||||
-rw-r--r-- | patchtracker/DB.py | 27 | ||||
-rw-r--r-- | patchtracker/DebTarHandler.py | 27 | ||||
-rw-r--r-- | patchtracker/Patch.py | 65 | ||||
-rwxr-xr-x | patchtracker/ReqHandler.py | 8 | ||||
-rwxr-xr-x | patchtracker/SourceArchive.py | 14 | ||||
-rwxr-xr-x | patchtracker/Templates.py | 13 | ||||
-rwxr-xr-x | reprepro/conf/diffsonly.py | 5 | ||||
-rwxr-xr-x | templates/package_vers.tmpl | 27 |
9 files changed, 154 insertions, 35 deletions
@@ -10,6 +10,9 @@ CREATE TABLE packages ( diffgz_name TEXT DEFAULT NULL, diffgz_size INTEGER DEFAULT NULL, diffgz_md5sum TEXT DEFAULT NULL, + debtar_name TEXT DEFAULT NULL, + debtar_size INTEGER DEFAULT NULL, + debtar_md5sum TEXT DEFAULT NULL, maintainer TEXT NOT NULL, uploaders TEXT DEFAULT NULL ); diff --git a/patchtracker/DB.py b/patchtracker/DB.py index 88d2886..0bb0966 100644 --- a/patchtracker/DB.py +++ b/patchtracker/DB.py @@ -16,6 +16,10 @@ def srcpkg_factory(cursor, row): diffgz = {'name':d['diffgz_name'], 'size':d['diffgz_size'], 'md5sum':d['diffgz_md5sum'] } info['Files'].append(diffgz) + if d['debtar_name']: + debtar = {'name':d['debtar_name'], 'size':d['debtar_size'], + 'md5sum':d['debtar_md5sum'] } + info['Files'].append(debtar) colmap = {'name':'Package','version':'Version','format':'Format', 'loc':'Directory','maintainer':'Maintainer','uploaders':'Uploaders'} @@ -39,6 +43,10 @@ def srcpkg_collection_factory(cursor, row): diffgz = {'name':d['diffgz_name'], 'size':d['diffgz_size'], 'md5sum':d['diffgz_md5sum'] } info['Files'].append(diffgz) + if d['debtar_name']: + debtar = {'name':d['debtar_name'], 'size':d['debtar_size'], + 'md5sum':d['debtar_md5sum'] } + info['Files'].append(debtar) colmap = {'name':'Package','version':'Version','format':'Format', 'loc':'Directory','maintainer':'Maintainer','uploaders':'Uploaders'} @@ -70,11 +78,14 @@ class PatchTrackerDB: cursor = self.db.cursor() #print "creating new record for",srcpkg q = "INSERT OR IGNORE INTO packages \ - (name,format,loc,version,diffgz_name,diffgz_size,diffgz_md5sum,maintainer,uploaders) \ - VALUES (?,?,?,?,?,?,?,?,?)" + (name,format,loc,version,diffgz_name,diffgz_size,diffgz_md5sum,debtar_name,debtar_size,debtar_md5sum,maintainer,uploaders) \ + VALUES (?,?,?,?,?,?,?,?,?,?,?,?)" cursor.execute(q, (srcpkg.name,srcpkg.format,srcpkg.loc, srcpkg.version,srcpkg.diffgz_name,srcpkg.diffgz_size, - srcpkg.diffgz_md5sum,srcpkg.maintainers,srcpkg.uploaders)) + srcpkg.diffgz_md5sum, + srcpkg.debtar_name,srcpkg.debtar_size, + srcpkg.debtar_md5sum, + srcpkg.maintainers,srcpkg.uploaders)) def saveSuite(self, suite): q = "INSERT INTO suites (name) VALUES (?)" @@ -146,6 +157,16 @@ class PatchTrackerDB: except: return None + def findDebTar(self, pkgname, version): + q = "SELECT debtar_name,loc FROM packages WHERE name=? AND version=?" + cursor = self.db.cursor() + cursor.execute(q, (pkgname, version)) + try: + debtar,loc = cursor.fetchone() + return os.sep.join([Conf.archive_root, loc, debtar]) + except: + return None + def prune(self): q = "DELETE FROM package_rel_map WHERE marked != 1" cursor = self.db.cursor() diff --git a/patchtracker/DebTarHandler.py b/patchtracker/DebTarHandler.py new file mode 100644 index 0000000..311e39b --- /dev/null +++ b/patchtracker/DebTarHandler.py @@ -0,0 +1,27 @@ +import os +import stat +import sys + +import Patch + +class DebTarHandler: + diff = None + def __init__(self,fname): + self.tarfile = fname + self.size = os.stat(fname)[stat.ST_SIZE] + + def series(self): + return Patch.Quilt30PatchSeries(self.tarfile) + +if __name__ == "__main__": + print "DebTarHandler testing" + try: + dh = DebTarHandler(sys.argv[1]) + except IndexError: + print "usage: %s <diffgz>"%(sys.argv[0]) + sys.exit(1) + + print "series:" + for f,p in dh.series(): + print f + print p diff --git a/patchtracker/Patch.py b/patchtracker/Patch.py index 670f389..e19ad8c 100644 --- a/patchtracker/Patch.py +++ b/patchtracker/Patch.py @@ -2,6 +2,7 @@ import sys import os import errno from glob import glob +import tarfile class Diffstat: def __init__(self, patch): @@ -38,9 +39,35 @@ class Patch: def diffstat(self): return Diffstat(self) -# XXX this entire __init__ stuff is way to ugly -class PatchSeries (list): +class GenericPatchSeries (list): + def blank(self): + self.names = [] + self.style = "unknown" + self.patches = {} + self.patchargs = {} + + # WTF am i doing this for, again? + def iterpatches(self): + for p in self.names: + yield (p, self.patches[p]) + + def __iter__(self): + return self.iterpatches() + + def __getitem__(self, y): + return self.patches[self.names[y]] + + def __len__(self): + return len(self.names) + + def fetch(self, name): + return self.patches[name] + + def __str__(self): + return "\n".join(self.names) +# XXX this entire __init__ stuff is way to ugly +class PatchSeries (GenericPatchSeries): def __init__(self, dir): fd = None self.blank() @@ -110,27 +137,19 @@ class PatchSeries (list): for p in removelater: self.names.remove(p) - def blank(self): - self.names = [] - self.style = "unknown" - self.patches = {} - self.patchargs = {} - - def iterpatches(self): - for p in self.names: - yield (p, self.patches[p]) - - def __getitem__(self, y): - return self.patches[self.names[y]] - - def __len__(self): - return len(self.names) - - def fetch(self, name): - return self.patches[name] - - def __str__(self): - return "\n".join(self.names) +class Quilt30PatchSeries (GenericPatchSeries): + def __init__(self, tarBall): + self.blank() + self.style = "quilt (3.0)" + self.tarfh = tarfile.open(tarBall, 'r:*') + try: + series_fh = self.tarfh.extractfile("debian/patches/debian.series") + except KeyError: + series_fh = self.tarfh.extractfile("debian/patches/series") + self.names = ["debian/patches/"+fn.strip() for fn in series_fh.readlines()] + # XXX to lazy eval this might be better + for name in self.names: + self.patches[name] = Patch(self.tarfh.extractfile(name)) if __name__ == "__main__": print "Patch.py testing" diff --git a/patchtracker/ReqHandler.py b/patchtracker/ReqHandler.py index af54116..90fc75a 100755 --- a/patchtracker/ReqHandler.py +++ b/patchtracker/ReqHandler.py @@ -7,6 +7,7 @@ import sys import patchtracker.Conf as Conf from patchtracker.Templates import ErrorTemplate, PatchTemplate, PackageVersTemplate, LetterTocTemplate, FrontPageTemplate, SearchResultsTemplate from patchtracker.DiffGzHandler import DiffGzHandler, DiffGzException +from patchtracker.DebTarHandler import DebTarHandler from patchtracker.CacheObject import CacheObject, CacheMissException import patchtracker.DB as DB from patchtracker.DB import PatchTrackerDB @@ -66,12 +67,17 @@ class PatchCmd(Cmd): if mode == "dl": self.content_type = "text/x-diff" + # XXX this is kinda ugly... def make_diffhandler(self, pkgname, vers): dfile = self.db.findDiffGz(pkgname,vers) if dfile: return DiffGzHandler(dfile) else: - raise ReqHandlerException("can not find diff file for %s / %s"%(pkgname,vers)) + dfile = self.db.findDebTar(pkgname, vers) + if dfile: + return DebTarHandler(dfile) + else: + raise ReqHandlerException("can not find diff file for %s / %s"%(pkgname,vers)) def output(self): if self.mode == "dl": diff --git a/patchtracker/SourceArchive.py b/patchtracker/SourceArchive.py index 6134682..da18e83 100755 --- a/patchtracker/SourceArchive.py +++ b/patchtracker/SourceArchive.py @@ -91,10 +91,19 @@ def getidx(letter): class SourcePackage: def __init__(self, info): + # attributes for debian .diff.gz source packages self.diffgz_name = None self.diffgz_size = None self.diffgz_md5sum = None self.diffgz = None + + # attributes for debian .debian.tar.gz source packages + self.debtar_name = None + self.debtar_size = None + self.debtar_md5sum = None + self.debtar = None + + # some other defaults self.type = "Native" self.name = info['Package'] self.format = info['Format'] @@ -120,6 +129,11 @@ class SourcePackage: self.diffgz_size=f['size'] self.diffgz_md5sum=f['md5sum'] self.type = "Debian-diff" + elif fnmatch(f['name'], '*.debian.tar.gz'): + self.debtar_name=f['name'] + self.debtar_size=f['size'] + self.debtar_md5sum=f['md5sum'] + self.type = "Debian-tar" def __str__(self): return self.name diff --git a/patchtracker/Templates.py b/patchtracker/Templates.py index a30e2c0..42140a8 100755 --- a/patchtracker/Templates.py +++ b/patchtracker/Templates.py @@ -1,5 +1,6 @@ -from patchtracker import Conf +from patchtracker import Conf, DB from patchtracker.DiffGzHandler import DiffGzHandler +from patchtracker.DebTarHandler import DebTarHandler from patchtracker.SourceArchive import ReleaseList from Cheetah.Template import Template @@ -34,11 +35,15 @@ class PackageVersTemplate(OurTemplate): self.src = srcpkg tpl=os.sep.join([Conf.template_dir, "package_vers.tmpl"]) sl = {} - if srcpkg.diffgz_name: - dfile = os.sep.join([Conf.archive_root,srcpkg.loc,srcpkg.diffgz_name]) + # XXX c/p from PatchCmd.make_diffhandler + db = DB.PatchTrackerDB() + dfile = db.findDiffGz(srcpkg.name,srcpkg.version) + if dfile: sl['diffhandler'] = DiffGzHandler(dfile) else: - sl['diffhandler'] = None + dfile = db.findDebTar(srcpkg.name, srcpkg.version) + if dfile: + sl['diffhandler'] = DebTarHandler(dfile) sl['crumbs'] = [("package/"+srcpkg.name,srcpkg.name), ("package/"+srcpkg.name+"/"+srcpkg.version, srcpkg.name+"/"+srcpkg.version)] diff --git a/reprepro/conf/diffsonly.py b/reprepro/conf/diffsonly.py index e37b911..ad0a495 100755 --- a/reprepro/conf/diffsonly.py +++ b/reprepro/conf/diffsonly.py @@ -35,8 +35,9 @@ if __name__ == '__main__': newfiles = [] if ent.has_key(k): for f in ent[k]: - if fnmatch(f['name'], '*.diff.gz') or fnmatch(f['name'], '*.dsc'): - newfiles.append(f) + for wanted_glob in ['*.diff.gz', '*.dsc', '*.debian.tar.gz']: + if fnmatch(f['name'], wanted_glob): + newfiles.append(f) ent[k] = newfiles outf.write(str(ent)) outf.write("\n") diff --git a/templates/package_vers.tmpl b/templates/package_vers.tmpl index 896b82d..07b11ec 100755 --- a/templates/package_vers.tmpl +++ b/templates/package_vers.tmpl @@ -23,6 +23,29 @@ debian specific patch information for $src.name / $src.version </table> </div> <!-- diffsummary --> +#if $src.debtar_name + <div class="debdiff"> + <a name="debian-tarball"></a> + <h2> "Debian tarball" Information </h2> + <table class="patchlisting"> + <tr> + <th>Debian changes tarfile</th> + <td colspan="2"> + <a href="$conf.archive_root_url/$src.loc/$src.debtar_name"> + $src.debtar_name + </a> + </td> + </tr> + <tr> + <th>Size</th><td colspan="2">$src.debtar_size</td> + </tr> + <tr> + <th>MD5sum</th><td colspan="2">$src.debtar_md5sum</td> + </tr> + </table> + </div> <!-- debdiff --> +#end if + #if $src.diffgz_name <div class="debdiff"> <a name="debian-patches"></a> @@ -63,8 +86,8 @@ debian specific patch information for $src.name / $src.version </tr> #end if </table> - #end if </div> <!-- debdiff --> + #end if #if $src.diffgz_name and $diffhandler.nondebiandir.lines <div class="nondebdiff"> @@ -94,7 +117,7 @@ debian specific patch information for $src.name / $src.version </div> <!-- nondebdiff --> #end if -#if $src.diffgz_name +#if $src.diffgz_name or $src.debtar_name #set $series = $diffhandler.series #if $series <div class="debseries"> |