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 <dennis@ausil.us>
This commit is contained in:
Dennis Gilmore 2017-01-18 20:51:02 -06:00
parent 4edf567bd4
commit 59dd4dbcd8
2 changed files with 12 additions and 4 deletions

View File

@ -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:

View File

@ -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',