rpm: support conditionals in patch-export
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Mon, 25 Feb 2013 10:11:14 +0000 (12:11 +0200)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Fri, 14 Nov 2014 12:46:23 +0000 (14:46 +0200)
One can now define conditional patches that are enclosed in '%if' or
'%ifarch' when the spec file is updated. One can do this by defining
'Gbp-Rpm-If: <conditional>' and 'Gbp-Rpm-IfArch: <conditional>' in the
commit message.

Only one conditional per patch is supported, i.e. you cannot define
'IfArch' and 'If' for the same patch.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gbp/scripts/pq_rpm.py

index d3da13a8a6989ad67a7fe3eb7575ea9ffb1d64d8..edb327f6be16dfd315f8c3e0ae2c3ab41018c4b0 100755 (executable)
@@ -110,7 +110,8 @@ def generate_patches(repo, start, squash, end, outdir, options):
     # Generate patches
     for commit in reversed(repo.get_commits(start, end_commit)):
         info = repo.get_commit_info(commit)
-        cmds = parse_gbp_commands(info, 'gbp-rpm', ('ignore'), None)[0]
+        cmds = parse_gbp_commands(info, 'gbp-rpm', ('ignore'),
+                                  ('if', 'ifarch'))[0]
         if not 'ignore' in cmds:
             patch_fn = format_patch(outdir, repo, info, patches,
                                     options.patch_numbers,
@@ -164,9 +165,9 @@ def update_patch_series(repo, spec, start, end, options):
     # Unlink old patch files and generate new patches
     rm_patch_files(spec)
 
-    patches, _commands = generate_patches(repo, start, squash, end,
-                                          spec.specdir, options)
-    spec.update_patches(patches)
+    patches, commands = generate_patches(repo, start, squash, end,
+                                         spec.specdir, options)
+    spec.update_patches(patches, commands)
     spec.write_spec_file()