summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gbp/rpm/__init__.py13
-rw-r--r--tests/test_rpm.py8
-rw-r--r--tests/test_rpm_data/rpmbuild/SPECS/gbp-test2.spec2
-rw-r--r--tests/test_rpm_data/specs/gbp-test-tags.spec3
-rw-r--r--tests/test_rpm_data/specs/gbp-test-updates-reference.spec4
-rw-r--r--tests/test_rpm_data/specs/gbp-test-updates.spec6
-rw-r--r--tests/test_rpm_data/specs/gbp-test2-reference.spec6
-rw-r--r--tests/test_rpm_data/specs/gbp-test2-reference2.spec6
8 files changed, 25 insertions, 23 deletions
diff --git a/gbp/rpm/__init__.py b/gbp/rpm/__init__.py
index cc42b530..c01b44c5 100644
--- a/gbp/rpm/__init__.py
+++ b/gbp/rpm/__init__.py
@@ -43,9 +43,6 @@ except ImportError:
gbp.log.debug("Failed to import '%s' as rpm python module, using host's default rpm library instead" % RpmPkgPolicy.python_rpmlib_module_name)
import rpm
-# define a large number to check the valid id of source file
-MAX_SOURCE_NUMBER = 99999
-
class NoSpecError(Exception):
"""Spec file parsing error"""
@@ -278,7 +275,7 @@ class SpecFile(object):
'setup_options': None, }
# 'Patch:' tags
elif tagname == 'patch':
- tagnum = 0 if tagnum is None else tagnum
+ tagnum = -1 if tagnum is None else tagnum
new_patch = {'name': matchobj.group('name').strip(),
'filename': matchobj.group('name'),
'apply': False,
@@ -355,7 +352,7 @@ class SpecFile(object):
elif opts.patchnum:
directiveid = int(opts.patchnum)
else:
- directiveid = 0
+ directiveid = -1
if opts.strip:
self.patches[directiveid]['strip'] = opts.strip
@@ -425,8 +422,6 @@ class SpecFile(object):
# And, double-check that we parsed spec content correctly
for (name, num, typ) in self._specinfo.sources:
# workaround rpm parsing bug
- if num >= MAX_SOURCE_NUMBER:
- num = 0
if typ == 1 or typ == 9:
if num in self.sources:
self.sources[num]['filename'] = os.path.basename(name)
@@ -444,6 +439,10 @@ class SpecFile(object):
else:
gbp.log.err("BUG: we didn't correctly parse all 'Source' tags!")
if typ == 2 or typ == 10:
+ # Patch tag without any number defined is treated by RPM as
+ # having number (2^31-1), we use number -1
+ if num >= pow(2,30):
+ num = -1
if num in self.patches:
self.patches[num]['filename'] = name
else:
diff --git a/tests/test_rpm.py b/tests/test_rpm.py
index 7124c991..29ecb56c 100644
--- a/tests/test_rpm.py
+++ b/tests/test_rpm.py
@@ -198,8 +198,8 @@ class TestSpecFile(object):
prev = spec.protected('_delete_tag')('Vendor', None)
spec.protected('_set_tag')('License', None, 'new license', prev)
spec.protected('_delete_tag')('source', 0)
- spec.protected('_delete_tag')('patch', 1)
spec.protected('_delete_tag')('patch', 0)
+ spec.protected('_delete_tag')('patch', -1)
prev = spec.protected('_delete_tag')('invalidtag', None)
with assert_raises(GbpError):
@@ -210,9 +210,9 @@ class TestSpecFile(object):
spec.set_tag('invalidtag', None, 'value')
# Mangle macros
- prev = spec.protected('_delete_special_macro')('patch', 0)
+ prev = spec.protected('_delete_special_macro')('patch', -1)
spec.protected('_delete_special_macro')('patch', 123)
- spec.protected('_set_special_macro')('patch', 1, 'my new args', prev)
+ spec.protected('_set_special_macro')('patch', 0, 'my new args', prev)
with assert_raises(GbpError):
spec.protected('_delete_special_macro')('invalidmacro', 0)
with assert_raises(GbpError):
@@ -250,6 +250,8 @@ class TestSpecFile(object):
(name, val['value'], rval))
assert spec.ignorepatches == []
+ assert spec.patches.keys() == [0, -1]
+
class TestUtilityFunctions(object):
"""Test utility functions of L{gbp.rpm}"""
diff --git a/tests/test_rpm_data/rpmbuild/SPECS/gbp-test2.spec b/tests/test_rpm_data/rpmbuild/SPECS/gbp-test2.spec
index 4180a877..dd9e2ec2 100644
--- a/tests/test_rpm_data/rpmbuild/SPECS/gbp-test2.spec
+++ b/tests/test_rpm_data/rpmbuild/SPECS/gbp-test2.spec
@@ -8,7 +8,7 @@ License: GPLv2
Source10: ftp://ftp.host.com/%{name}-%{version}.tar.gz
Source: foo.txt
Source20: bar.tar.gz
-# Gbp-Ignore-Patches: 0
+# Gbp-Ignore-Patches: -1
Patch: my.patch
Patch10: my2.patch
Patch20: my3.patch
diff --git a/tests/test_rpm_data/specs/gbp-test-tags.spec b/tests/test_rpm_data/specs/gbp-test-tags.spec
index 9841a39e..47421a9d 100644
--- a/tests/test_rpm_data/specs/gbp-test-tags.spec
+++ b/tests/test_rpm_data/specs/gbp-test-tags.spec
@@ -27,7 +27,8 @@ Packager: my_packager
Url: my_url
Vcs: my_vcs
Source: my_source
-Patch0: my_patch
+Patch: my_patch
+Patch0: my_patch0
Nosource: 0
Nopatch: 0
#Icon: my_icon
diff --git a/tests/test_rpm_data/specs/gbp-test-updates-reference.spec b/tests/test_rpm_data/specs/gbp-test-updates-reference.spec
index eae2739a..ff56f589 100644
--- a/tests/test_rpm_data/specs/gbp-test-updates-reference.spec
+++ b/tests/test_rpm_data/specs/gbp-test-updates-reference.spec
@@ -16,7 +16,7 @@ Packager: my_packager
Url: my_url
Vcs: my_vcs
Nosource: 0
-Nopatch: 1
+Nopatch: 0
BuildRoot: my_buildroot
Provides: my_provides
Requires: my_requires
@@ -37,7 +37,7 @@ Package for testing GBP.
%prep
%setup -n my_prefix
-%patch1 my new args
+%patch0 my new args
%build
diff --git a/tests/test_rpm_data/specs/gbp-test-updates.spec b/tests/test_rpm_data/specs/gbp-test-updates.spec
index 0bc15712..dc8ffbf9 100644
--- a/tests/test_rpm_data/specs/gbp-test-updates.spec
+++ b/tests/test_rpm_data/specs/gbp-test-updates.spec
@@ -18,9 +18,9 @@ Url: my_url
Vcs: my_vcs
Source: my_source
Patch: my_%patch_fn_base
-Patch1: my_%{patch_fn_base}1
+Patch0: my_%{patch_fn_base}0
Nosource: 0
-Nopatch: 1
+Nopatch: 0
BuildRoot: my_buildroot
Provides: my_provides
Requires: my_requires
@@ -42,7 +42,7 @@ Package for testing GBP.
%setup -n my_prefix
%patch -b my_patch
-%patch -P1 -b my_patch0
+%patch -P0 -b my_patch0
%build
diff --git a/tests/test_rpm_data/specs/gbp-test2-reference.spec b/tests/test_rpm_data/specs/gbp-test2-reference.spec
index fbb7ad82..e31930d7 100644
--- a/tests/test_rpm_data/specs/gbp-test2-reference.spec
+++ b/tests/test_rpm_data/specs/gbp-test2-reference.spec
@@ -8,10 +8,10 @@ License: GPLv2
Source10: ftp://ftp.host.com/%{name}-%{version}.tar.gz
Source: foo.txt
Source20: bar.tar.gz
-# Gbp-Ignore-Patches: 0
+# Gbp-Ignore-Patches: -1
Patch: my.patch
# Patches auto-generated by git-buildpackage:
-Patch1: new.patch
+Patch0: new.patch
Packager: Markus Lehtonen <markus.lehtonen@linux.intel.com>
%description
@@ -27,7 +27,7 @@ echo "Do things"
# Gbp-Patch-Macros
# new.patch
-%patch1 -p1
+%patch0 -p1
%build
make
diff --git a/tests/test_rpm_data/specs/gbp-test2-reference2.spec b/tests/test_rpm_data/specs/gbp-test2-reference2.spec
index 02356d0a..095600d3 100644
--- a/tests/test_rpm_data/specs/gbp-test2-reference2.spec
+++ b/tests/test_rpm_data/specs/gbp-test2-reference2.spec
@@ -8,10 +8,10 @@ License: GPLv2
Source10: ftp://ftp.host.com/%{name}-%{version}.tar.gz
Source: foo.txt
Source20: bar.tar.gz
-# Gbp-Ignore-Patches: 0
+# Gbp-Ignore-Patches: -1
Patch: my.patch
# Patches auto-generated by git-buildpackage:
-Patch1: new.patch
+Patch0: new.patch
Packager: Markus Lehtonen <markus.lehtonen@linux.intel.com>
VCS: myvcstag
@@ -28,7 +28,7 @@ echo "Do things"
# Gbp-Patch-Macros
# new.patch
-%patch1 -p1
+%patch0 -p1
%build
make