From: Ansgar Burchardt Date: Thu, 13 Aug 2015 09:43:55 +0000 (+0200) Subject: Add install_source_to_archive method X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=e409fd8d87c4961c0259baad901f498f719fe1a2;p=dak.git Add install_source_to_archive method This method install the source into an archive without adding it to any suite. It is intended to be used to import extra source packages (i.e. those referenced only by Built-Using). --- diff --git a/daklib/archive.py b/daklib/archive.py index 0891922d..99167af5 100644 --- a/daklib/archive.py +++ b/daklib/archive.py @@ -263,35 +263,8 @@ class ArchiveTransaction(object): db_binary.extra_sources.append(bu_source) - def install_source(self, directory, source, suite, component, changed_by, allow_tainted=False, fingerprint=None): - """Install a source package - - @type directory: str - @param directory: directory the source package is located in - - @type source: L{daklib.upload.Source} - @param source: source package to install - - @type suite: L{daklib.dbconn.Suite} - @param suite: target suite - - @type component: L{daklib.dbconn.Component} - @param component: target component - - @type changed_by: L{daklib.dbconn.Maintainer} - @param changed_by: person who prepared this version of the package - - @type allow_tainted: bool - @param allow_tainted: allow to copy additional files from tainted archives - - @type fingerprint: L{daklib.dbconn.Fingerprint} - @param fingerprint: optional fingerprint - - @rtype: L{daklib.dbconn.DBSource} - @return: database object for the new source - """ + def install_source_to_archive(self, directory, source, archive, component, changed_by, allow_tainted=False, fingerprint=None): session = self.session - archive = suite.archive control = source.dsc maintainer = get_or_set_maintainer(control['Maintainer'], session) source_name = control['Source'] @@ -343,11 +316,6 @@ class ArchiveTransaction(object): session.add(db_dsc_file) session.flush() - if suite in db_source.suites: - return db_source - - db_source.suites.append(suite) - if not created: for f in db_source.srcfiles: self._copy_file(f.poolfile, archive, component, allow_tainted=allow_tainted) @@ -384,6 +352,42 @@ class ArchiveTransaction(object): return db_source + def install_source(self, directory, source, suite, component, changed_by, allow_tainted=False, fingerprint=None): + """Install a source package + + @type directory: str + @param directory: directory the source package is located in + + @type source: L{daklib.upload.Source} + @param source: source package to install + + @type suite: L{daklib.dbconn.Suite} + @param suite: target suite + + @type component: L{daklib.dbconn.Component} + @param component: target component + + @type changed_by: L{daklib.dbconn.Maintainer} + @param changed_by: person who prepared this version of the package + + @type allow_tainted: bool + @param allow_tainted: allow to copy additional files from tainted archives + + @type fingerprint: L{daklib.dbconn.Fingerprint} + @param fingerprint: optional fingerprint + + @rtype: L{daklib.dbconn.DBSource} + @return: database object for the new source + """ + db_source = self.install_source_to_archive(directory, source, suite.archive, component, changed_by, allow_tainted, fingerprint) + + if suite in db_source.suites: + return db_source + db_source.suites.append(suite) + self.session.flush() + + return db_source + def _copy_file(self, db_file, archive, component, allow_tainted=False): """Copy a file to the given archive and component