summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgbp/scripts/import_srpm.py7
m---------tests/component/rpm/data0
-rw-r--r--tests/component/rpm/test_import_srpm.py15
3 files changed, 19 insertions, 3 deletions
diff --git a/gbp/scripts/import_srpm.py b/gbp/scripts/import_srpm.py
index ee96c004..bf9a61a0 100755
--- a/gbp/scripts/import_srpm.py
+++ b/gbp/scripts/import_srpm.py
@@ -267,13 +267,18 @@ def main(argv):
prefix='pkgextract_')
gbp.log.info("Extracting src rpm to '%s'" % dirs['pkgextract'])
src.unpack(dirs['pkgextract'])
+ preferred_spec = src.name + '.spec'
srpm = dirs['pkgextract']
+ elif os.path.isdir(srpm):
+ preferred_spec = os.path.basename(srpm.rstrip('/')) + '.spec'
+ else:
+ preferred_spec = None
# Find and parse spec file
if os.path.isdir(srpm):
gbp.log.debug("Trying to import an unpacked srpm from '%s'" % srpm)
dirs['src'] = os.path.abspath(srpm)
- spec = parse_spec(guess_spec(srpm, True))
+ spec = parse_spec(guess_spec(srpm, True, preferred_spec))
else:
gbp.log.debug("Trying to import an srpm from '%s' with spec "\
"file '%s'" % (os.path.dirname(srpm), srpm))
diff --git a/tests/component/rpm/data b/tests/component/rpm/data
-Subproject 4aa7e2901ab84bd91c1d2289dd4138c531c1937
+Subproject a82b547dd777f1ca843232ce9e61ded942d0329
diff --git a/tests/component/rpm/test_import_srpm.py b/tests/component/rpm/test_import_srpm.py
index b17f8d23..5430c3cb 100644
--- a/tests/component/rpm/test_import_srpm.py
+++ b/tests/component/rpm/test_import_srpm.py
@@ -51,6 +51,17 @@ class TestImportPacked(ComponentTestBase):
# of imported patches
assert len(repo.get_commits()) == 4
+ def test_basic_import2(self):
+ """Import package with multiple spec files and full url patch"""
+ srpm = os.path.join(DATA_DIR, 'gbp-test2-2.0-0.src.rpm')
+ assert import_srpm(['arg0', srpm]) == 0
+ # Check repository state
+ repo = GitRepository('gbp-test2')
+ self._check_repo_state(repo, 'master', ['master', 'upstream'])
+ # Four commits: upstream, packaging files, one patch and the removal
+ # of imported patches
+ assert len(repo.get_commits()) == 4
+
def test_basic_import_orphan(self):
"""
Test importing of non-native src.rpm to separate packaging and
@@ -208,9 +219,9 @@ class TestImportUnPacked(ComponentTestBase):
def test_missing_files(self):
"""Test importing of directory with missing packaging files"""
-
+ specfile = 'gbp-test2-2.0-0-unpack/gbp-test2.spec'
os.unlink('gbp-test2-2.0-0-unpack/my.patch')
- assert import_srpm(['arg0', 'gbp-test2-2.0-0-unpack']) == 1
+ assert import_srpm(['arg0', specfile]) == 1
self._check_log(-1, "gbp:error: File 'my.patch' listed in spec "
"not found")