From 59dd4dbcd84ce30faa6558ad0d052370077d3fe5 Mon Sep 17 00:00:00 2001 From: Dennis Gilmore Date: Wed, 18 Jan 2017 20:51:02 -0600 Subject: [PATCH] replace ${basearch} when updating the ref pungi-make-ostree has to run on the target arch so that rpm scriptlets can be ran. as a reult we can ask rpm what the basearch is for the running environment. For notifications we have to pass in the arch we are running for. Signed-off-by: Dennis Gilmore --- pungi/ostree/utils.py | 14 +++++++++++--- pungi/phases/ostree.py | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pungi/ostree/utils.py b/pungi/ostree/utils.py index 02540c92..d80fb9f8 100644 --- a/pungi/ostree/utils.py +++ b/pungi/ostree/utils.py @@ -17,6 +17,7 @@ import datetime import json import os +import rpmUtils.arch from pungi.util import makedirs @@ -29,14 +30,21 @@ def make_log_file(log_dir, filename): return os.path.join(log_dir, '%s.log' % filename) -def get_ref_from_treefile(treefile): - """Return ref name by parsing the tree config file""" +def get_ref_from_treefile(treefile, arch=None): + """ + Return ref name by parsing the tree config file. Replacing ${basearch} with + the basearch of the architecture we are running on or of the passed in arch. + """ ref = None if os.path.isfile(treefile): with open(treefile, 'r') as f: try: parsed = json.loads(f.read()) - ref = parsed['ref'] + if arch is None: + basearch = rpmUtils.arch.getBaseArch() + else: + basearch = rpmUtils.arch.getBaseArch(arch) + ref = parsed['ref'].replace('${basearch}', basearch) except Exception as e: print('Unable to get ref from treefile: %s' % e) else: diff --git a/pungi/phases/ostree.py b/pungi/phases/ostree.py index ebe03d0d..e61e969c 100644 --- a/pungi/phases/ostree.py +++ b/pungi/phases/ostree.py @@ -104,7 +104,7 @@ class OSTreeThread(WorkerThread): extra_config_file=extra_config_file) if compose.notifier: - ref = get_ref_from_treefile(os.path.join(repodir, config['treefile'])) + ref = get_ref_from_treefile(os.path.join(repodir, config['treefile']), arch) # 'pungi-make-ostree tree' writes commitid to commitid.log in logdir commitid = get_commitid_from_commitid_file(os.path.join(self.logdir, 'commitid.log')) compose.notifier.send('ostree',