diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2013-01-09 14:06:39 +0200 |
---|---|---|
committer | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2013-04-03 10:11:41 +0300 |
commit | 07335a8fea9dfb1c9e3772a9eed66ac2ac950d6c (patch) | |
tree | e0042d87dc07cfbe56685c016ffc65c7e0b420fc | |
parent | e73485bcff692fa0f157a8e131b5a949a6d533db (diff) | |
download | git-buildpackage-07335a8fea9dfb1c9e3772a9eed66ac2ac950d6c.tar.gz git-buildpackage-07335a8fea9dfb1c9e3772a9eed66ac2ac950d6c.tar.bz2 git-buildpackage-07335a8fea9dfb1c9e3772a9eed66ac2ac950d6c.zip |
import-srpm: enhance spec guessing
Use package name (in case of src.rpm) or directory name (in case of dir)
as the preferred name of the spec file.
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rwxr-xr-x | gbp/scripts/import_srpm.py | 7 | ||||
m--------- | tests/component/rpm/data | 0 | ||||
-rw-r--r-- | tests/component/rpm/test_import_srpm.py | 15 |
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") |