summaryrefslogtreecommitdiff
path: root/gbp
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2012-11-01 16:36:16 +0200
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>2013-04-03 10:10:30 +0300
commitd307dbee5c06e07a7bb39b8dc420b057c0b6796e (patch)
tree86caa6258b1c47ca5a1e8116b0e99978b0d5f097 /gbp
parenta2bcc621bd4a55d838d1c143514717ed1b546b03 (diff)
downloadgit-buildpackage-d307dbee5c06e07a7bb39b8dc420b057c0b6796e.tar.gz
git-buildpackage-d307dbee5c06e07a7bb39b8dc420b057c0b6796e.tar.bz2
git-buildpackage-d307dbee5c06e07a7bb39b8dc420b057c0b6796e.zip
rpm: circumvent a bug in python-rpm
Which caused the packager tag to be incorrect in some cases. Rpm-python doesn't seem to reset spec.sourceHeader[rpm.RPMTAG_PACKAGER] if no packager tag is defined in the spec file. Thus, if we (in the same context) first parse spec A (which has a packager tag) and then spec B (which doesn't have a packager tag) python-rpm will give the packager of A for B as well. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Diffstat (limited to 'gbp')
-rw-r--r--gbp/rpm/__init__.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/gbp/rpm/__init__.py b/gbp/rpm/__init__.py
index dec4ac7b..1d24c5c2 100644
--- a/gbp/rpm/__init__.py
+++ b/gbp/rpm/__init__.py
@@ -117,6 +117,7 @@ class SrcRpmFile(object):
class SpecFile(object):
"""Class for parsing/modifying spec files"""
+ tag_re = re.compile(r'^(?P<name>[a-z][a-z0-9]*)\s*:\s*(?P<value>\S(.*\S)?)\s*$', flags=re.I)
source_re = re.compile(r'^Source(?P<srcnum>[0-9]+)?\s*:\s*(?P<name>[^\s].*[^\s])\s*$', flags=re.I)
patchtag_re = re.compile(r'^Patch(?P<patchnum>[0-9]+)?\s*:\s*(?P<name>\S.*)$', flags=re.I)
patchmacro_re = re.compile(r'^%patch(?P<patchnum>[0-9]+)?(\s+(?P<args>.*))?$')
@@ -160,6 +161,13 @@ class SpecFile(object):
f.close()
loc = self.parse_content()
+
+ # Find 'Packager' tag. Needed to circumvent a bug in python-rpm where
+ # spec.sourceHeader[rpm.RPMTAG_PACKAGER] is not reset when a new spec
+ # file is parsed
+ if loc['packagertag'] is None:
+ self.packager = None
+
# Update sources info (basically possible macros expanded by spec.__init__()
# And, double-check that we parsed spec content correctly
for (name, num, typ) in self.specinfo.sources:
@@ -253,6 +261,7 @@ class SpecFile(object):
"""
# Check location of "interesting" tags and macros
ret = {'nametag': None,
+ 'packagertag': None,
'setupmacro': None,
'prepmacro': None}
@@ -381,12 +390,16 @@ class SpecFile(object):
continue
# Only search for the last occurrence of the following
- if re.match("^\s*Name:.*$", line, flags=re.I):
- ret['setupmacro'] = i
+ m = self.tag_re.match(line)
+ if m:
+ if m.group('name').lower() == 'name':
+ ret['nametag'] = i
+ if m.group('name').lower() == 'packager':
+ ret['packagertag'] = i
+ continue
if re.match("^%prep(\s.*)?$", line):
ret['prepmacro'] = i
continue
-
return ret