1. Reset to 0.27 debian/0.7.4
authorJun Wang <junbill.wang@samsung.com>
Tue, 10 May 2016 07:03:01 +0000 (15:03 +0800)
committerJun Wang <junbill.wang@samsung.com>
Tue, 10 May 2016 07:04:42 +0000 (15:04 +0800)
2. Keep same code with latest release

Change-Id: I30588773b0a039c9f5002bf65b5c768a16fb7935

68 files changed:
.gitmodules
README
TODO
debian/changelog
debian/source/options
gbp/scripts/common/import_orig.py
packaging/git-buildpackage.changes
packaging/git-buildpackage.spec
tests/20_test_rpm.py [deleted file]
tests/component/rpm/test_import_srpm.py
tests/data/rpm/rpmbuild/SOURCES/bar.tar.gz [deleted file]
tests/data/rpm/rpmbuild/SOURCES/foo.txt [deleted file]
tests/data/rpm/rpmbuild/SOURCES/gbp-test-1.0.tar.bz2 [deleted file]
tests/data/rpm/rpmbuild/SOURCES/gbp-test-native-1.0.zip [deleted file]
tests/data/rpm/rpmbuild/SOURCES/gbp-test2-3.0.tar.gz [deleted file]
tests/data/rpm/rpmbuild/SOURCES/my.patch [deleted file]
tests/data/rpm/rpmbuild/SOURCES/my2.patch [deleted file]
tests/data/rpm/rpmbuild/SOURCES/my3.patch [deleted file]
tests/data/rpm/rpmbuild/SPECS/gbp-test-native.spec [deleted file]
tests/data/rpm/rpmbuild/SPECS/gbp-test-native2.spec [deleted file]
tests/data/rpm/rpmbuild/SPECS/gbp-test.spec [deleted file]
tests/data/rpm/rpmbuild/SPECS/gbp-test2.spec [deleted file]
tests/data/rpm/specs/gbp-test-native.spec [deleted symlink]
tests/data/rpm/specs/gbp-test-native2.spec [deleted symlink]
tests/data/rpm/specs/gbp-test-quirks.spec [deleted file]
tests/data/rpm/specs/gbp-test-reference.spec [deleted file]
tests/data/rpm/specs/gbp-test-reference2.spec [deleted file]
tests/data/rpm/specs/gbp-test-tags.spec [deleted file]
tests/data/rpm/specs/gbp-test-updates-reference.spec [deleted file]
tests/data/rpm/specs/gbp-test-updates.spec [deleted file]
tests/data/rpm/specs/gbp-test.spec [deleted symlink]
tests/data/rpm/specs/gbp-test2-reference.spec [deleted file]
tests/data/rpm/specs/gbp-test2-reference2.spec [deleted file]
tests/data/rpm/specs/gbp-test2.spec [deleted symlink]
tests/data/rpm/srpms/gbp-test-1.0-1.src.rpm [deleted file]
tests/data/rpm/srpms/gbp-test-native-1.0-1.src.rpm [deleted file]
tests/data/rpm/srpms/gbp-test-native2-2.0-0.src.rpm [deleted file]
tests/data/rpm/srpms/gbp-test2-3.0-0.src.rpm [deleted file]
tests/test_rpm.py [new file with mode: 0644]
tests/test_rpm_data/rpmbuild/SOURCES/bar.tar.gz [new file with mode: 0644]
tests/test_rpm_data/rpmbuild/SOURCES/foo.txt [new file with mode: 0644]
tests/test_rpm_data/rpmbuild/SOURCES/gbp-test-1.0.tar.bz2 [new file with mode: 0644]
tests/test_rpm_data/rpmbuild/SOURCES/gbp-test-native-1.0.zip [new file with mode: 0644]
tests/test_rpm_data/rpmbuild/SOURCES/gbp-test2-3.0.tar.gz [new file with mode: 0644]
tests/test_rpm_data/rpmbuild/SOURCES/my.patch [new file with mode: 0644]
tests/test_rpm_data/rpmbuild/SOURCES/my2.patch [new file with mode: 0644]
tests/test_rpm_data/rpmbuild/SOURCES/my3.patch [new file with mode: 0644]
tests/test_rpm_data/rpmbuild/SPECS/gbp-test-native.spec [new file with mode: 0644]
tests/test_rpm_data/rpmbuild/SPECS/gbp-test-native2.spec [new file with mode: 0644]
tests/test_rpm_data/rpmbuild/SPECS/gbp-test.spec [new file with mode: 0644]
tests/test_rpm_data/rpmbuild/SPECS/gbp-test2.spec [new file with mode: 0644]
tests/test_rpm_data/rpmbuild/SPECS/gbp-test2.spec.orig [new file with mode: 0644]
tests/test_rpm_data/specs/gbp-test-native.spec [new symlink]
tests/test_rpm_data/specs/gbp-test-native2.spec [new symlink]
tests/test_rpm_data/specs/gbp-test-quirks.spec [new file with mode: 0644]
tests/test_rpm_data/specs/gbp-test-reference.spec [new file with mode: 0644]
tests/test_rpm_data/specs/gbp-test-reference2.spec [new file with mode: 0644]
tests/test_rpm_data/specs/gbp-test-tags.spec [new file with mode: 0644]
tests/test_rpm_data/specs/gbp-test-updates-reference.spec [new file with mode: 0644]
tests/test_rpm_data/specs/gbp-test-updates.spec [new file with mode: 0644]
tests/test_rpm_data/specs/gbp-test.spec [new symlink]
tests/test_rpm_data/specs/gbp-test2-reference.spec [new file with mode: 0644]
tests/test_rpm_data/specs/gbp-test2-reference2.spec [new file with mode: 0644]
tests/test_rpm_data/specs/gbp-test2.spec [new symlink]
tests/test_rpm_data/srpms/gbp-test-1.0-1.src.rpm [new file with mode: 0644]
tests/test_rpm_data/srpms/gbp-test-native-1.0-1.src.rpm [new file with mode: 0644]
tests/test_rpm_data/srpms/gbp-test-native2-2.0-0.src.rpm [new file with mode: 0644]
tests/test_rpm_data/srpms/gbp-test2-3.0-0.src.rpm [new file with mode: 0644]

index 7f8a520a6ab27e810617c5c235a8d2ad157cf82e..02d21b87c20f425b40c172261cb8a588cd6c8c27 100644 (file)
@@ -1,6 +1,6 @@
-[submodule "tests/component/rpm/data"]
-       path = tests/component/rpm/data
-       url = ssh://jenkins@109.123.100.123:29418/tizen.org-tools/git-buildpackage-rpm-testdata
 [submodule "tests/component/deb/data"]
        path = tests/component/deb/data
        url = ssh://jenkins@109.123.100.123:29418/tizen.org-tools/git-buildpackage-deb-testdata
+[submodule "tests/component/rpm/data"]
+       path = tests/component/rpm/data
+       url = ssh://jenkins@109.123.100.123:29418/tizen.org-tools/git-buildpackage-rpm-testdata
diff --git a/README b/README
index 4acc68bc65959aa833a2ad61bd7ce8575be5de79..26a155aa6eb61b29b78bd8f91dee45bc3befea62 100644 (file)
--- a/README
+++ b/README
@@ -14,6 +14,10 @@ The API documentation of the gbp module can be found at:
     http://honk.sigxcpu.org/projects/git-buildpackage/apidocs/
 
 
-The documentation available for the RPM support can be found at
+The limited documentation available for the RPM support can be found at
 
     http://marquiz.github.com/git-buildpackage-rpm/
+
+Unfortunately, the manpages for RPM tools are still missing. Refer to
+--help option of the commands, for the most detailed description of different
+options.
diff --git a/TODO b/TODO
index cf9c6809caa7708b236f06dba25a60ce03edec1d..295398a5c5ac30f12b8ae6786277486fea2c5b7e 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,8 +1,5 @@
 See https://honk.sigxcpu.org/piki/projects/git-buildpackage/
 
-
-
-
 RPM-related things:
 - unit tests:
   - add unit tests for the rpm command line tools
index a6adc71f1ea3372ce45024da3e104c4806796d26..ee6ad668951edc578f2bf6d870261ed4c6d3922b 100644 (file)
@@ -1,11 +1,3 @@
-git-buildpackage (0.6.28-tizen20160308) unstable; urgency=medium
-
-  * Check codes in devel branch
-
- -- Jun Wang  <junbill.wangx@samsung.com>  TUE, 08 Mar 2016 10:20:21 +0800
-
-
-
 git-buildpackage (0.6.27-tizen20160302) unstable; urgency=medium
 
   * Fix error logs when __import__ faild,like "No handlers could be found fo logger"
index 6862544b6e34ae894312584b7bdd1e596d9f988d..f259290351dfd47747f2df4295de52d2e730ab90 100644 (file)
@@ -1,2 +1,2 @@
-extend-diff-ignore = "^(tests/data/rpm/.*|tests/component/rpm/data/.*|tests/component/deb/data/.*)"
+extend-diff-ignore = "^(tests/test_rpm_data/.*|tests/component/rpm/data/.*|tests/component/deb/data/.*)"
 diff-ignore
index 45e71c577093666754a076f231d97b09f47ee539..162444232db3197b2e9b1eedf5081460c7e10899 100644 (file)
@@ -148,16 +148,6 @@ def prepare_sources(source, pkg_name, pkg_version, pristine_commit_name,
     pristine_path = pristine.path if pristine else ''
     return (filtered.unpacked, pristine_path)
 
-def repack_source(source, new_name, unpack_dir, filters, new_prefix=None):
-    """Repack the source tree"""
-    repacked = source.pack(new_name, filters, new_prefix)
-    if source.is_tarball(): # the tarball was filtered on unpack
-        repacked.unpacked = source.unpacked
-    else: # otherwise unpack the generated tarball get a filtered tree
-        repacked.unpack(unpack_dir)
-    return repacked
-
-
 def prepare_pristine_tar(source, pkg_name, pkg_version, pristine_commit_name,
                          filters=None, prefix=None, tmpdir=None):
     """
index ef2c9eba340da99e90bb94b065fdc56ac62deaaf..5f8ecf5526aedba13213a7efe45e93bf5459d5e3 100644 (file)
@@ -1,7 +1,3 @@
-* Wed Mar 08 2016 Jun Wang <junbill.wang@samsung.com> tizen/0.6.28-20160308
-- Make new tag in devel
-- Upgrade version to 0.6.28
-
 * Wed Mar 02 2016 Jun Wang <junbill.wang@samsung.com> tizen/0.6.27-20160302
 - Upgrade version to 0.6.27
 
index 5532b3b3b439b3925db461363ebec31005d43a08..d71f172de01f91839caf30f55958e6dd2dd9525e 100644 (file)
@@ -3,7 +3,7 @@
 
 Name:       git-buildpackage
 Summary:    Build packages from git
-Version:    0.6.28
+Version:    0.6.27
 Release:    0
 Group:      Development/Tools/Building
 License:    GPLv2
diff --git a/tests/20_test_rpm.py b/tests/20_test_rpm.py
deleted file mode 100644 (file)
index 52a14ff..0000000
+++ /dev/null
@@ -1,479 +0,0 @@
-# vim: set fileencoding=utf-8 :
-#
-# (C) 2012 Intel Corporation <markus.lehtonen@linux.intel.com>
-#    This program is free software; you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation; either version 2 of the License, or
-#    (at your option) any later version.
-#
-#    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
-#
-#    You should have received a copy of the GNU General Public License
-#    along with this program; if not, write to the Free Software
-#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-"""Test the classes under L{gbp.rpm}"""
-
-import filecmp
-import os
-import shutil
-import tempfile
-from nose.tools import assert_raises, eq_
-
-from gbp.errors import GbpError
-from gbp.rpm import (SrcRpmFile, SpecFile, parse_srpm, NoSpecError, guess_spec,
-                     guess_spec_repo, spec_from_repo)
-from gbp.git.repository import GitRepository
-
-DATA_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data','rpm')
-SRPM_DIR = os.path.join(DATA_DIR, 'srpms')
-SPEC_DIR = os.path.join(DATA_DIR, 'specs')
-
-class SpecFileTester(SpecFile):
-    """Helper class for testing"""
-
-    def protected(self, name):
-        """Get a protected member"""
-        return super(SpecFileTester, self).__getattribute__(name)
-
-
-class TestSrcRpmFile(object):
-    """Test L{gbp.rpm.SrcRpmFile}"""
-
-    def setup(self):
-        self.tmpdir = tempfile.mkdtemp(prefix='gbp_%s_' % __name__, dir='.')
-
-    def teardown(self):
-        shutil.rmtree(self.tmpdir)
-
-    def test_srpm(self):
-        """Test parsing of a source rpm"""
-        srpm = SrcRpmFile(os.path.join(SRPM_DIR, 'gbp-test-1.0-1.src.rpm'))
-        assert srpm.version ==  {'release': '1', 'upstreamversion': '1.0'}
-        assert srpm.name == 'gbp-test'
-        assert srpm.upstreamversion == '1.0'
-        assert srpm.packager is None
-
-    def test_srpm_2(self):
-        """Test parsing of another source rpm"""
-        srpm = SrcRpmFile(os.path.join(SRPM_DIR, 'gbp-test2-3.0-0.src.rpm'))
-        assert srpm.version == {'release': '0', 'upstreamversion': '3.0',
-                                'epoch': '2'}
-        assert srpm.packager == 'Markus Lehtonen '\
-                                '<markus.lehtonen@linux.intel.com>'
-
-    def test_unpack_srpm(self):
-        """Test unpacking of a source rpm"""
-        srpm = SrcRpmFile(os.path.join(SRPM_DIR, 'gbp-test-1.0-1.src.rpm'))
-        srpm.unpack(self.tmpdir)
-        for fn in ['gbp-test-1.0.tar.bz2', 'foo.txt', 'bar.tar.gz', 'my.patch',
-                   'my2.patch', 'my3.patch']:
-            assert os.path.exists(os.path.join(self.tmpdir, fn)), \
-                    "%s not found" % fn
-
-
-class TestSpecFile(object):
-    """Test L{gbp.rpm.SpecFile}"""
-
-    def setup(self):
-        self.tmpdir = tempfile.mkdtemp(prefix='gbp_%s_' % __name__, dir='.')
-
-    def teardown(self):
-        shutil.rmtree(self.tmpdir)
-
-    def test_spec(self):
-        """Test parsing of a valid spec file"""
-        spec_filepath = os.path.join(SPEC_DIR, 'gbp-test.spec')
-        spec = SpecFileTester(spec_filepath)
-
-        # Test basic properties
-        assert spec.specfile == os.path.basename(spec_filepath)
-        assert spec.specdir == os.path.dirname(spec_filepath)
-        assert spec.specpath == spec_filepath
-
-        assert spec.name == 'gbp-test'
-        assert spec.packager is None
-
-        assert spec.upstreamversion == '1.0'
-        assert spec.release == '1'
-        assert spec.epoch is None
-        assert spec.version == {'release': '1', 'upstreamversion': '1.0'}
-
-        orig = spec.orig_src
-        assert orig['filename'] == 'gbp-test-1.0.tar.bz2'
-        assert orig['uri'] == 'gbp-test-1.0.tar.bz2'
-        assert orig['filename_base'] == 'gbp-test-1.0'
-        assert orig['archive_fmt'] == 'tar'
-        assert orig['compression'] == 'bzip2'
-        assert orig['prefix'] == 'gbp-test/'
-
-    def test_spec_2(self):
-        """Test parsing of another valid spec file"""
-        spec_filepath = os.path.join(SPEC_DIR, 'gbp-test2.spec')
-        spec = SpecFile(spec_filepath)
-
-        # Test basic properties
-        assert spec.name == 'gbp-test2'
-        assert spec.packager == 'Markus Lehtonen ' \
-                                '<markus.lehtonen@linux.intel.com>'
-
-        assert spec.epoch == '2'
-        assert spec.version == {'release': '0', 'upstreamversion': '3.0',
-                                'epoch': '2'}
-
-        orig = spec.orig_src
-        assert orig['filename'] == 'gbp-test2-3.0.tar.gz'
-        assert orig['uri'] == 'ftp://ftp.host.com/gbp-test2-3.0.tar.gz'
-        assert orig['archive_fmt'] == 'tar'
-        assert orig['compression'] == 'gzip'
-        assert orig['prefix'] == ''
-
-    def test_spec_3(self):
-        """Test parsing of yet another valid spec file"""
-        spec_filepath = os.path.join(SPEC_DIR, 'gbp-test-native.spec')
-        spec = SpecFile(spec_filepath)
-
-        # Test basic properties
-        assert spec.name == 'gbp-test-native'
-        orig = spec.orig_src
-        assert orig['filename'] == 'gbp-test-native-1.0.zip'
-        assert orig['archive_fmt'] == 'zip'
-        assert orig['compression'] == None
-        assert orig['prefix'] == 'gbp-test-native-1.0/'
-
-    def test_spec_4(self):
-        """Test parsing of spec without orig tarball"""
-        spec_filepath = os.path.join(SPEC_DIR, 'gbp-test-native2.spec')
-        spec = SpecFile(spec_filepath)
-
-        # Test basic properties
-        assert spec.name == 'gbp-test-native2'
-        assert spec.orig_src is None
-
-    def test_parse_raw(self):
-        """Test parsing of a valid spec file"""
-       assert_raises(NoSpecError, SpecFile, None, None)
-       assert_raises(NoSpecError, SpecFile, 'filename', 'filedata')
-
-       """
-        with assert_raises(NoSpecError):
-            SpecFile(None, None)
-        with assert_raises(NoSpecError):
-            SpecFile('filename', 'filedata')
-       """
-
-        spec_filepath = os.path.join(SPEC_DIR, 'gbp-test.spec')
-        with open(spec_filepath, 'r') as spec_fd:
-            spec_data = spec_fd.read()
-        spec = SpecFile(filedata=spec_data)
-
-        # Test basic properties
-        assert spec.specfile == None
-        assert spec.specdir == None
-        assert spec.name == 'gbp-test'
-
-    def test_update_spec(self):
-        """Test spec autoupdate functionality"""
-        # Create temporary spec file
-        tmp_spec = os.path.join(self.tmpdir, 'gbp-test.spec')
-        shutil.copy2(os.path.join(SPEC_DIR, 'gbp-test.spec'), tmp_spec)
-
-        reference_spec = os.path.join(SPEC_DIR, 'gbp-test-reference.spec')
-        spec = SpecFile(tmp_spec)
-        spec.update_patches(['new.patch'], {})
-        spec.write_spec_file()
-        assert filecmp.cmp(tmp_spec, reference_spec) is True
-
-        # Test adding the VCS tag and adding changelog
-        reference_spec = os.path.join(SPEC_DIR, 'gbp-test-reference2.spec')
-        spec.set_tag('VCS', None, 'myvcstag')
-        spec.set_changelog("* Wed Feb 05 2014 Name <email> 1\n- New entry\n")
-        spec.write_spec_file()
-        assert filecmp.cmp(tmp_spec, reference_spec) is True
-
-    def test_update_spec2(self):
-        """Another test for spec autoupdate functionality"""
-        tmp_spec = os.path.join(self.tmpdir, 'gbp-test2.spec')
-        shutil.copy2(os.path.join(SPEC_DIR, 'gbp-test2.spec'), tmp_spec)
-
-        reference_spec = os.path.join(SPEC_DIR, 'gbp-test2-reference2.spec')
-        spec = SpecFile(tmp_spec)
-        spec.update_patches(['1.patch', '2.patch'],
-                            {'1.patch': {'if': 'true'},
-                             '2.patch': {'ifarch': '%ix86'}})
-        spec.set_tag('VCS', None, 'myvcstag')
-        spec.write_spec_file()
-        assert filecmp.cmp(tmp_spec, reference_spec) is True
-
-        # Test updating patches again, removing the VCS tag and re-writing
-        # changelog
-        reference_spec = os.path.join(SPEC_DIR, 'gbp-test2-reference.spec')
-        spec.update_patches(['new.patch'], {'new.patch': {'if': '1'}})
-        spec.set_tag('VCS', None, '')
-        spec.set_changelog("* Wed Feb 05 2014 Name <email> 2\n- New entry\n\n")
-        spec.write_spec_file()
-        assert filecmp.cmp(tmp_spec, reference_spec) is True
-
-    def test_modifying(self):
-        """Test updating/deleting of tags and macros"""
-        tmp_spec = os.path.join(self.tmpdir, 'gbp-test.spec')
-        shutil.copy2(os.path.join(SPEC_DIR, 'gbp-test-updates.spec'), tmp_spec)
-        reference_spec = os.path.join(SPEC_DIR,
-                                      'gbp-test-updates-reference.spec')
-        spec = SpecFileTester(tmp_spec)
-
-        # Mangle tags
-        prev = spec.protected('_delete_tag')('Vendor', None)
-        spec.protected('_set_tag')('License', None, 'new license', prev)
-        spec.protected('_delete_tag')('source', 0)
-        assert spec.sources() == {}
-        spec.protected('_delete_tag')('patch', 0)
-        spec.protected('_delete_tag')('patch', -1)
-        assert spec.protected('_patches')() == {}
-        prev = spec.protected('_delete_tag')('invalidtag', None)
-
-       assert_raises(GbpError, spec.protected('_set_tag'),
-            'Version', None, '', prev)
-       assert_raises(GbpError, spec.set_tag,
-            'invalidtag', None, 'value')
-
-       """
-        with assert_raises(GbpError):
-            # Check that setting empty value fails
-            spec.protected('_set_tag')('Version', None, '', prev)
-        with assert_raises(GbpError):
-            # Check that setting invalid tag with public method fails
-            spec.set_tag('invalidtag', None, 'value')
-       """
-
-        # Mangle macros
-        prev = spec.protected('_delete_special_macro')('patch', -1)
-        spec.protected('_delete_special_macro')('patch', 123)
-        spec.protected('_set_special_macro')('patch', 0, 'my new args', prev)
-       assert_raises(GbpError, spec.protected('_delete_special_macro'),
-            'invalidmacro', 0)
-       assert_raises(GbpError, spec.protected('_set_special_macro'),
-            'invalidmacro', 0, 'args', prev)
-
-       """
-        with assert_raises(GbpError):
-            spec.protected('_delete_special_macro')('invalidmacro', 0)
-        with assert_raises(GbpError):
-            spec.protected('_set_special_macro')('invalidmacro', 0, 'args',
-                           prev)
-       """
-
-        # Check resulting spec file
-        spec.write_spec_file()
-        assert filecmp.cmp(tmp_spec, reference_spec) is True
-
-    def test_modifying_err(self):
-        """Test error conditions of modification methods"""
-        spec_filepath = os.path.join(SPEC_DIR, 'gbp-test2.spec')
-        spec = SpecFileTester(spec_filepath)
-
-        # Unknown/invalid section name
-       assert_raises(GbpError, spec.protected('_set_section'),
-            'patch', 'new content\n')
-       """
-        with assert_raises(GbpError):
-            spec.protected('_set_section')('patch', 'new content\n')
-       """
-
-        # Multiple sections with the same name
-       assert_raises(GbpError, spec.protected('_set_section'),
-            'files', '%{_sysconfdir}/foo\n')
-
-       """
-        with assert_raises(GbpError):
-            spec.protected('_set_section')('files', '%{_sysconfdir}/foo\n')
-       """
-
-    def test_changelog(self):
-        """Test changelog methods"""
-        spec_filepath = os.path.join(SPEC_DIR, 'gbp-test2.spec')
-        spec = SpecFile(spec_filepath)
-
-        # Read changelog
-        eq_(spec.get_changelog(),
-            "* Tue Feb 04 2014 Name <email> 1\n- My change\n\n\n")
-
-        # Set changelog and check again
-        new_text = "* Wed Feb 05 2014 Name <email> 2\n- New entry\n\n\n"
-        spec.set_changelog(new_text)
-        eq_(spec.get_changelog(), new_text)
-
-    def test_quirks(self):
-        """Test spec that is broken/has anomalities"""
-        spec_filepath = os.path.join(SPEC_DIR, 'gbp-test-quirks.spec')
-        spec = SpecFile(spec_filepath)
-
-        # Check that we quess orig source and prefix correctly
-        assert spec.orig_src['prefix'] == 'foobar/'
-
-    def test_tags(self):
-        """Test parsing of all the different tags of spec file"""
-        spec_filepath = os.path.join(SPEC_DIR, 'gbp-test-tags.spec')
-        spec = SpecFileTester(spec_filepath)
-
-        # Check all the tags
-        for name, val in spec.protected('_tags').iteritems():
-            rval = None
-            if name in ('version', 'release', 'epoch'):
-                rval = '0'
-            elif name in ('autoreq', 'autoprov', 'autoreqprov'):
-                rval = 'No'
-            elif name not in spec.protected('_listtags'):
-                rval = 'my_%s' % name
-            if rval:
-                assert val['value'] == rval, ("'%s:' is '%s', expecting '%s'" %
-                                              (name, val['value'], rval))
-            assert spec.ignorepatches == []
-            # Check patch numbers and patch filenames
-            patches = {}
-            for patch in spec.protected('_tags')['patch']['lines']:
-                patches[patch['num']] = patch['linevalue']
-
-            assert patches == {0: 'my_patch0', -1: 'my_patch'}
-
-    def test_patch_series(self):
-        """Test the getting the patches as a patchseries"""
-        spec_filepath = os.path.join(SPEC_DIR, 'gbp-test-native.spec')
-        spec = SpecFileTester(spec_filepath)
-
-        assert len(spec.patchseries()) == 0
-        spec.update_patches(['1.patch', '2.patch', '3.patch'], {})
-        assert len(spec.patchseries()) == 3
-        spec.protected('_gbp_tags')['ignore-patches'].append({'args': "0"})
-        spec.update_patches(['4.patch'], {})
-        assert len(spec.patchseries()) == 1
-        assert len(spec.patchseries(ignored=True)) == 2
-        spec.protected('_delete_special_macro')('patch', 0)
-        assert len(spec.patchseries(ignored=True)) == 1
-        series = spec.patchseries(unapplied=True, ignored=True)
-        assert len(series) == 2
-        assert os.path.basename(series[-1].path) == '1.patch'
-
-    def test_patch_series_quirks(self):
-        """Patches are applied in order different from the patch numbering"""
-        spec_filepath = os.path.join(SPEC_DIR, 'gbp-test-quirks.spec')
-        spec = SpecFileTester(spec_filepath)
-
-        # Check series is returned in the order the patches are applied
-        files = [os.path.basename(patch.path) for patch in spec.patchseries()]
-        assert files == ['05.patch', '01.patch']
-        # Also ignored patches are returned in the correct order
-        files = [os.path.basename(patch.path) for patch in
-                    spec.patchseries(ignored=True)]
-        assert files == ['05.patch', '02.patch', '01.patch']
-        # Unapplied patches are added to the end of the series
-        files = [os.path.basename(patch.path) for patch in
-                    spec.patchseries(unapplied=True)]
-        assert files == ['05.patch', '01.patch', '03.patch']
-        # Return all patches (for which tag is found)
-        files = [os.path.basename(patch.path) for patch in
-                    spec.patchseries(unapplied=True, ignored=True)]
-        assert files == ['05.patch', '02.patch', '01.patch', '03.patch',
-                         '04.patch']
-
-
-class TestUtilityFunctions(object):
-    """Test utility functions of L{gbp.rpm}"""
-    def setup(self):
-        self.tmpdir = tempfile.mkdtemp(prefix='gbp_%s_' % __name__, dir='.')
-
-    def teardown(self):
-        shutil.rmtree(self.tmpdir)
-
-    def test_parse_srpm(self):
-        """Test parse_srpm() function"""
-        parse_srpm(os.path.join(SRPM_DIR, 'gbp-test-1.0-1.src.rpm'))
-       assert_raises(GbpError, parse_srpm,
-               os.path.join(DATA_DIR, 'notexists.src.rpm'))
-
-       """
-        with assert_raises(GbpError):
-            parse_srpm(os.path.join(DATA_DIR, 'notexists.src.rpm'))
-        with assert_raises(GbpError):
-            parse_srpm(os.path.join(SPEC_DIR, 'gbp-test.spec'))
-       """
-
-    def test_guess_spec(self):
-        """Test guess_spec() function"""
-        # Spec not found
-       assert_raises(NoSpecError, guess_spec,
-            DATA_DIR, recursive=False)
-
-       """
-        with assert_raises(NoSpecError):
-            guess_spec(DATA_DIR, recursive=False)
-       """
-
-        # Multiple spec files
-       assert_raises(NoSpecError, guess_spec,
-            DATA_DIR, recursive=True)
-       assert_raises(NoSpecError, guess_spec,
-            SPEC_DIR, recursive=False)
-
-       """
-        with assert_raises(NoSpecError):
-            guess_spec(DATA_DIR, recursive=True)
-        with assert_raises(NoSpecError):
-            guess_spec(SPEC_DIR, recursive=False)
-       """
-
-        # Spec found
-        spec = guess_spec(SPEC_DIR, recursive=False,
-                             preferred_name = 'gbp-test2.spec')
-        assert spec.specfile == 'gbp-test2.spec'
-        assert spec.specdir == SPEC_DIR
-
-    def test_guess_spec_repo(self):
-        """Test guess_spec_repo() and spec_from_repo() functions"""
-        # Create dummy repository with some commits
-        repo = GitRepository.create(self.tmpdir)
-        with open(os.path.join(repo.path, 'foo.txt'), 'w') as fobj:
-            fobj.write('bar\n')
-        repo.add_files('foo.txt')
-        repo.commit_all('Add dummy file')
-        os.mkdir(os.path.join(repo.path, 'packaging'))
-        shutil.copy(os.path.join(SPEC_DIR, 'gbp-test.spec'),
-                    os.path.join(repo.path, 'packaging'))
-        repo.add_files('packaging/gbp-test.spec')
-        repo.commit_all('Add spec file')
-
-        # Spec not found
-       assert_raises(NoSpecError, guess_spec_repo,
-            repo, 'HEAD~1', recursive=True)
-       assert_raises(NoSpecError, guess_spec_repo,
-            repo, 'HEAD', recursive=False)
-
-       """
-        with assert_raises(NoSpecError):
-            guess_spec_repo(repo, 'HEAD~1', recursive=True)
-        with assert_raises(NoSpecError):
-            guess_spec_repo(repo, 'HEAD', recursive=False)
-       """
-
-        # Spec found
-        spec = guess_spec_repo(repo, 'HEAD', 'packaging', recursive=False)
-        spec = guess_spec_repo(repo, 'HEAD', recursive=True)
-        assert spec.specfile == 'gbp-test.spec'
-        assert spec.specdir == 'packaging'
-        assert spec.specpath == 'packaging/gbp-test.spec'
-
-        # Test spec_from_repo()
-       assert_raises(NoSpecError, spec_from_repo,
-            repo, 'HEAD~1', 'packaging/gbp-test.spec')
-
-       """
-        with assert_raises(NoSpecError):
-            spec_from_repo(repo, 'HEAD~1', 'packaging/gbp-test.spec')
-       """
-
-        spec = spec_from_repo(repo, 'HEAD', 'packaging/gbp-test.spec')
-        assert spec.specfile == 'gbp-test.spec'
-
-# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·:
index b35a5bd6429fbd06ee97efdfd798bbdfe662b8a3..6635400be4d09bf377c50d27461eee9d5d668ebd 100644 (file)
@@ -72,8 +72,8 @@ class TestImportPacked(ComponentTestBase):
         # Check repository state
         repo = GitRepository('gbp-test2')
         files = set(['Makefile', 'README', 'bar.tar.gz', 'dummy.sh', 'foo.txt',
-                 'gbp-test2.spec', 'gbp-test2-alt.spec', 'my.patch',
-                 'mydir/myfile.txt'])
+                     'gbp-test2.spec', 'gbp-test2-alt.spec', 'my.patch',
+                     'mydir/myfile.txt'])
         self._check_repo_state(repo, 'master', ['master', 'upstream'], files)
 
         # Four commits: upstream, packaging files, one patch and the removal
@@ -101,7 +101,7 @@ class TestImportPacked(ComponentTestBase):
         eq_(mock_import(['--native', srpm]), 0)
         # Check repository state
         files = set(['.gbp.conf', 'Makefile', 'README', 'dummy.sh',
-                 'packaging/gbp-test-native.spec'])
+                     'packaging/gbp-test-native.spec'])
         repo = GitRepository('gbp-test-native')
         self._check_repo_state(repo, 'master', ['master'], files)
         # Only one commit: the imported source tarball
@@ -120,7 +120,7 @@ class TestImportPacked(ComponentTestBase):
     def test_import_compressed_patches(self):
         """Test importing of non-native src.rpm with compressed patches"""
         srpm = os.path.join(DATA_DIR, 'gbp-test-1.1-2.src.rpm')
-        eq_(import_srpm(['arg0', srpm]), 0)
+        eq_(mock_import([srpm]), 0)
         # Check repository state
         repo = GitRepository('gbp-test')
         files =  set(['Makefile', 'README', 'AUTHORS', 'NEWS', 'bar.tar.gz',
@@ -144,13 +144,12 @@ class TestImportPacked(ComponentTestBase):
         eq_(mock_import([srpms[1]]), 0)
         eq_(len(repo.get_commits()), 4)
         eq_(len(repo.get_commits(until='upstream')), 1)
-        eq_(mock_import(['--no-pristine-tar', '--allow-same-version',
-                         srpms[1]]), 0)
+        eq_(mock_import(['--allow-same-version', srpms[1]]), 0)
         # Added new versio packaging plus one patch
         eq_(len(repo.get_commits()), 7)
         eq_(len(repo.get_commits(until='upstream')), 1)
         # Import new version
-        eq_(mock_import(['--no-pristine-tar', srpms[2]]), 0)
+        eq_(mock_import([srpms[2]]), 0)
         files = set(['Makefile', 'README', 'bar.tar.gz', 'dummy.sh', 'foo.txt',
                  'gbp-test.spec', 'my.patch', 'mydir/myfile.txt'])
         self._check_repo_state(repo, 'master', ['master', 'upstream'], files)
@@ -207,7 +206,7 @@ class TestImportPacked(ComponentTestBase):
         """Test various options of git-import-srpm"""
         srpm = os.path.join(DATA_DIR, 'gbp-test2-2.0-0.src.rpm')
 
-        eq_(mock_import(['--no-pristine-tar',
+        eq_(mock_import([
                     '--no-patch-import',
                     '--packaging-branch=pack',
                     '--upstream-branch=orig',
@@ -219,9 +218,9 @@ class TestImportPacked(ComponentTestBase):
         # Check repository state
         repo = GitRepository('gbp-test2')
         files = set(['Makefile', 'README', 'dummy.sh', 'packaging/bar.tar.gz',
-                 'packaging/foo.txt', 'packaging/gbp-test2.spec',
-                 'packaging/gbp-test2-alt.spec', 'packaging/my.patch',
-                 'packaging/my2.patch', 'packaging/my3.patch'])
+                     'packaging/foo.txt', 'packaging/gbp-test2.spec',
+                     'packaging/gbp-test2-alt.spec', 'packaging/my.patch',
+                     'packaging/my2.patch', 'packaging/my3.patch'])
         self._check_repo_state(repo, 'pack', ['pack', 'orig'], files)
         eq_(len(repo.get_commits()), 2)
         # Check packaging dir
diff --git a/tests/data/rpm/rpmbuild/SOURCES/bar.tar.gz b/tests/data/rpm/rpmbuild/SOURCES/bar.tar.gz
deleted file mode 100644 (file)
index f5dae80..0000000
Binary files a/tests/data/rpm/rpmbuild/SOURCES/bar.tar.gz and /dev/null differ
diff --git a/tests/data/rpm/rpmbuild/SOURCES/foo.txt b/tests/data/rpm/rpmbuild/SOURCES/foo.txt
deleted file mode 100644 (file)
index 25ed442..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-FOO:
-
-file for testing rpm support of git-buildpackage.
diff --git a/tests/data/rpm/rpmbuild/SOURCES/gbp-test-1.0.tar.bz2 b/tests/data/rpm/rpmbuild/SOURCES/gbp-test-1.0.tar.bz2
deleted file mode 100644 (file)
index 7d0759f..0000000
Binary files a/tests/data/rpm/rpmbuild/SOURCES/gbp-test-1.0.tar.bz2 and /dev/null differ
diff --git a/tests/data/rpm/rpmbuild/SOURCES/gbp-test-native-1.0.zip b/tests/data/rpm/rpmbuild/SOURCES/gbp-test-native-1.0.zip
deleted file mode 100644 (file)
index 22a273d..0000000
Binary files a/tests/data/rpm/rpmbuild/SOURCES/gbp-test-native-1.0.zip and /dev/null differ
diff --git a/tests/data/rpm/rpmbuild/SOURCES/gbp-test2-3.0.tar.gz b/tests/data/rpm/rpmbuild/SOURCES/gbp-test2-3.0.tar.gz
deleted file mode 100644 (file)
index 7b3eaf3..0000000
Binary files a/tests/data/rpm/rpmbuild/SOURCES/gbp-test2-3.0.tar.gz and /dev/null differ
diff --git a/tests/data/rpm/rpmbuild/SOURCES/my.patch b/tests/data/rpm/rpmbuild/SOURCES/my.patch
deleted file mode 100644 (file)
index 50870df..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-diff --git a/dummy.sh b/dummy.sh
-index 8c33db6..6f04268 100755
---- dummy.sh
-+++ dummy.sh
-@@ -1,3 +1,3 @@
- #!/bin/sh
--echo "Hello world"
-+echo "Hello GBP"
diff --git a/tests/data/rpm/rpmbuild/SOURCES/my2.patch b/tests/data/rpm/rpmbuild/SOURCES/my2.patch
deleted file mode 100644 (file)
index ad5ca2d..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-diff --git a/mydir/myfile.txt b/mydir/myfile.txt
-new file mode 100644
-index 0000000..2cdad29
---- /dev/null
-+++ b/mydir/myfile.txt
-@@ -0,0 +1 @@
-+Dummy
diff --git a/tests/data/rpm/rpmbuild/SOURCES/my3.patch b/tests/data/rpm/rpmbuild/SOURCES/my3.patch
deleted file mode 100644 (file)
index 9fee859..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-diff --git a/README b/README
-index a1311cb..a59f1b9 100644
---- a/README
-+++ b/README
-@@ -1 +1 @@
--Just for testing git-buildpackage.
-+Just for testing GBP.
diff --git a/tests/data/rpm/rpmbuild/SPECS/gbp-test-native.spec b/tests/data/rpm/rpmbuild/SPECS/gbp-test-native.spec
deleted file mode 100644 (file)
index 38b07e4..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-Name:       gbp-test-native
-Summary:    Test package for git-buildpackage
-Version:    1.0
-Release:    1
-Group:      Development/Libraries
-License:    GPLv2
-Source1:    %{name}-%{version}.zip
-BuildRequires:  unzip
-
-%description
-Package for testing the RPM functionality of git-buildpackage.
-Mimics a "native" package
-
-
-%prep
-unzip %{SOURCE1}
-%setup -T -D
-
-
-%build
-make
-
-
-%install
-rm -rf %{buildroot}
-mkdir -p %{buildroot}/%{_datadir}/%{name}
-cp -R * %{buildroot}/%{_datadir}/%{name}
-
-
-
-%files
-%defattr(-,root,root,-)
-%dir %{_datadir}/%{name}
-%{_datadir}/%{name}
diff --git a/tests/data/rpm/rpmbuild/SPECS/gbp-test-native2.spec b/tests/data/rpm/rpmbuild/SPECS/gbp-test-native2.spec
deleted file mode 100644 (file)
index 34fd33d..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-Name:       gbp-test-native2
-Summary:    Test package for git-buildpackage
-Version:    2.0
-Release:    0
-Group:      Development/Libraries
-License:    GPLv2
-Source:     foo.txt
-BuildRequires:  unzip
-
-%description
-Package for testing the RPM functionality of git-buildpackage.
-Mimics a "native" package that doesn't have any source tarball.
-
-
-%prep
-# Just create build dir
-%setup -T -c
-cp %{SOURCE0} .
-
-
-%build
-# Nothing to do
-
-
-%install
-rm -rf %{buildroot}
-mkdir -p %{buildroot}/%{_datadir}/%{name}
-cp -R * %{buildroot}/%{_datadir}/%{name}
-
-
-
-%files
-%defattr(-,root,root,-)
-%dir %{_datadir}/%{name}
-%{_datadir}/%{name}
diff --git a/tests/data/rpm/rpmbuild/SPECS/gbp-test.spec b/tests/data/rpm/rpmbuild/SPECS/gbp-test.spec
deleted file mode 100644 (file)
index c46a734..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-Name:       gbp-test
-Summary:    Test package for git-buildpackage
-Version:    1.0
-Release:    1
-Group:      Development/Libraries
-License:    GPLv2
-Source:     %{name}-%{version}.tar.bz2
-Source1:    foo.txt
-Source20:   bar.tar.gz
-# Gbp-Ignore-Patches: 0
-Patch0:     my.patch
-Patch10:    my2.patch
-Patch20:    my3.patch
-
-
-%description
-Package for testing the RPM functionality of git-buildpackage.
-
-
-%prep
-%setup -n %{name} -a 20
-
-%patch0
-%patch10 -p1
-
-
-%build
-make
-
-
-%install
-rm -rf %{buildroot}
-mkdir -p %{buildroot}/%{_datadir}/%{name}
-cp -R * %{buildroot}/%{_datadir}/%{name}
-install %{SOURCE0} %{buildroot}/%{_datadir}/%{name}
-
-
-
-%files
-%defattr(-,root,root,-)
-%dir %{_datadir}/%{name}
-%{_datadir}/%{name}
diff --git a/tests/data/rpm/rpmbuild/SPECS/gbp-test2.spec b/tests/data/rpm/rpmbuild/SPECS/gbp-test2.spec
deleted file mode 100644 (file)
index 8a92725..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-Name:       gbp-test2
-Summary:    Test package 2 for git-buildpackage
-Epoch:      2
-Version:    3.0
-Release:    0
-Group:      Development/Libraries
-License:    GPLv2
-Source10:   ftp://ftp.host.com/%{name}-%{version}.tar.gz
-Source:     foo.txt
-Source20:   bar.tar.gz
-# Gbp-Ignore-Patches: -1
-Patch:      my.patch
-Patch10:    my2.patch
-Patch20:    my3.patch
-Packager:   Markus Lehtonen <markus.lehtonen@linux.intel.com>
-VCS:        myoldvcstag
-
-%description
-Package for testing the RPM functionality of git-buildpackage.
-
-%package empty
-Summary:    Empty subpackage
-
-%description empty
-Empty subpackage for the %{name} test package.
-
-
-%prep
-%setup -T -n %{name}-%{version} -c -a 10
-
-%patch
-%patch -P 10 -p1
-
-echo "Do things"
-
-# Gbp-Patch-Macros
-
-%build
-make
-
-
-%install
-rm -rf %{buildroot}
-mkdir -p %{buildroot}/%{_datadir}/%{name}
-cp -R * %{buildroot}/%{_datadir}/%{name}
-install %{SOURCE0} %{buildroot}/%{_datadir}/%{name}
-
-
-%changelog
-* Tue Feb 04 2014 Name <email> 1
-- My change
-
-
-%files
-%defattr(-,root,root,-)
-%dir %{_datadir}/%{name}
-%{_datadir}/%{name}
-
-%files empty
-%defattr(-,root,root,-)
diff --git a/tests/data/rpm/specs/gbp-test-native.spec b/tests/data/rpm/specs/gbp-test-native.spec
deleted file mode 120000 (symlink)
index 60de36f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../rpmbuild/SPECS/gbp-test-native.spec
\ No newline at end of file
diff --git a/tests/data/rpm/specs/gbp-test-native2.spec b/tests/data/rpm/specs/gbp-test-native2.spec
deleted file mode 120000 (symlink)
index ad13ad6..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../rpmbuild/SPECS/gbp-test-native2.spec
\ No newline at end of file
diff --git a/tests/data/rpm/specs/gbp-test-quirks.spec b/tests/data/rpm/specs/gbp-test-quirks.spec
deleted file mode 100644 (file)
index bb56b00..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# Spec for testing some quirks of spec parsing
-#
-
-Name:           pkg_name
-Summary:        Spec for testing some quirks of spec parsing
-Version:        0.1
-Release:        1.2
-License:        GPLv2
-Source1:        foobar.tar.gz
-# Gbp-Ignore-Patches: 2 4 888
-Patch1:         01.patch
-Patch2:         02.patch
-Patch3:         03.patch
-Patch4:         04.patch
-Patch5:         05.patch
-
-%description
-Spec for testing some quirks of spec parsing. No intended for building an RPM.
-
-%prep
-# We don't have Source0 so rpmbuild would fail, but gbp shouldn't crash
-%setup -q
-
-# Patches are applied out-of-order wrt. numbering
-%patch5
-%patch2
-%patch1
-# Patch 999 does not exist, rpmbuild would fail but GBP should not
-%patch999
diff --git a/tests/data/rpm/specs/gbp-test-reference.spec b/tests/data/rpm/specs/gbp-test-reference.spec
deleted file mode 100644 (file)
index 050d139..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-Name:       gbp-test
-Summary:    Test package for git-buildpackage
-Version:    1.0
-Release:    1
-Group:      Development/Libraries
-License:    GPLv2
-Source:     %{name}-%{version}.tar.bz2
-Source1:    foo.txt
-Source20:   bar.tar.gz
-# Gbp-Ignore-Patches: 0
-Patch0:     my.patch
-# Patches auto-generated by git-buildpackage:
-Patch1:     new.patch
-
-
-%description
-Package for testing the RPM functionality of git-buildpackage.
-
-
-%prep
-%setup -n %{name} -a 20
-
-%patch0
-# new.patch
-%patch1 -p1
-
-
-%build
-make
-
-
-%install
-rm -rf %{buildroot}
-mkdir -p %{buildroot}/%{_datadir}/%{name}
-cp -R * %{buildroot}/%{_datadir}/%{name}
-install %{SOURCE0} %{buildroot}/%{_datadir}/%{name}
-
-
-
-%files
-%defattr(-,root,root,-)
-%dir %{_datadir}/%{name}
-%{_datadir}/%{name}
diff --git a/tests/data/rpm/specs/gbp-test-reference2.spec b/tests/data/rpm/specs/gbp-test-reference2.spec
deleted file mode 100644 (file)
index 0fbe026..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-Name:       gbp-test
-VCS:        myvcstag
-Summary:    Test package for git-buildpackage
-Version:    1.0
-Release:    1
-Group:      Development/Libraries
-License:    GPLv2
-Source:     %{name}-%{version}.tar.bz2
-Source1:    foo.txt
-Source20:   bar.tar.gz
-# Gbp-Ignore-Patches: 0
-Patch0:     my.patch
-# Patches auto-generated by git-buildpackage:
-Patch1:     new.patch
-
-
-%description
-Package for testing the RPM functionality of git-buildpackage.
-
-
-%prep
-%setup -n %{name} -a 20
-
-%patch0
-# new.patch
-%patch1 -p1
-
-
-%build
-make
-
-
-%install
-rm -rf %{buildroot}
-mkdir -p %{buildroot}/%{_datadir}/%{name}
-cp -R * %{buildroot}/%{_datadir}/%{name}
-install %{SOURCE0} %{buildroot}/%{_datadir}/%{name}
-
-
-
-%files
-%defattr(-,root,root,-)
-%dir %{_datadir}/%{name}
-%{_datadir}/%{name}
-%changelog
-* Wed Feb 05 2014 Name <email> 1
-- New entry
diff --git a/tests/data/rpm/specs/gbp-test-tags.spec b/tests/data/rpm/specs/gbp-test-tags.spec
deleted file mode 100644 (file)
index ee4c2b9..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-#
-# Spec file for testing all RPM tags (that we know of
-#
-
-%define suse_release %(test -e /etc/SuSE-release && head -n1 /etc/SuSE-release | cut -d ' ' -f2 | cut --output-delimiter=0 -d. -f1,2 || echo 0)
-%if "%{suse_release}" >= "1201"
-%define test_weak_dep_tags 1
-%endif
-
-%define test_arch_os_tags %(test -n "$GBP_SKIP_ARCH_OS_TAGS" && echo 0 || echo 1)
-
-%define source_fn_base source
-%define patch_fn_base patch
-
-# Gbp-Undefined-Tag: foobar
-
-# Test that we accept different cases
-NAME:           my_name
-version:        0
-ReLeasE:        0
-
-# Rest of the tags
-Epoch:          0
-Summary:        my_summary
-License:        my_license
-Distribution:   my_distribution
-Vendor:         my_vendor
-Group:          my_group
-Packager:       my_packager
-Url:            my_url
-Vcs:            my_vcs
-Source:         my_source
-Patch:          my_%patch_fn_base
-Patch0:         my_%{patch_fn_base}0
-Nosource:       0
-Nopatch:        0
-#Icon:           my_icon
-BuildRoot:      my_buildroot
-Provides:       my_provides
-Requires:       my_requires
-Conflicts:      my_conflicts
-Obsoletes:      my_obsoletes
-BuildConflicts: my_buildconflicts
-BuildRequires:  my_buildrequires
-AutoReqProv:    No
-AutoReq:        No
-AutoProv:       No
-DistTag:        my_disttag
-BugUrl:         my_bugurl
-Collections:    my_collections
-
-%if 0%{?test_weak_dep_tags}
-Recommends:     my_recommends
-Suggests:       my_suggests
-Supplements:    my_supplements
-Enhances:       my_enhances
-BuildRecommends:my_buildrecommends
-BuildSuggests:  my_buildsuggests
-BuildSupplements:my_buildsupplements
-BuildEnhances:  my_buildenhances
-%endif
-
-# These should be filtered out by GBP
-%if "%{test_arch_os_tags}" != "0"
-BuildArch:      my_buildarch
-ExcludeArch:    my_excludearch
-ExclusiveArch:  my_exclusivearch
-ExcludeOs:      my_excludeos
-ExclusiveOs:    my_exclusiveos
-%endif
-
-%description
-Package for testing GBP.
-
diff --git a/tests/data/rpm/specs/gbp-test-updates-reference.spec b/tests/data/rpm/specs/gbp-test-updates-reference.spec
deleted file mode 100644 (file)
index ff56f58..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-# Spec file for testing deleting/adding/updating tags and macros
-#
-
-# Gbp-Undefined-Tag: foobar
-
-# Test that we accept different cases
-Name:           my_name
-Version:        0
-Release:        1
-Summary:        my_summary
-License:        new license
-Distribution:   my_distribution
-Group:          my_group
-Packager:       my_packager
-Url:            my_url
-Vcs:            my_vcs
-Nosource:       0
-Nopatch:        0
-BuildRoot:      my_buildroot
-Provides:       my_provides
-Requires:       my_requires
-Conflicts:      my_conflicts
-Obsoletes:      my_obsoletes
-BuildConflicts: my_buildconflicts
-BuildRequires:  my_buildrequires
-AutoReqProv:    No
-AutoReq:        No
-AutoProv:       No
-DistTag:        my_disttag
-BugUrl:         my_bugurl
-Collections:    my_collections
-
-%description
-Package for testing GBP.
-
-%prep
-%setup -n my_prefix
-
-%patch0 my new args
-
-%build
-
-%install
diff --git a/tests/data/rpm/specs/gbp-test-updates.spec b/tests/data/rpm/specs/gbp-test-updates.spec
deleted file mode 100644 (file)
index dc8ffbf..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#
-# Spec file for testing deleting/adding/updating tags and macros
-#
-
-# Gbp-Undefined-Tag: foobar
-
-# Test that we accept different cases
-Name:           my_name
-Version:        0
-Release:        1
-Summary:        my_summary
-License:        my_license
-Distribution:   my_distribution
-Vendor:         my_vendor
-Group:          my_group
-Packager:       my_packager
-Url:            my_url
-Vcs:            my_vcs
-Source:         my_source
-Patch:          my_%patch_fn_base
-Patch0:         my_%{patch_fn_base}0
-Nosource:       0
-Nopatch:        0
-BuildRoot:      my_buildroot
-Provides:       my_provides
-Requires:       my_requires
-Conflicts:      my_conflicts
-Obsoletes:      my_obsoletes
-BuildConflicts: my_buildconflicts
-BuildRequires:  my_buildrequires
-AutoReqProv:    No
-AutoReq:        No
-AutoProv:       No
-DistTag:        my_disttag
-BugUrl:         my_bugurl
-Collections:    my_collections
-
-%description
-Package for testing GBP.
-
-%prep
-%setup -n my_prefix
-
-%patch -b my_patch
-%patch -P0 -b my_patch0
-
-%build
-
-%install
diff --git a/tests/data/rpm/specs/gbp-test.spec b/tests/data/rpm/specs/gbp-test.spec
deleted file mode 120000 (symlink)
index 30ae284..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../rpmbuild/SPECS/gbp-test.spec
\ No newline at end of file
diff --git a/tests/data/rpm/specs/gbp-test2-reference.spec b/tests/data/rpm/specs/gbp-test2-reference.spec
deleted file mode 100644 (file)
index 1882131..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-Name:       gbp-test2
-Summary:    Test package 2 for git-buildpackage
-Epoch:      2
-Version:    3.0
-Release:    0
-Group:      Development/Libraries
-License:    GPLv2
-Source10:   ftp://ftp.host.com/%{name}-%{version}.tar.gz
-Source:     foo.txt
-Source20:   bar.tar.gz
-# Gbp-Ignore-Patches: -1
-Patch:      my.patch
-# Patches auto-generated by git-buildpackage:
-Patch0:     new.patch
-Packager:   Markus Lehtonen <markus.lehtonen@linux.intel.com>
-
-%description
-Package for testing the RPM functionality of git-buildpackage.
-
-%package empty
-Summary:    Empty subpackage
-
-%description empty
-Empty subpackage for the %{name} test package.
-
-
-%prep
-%setup -T -n %{name}-%{version} -c -a 10
-
-%patch
-
-echo "Do things"
-
-# Gbp-Patch-Macros
-# new.patch
-%if 1
-%patch0 -p1
-%endif
-
-%build
-make
-
-
-%install
-rm -rf %{buildroot}
-mkdir -p %{buildroot}/%{_datadir}/%{name}
-cp -R * %{buildroot}/%{_datadir}/%{name}
-install %{SOURCE0} %{buildroot}/%{_datadir}/%{name}
-
-
-%changelog
-* Wed Feb 05 2014 Name <email> 2
-- New entry
-
-%files
-%defattr(-,root,root,-)
-%dir %{_datadir}/%{name}
-%{_datadir}/%{name}
-
-%files empty
-%defattr(-,root,root,-)
diff --git a/tests/data/rpm/specs/gbp-test2-reference2.spec b/tests/data/rpm/specs/gbp-test2-reference2.spec
deleted file mode 100644 (file)
index d41f450..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-Name:       gbp-test2
-Summary:    Test package 2 for git-buildpackage
-Epoch:      2
-Version:    3.0
-Release:    0
-Group:      Development/Libraries
-License:    GPLv2
-Source10:   ftp://ftp.host.com/%{name}-%{version}.tar.gz
-Source:     foo.txt
-Source20:   bar.tar.gz
-# Gbp-Ignore-Patches: -1
-Patch:      my.patch
-# Patches auto-generated by git-buildpackage:
-Patch0:     1.patch
-Patch1:     2.patch
-Packager:   Markus Lehtonen <markus.lehtonen@linux.intel.com>
-VCS:        myvcstag
-
-%description
-Package for testing the RPM functionality of git-buildpackage.
-
-%package empty
-Summary:    Empty subpackage
-
-%description empty
-Empty subpackage for the %{name} test package.
-
-
-%prep
-%setup -T -n %{name}-%{version} -c -a 10
-
-%patch
-
-echo "Do things"
-
-# Gbp-Patch-Macros
-# 1.patch
-%if true
-%patch0 -p1
-%endif
-# 2.patch
-%ifarch %ix86
-%patch1 -p1
-%endif
-
-%build
-make
-
-
-%install
-rm -rf %{buildroot}
-mkdir -p %{buildroot}/%{_datadir}/%{name}
-cp -R * %{buildroot}/%{_datadir}/%{name}
-install %{SOURCE0} %{buildroot}/%{_datadir}/%{name}
-
-
-%changelog
-* Tue Feb 04 2014 Name <email> 1
-- My change
-
-
-%files
-%defattr(-,root,root,-)
-%dir %{_datadir}/%{name}
-%{_datadir}/%{name}
-
-%files empty
-%defattr(-,root,root,-)
diff --git a/tests/data/rpm/specs/gbp-test2.spec b/tests/data/rpm/specs/gbp-test2.spec
deleted file mode 120000 (symlink)
index af4080c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../rpmbuild/SPECS/gbp-test2.spec
\ No newline at end of file
diff --git a/tests/data/rpm/srpms/gbp-test-1.0-1.src.rpm b/tests/data/rpm/srpms/gbp-test-1.0-1.src.rpm
deleted file mode 100644 (file)
index 74afbd6..0000000
Binary files a/tests/data/rpm/srpms/gbp-test-1.0-1.src.rpm and /dev/null differ
diff --git a/tests/data/rpm/srpms/gbp-test-native-1.0-1.src.rpm b/tests/data/rpm/srpms/gbp-test-native-1.0-1.src.rpm
deleted file mode 100644 (file)
index 1002aae..0000000
Binary files a/tests/data/rpm/srpms/gbp-test-native-1.0-1.src.rpm and /dev/null differ
diff --git a/tests/data/rpm/srpms/gbp-test-native2-2.0-0.src.rpm b/tests/data/rpm/srpms/gbp-test-native2-2.0-0.src.rpm
deleted file mode 100644 (file)
index 880b310..0000000
Binary files a/tests/data/rpm/srpms/gbp-test-native2-2.0-0.src.rpm and /dev/null differ
diff --git a/tests/data/rpm/srpms/gbp-test2-3.0-0.src.rpm b/tests/data/rpm/srpms/gbp-test2-3.0-0.src.rpm
deleted file mode 100644 (file)
index 1cf12c7..0000000
Binary files a/tests/data/rpm/srpms/gbp-test2-3.0-0.src.rpm and /dev/null differ
diff --git a/tests/test_rpm.py b/tests/test_rpm.py
new file mode 100644 (file)
index 0000000..9739046
--- /dev/null
@@ -0,0 +1,479 @@
+# vim: set fileencoding=utf-8 :
+#
+# (C) 2012 Intel Corporation <markus.lehtonen@linux.intel.com>
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program; if not, write to the Free Software
+#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+"""Test the classes under L{gbp.rpm}"""
+
+import filecmp
+import os
+import shutil
+import tempfile
+from nose.tools import assert_raises, eq_
+
+from gbp.errors import GbpError
+from gbp.rpm import (SrcRpmFile, SpecFile, parse_srpm, NoSpecError, guess_spec,
+                     guess_spec_repo, spec_from_repo)
+from gbp.git.repository import GitRepository
+
+DATA_DIR = os.path.abspath(os.path.splitext(__file__)[0] + '_data')
+SRPM_DIR = os.path.join(DATA_DIR, 'srpms')
+SPEC_DIR = os.path.join(DATA_DIR, 'specs')
+
+class SpecFileTester(SpecFile):
+    """Helper class for testing"""
+
+    def protected(self, name):
+        """Get a protected member"""
+        return super(SpecFileTester, self).__getattribute__(name)
+
+
+class TestSrcRpmFile(object):
+    """Test L{gbp.rpm.SrcRpmFile}"""
+
+    def setup(self):
+        self.tmpdir = tempfile.mkdtemp(prefix='gbp_%s_' % __name__, dir='.')
+
+    def teardown(self):
+        shutil.rmtree(self.tmpdir)
+
+    def test_srpm(self):
+        """Test parsing of a source rpm"""
+        srpm = SrcRpmFile(os.path.join(SRPM_DIR, 'gbp-test-1.0-1.src.rpm'))
+        assert srpm.version ==  {'release': '1', 'upstreamversion': '1.0'}
+        assert srpm.name == 'gbp-test'
+        assert srpm.upstreamversion == '1.0'
+        assert srpm.packager is None
+
+    def test_srpm_2(self):
+        """Test parsing of another source rpm"""
+        srpm = SrcRpmFile(os.path.join(SRPM_DIR, 'gbp-test2-3.0-0.src.rpm'))
+        assert srpm.version == {'release': '0', 'upstreamversion': '3.0',
+                                'epoch': '2'}
+        assert srpm.packager == 'Markus Lehtonen '\
+                                '<markus.lehtonen@linux.intel.com>'
+
+    def test_unpack_srpm(self):
+        """Test unpacking of a source rpm"""
+        srpm = SrcRpmFile(os.path.join(SRPM_DIR, 'gbp-test-1.0-1.src.rpm'))
+        srpm.unpack(self.tmpdir)
+        for fn in ['gbp-test-1.0.tar.bz2', 'foo.txt', 'bar.tar.gz', 'my.patch',
+                   'my2.patch', 'my3.patch']:
+            assert os.path.exists(os.path.join(self.tmpdir, fn)), \
+                    "%s not found" % fn
+
+
+class TestSpecFile(object):
+    """Test L{gbp.rpm.SpecFile}"""
+
+    def setup(self):
+        self.tmpdir = tempfile.mkdtemp(prefix='gbp_%s_' % __name__, dir='.')
+
+    def teardown(self):
+        shutil.rmtree(self.tmpdir)
+
+    def test_spec(self):
+        """Test parsing of a valid spec file"""
+        spec_filepath = os.path.join(SPEC_DIR, 'gbp-test.spec')
+        spec = SpecFileTester(spec_filepath)
+
+        # Test basic properties
+        assert spec.specfile == os.path.basename(spec_filepath)
+        assert spec.specdir == os.path.dirname(spec_filepath)
+        assert spec.specpath == spec_filepath
+
+        assert spec.name == 'gbp-test'
+        assert spec.packager is None
+
+        assert spec.upstreamversion == '1.0'
+        assert spec.release == '1'
+        assert spec.epoch is None
+        assert spec.version == {'release': '1', 'upstreamversion': '1.0'}
+
+        orig = spec.orig_src
+        assert orig['filename'] == 'gbp-test-1.0.tar.bz2'
+        assert orig['uri'] == 'gbp-test-1.0.tar.bz2'
+        assert orig['filename_base'] == 'gbp-test-1.0'
+        assert orig['archive_fmt'] == 'tar'
+        assert orig['compression'] == 'bzip2'
+        assert orig['prefix'] == 'gbp-test/'
+
+    def test_spec_2(self):
+        """Test parsing of another valid spec file"""
+        spec_filepath = os.path.join(SPEC_DIR, 'gbp-test2.spec')
+        spec = SpecFile(spec_filepath)
+
+        # Test basic properties
+        assert spec.name == 'gbp-test2'
+        assert spec.packager == 'Markus Lehtonen ' \
+                                '<markus.lehtonen@linux.intel.com>'
+
+        assert spec.epoch == '2'
+        assert spec.version == {'release': '0', 'upstreamversion': '3.0',
+                                'epoch': '2'}
+
+        orig = spec.orig_src
+        assert orig['filename'] == 'gbp-test2-3.0.tar.gz'
+        assert orig['uri'] == 'ftp://ftp.host.com/gbp-test2-3.0.tar.gz'
+        assert orig['archive_fmt'] == 'tar'
+        assert orig['compression'] == 'gzip'
+        assert orig['prefix'] == ''
+
+    def test_spec_3(self):
+        """Test parsing of yet another valid spec file"""
+        spec_filepath = os.path.join(SPEC_DIR, 'gbp-test-native.spec')
+        spec = SpecFile(spec_filepath)
+
+        # Test basic properties
+        assert spec.name == 'gbp-test-native'
+        orig = spec.orig_src
+        assert orig['filename'] == 'gbp-test-native-1.0.zip'
+        assert orig['archive_fmt'] == 'zip'
+        assert orig['compression'] == None
+        assert orig['prefix'] == 'gbp-test-native-1.0/'
+
+    def test_spec_4(self):
+        """Test parsing of spec without orig tarball"""
+        spec_filepath = os.path.join(SPEC_DIR, 'gbp-test-native2.spec')
+        spec = SpecFile(spec_filepath)
+
+        # Test basic properties
+        assert spec.name == 'gbp-test-native2'
+        assert spec.orig_src is None
+
+    def test_parse_raw(self):
+        """Test parsing of a valid spec file"""
+       assert_raises(NoSpecError, SpecFile, None, None)
+       assert_raises(NoSpecError, SpecFile, 'filename', 'filedata')
+
+       """
+        with assert_raises(NoSpecError):
+            SpecFile(None, None)
+        with assert_raises(NoSpecError):
+            SpecFile('filename', 'filedata')
+       """
+
+        spec_filepath = os.path.join(SPEC_DIR, 'gbp-test.spec')
+        with open(spec_filepath, 'r') as spec_fd:
+            spec_data = spec_fd.read()
+        spec = SpecFile(filedata=spec_data)
+
+        # Test basic properties
+        assert spec.specfile == None
+        assert spec.specdir == None
+        assert spec.name == 'gbp-test'
+
+    def test_update_spec(self):
+        """Test spec autoupdate functionality"""
+        # Create temporary spec file
+        tmp_spec = os.path.join(self.tmpdir, 'gbp-test.spec')
+        shutil.copy2(os.path.join(SPEC_DIR, 'gbp-test.spec'), tmp_spec)
+
+        reference_spec = os.path.join(SPEC_DIR, 'gbp-test-reference.spec')
+        spec = SpecFile(tmp_spec)
+        spec.update_patches(['new.patch'], {})
+        spec.write_spec_file()
+        assert filecmp.cmp(tmp_spec, reference_spec) is True
+
+        # Test adding the VCS tag and adding changelog
+        reference_spec = os.path.join(SPEC_DIR, 'gbp-test-reference2.spec')
+        spec.set_tag('VCS', None, 'myvcstag')
+        spec.set_changelog("* Wed Feb 05 2014 Name <email> 1\n- New entry\n")
+        spec.write_spec_file()
+        assert filecmp.cmp(tmp_spec, reference_spec) is True
+
+    def test_update_spec2(self):
+        """Another test for spec autoupdate functionality"""
+        tmp_spec = os.path.join(self.tmpdir, 'gbp-test2.spec')
+        shutil.copy2(os.path.join(SPEC_DIR, 'gbp-test2.spec'), tmp_spec)
+
+        reference_spec = os.path.join(SPEC_DIR, 'gbp-test2-reference2.spec')
+        spec = SpecFile(tmp_spec)
+        spec.update_patches(['1.patch', '2.patch'],
+                            {'1.patch': {'if': 'true'},
+                             '2.patch': {'ifarch': '%ix86'}})
+        spec.set_tag('VCS', None, 'myvcstag')
+        spec.write_spec_file()
+        assert filecmp.cmp(tmp_spec, reference_spec) is True
+
+        # Test updating patches again, removing the VCS tag and re-writing
+        # changelog
+        reference_spec = os.path.join(SPEC_DIR, 'gbp-test2-reference.spec')
+        spec.update_patches(['new.patch'], {'new.patch': {'if': '1'}})
+        spec.set_tag('VCS', None, '')
+        spec.set_changelog("* Wed Feb 05 2014 Name <email> 2\n- New entry\n\n")
+        spec.write_spec_file()
+        assert filecmp.cmp(tmp_spec, reference_spec) is True
+
+    def test_modifying(self):
+        """Test updating/deleting of tags and macros"""
+        tmp_spec = os.path.join(self.tmpdir, 'gbp-test.spec')
+        shutil.copy2(os.path.join(SPEC_DIR, 'gbp-test-updates.spec'), tmp_spec)
+        reference_spec = os.path.join(SPEC_DIR,
+                                      'gbp-test-updates-reference.spec')
+        spec = SpecFileTester(tmp_spec)
+
+        # Mangle tags
+        prev = spec.protected('_delete_tag')('Vendor', None)
+        spec.protected('_set_tag')('License', None, 'new license', prev)
+        spec.protected('_delete_tag')('source', 0)
+        assert spec.sources() == {}
+        spec.protected('_delete_tag')('patch', 0)
+        spec.protected('_delete_tag')('patch', -1)
+        assert spec.protected('_patches')() == {}
+        prev = spec.protected('_delete_tag')('invalidtag', None)
+
+       assert_raises(GbpError, spec.protected('_set_tag'),
+            'Version', None, '', prev)
+       assert_raises(GbpError, spec.set_tag,
+            'invalidtag', None, 'value')
+
+       """
+        with assert_raises(GbpError):
+            # Check that setting empty value fails
+            spec.protected('_set_tag')('Version', None, '', prev)
+        with assert_raises(GbpError):
+            # Check that setting invalid tag with public method fails
+            spec.set_tag('invalidtag', None, 'value')
+       """
+
+        # Mangle macros
+        prev = spec.protected('_delete_special_macro')('patch', -1)
+        spec.protected('_delete_special_macro')('patch', 123)
+        spec.protected('_set_special_macro')('patch', 0, 'my new args', prev)
+       assert_raises(GbpError, spec.protected('_delete_special_macro'),
+            'invalidmacro', 0)
+       assert_raises(GbpError, spec.protected('_set_special_macro'),
+            'invalidmacro', 0, 'args', prev)
+
+       """
+        with assert_raises(GbpError):
+            spec.protected('_delete_special_macro')('invalidmacro', 0)
+        with assert_raises(GbpError):
+            spec.protected('_set_special_macro')('invalidmacro', 0, 'args',
+                           prev)
+       """
+
+        # Check resulting spec file
+        spec.write_spec_file()
+        assert filecmp.cmp(tmp_spec, reference_spec) is True
+
+    def test_modifying_err(self):
+        """Test error conditions of modification methods"""
+        spec_filepath = os.path.join(SPEC_DIR, 'gbp-test2.spec')
+        spec = SpecFileTester(spec_filepath)
+
+        # Unknown/invalid section name
+       assert_raises(GbpError, spec.protected('_set_section'),
+            'patch', 'new content\n')
+       """
+        with assert_raises(GbpError):
+            spec.protected('_set_section')('patch', 'new content\n')
+       """
+
+        # Multiple sections with the same name
+       assert_raises(GbpError, spec.protected('_set_section'),
+            'files', '%{_sysconfdir}/foo\n')
+
+       """
+        with assert_raises(GbpError):
+            spec.protected('_set_section')('files', '%{_sysconfdir}/foo\n')
+       """
+
+    def test_changelog(self):
+        """Test changelog methods"""
+        spec_filepath = os.path.join(SPEC_DIR, 'gbp-test2.spec')
+        spec = SpecFile(spec_filepath)
+
+        # Read changelog
+        eq_(spec.get_changelog(),
+            "* Tue Feb 04 2014 Name <email> 1\n- My change\n\n\n")
+
+        # Set changelog and check again
+        new_text = "* Wed Feb 05 2014 Name <email> 2\n- New entry\n\n\n"
+        spec.set_changelog(new_text)
+        eq_(spec.get_changelog(), new_text)
+
+    def test_quirks(self):
+        """Test spec that is broken/has anomalities"""
+        spec_filepath = os.path.join(SPEC_DIR, 'gbp-test-quirks.spec')
+        spec = SpecFile(spec_filepath)
+
+        # Check that we quess orig source and prefix correctly
+        assert spec.orig_src['prefix'] == 'foobar/'
+
+    def test_tags(self):
+        """Test parsing of all the different tags of spec file"""
+        spec_filepath = os.path.join(SPEC_DIR, 'gbp-test-tags.spec')
+        spec = SpecFileTester(spec_filepath)
+
+        # Check all the tags
+        for name, val in spec.protected('_tags').iteritems():
+            rval = None
+            if name in ('version', 'release', 'epoch'):
+                rval = '0'
+            elif name in ('autoreq', 'autoprov', 'autoreqprov'):
+                rval = 'No'
+            elif name not in spec.protected('_listtags'):
+                rval = 'my_%s' % name
+            if rval:
+                assert val['value'] == rval, ("'%s:' is '%s', expecting '%s'" %
+                                              (name, val['value'], rval))
+            assert spec.ignorepatches == []
+            # Check patch numbers and patch filenames
+            patches = {}
+            for patch in spec.protected('_tags')['patch']['lines']:
+                patches[patch['num']] = patch['linevalue']
+
+            assert patches == {0: 'my_patch0', -1: 'my_patch'}
+
+    def test_patch_series(self):
+        """Test the getting the patches as a patchseries"""
+        spec_filepath = os.path.join(SPEC_DIR, 'gbp-test-native.spec')
+        spec = SpecFileTester(spec_filepath)
+
+        assert len(spec.patchseries()) == 0
+        spec.update_patches(['1.patch', '2.patch', '3.patch'], {})
+        assert len(spec.patchseries()) == 3
+        spec.protected('_gbp_tags')['ignore-patches'].append({'args': "0"})
+        spec.update_patches(['4.patch'], {})
+        assert len(spec.patchseries()) == 1
+        assert len(spec.patchseries(ignored=True)) == 2
+        spec.protected('_delete_special_macro')('patch', 0)
+        assert len(spec.patchseries(ignored=True)) == 1
+        series = spec.patchseries(unapplied=True, ignored=True)
+        assert len(series) == 2
+        assert os.path.basename(series[-1].path) == '1.patch'
+
+    def test_patch_series_quirks(self):
+        """Patches are applied in order different from the patch numbering"""
+        spec_filepath = os.path.join(SPEC_DIR, 'gbp-test-quirks.spec')
+        spec = SpecFileTester(spec_filepath)
+
+        # Check series is returned in the order the patches are applied
+        files = [os.path.basename(patch.path) for patch in spec.patchseries()]
+        assert files == ['05.patch', '01.patch']
+        # Also ignored patches are returned in the correct order
+        files = [os.path.basename(patch.path) for patch in
+                    spec.patchseries(ignored=True)]
+        assert files == ['05.patch', '02.patch', '01.patch']
+        # Unapplied patches are added to the end of the series
+        files = [os.path.basename(patch.path) for patch in
+                    spec.patchseries(unapplied=True)]
+        assert files == ['05.patch', '01.patch', '03.patch']
+        # Return all patches (for which tag is found)
+        files = [os.path.basename(patch.path) for patch in
+                    spec.patchseries(unapplied=True, ignored=True)]
+        assert files == ['05.patch', '02.patch', '01.patch', '03.patch',
+                         '04.patch']
+
+
+class TestUtilityFunctions(object):
+    """Test utility functions of L{gbp.rpm}"""
+    def setup(self):
+        self.tmpdir = tempfile.mkdtemp(prefix='gbp_%s_' % __name__, dir='.')
+
+    def teardown(self):
+        shutil.rmtree(self.tmpdir)
+
+    def test_parse_srpm(self):
+        """Test parse_srpm() function"""
+        parse_srpm(os.path.join(SRPM_DIR, 'gbp-test-1.0-1.src.rpm'))
+       assert_raises(GbpError, parse_srpm, 
+               os.path.join(DATA_DIR, 'notexists.src.rpm'))
+
+       """
+        with assert_raises(GbpError):
+            parse_srpm(os.path.join(DATA_DIR, 'notexists.src.rpm'))
+        with assert_raises(GbpError):
+            parse_srpm(os.path.join(SPEC_DIR, 'gbp-test.spec'))
+       """
+
+    def test_guess_spec(self):
+        """Test guess_spec() function"""
+        # Spec not found
+       assert_raises(NoSpecError, guess_spec,
+            DATA_DIR, recursive=False)
+
+       """
+        with assert_raises(NoSpecError):
+            guess_spec(DATA_DIR, recursive=False)
+       """
+
+        # Multiple spec files
+       assert_raises(NoSpecError, guess_spec,
+            DATA_DIR, recursive=True)
+       assert_raises(NoSpecError, guess_spec,
+            SPEC_DIR, recursive=False)
+
+       """
+        with assert_raises(NoSpecError):
+            guess_spec(DATA_DIR, recursive=True)
+        with assert_raises(NoSpecError):
+            guess_spec(SPEC_DIR, recursive=False)
+       """
+
+        # Spec found
+        spec = guess_spec(SPEC_DIR, recursive=False,
+                             preferred_name = 'gbp-test2.spec')
+        assert spec.specfile == 'gbp-test2.spec'
+        assert spec.specdir == SPEC_DIR
+
+    def test_guess_spec_repo(self):
+        """Test guess_spec_repo() and spec_from_repo() functions"""
+        # Create dummy repository with some commits
+        repo = GitRepository.create(self.tmpdir)
+        with open(os.path.join(repo.path, 'foo.txt'), 'w') as fobj:
+            fobj.write('bar\n')
+        repo.add_files('foo.txt')
+        repo.commit_all('Add dummy file')
+        os.mkdir(os.path.join(repo.path, 'packaging'))
+        shutil.copy(os.path.join(SPEC_DIR, 'gbp-test.spec'),
+                    os.path.join(repo.path, 'packaging'))
+        repo.add_files('packaging/gbp-test.spec')
+        repo.commit_all('Add spec file')
+
+        # Spec not found
+       assert_raises(NoSpecError, guess_spec_repo,
+            repo, 'HEAD~1', recursive=True)
+       assert_raises(NoSpecError, guess_spec_repo,
+            repo, 'HEAD', recursive=False)
+
+       """
+        with assert_raises(NoSpecError):
+            guess_spec_repo(repo, 'HEAD~1', recursive=True)
+        with assert_raises(NoSpecError):
+            guess_spec_repo(repo, 'HEAD', recursive=False)
+       """
+
+        # Spec found
+        spec = guess_spec_repo(repo, 'HEAD', 'packaging', recursive=False)
+        spec = guess_spec_repo(repo, 'HEAD', recursive=True)
+        assert spec.specfile == 'gbp-test.spec'
+        assert spec.specdir == 'packaging'
+        assert spec.specpath == 'packaging/gbp-test.spec'
+
+        # Test spec_from_repo()
+       assert_raises(NoSpecError, spec_from_repo,
+            repo, 'HEAD~1', 'packaging/gbp-test.spec')
+
+       """
+        with assert_raises(NoSpecError):
+            spec_from_repo(repo, 'HEAD~1', 'packaging/gbp-test.spec')
+       """
+
+        spec = spec_from_repo(repo, 'HEAD', 'packaging/gbp-test.spec')
+        assert spec.specfile == 'gbp-test.spec'
+
+# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·:
diff --git a/tests/test_rpm_data/rpmbuild/SOURCES/bar.tar.gz b/tests/test_rpm_data/rpmbuild/SOURCES/bar.tar.gz
new file mode 100644 (file)
index 0000000..f5dae80
Binary files /dev/null and b/tests/test_rpm_data/rpmbuild/SOURCES/bar.tar.gz differ
diff --git a/tests/test_rpm_data/rpmbuild/SOURCES/foo.txt b/tests/test_rpm_data/rpmbuild/SOURCES/foo.txt
new file mode 100644 (file)
index 0000000..25ed442
--- /dev/null
@@ -0,0 +1,3 @@
+FOO:
+
+file for testing rpm support of git-buildpackage.
diff --git a/tests/test_rpm_data/rpmbuild/SOURCES/gbp-test-1.0.tar.bz2 b/tests/test_rpm_data/rpmbuild/SOURCES/gbp-test-1.0.tar.bz2
new file mode 100644 (file)
index 0000000..7d0759f
Binary files /dev/null and b/tests/test_rpm_data/rpmbuild/SOURCES/gbp-test-1.0.tar.bz2 differ
diff --git a/tests/test_rpm_data/rpmbuild/SOURCES/gbp-test-native-1.0.zip b/tests/test_rpm_data/rpmbuild/SOURCES/gbp-test-native-1.0.zip
new file mode 100644 (file)
index 0000000..22a273d
Binary files /dev/null and b/tests/test_rpm_data/rpmbuild/SOURCES/gbp-test-native-1.0.zip differ
diff --git a/tests/test_rpm_data/rpmbuild/SOURCES/gbp-test2-3.0.tar.gz b/tests/test_rpm_data/rpmbuild/SOURCES/gbp-test2-3.0.tar.gz
new file mode 100644 (file)
index 0000000..7b3eaf3
Binary files /dev/null and b/tests/test_rpm_data/rpmbuild/SOURCES/gbp-test2-3.0.tar.gz differ
diff --git a/tests/test_rpm_data/rpmbuild/SOURCES/my.patch b/tests/test_rpm_data/rpmbuild/SOURCES/my.patch
new file mode 100644 (file)
index 0000000..50870df
--- /dev/null
@@ -0,0 +1,9 @@
+diff --git a/dummy.sh b/dummy.sh
+index 8c33db6..6f04268 100755
+--- dummy.sh
++++ dummy.sh
+@@ -1,3 +1,3 @@
+ #!/bin/sh
+-echo "Hello world"
++echo "Hello GBP"
diff --git a/tests/test_rpm_data/rpmbuild/SOURCES/my2.patch b/tests/test_rpm_data/rpmbuild/SOURCES/my2.patch
new file mode 100644 (file)
index 0000000..ad5ca2d
--- /dev/null
@@ -0,0 +1,7 @@
+diff --git a/mydir/myfile.txt b/mydir/myfile.txt
+new file mode 100644
+index 0000000..2cdad29
+--- /dev/null
++++ b/mydir/myfile.txt
+@@ -0,0 +1 @@
++Dummy
diff --git a/tests/test_rpm_data/rpmbuild/SOURCES/my3.patch b/tests/test_rpm_data/rpmbuild/SOURCES/my3.patch
new file mode 100644 (file)
index 0000000..9fee859
--- /dev/null
@@ -0,0 +1,7 @@
+diff --git a/README b/README
+index a1311cb..a59f1b9 100644
+--- a/README
++++ b/README
+@@ -1 +1 @@
+-Just for testing git-buildpackage.
++Just for testing GBP.
diff --git a/tests/test_rpm_data/rpmbuild/SPECS/gbp-test-native.spec b/tests/test_rpm_data/rpmbuild/SPECS/gbp-test-native.spec
new file mode 100644 (file)
index 0000000..38b07e4
--- /dev/null
@@ -0,0 +1,34 @@
+Name:       gbp-test-native
+Summary:    Test package for git-buildpackage
+Version:    1.0
+Release:    1
+Group:      Development/Libraries
+License:    GPLv2
+Source1:    %{name}-%{version}.zip
+BuildRequires:  unzip
+
+%description
+Package for testing the RPM functionality of git-buildpackage.
+Mimics a "native" package
+
+
+%prep
+unzip %{SOURCE1}
+%setup -T -D
+
+
+%build
+make
+
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/%{_datadir}/%{name}
+cp -R * %{buildroot}/%{_datadir}/%{name}
+
+
+
+%files
+%defattr(-,root,root,-)
+%dir %{_datadir}/%{name}
+%{_datadir}/%{name}
diff --git a/tests/test_rpm_data/rpmbuild/SPECS/gbp-test-native2.spec b/tests/test_rpm_data/rpmbuild/SPECS/gbp-test-native2.spec
new file mode 100644 (file)
index 0000000..34fd33d
--- /dev/null
@@ -0,0 +1,35 @@
+Name:       gbp-test-native2
+Summary:    Test package for git-buildpackage
+Version:    2.0
+Release:    0
+Group:      Development/Libraries
+License:    GPLv2
+Source:     foo.txt
+BuildRequires:  unzip
+
+%description
+Package for testing the RPM functionality of git-buildpackage.
+Mimics a "native" package that doesn't have any source tarball.
+
+
+%prep
+# Just create build dir
+%setup -T -c
+cp %{SOURCE0} .
+
+
+%build
+# Nothing to do
+
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/%{_datadir}/%{name}
+cp -R * %{buildroot}/%{_datadir}/%{name}
+
+
+
+%files
+%defattr(-,root,root,-)
+%dir %{_datadir}/%{name}
+%{_datadir}/%{name}
diff --git a/tests/test_rpm_data/rpmbuild/SPECS/gbp-test.spec b/tests/test_rpm_data/rpmbuild/SPECS/gbp-test.spec
new file mode 100644 (file)
index 0000000..c46a734
--- /dev/null
@@ -0,0 +1,42 @@
+Name:       gbp-test
+Summary:    Test package for git-buildpackage
+Version:    1.0
+Release:    1
+Group:      Development/Libraries
+License:    GPLv2
+Source:     %{name}-%{version}.tar.bz2
+Source1:    foo.txt
+Source20:   bar.tar.gz
+# Gbp-Ignore-Patches: 0
+Patch0:     my.patch
+Patch10:    my2.patch
+Patch20:    my3.patch
+
+
+%description
+Package for testing the RPM functionality of git-buildpackage.
+
+
+%prep
+%setup -n %{name} -a 20
+
+%patch0
+%patch10 -p1
+
+
+%build
+make
+
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/%{_datadir}/%{name}
+cp -R * %{buildroot}/%{_datadir}/%{name}
+install %{SOURCE0} %{buildroot}/%{_datadir}/%{name}
+
+
+
+%files
+%defattr(-,root,root,-)
+%dir %{_datadir}/%{name}
+%{_datadir}/%{name}
diff --git a/tests/test_rpm_data/rpmbuild/SPECS/gbp-test2.spec b/tests/test_rpm_data/rpmbuild/SPECS/gbp-test2.spec
new file mode 100644 (file)
index 0000000..8a92725
--- /dev/null
@@ -0,0 +1,60 @@
+Name:       gbp-test2
+Summary:    Test package 2 for git-buildpackage
+Epoch:      2
+Version:    3.0
+Release:    0
+Group:      Development/Libraries
+License:    GPLv2
+Source10:   ftp://ftp.host.com/%{name}-%{version}.tar.gz
+Source:     foo.txt
+Source20:   bar.tar.gz
+# Gbp-Ignore-Patches: -1
+Patch:      my.patch
+Patch10:    my2.patch
+Patch20:    my3.patch
+Packager:   Markus Lehtonen <markus.lehtonen@linux.intel.com>
+VCS:        myoldvcstag
+
+%description
+Package for testing the RPM functionality of git-buildpackage.
+
+%package empty
+Summary:    Empty subpackage
+
+%description empty
+Empty subpackage for the %{name} test package.
+
+
+%prep
+%setup -T -n %{name}-%{version} -c -a 10
+
+%patch
+%patch -P 10 -p1
+
+echo "Do things"
+
+# Gbp-Patch-Macros
+
+%build
+make
+
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/%{_datadir}/%{name}
+cp -R * %{buildroot}/%{_datadir}/%{name}
+install %{SOURCE0} %{buildroot}/%{_datadir}/%{name}
+
+
+%changelog
+* Tue Feb 04 2014 Name <email> 1
+- My change
+
+
+%files
+%defattr(-,root,root,-)
+%dir %{_datadir}/%{name}
+%{_datadir}/%{name}
+
+%files empty
+%defattr(-,root,root,-)
diff --git a/tests/test_rpm_data/rpmbuild/SPECS/gbp-test2.spec.orig b/tests/test_rpm_data/rpmbuild/SPECS/gbp-test2.spec.orig
new file mode 100644 (file)
index 0000000..ffae7e9
--- /dev/null
@@ -0,0 +1,46 @@
+Name:       gbp-test2
+Summary:    Test package 2 for git-buildpackage
+Epoch:      2
+Version:    3.0
+Release:    0
+Group:      Development/Libraries
+License:    GPLv2
+Source10:   ftp://ftp.host.com/%{name}-%{version}.tar.gz
+Source:     foo.txt
+Source20:   bar.tar.gz
+# Gbp-Ignore-Patches: 0
+Patch:      my.patch
+Patch10:    my2.patch
+Patch20:    my3.patch
+Packager:   Markus Lehtonen <markus.lehtonen@linux.intel.com>
+
+%description
+Package for testing the RPM functionality of git-buildpackage.
+
+
+%prep
+%setup -T -n %{name}-%{version} -c -a 10
+
+%patch
+%patch -P 10 -p1
+
+echo "Do things"
+
+# Gbp-Patch-Macros
+
+%build
+make
+
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/%{_datadir}/%{name}
+cp -R * %{buildroot}/%{_datadir}/%{name}
+install %{SOURCE0} %{buildroot}/%{_datadir}/%{name}
+
+
+
+%files
+%defattr(-,root,root,-)
+%dir %{_datadir}/%{name}
+%{_datadir}/%{name}
diff --git a/tests/test_rpm_data/specs/gbp-test-native.spec b/tests/test_rpm_data/specs/gbp-test-native.spec
new file mode 120000 (symlink)
index 0000000..60de36f
--- /dev/null
@@ -0,0 +1 @@
+../rpmbuild/SPECS/gbp-test-native.spec
\ No newline at end of file
diff --git a/tests/test_rpm_data/specs/gbp-test-native2.spec b/tests/test_rpm_data/specs/gbp-test-native2.spec
new file mode 120000 (symlink)
index 0000000..ad13ad6
--- /dev/null
@@ -0,0 +1 @@
+../rpmbuild/SPECS/gbp-test-native2.spec
\ No newline at end of file
diff --git a/tests/test_rpm_data/specs/gbp-test-quirks.spec b/tests/test_rpm_data/specs/gbp-test-quirks.spec
new file mode 100644 (file)
index 0000000..bb56b00
--- /dev/null
@@ -0,0 +1,30 @@
+#
+# Spec for testing some quirks of spec parsing
+#
+
+Name:           pkg_name
+Summary:        Spec for testing some quirks of spec parsing
+Version:        0.1
+Release:        1.2
+License:        GPLv2
+Source1:        foobar.tar.gz
+# Gbp-Ignore-Patches: 2 4 888
+Patch1:         01.patch
+Patch2:         02.patch
+Patch3:         03.patch
+Patch4:         04.patch
+Patch5:         05.patch
+
+%description
+Spec for testing some quirks of spec parsing. No intended for building an RPM.
+
+%prep
+# We don't have Source0 so rpmbuild would fail, but gbp shouldn't crash
+%setup -q
+
+# Patches are applied out-of-order wrt. numbering
+%patch5
+%patch2
+%patch1
+# Patch 999 does not exist, rpmbuild would fail but GBP should not
+%patch999
diff --git a/tests/test_rpm_data/specs/gbp-test-reference.spec b/tests/test_rpm_data/specs/gbp-test-reference.spec
new file mode 100644 (file)
index 0000000..050d139
--- /dev/null
@@ -0,0 +1,43 @@
+Name:       gbp-test
+Summary:    Test package for git-buildpackage
+Version:    1.0
+Release:    1
+Group:      Development/Libraries
+License:    GPLv2
+Source:     %{name}-%{version}.tar.bz2
+Source1:    foo.txt
+Source20:   bar.tar.gz
+# Gbp-Ignore-Patches: 0
+Patch0:     my.patch
+# Patches auto-generated by git-buildpackage:
+Patch1:     new.patch
+
+
+%description
+Package for testing the RPM functionality of git-buildpackage.
+
+
+%prep
+%setup -n %{name} -a 20
+
+%patch0
+# new.patch
+%patch1 -p1
+
+
+%build
+make
+
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/%{_datadir}/%{name}
+cp -R * %{buildroot}/%{_datadir}/%{name}
+install %{SOURCE0} %{buildroot}/%{_datadir}/%{name}
+
+
+
+%files
+%defattr(-,root,root,-)
+%dir %{_datadir}/%{name}
+%{_datadir}/%{name}
diff --git a/tests/test_rpm_data/specs/gbp-test-reference2.spec b/tests/test_rpm_data/specs/gbp-test-reference2.spec
new file mode 100644 (file)
index 0000000..0fbe026
--- /dev/null
@@ -0,0 +1,47 @@
+Name:       gbp-test
+VCS:        myvcstag
+Summary:    Test package for git-buildpackage
+Version:    1.0
+Release:    1
+Group:      Development/Libraries
+License:    GPLv2
+Source:     %{name}-%{version}.tar.bz2
+Source1:    foo.txt
+Source20:   bar.tar.gz
+# Gbp-Ignore-Patches: 0
+Patch0:     my.patch
+# Patches auto-generated by git-buildpackage:
+Patch1:     new.patch
+
+
+%description
+Package for testing the RPM functionality of git-buildpackage.
+
+
+%prep
+%setup -n %{name} -a 20
+
+%patch0
+# new.patch
+%patch1 -p1
+
+
+%build
+make
+
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/%{_datadir}/%{name}
+cp -R * %{buildroot}/%{_datadir}/%{name}
+install %{SOURCE0} %{buildroot}/%{_datadir}/%{name}
+
+
+
+%files
+%defattr(-,root,root,-)
+%dir %{_datadir}/%{name}
+%{_datadir}/%{name}
+%changelog
+* Wed Feb 05 2014 Name <email> 1
+- New entry
diff --git a/tests/test_rpm_data/specs/gbp-test-tags.spec b/tests/test_rpm_data/specs/gbp-test-tags.spec
new file mode 100644 (file)
index 0000000..ee4c2b9
--- /dev/null
@@ -0,0 +1,74 @@
+#
+# Spec file for testing all RPM tags (that we know of
+#
+
+%define suse_release %(test -e /etc/SuSE-release && head -n1 /etc/SuSE-release | cut -d ' ' -f2 | cut --output-delimiter=0 -d. -f1,2 || echo 0)
+%if "%{suse_release}" >= "1201"
+%define test_weak_dep_tags 1
+%endif
+
+%define test_arch_os_tags %(test -n "$GBP_SKIP_ARCH_OS_TAGS" && echo 0 || echo 1)
+
+%define source_fn_base source
+%define patch_fn_base patch
+
+# Gbp-Undefined-Tag: foobar
+
+# Test that we accept different cases
+NAME:           my_name
+version:        0
+ReLeasE:        0
+
+# Rest of the tags
+Epoch:          0
+Summary:        my_summary
+License:        my_license
+Distribution:   my_distribution
+Vendor:         my_vendor
+Group:          my_group
+Packager:       my_packager
+Url:            my_url
+Vcs:            my_vcs
+Source:         my_source
+Patch:          my_%patch_fn_base
+Patch0:         my_%{patch_fn_base}0
+Nosource:       0
+Nopatch:        0
+#Icon:           my_icon
+BuildRoot:      my_buildroot
+Provides:       my_provides
+Requires:       my_requires
+Conflicts:      my_conflicts
+Obsoletes:      my_obsoletes
+BuildConflicts: my_buildconflicts
+BuildRequires:  my_buildrequires
+AutoReqProv:    No
+AutoReq:        No
+AutoProv:       No
+DistTag:        my_disttag
+BugUrl:         my_bugurl
+Collections:    my_collections
+
+%if 0%{?test_weak_dep_tags}
+Recommends:     my_recommends
+Suggests:       my_suggests
+Supplements:    my_supplements
+Enhances:       my_enhances
+BuildRecommends:my_buildrecommends
+BuildSuggests:  my_buildsuggests
+BuildSupplements:my_buildsupplements
+BuildEnhances:  my_buildenhances
+%endif
+
+# These should be filtered out by GBP
+%if "%{test_arch_os_tags}" != "0"
+BuildArch:      my_buildarch
+ExcludeArch:    my_excludearch
+ExclusiveArch:  my_exclusivearch
+ExcludeOs:      my_excludeos
+ExclusiveOs:    my_exclusiveos
+%endif
+
+%description
+Package for testing GBP.
+
diff --git a/tests/test_rpm_data/specs/gbp-test-updates-reference.spec b/tests/test_rpm_data/specs/gbp-test-updates-reference.spec
new file mode 100644 (file)
index 0000000..ff56f58
--- /dev/null
@@ -0,0 +1,44 @@
+#
+# Spec file for testing deleting/adding/updating tags and macros
+#
+
+# Gbp-Undefined-Tag: foobar
+
+# Test that we accept different cases
+Name:           my_name
+Version:        0
+Release:        1
+Summary:        my_summary
+License:        new license
+Distribution:   my_distribution
+Group:          my_group
+Packager:       my_packager
+Url:            my_url
+Vcs:            my_vcs
+Nosource:       0
+Nopatch:        0
+BuildRoot:      my_buildroot
+Provides:       my_provides
+Requires:       my_requires
+Conflicts:      my_conflicts
+Obsoletes:      my_obsoletes
+BuildConflicts: my_buildconflicts
+BuildRequires:  my_buildrequires
+AutoReqProv:    No
+AutoReq:        No
+AutoProv:       No
+DistTag:        my_disttag
+BugUrl:         my_bugurl
+Collections:    my_collections
+
+%description
+Package for testing GBP.
+
+%prep
+%setup -n my_prefix
+
+%patch0 my new args
+
+%build
+
+%install
diff --git a/tests/test_rpm_data/specs/gbp-test-updates.spec b/tests/test_rpm_data/specs/gbp-test-updates.spec
new file mode 100644 (file)
index 0000000..dc8ffbf
--- /dev/null
@@ -0,0 +1,49 @@
+#
+# Spec file for testing deleting/adding/updating tags and macros
+#
+
+# Gbp-Undefined-Tag: foobar
+
+# Test that we accept different cases
+Name:           my_name
+Version:        0
+Release:        1
+Summary:        my_summary
+License:        my_license
+Distribution:   my_distribution
+Vendor:         my_vendor
+Group:          my_group
+Packager:       my_packager
+Url:            my_url
+Vcs:            my_vcs
+Source:         my_source
+Patch:          my_%patch_fn_base
+Patch0:         my_%{patch_fn_base}0
+Nosource:       0
+Nopatch:        0
+BuildRoot:      my_buildroot
+Provides:       my_provides
+Requires:       my_requires
+Conflicts:      my_conflicts
+Obsoletes:      my_obsoletes
+BuildConflicts: my_buildconflicts
+BuildRequires:  my_buildrequires
+AutoReqProv:    No
+AutoReq:        No
+AutoProv:       No
+DistTag:        my_disttag
+BugUrl:         my_bugurl
+Collections:    my_collections
+
+%description
+Package for testing GBP.
+
+%prep
+%setup -n my_prefix
+
+%patch -b my_patch
+%patch -P0 -b my_patch0
+
+%build
+
+%install
diff --git a/tests/test_rpm_data/specs/gbp-test.spec b/tests/test_rpm_data/specs/gbp-test.spec
new file mode 120000 (symlink)
index 0000000..30ae284
--- /dev/null
@@ -0,0 +1 @@
+../rpmbuild/SPECS/gbp-test.spec
\ No newline at end of file
diff --git a/tests/test_rpm_data/specs/gbp-test2-reference.spec b/tests/test_rpm_data/specs/gbp-test2-reference.spec
new file mode 100644 (file)
index 0000000..1882131
--- /dev/null
@@ -0,0 +1,61 @@
+Name:       gbp-test2
+Summary:    Test package 2 for git-buildpackage
+Epoch:      2
+Version:    3.0
+Release:    0
+Group:      Development/Libraries
+License:    GPLv2
+Source10:   ftp://ftp.host.com/%{name}-%{version}.tar.gz
+Source:     foo.txt
+Source20:   bar.tar.gz
+# Gbp-Ignore-Patches: -1
+Patch:      my.patch
+# Patches auto-generated by git-buildpackage:
+Patch0:     new.patch
+Packager:   Markus Lehtonen <markus.lehtonen@linux.intel.com>
+
+%description
+Package for testing the RPM functionality of git-buildpackage.
+
+%package empty
+Summary:    Empty subpackage
+
+%description empty
+Empty subpackage for the %{name} test package.
+
+
+%prep
+%setup -T -n %{name}-%{version} -c -a 10
+
+%patch
+
+echo "Do things"
+
+# Gbp-Patch-Macros
+# new.patch
+%if 1
+%patch0 -p1
+%endif
+
+%build
+make
+
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/%{_datadir}/%{name}
+cp -R * %{buildroot}/%{_datadir}/%{name}
+install %{SOURCE0} %{buildroot}/%{_datadir}/%{name}
+
+
+%changelog
+* Wed Feb 05 2014 Name <email> 2
+- New entry
+
+%files
+%defattr(-,root,root,-)
+%dir %{_datadir}/%{name}
+%{_datadir}/%{name}
+
+%files empty
+%defattr(-,root,root,-)
diff --git a/tests/test_rpm_data/specs/gbp-test2-reference2.spec b/tests/test_rpm_data/specs/gbp-test2-reference2.spec
new file mode 100644 (file)
index 0000000..d41f450
--- /dev/null
@@ -0,0 +1,68 @@
+Name:       gbp-test2
+Summary:    Test package 2 for git-buildpackage
+Epoch:      2
+Version:    3.0
+Release:    0
+Group:      Development/Libraries
+License:    GPLv2
+Source10:   ftp://ftp.host.com/%{name}-%{version}.tar.gz
+Source:     foo.txt
+Source20:   bar.tar.gz
+# Gbp-Ignore-Patches: -1
+Patch:      my.patch
+# Patches auto-generated by git-buildpackage:
+Patch0:     1.patch
+Patch1:     2.patch
+Packager:   Markus Lehtonen <markus.lehtonen@linux.intel.com>
+VCS:        myvcstag
+
+%description
+Package for testing the RPM functionality of git-buildpackage.
+
+%package empty
+Summary:    Empty subpackage
+
+%description empty
+Empty subpackage for the %{name} test package.
+
+
+%prep
+%setup -T -n %{name}-%{version} -c -a 10
+
+%patch
+
+echo "Do things"
+
+# Gbp-Patch-Macros
+# 1.patch
+%if true
+%patch0 -p1
+%endif
+# 2.patch
+%ifarch %ix86
+%patch1 -p1
+%endif
+
+%build
+make
+
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/%{_datadir}/%{name}
+cp -R * %{buildroot}/%{_datadir}/%{name}
+install %{SOURCE0} %{buildroot}/%{_datadir}/%{name}
+
+
+%changelog
+* Tue Feb 04 2014 Name <email> 1
+- My change
+
+
+%files
+%defattr(-,root,root,-)
+%dir %{_datadir}/%{name}
+%{_datadir}/%{name}
+
+%files empty
+%defattr(-,root,root,-)
diff --git a/tests/test_rpm_data/specs/gbp-test2.spec b/tests/test_rpm_data/specs/gbp-test2.spec
new file mode 120000 (symlink)
index 0000000..af4080c
--- /dev/null
@@ -0,0 +1 @@
+../rpmbuild/SPECS/gbp-test2.spec
\ No newline at end of file
diff --git a/tests/test_rpm_data/srpms/gbp-test-1.0-1.src.rpm b/tests/test_rpm_data/srpms/gbp-test-1.0-1.src.rpm
new file mode 100644 (file)
index 0000000..74afbd6
Binary files /dev/null and b/tests/test_rpm_data/srpms/gbp-test-1.0-1.src.rpm differ
diff --git a/tests/test_rpm_data/srpms/gbp-test-native-1.0-1.src.rpm b/tests/test_rpm_data/srpms/gbp-test-native-1.0-1.src.rpm
new file mode 100644 (file)
index 0000000..1002aae
Binary files /dev/null and b/tests/test_rpm_data/srpms/gbp-test-native-1.0-1.src.rpm differ
diff --git a/tests/test_rpm_data/srpms/gbp-test-native2-2.0-0.src.rpm b/tests/test_rpm_data/srpms/gbp-test-native2-2.0-0.src.rpm
new file mode 100644 (file)
index 0000000..880b310
Binary files /dev/null and b/tests/test_rpm_data/srpms/gbp-test-native2-2.0-0.src.rpm differ
diff --git a/tests/test_rpm_data/srpms/gbp-test2-3.0-0.src.rpm b/tests/test_rpm_data/srpms/gbp-test2-3.0-0.src.rpm
new file mode 100644 (file)
index 0000000..1cf12c7
Binary files /dev/null and b/tests/test_rpm_data/srpms/gbp-test2-3.0-0.src.rpm differ