Merge #309 Add compatibility for Python 2.6
This commit is contained in:
commit
264c7b1ddf
26 changed files with 184 additions and 129 deletions
|
|
@ -25,7 +25,7 @@ def make_log_file(log_dir, filename):
|
|||
if not log_dir:
|
||||
return None
|
||||
ensure_dir(log_dir)
|
||||
return os.path.join(log_dir, '{}.log'.format(filename))
|
||||
return os.path.join(log_dir, '%s.log' % filename)
|
||||
|
||||
|
||||
def init_ostree_repo(repo, log_dir=None):
|
||||
|
|
@ -33,13 +33,13 @@ def init_ostree_repo(repo, log_dir=None):
|
|||
log_file = make_log_file(log_dir, 'init-ostree-repo')
|
||||
if not os.path.isdir(repo) or not os.listdir(repo):
|
||||
ensure_dir(repo)
|
||||
shortcuts.run(['ostree', 'init', '--repo={}'.format(repo), '--mode=archive-z2'],
|
||||
shortcuts.run(['ostree', 'init', '--repo=%s' % repo, '--mode=archive-z2'],
|
||||
show_cmd=True, stdout=True, logfile=log_file)
|
||||
|
||||
|
||||
def make_ostree_repo(repo, config, log_dir=None):
|
||||
log_file = make_log_file(log_dir, 'create-ostree-repo')
|
||||
shortcuts.run(['rpm-ostree', 'compose', 'tree', '--repo={}'.format(repo), config],
|
||||
shortcuts.run(['rpm-ostree', 'compose', 'tree', '--repo=%s' % repo, config],
|
||||
show_cmd=True, stdout=True, logfile=log_file)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -103,8 +103,8 @@ class ImageConfigMixin(object):
|
|||
def get_config(self, cfg, opt):
|
||||
return cfg.get(
|
||||
opt, self.compose.conf.get(
|
||||
'{}_{}'.format(self.name, opt), self.compose.conf.get(
|
||||
'global_{}'.format(opt))))
|
||||
'%s_%s' % (self.name, opt), self.compose.conf.get(
|
||||
'global_%s' % opt)))
|
||||
|
||||
def get_release(self, cfg):
|
||||
"""
|
||||
|
|
@ -113,7 +113,7 @@ class ImageConfigMixin(object):
|
|||
global settings.
|
||||
"""
|
||||
for key, conf in [('release', cfg),
|
||||
('{}_release'.format(self.name), self.compose.conf),
|
||||
('%s_release' % self.name, self.compose.conf),
|
||||
('global_release', self.compose.conf)]:
|
||||
if key in conf:
|
||||
return conf[key] or self.compose.image_release
|
||||
|
|
@ -126,7 +126,7 @@ class ImageConfigMixin(object):
|
|||
"""
|
||||
if 'ksurl' in cfg:
|
||||
return util.resolve_git_url(cfg['ksurl'])
|
||||
if '{}_ksurl'.format(self.name) in self.compose.conf:
|
||||
if '%s_ksurl' % self.name in self.compose.conf:
|
||||
return self.phase_ksurl
|
||||
if 'global_ksurl' in self.compose.conf:
|
||||
return self.global_ksurl
|
||||
|
|
@ -137,7 +137,7 @@ class ImageConfigMixin(object):
|
|||
"""Get phase level ksurl, making sure to resolve it only once."""
|
||||
# The phase-level setting is cached as instance attribute of the phase.
|
||||
if not self._phase_ksurl:
|
||||
ksurl = self.compose.conf.get('{}_ksurl'.format(self.name))
|
||||
ksurl = self.compose.conf.get('%s_ksurl' % self.name)
|
||||
self._phase_ksurl = util.resolve_git_url(ksurl)
|
||||
return self._phase_ksurl
|
||||
|
||||
|
|
|
|||
|
|
@ -127,16 +127,16 @@ class CreateisoPhase(PhaseBase):
|
|||
|
||||
cmd['cmd'] = [
|
||||
'pungi-createiso',
|
||||
'--output-dir={}'.format(iso_dir),
|
||||
'--iso-name={}'.format(filename),
|
||||
'--volid={}'.format(volid),
|
||||
'--graft-points={}'.format(graft_points),
|
||||
'--arch={}'.format(arch),
|
||||
'--output-dir=%s' % iso_dir,
|
||||
'--iso-name=%s' % filename,
|
||||
'--volid=%s' % volid,
|
||||
'--graft-points=%s' % graft_points,
|
||||
'--arch=%s' % arch,
|
||||
]
|
||||
|
||||
if bootable:
|
||||
cmd['cmd'].append(
|
||||
'--buildinstall-method={}'.format(self.compose.conf['buildinstall_method'])
|
||||
'--buildinstall-method=%s' % self.compose.conf['buildinstall_method']
|
||||
)
|
||||
|
||||
if self.compose.supported:
|
||||
|
|
@ -145,8 +145,8 @@ class CreateisoPhase(PhaseBase):
|
|||
if self.compose.conf.get('create_jigdo', True):
|
||||
jigdo_dir = self.compose.paths.compose.jigdo_dir(arch, variant)
|
||||
cmd['cmd'].extend([
|
||||
'--jigdo-dir={}'.format(jigdo_dir),
|
||||
'--os-tree={}'.format(os_tree),
|
||||
'--jigdo-dir=%s' % jigdo_dir,
|
||||
'--os-tree=%s' % os_tree,
|
||||
])
|
||||
|
||||
commands.append((cmd, variant, arch))
|
||||
|
|
|
|||
|
|
@ -67,8 +67,8 @@ class OSTreeThread(WorkerThread):
|
|||
def _run_ostree_cmd(self, compose, variant, arch, config, config_repo):
|
||||
cmd = [
|
||||
'pungi-make-ostree',
|
||||
'--log-dir={}'.format(os.path.join(self.logdir)),
|
||||
'--treefile={}'.format(os.path.join(config_repo, config['treefile'])),
|
||||
'--log-dir=%s' % os.path.join(self.logdir),
|
||||
'--treefile=%s' % os.path.join(config_repo, config['treefile']),
|
||||
config['ostree_repo']
|
||||
]
|
||||
|
||||
|
|
@ -107,8 +107,8 @@ def tweak_file(path, source_repo):
|
|||
"""
|
||||
with open(path, 'r') as f:
|
||||
contents = f.read()
|
||||
replacement = 'baseurl={}'.format(source_repo)
|
||||
contents = re.sub(r'^(mirrorlist|metalink|baseurl)=.*$',
|
||||
replacement, contents, flags=re.MULTILINE)
|
||||
replacement = 'baseurl=%s' % source_repo
|
||||
exp = re.compile(r'^(mirrorlist|metalink|baseurl)=.*$', re.MULTILINE)
|
||||
contents = exp.sub(replacement, contents)
|
||||
with open(path, 'w') as f:
|
||||
f.write(contents)
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class OstreeInstallerThread(WorkerThread):
|
|||
def worker(self, compose, variant, arch, config):
|
||||
msg = 'Ostree phase for variant %s, arch %s' % (variant.uid, arch)
|
||||
self.pool.log_info('[BEGIN] %s' % msg)
|
||||
self.logdir = compose.paths.log.topdir('{}/ostree_installer'.format(arch))
|
||||
self.logdir = compose.paths.log.topdir('%s/ostree_installer' % arch)
|
||||
|
||||
source_repo = self._get_source_repo(compose, arch, config['source_repo_from'])
|
||||
output_dir = os.path.join(compose.paths.work.topdir(arch), variant.uid, 'ostree_installer')
|
||||
|
|
|
|||
|
|
@ -456,10 +456,10 @@ def find_old_compose(old_compose_dirs, release_short, release_version,
|
|||
def process_args(fmt, args):
|
||||
"""Given a list of arguments, format each value with the format string.
|
||||
|
||||
>>> process_args('--opt={}', ['foo', 'bar'])
|
||||
>>> process_args('--opt=%s', ['foo', 'bar'])
|
||||
['--opt=foo', '--opt=bar']
|
||||
"""
|
||||
return [fmt.format(val) for val in force_list(args or [])]
|
||||
return [fmt % val for val in force_list(args or [])]
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
|
|
|
|||
|
|
@ -58,11 +58,11 @@ class LoraxWrapper(object):
|
|||
if volid:
|
||||
cmd.append("--volid=%s" % volid)
|
||||
|
||||
cmd.extend(process_args('--installpkgs={}', buildinstallpackages))
|
||||
cmd.extend(process_args('--add-template={}', add_template))
|
||||
cmd.extend(process_args('--add-arch-template={}', add_arch_template))
|
||||
cmd.extend(process_args('--add-template-var={}', add_template_var))
|
||||
cmd.extend(process_args('--add-arch-template-var={}', add_arch_template_var))
|
||||
cmd.extend(process_args('--installpkgs=%s', buildinstallpackages))
|
||||
cmd.extend(process_args('--add-template=%s', add_template))
|
||||
cmd.extend(process_args('--add-arch-template=%s', add_arch_template))
|
||||
cmd.extend(process_args('--add-template-var=%s', add_template_var))
|
||||
cmd.extend(process_args('--add-arch-template-var=%s', add_arch_template_var))
|
||||
|
||||
output_dir = os.path.abspath(output_dir)
|
||||
cmd.append(output_dir)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue