@@ -69,3 +69,6 @@ tramp
Session.vim
.netrwhist
*~
+
+# rpm
+*/*.spec.processed
\ No newline at end of file
@@ -404,7 +404,12 @@ def get_image_id(args,image_name):
def run_rpm_build(args,spec_file,env):
version = get_version();
- with open(spec_file,"r") as F:
+
+ # Pre-process file with rpm spec to avoid manually replacing macros
+ f = open(spec_file + ".processed", "w");
+ subprocess.check_call(["rpmspec", "-P", spec_file], stdout=f);
+
+ with open(spec_file + ".processed" ,"r") as F:
for ln in F:
if ln.startswith("Version:"):
ver = ln.strip().partition(' ')[2].strip();
@@ -412,7 +417,6 @@ def run_rpm_build(args,spec_file,env):
if ln.startswith("Source:"):
tarfn = ln.strip().partition(' ')[2].strip();
- tarfn = tarfn.replace("%{version}",version);
image_id = get_image_id(args,env.image_name());
with private_tmp(args) as tmpdir:
Generate a temporary file with the spec file parsed and all its macro replaced. Avoid manually replacing Version and handle extra macros Signed-off-by: Nicolas Morey-Chaisemartin <NMoreyChaisemartin@suse.com> --- .gitignore | 3 +++ buildlib/cbuild | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-)