import-orig: Handle tarball signature when using pristine-tar
authorGuido Günther <agx@sigxcpu.org>
Sat, 26 Oct 2019 11:26:53 +0000 (13:26 +0200)
committerGuido Günther <agx@sigxcpu.org>
Sun, 27 Oct 2019 10:35:45 +0000 (11:35 +0100)
gbp/config.py
gbp/deb/git.py
gbp/scripts/import_orig.py

index cef355a8fc24e89c4c547dfb36600cfe295f6078..495ec630ac6ed914b5ecfe23a13736d7fbc3fa9b 100644 (file)
@@ -181,6 +181,7 @@ class GbpOptionParser(OptionParser):
                 'submodules': 'False',
                 'symlink-orig': 'True',
                 'tarball-dir': '',
+                'upstream-signatures': 'auto',
                 'template-dir': '',
                 'time-machine': 1,
                 'track': 'True',
@@ -327,6 +328,8 @@ class GbpOptionParser(OptionParser):
             "default is '%(postimport)s'",
         'hooks':
             "Enable running all hooks, default is %(hooks)s",
+        'upstream-signatures':
+            "Whether to import/export upstream tarball signatures",
         'time-machine':
             "don't try to apply patch queue to head commit only. "
             "Try at most TIME_MACHINE commits back, "
index 5f9003c4379569cc879f44998cb85745a59ef15f..3584f6ff914634052fdc6cd8b0b7f9d5320cf5ec 100644 (file)
@@ -302,8 +302,8 @@ class DebianGitRepository(PkgGitRepository):
                                              "pristine tar commit from" % (source.component,
                                                                            upstream_tree))
                 gbp.log.debug("Creating pristine tar commit '%s' from '%s'" % (source.path, subtree))
-                self.pristine_tar.commit(source.path, subtree, quiet=True)
-            self.pristine_tar.commit(sources[0].path, main_tree, quiet=True)
+                self.pristine_tar.commit(source.path, subtree, signaturefile=source.signaturefile, quiet=True)
+            self.pristine_tar.commit(sources[0].path, main_tree, signaturefile=sources[0].signaturefile, quiet=True)
         except CommandExecFailed as e:
             raise GitRepositoryError(str(e))
 
index 0aa4ec79fa38a95c472693a12e258d71e5a2aa07..2ebd279eec77027689c322cb1f26b87d1d7335db 100644 (file)
@@ -25,8 +25,7 @@ import time
 import gbp.command_wrappers as gbpc
 from gbp.deb import (DebianPkgPolicy, parse_changelog_repo)
 from gbp.deb.format import DebianSourceFormat
-from gbp.deb.upstreamsource import (DebianUpstreamSource,
-                                    DebianAdditionalTarball)
+from gbp.deb.upstreamsource import DebianUpstreamSource
 from gbp.deb.uscan import (Uscan, UscanError)
 from gbp.deb.changelog import ChangeLog, NoChangeLogError
 from gbp.deb.git import GitRepositoryError
@@ -371,6 +370,9 @@ def build_parser(name):
                                                 dest="symlink_orig")
     import_group.add_config_file_option("component", action="append", metavar='COMPONENT',
                                         dest="components")
+    import_group.add_config_file_option(option_name="upstream-signatures",
+                                        dest="upstream_signatures",
+                                        type='tristate')
     cmd_group.add_config_file_option(option_name="postimport", dest="postimport")
     cmd_group.add_config_file_option(option_name="postunpack", dest="postunpack")
 
@@ -497,6 +499,10 @@ def main(argv):
             if options.pristine_tar:
                 if pristine_orig:
                     repo.rrr_branch('pristine-tar')
+                    for source in sources:
+                        # Enforce signature file exists with --upstream-signatures=on
+                        if options.upstream_signatures.is_on() and not source.signaturefile:
+                            raise GbpError("%s does not have a signature file" % source.path)
                     # For all practical purposes we're interested in pristine_orig's path
                     if pristine_orig != sources[0].path:
                         sources[0]._path = pristine_orig