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@xxxxxxxx> --- .gitignore | 3 +++ buildlib/cbuild | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index f31a0617..52c7af2f 100644 --- a/.gitignore +++ b/.gitignore @@ -69,3 +69,6 @@ tramp Session.vim .netrwhist *~ + +# rpm +*/*.spec.processed \ No newline at end of file diff --git a/buildlib/cbuild b/buildlib/cbuild index 5228ec1b..cf7828eb 100755 --- a/buildlib/cbuild +++ b/buildlib/cbuild @@ -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: -- 2.14.0.rc1.4.gab083fa77.dirty -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html