summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2013-01-11 16:36:28 +0200
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>2013-03-08 14:04:00 +0200
commit51e5bb883dd60ec20578b57828f48c610885b28b (patch)
tree718d665938655fcf57ff8dedeb631029c7b767cf
parentff0307174b3ceaa7a9c4ff628a9ea513d2123647 (diff)
downloadgit-buildpackage-51e5bb883dd60ec20578b57828f48c610885b28b.tar.gz
git-buildpackage-51e5bb883dd60ec20578b57828f48c610885b28b.tar.bz2
git-buildpackage-51e5bb883dd60ec20578b57828f48c610885b28b.zip
rpm helpers: yet another fix to patch numbering
'Patch:' does not indicate "patch number 0". Patch: and 'Patch0:' can both be present in the same spec file. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rw-r--r--gbp/rpm/__init__.py13
m---------tests/component/rpm/data0
-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
9 files changed, 25 insertions, 23 deletions
diff --git a/gbp/rpm/__init__.py b/gbp/rpm/__init__.py
index 372bdd59..7129a238 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):
"""no changelog found"""
pass
@@ -270,7 +267,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,
@@ -347,7 +344,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
@@ -421,8 +418,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)
@@ -440,6 +435,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/component/rpm/data b/tests/component/rpm/data
-Subproject a82b547dd777f1ca843232ce9e61ded942d0329
+Subproject aec4222cbd9e2efbd60c56ee4e9cc4d8eb7265b
diff --git a/tests/test_rpm.py b/tests/test_rpm.py
index 06b5faa8..85110f06 100644
--- a/tests/test_rpm.py
+++ b/tests/test_rpm.py
@@ -200,8 +200,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):
@@ -212,9 +212,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):
@@ -252,6 +252,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 46e553fa..6c4769c5 100644
--- a/tests/test_rpm_data/specs/gbp-test-tags.spec
+++ b/tests/test_rpm_data/specs/gbp-test-tags.spec
@@ -23,7 +23,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