import-srpm: skip pristine-tar for non-tar sources archives
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 26 Feb 2013 10:01:32 +0000 (12:01 +0200)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 7 Jan 2014 14:21:30 +0000 (16:21 +0200)
Don't even try to import non-tar archives to pristine-tar because that
fails. Instead, print a warning and continue without using pristine-tar.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gbp/scripts/import_srpm.py
tests/component/rpm/test_import_srpm.py

index b7a428fd123b27a7fe220fffbfda60360d766fd1..63ea7f7514b2e25e5b19c8a87223165f8d193b95 100755 (executable)
@@ -40,6 +40,7 @@ from gbp.errors import GbpError
 import gbp.log
 from gbp.scripts.pq_rpm import safe_patches, rm_patch_files, get_packager
 from gbp.scripts.common.pq import apply_and_commit_patch
+from gbp.pkg import parse_archive_filename
 
 no_packaging_branch_msg = """
 Repository does not have branch '%s' for packaging/distribution sources. If there is none see
@@ -405,9 +406,14 @@ def main(argv):
 
                 if not options.native:
                     if options.pristine_tar:
-                        repo.pristine_tar.commit(orig_tarball,
-                                                'refs/heads/%s' %
-                                                 options.upstream_branch)
+                        archive_fmt = parse_archive_filename(orig_tarball)[1]
+                        if archive_fmt == 'tar':
+                            repo.pristine_tar.commit(orig_tarball,
+                                                    'refs/heads/%s' %
+                                                     options.upstream_branch)
+                        else:
+                            gbp.log.warn('Ignoring pristine-tar, %s archives '
+                                         'not supported' % archive_fmt)
         else:
             gbp.log.info("No orig source archive imported")
 
index fe9062dc04d757bcdca3f441e3fe61a63306e1fa..c9a1a429fd2875f7351f3624fb54db9de839ebe3 100644 (file)
@@ -316,6 +316,16 @@ class TestPristineTar(ComponentTestBase):
         # of imported patches
         assert len(repo.get_commits()) == 4
 
+    def test_unsupported_archive(self):
+        """Test importing of src.rpm with a zip source archive"""
+        srpm = os.path.join(DATA_DIR, 'gbp-test-native-1.0-1.src.rpm')
+        assert import_srpm(['arg0', '--pristine-tar', srpm]) == 0
+        # Check repository state
+        repo = GitRepository('gbp-test-native')
+        self._check_repo_state(repo, 'master', ['master', 'upstream'])
+        # Check that a warning is printed
+        self._check_log(-1, "gbp:warning: Ignoring pristine-tar")
+
 
 class TestBareRepo(ComponentTestBase):
     """Test importing to a bare repository"""