X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fdbconn.py;h=24f8fb17d9620f99570db40e203ac21381ec142c;hb=4db9c79b71600a48f5323bd75a0ef4f894f02559;hp=d430124ae13c7f3c4480f285f8291798558ee828;hpb=15193f20eeebbd19c75f0d124f1a7b2a582a179b;p=dak.git diff --git a/daklib/dbconn.py b/daklib/dbconn.py index d430124a..24f8fb17 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -34,6 +34,7 @@ ################################################################################ import os +from os.path import normpath import re import psycopg2 import traceback @@ -49,6 +50,8 @@ except: from datetime import datetime, timedelta from errno import ENOENT from tempfile import mkstemp, mkdtemp +from subprocess import Popen, PIPE +from tarfile import TarFile from inspect import getargspec @@ -502,6 +505,26 @@ class DBBinary(ORMObject): def get_component_name(self): return self.poolfile.location.component.component_name + def scan_contents(self): + ''' + Yields the contents of the package. Only regular files are yielded and + the path names are normalized after converting them from either utf-8 or + iso8859-1 encoding. + ''' + fullpath = self.poolfile.fullpath + debdata = Popen(['dpkg-deb', '--fsys-tarfile', fullpath], + stdout = PIPE).stdout + tar = TarFile.open(fileobj = debdata, mode = 'r|') + for member in tar.getmembers(): + if member.isfile(): + try: + name = member.name.decode('utf-8') + except UnicodeDecodeError: + name = member.name.decode('iso8859-1') + yield normpath(name) + tar.close() + debdata.close() + __all__.append('DBBinary') @session_wrapper @@ -1814,12 +1837,22 @@ __all__.append('get_new_comments') ################################################################################ -class Override(object): - def __init__(self, *args, **kwargs): - pass +class Override(ORMObject): + def __init__(self, package = None, suite = None, component = None, overridetype = None, \ + section = None, priority = None): + self.package = package + self.suite = suite + self.component = component + self.overridetype = overridetype + self.section = section + self.priority = priority - def __repr__(self): - return '' % (self.package, self.suite_id) + def properties(self): + return ['package', 'suite', 'component', 'overridetype', 'section', \ + 'priority'] + + def not_null_constraints(self): + return ['package', 'suite', 'component', 'overridetype', 'section'] __all__.append('Override') @@ -2291,9 +2324,9 @@ def source_exists(source, source_version, suites = ["any"], session=None): maps = [ (x[1], x[2]) for x in maps if x[0] == "map" or x[0] == "silent-map" ] s = [suite] - for x in maps: - if x[1] in s and x[0] not in s: - s.append(x[0]) + for (from_, to) in maps: + if from_ in s and to not in s: + s.append(to) q = q.filter(DBSource.suites.any(Suite.suite_name.in_(s))) @@ -2923,6 +2956,7 @@ class DBConn(object): 'changes_pending_source_files', 'changes_pool_files', 'deb_contents', + # TODO: the maintainer column in table override should be removed. 'override', 'suite_architectures', 'suite_src_formats',