X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fdbconn.py;h=6cddd35ff0f188b8cc02fdc81c18ec10a0df11b8;hb=c5e62511336d16a4b1648b9b84b6b6d80e560c21;hp=8da26063607d7d501b224162fb1630118b48a5ff;hpb=78a9ce0b01a9d64e297bba87ad98219ce429b3b7;p=dak.git diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 8da26063..6cddd35f 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -39,6 +39,7 @@ import re import psycopg2 import traceback import commands +import signal try: # python >= 2.6 @@ -487,6 +488,11 @@ __all__.append('BinContents') ################################################################################ +def subprocess_setup(): + # Python installs a SIGPIPE handler by default. This is usually not what + # non-Python subprocesses expect. + signal.signal(signal.SIGPIPE, signal.SIG_DFL) + class DBBinary(ORMObject): def __init__(self, package = None, source = None, version = None, \ maintainer = None, architecture = None, poolfile = None, \ @@ -525,7 +531,8 @@ class DBBinary(ORMObject): package does not contain any regular file. ''' fullpath = self.poolfile.fullpath - dpkg = Popen(['dpkg-deb', '--fsys-tarfile', fullpath], stdout = PIPE) + dpkg = Popen(['dpkg-deb', '--fsys-tarfile', fullpath], stdout = PIPE, + preexec_fn = subprocess_setup) tar = TarFile.open(fileobj = dpkg.stdout, mode = 'r|') for member in tar.getmembers(): if not member.isdir(): @@ -1352,6 +1359,17 @@ __all__.append('get_dscfiles') ################################################################################ +class ExternalOverride(ORMObject): + def __init__(self, *args, **kwargs): + pass + + def __repr__(self): + return '' % (self.package, self.key, self.value) + +__all__.append('ExternalOverride') + +################################################################################ + class PoolFile(ORMObject): def __init__(self, filename = None, location = None, filesize = -1, \ md5sum = None): @@ -2590,7 +2608,11 @@ def add_dsc_to_db(u, filename, session=None): source.source = u.pkg.dsc["source"] source.version = u.pkg.dsc["version"] # NB: not files[file]["version"], that has no epoch source.maintainer_id = get_or_set_maintainer(u.pkg.dsc["maintainer"], session).maintainer_id - source.changedby_id = get_or_set_maintainer(u.pkg.changes["changed-by"], session).maintainer_id + # If Changed-By isn't available, fall back to maintainer + if u.pkg.changes.has_key("changed-by"): + source.changedby_id = get_or_set_maintainer(u.pkg.changes["changed-by"], session).maintainer_id + else: + source.changedby_id = get_or_set_maintainer(u.pkg.dsc["maintainer"], session).maintainer_id source.fingerprint_id = get_or_set_fingerprint(u.pkg.changes["fingerprint"], session).fingerprint_id source.install_date = datetime.now().date() @@ -2663,6 +2685,8 @@ def add_dsc_to_db(u, filename, session=None): session.add(df) # Add the src_uploaders to the DB + session.flush() + session.refresh(source) source.uploaders = [source.maintainer] if u.pkg.dsc.has_key("uploaders"): for up in u.pkg.dsc["uploaders"].replace(">, ", ">\t").split("\t"): @@ -2861,6 +2885,12 @@ class Suite(ORMObject): return session.query(DBSource).filter_by(source = source). \ with_parent(self) + def get_overridesuite(self): + if self.overridesuite is None: + return self + else: + return object_session(self).query(Suite).filter_by(suite_name=self.overridesuite).one() + __all__.append('Suite') @session_wrapper @@ -3136,7 +3166,9 @@ __all__.append('VersionCheck') def get_version_checks(suite_name, check = None, session = None): suite = get_suite(suite_name, session) if not suite: - return None + # Make sure that what we return is iterable so that list comprehensions + # involving this don't cause a traceback + return [] q = session.query(VersionCheck).filter_by(suite=suite) if check: q = q.filter_by(check=check) @@ -3184,6 +3216,7 @@ class DBConn(object): 'changes_pending_source_files', 'changes_pool_files', 'dsc_files', + 'external_overrides', 'extra_src_references', 'files', 'fingerprint', @@ -3318,6 +3351,13 @@ class DBConn(object): poolfile_id = self.tbl_dsc_files.c.file, poolfile = relation(PoolFile))) + mapper(ExternalOverride, self.tbl_external_overrides, + properties = dict( + suite_id = self.tbl_external_overrides.c.suite, + suite = relation(Suite), + component_id = self.tbl_external_overrides.c.component, + component = relation(Component))) + mapper(PoolFile, self.tbl_files, properties = dict(file_id = self.tbl_files.c.id, filesize = self.tbl_files.c.size,