add image-build sections
allows to use factory-parameters ... Signed-off-by: Lubos Kocman <lkocman@redhat.com>
This commit is contained in:
parent
39c688f7ef
commit
f067f38df0
@ -723,40 +723,67 @@ Example
|
||||
image_build = {
|
||||
'^Server$': [
|
||||
{
|
||||
'format': [('docker', 'tar.gz'), ('qcow2', 'qcow2')]
|
||||
'name': 'fedora-qcow-and-docker-base',
|
||||
'target': 'koji-target-name',
|
||||
'ksversion': 'F23', # value from pykickstart
|
||||
'version': '23',
|
||||
# correct SHA1 hash will be put into the URL below automatically
|
||||
'ksurl': 'https://git.fedorahosted.org/git/spin-kickstarts.git?somedirectoryifany#HEAD',
|
||||
'kickstart': "fedora-docker-base.ks",
|
||||
'repo': ["http://someextrarepos.org/repo", "ftp://rekcod.oi/repo].
|
||||
'distro': 'Fedora-20',
|
||||
'disk_size': 3,
|
||||
'image-build': {
|
||||
'format': [('docker', 'tar.gz'), ('qcow2', 'qcow2')]
|
||||
'name': 'fedora-qcow-and-docker-base',
|
||||
'target': 'koji-target-name',
|
||||
'ksversion': 'F23', # value from pykickstart
|
||||
'version': '23',
|
||||
# correct SHA1 hash will be put into the URL below automatically
|
||||
'ksurl': 'https://git.fedorahosted.org/git/spin-kickstarts.git?somedirectoryifany#HEAD',
|
||||
'kickstart': "fedora-docker-base.ks",
|
||||
'repo': ["http://someextrarepos.org/repo", "ftp://rekcod.oi/repo].
|
||||
'distro': 'Fedora-20',
|
||||
'disk_size': 3,
|
||||
|
||||
# this is set automatically by pungi to os_dir for given variant
|
||||
# 'install_tree': 'http://somepath',
|
||||
# this is set automatically by pungi to os_dir for given variant
|
||||
# 'install_tree': 'http://somepath',
|
||||
},
|
||||
'factory-parameters': {
|
||||
'docker_cmd': "[ '/bin/bash' ]",
|
||||
'docker_env': "[ 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' ]",
|
||||
'docker_labels': "{ 'Name': 'fedora-docker-base', 'License': u'GPLv2', 'RUN': 'docker run -it --rm ${OPT1} --privileged -v \`pwd\`:/atomicapp -v /run:/run -v /:/host --net=host --name ${NAME} -e NAME=${NAME} -e IMAGE=${IMAGE} ${IMAGE} -v ${OPT2} run ${OPT3} /atomicapp', 'Vendor': 'Fedora Project', 'Version': '23', 'Architecture': 'x86_64' }",
|
||||
}
|
||||
},
|
||||
{
|
||||
'format': [('qcow2','qcow2')]
|
||||
'name': 'fedora-qcow-base',
|
||||
'target': 'koji-target-name',
|
||||
'ksversion': 'F23', # value from pykickstart
|
||||
'version': '23',
|
||||
'ksurl': 'https://git.fedorahosted.org/git/spin-kickstarts.git?somedirectoryifany#HEAD',
|
||||
'kickstart': "fedora-docker-base.ks",
|
||||
'distro': 'Fedora-23',
|
||||
'image-build': {
|
||||
'format': [('docker', 'tar.gz'), ('qcow2', 'qcow2')]
|
||||
'name': 'fedora-qcow-and-docker-base',
|
||||
'target': 'koji-target-name',
|
||||
'ksversion': 'F23', # value from pykickstart
|
||||
'version': '23',
|
||||
# correct SHA1 hash will be put into the URL below automatically
|
||||
'ksurl': 'https://git.fedorahosted.org/git/spin-kickstarts.git?somedirectoryifany#HEAD',
|
||||
'kickstart': "fedora-docker-base.ks",
|
||||
'repo': ["http://someextrarepos.org/repo", "ftp://rekcod.oi/repo].
|
||||
'distro': 'Fedora-20',
|
||||
'disk_size': 3,
|
||||
|
||||
# only build this type of image on x86_64
|
||||
'arches': ['x86_64']
|
||||
# this is set automatically by pungi to os_dir for given variant
|
||||
# 'install_tree': 'http://somepath',
|
||||
}
|
||||
},
|
||||
{
|
||||
'image-build': {
|
||||
'format': [('qcow2','qcow2')]
|
||||
'name': 'fedora-qcow-base',
|
||||
'target': 'koji-target-name',
|
||||
'ksversion': 'F23', # value from pykickstart
|
||||
'version': '23',
|
||||
'ksurl': 'https://git.fedorahosted.org/git/spin-kickstarts.git?somedirectoryifany#HEAD',
|
||||
'kickstart': "fedora-docker-base.ks",
|
||||
'distro': 'Fedora-23',
|
||||
|
||||
# Use install tree and repo from Everything variant.
|
||||
'install_tree_from': 'Everything',
|
||||
'repo_from': ['Everything'],
|
||||
# only build this type of image on x86_64
|
||||
'arches': ['x86_64']
|
||||
|
||||
# Set release based on date and respin.
|
||||
'release': None,
|
||||
# Use install tree and repo from Everything variant.
|
||||
'install_tree_from': 'Everything',
|
||||
'repo_from': ['Everything'],
|
||||
|
||||
# Set release based on date and respin.
|
||||
'release': None,
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -73,8 +73,8 @@ class ImageBuildPhase(PhaseBase):
|
||||
return ",".join(repo)
|
||||
|
||||
def _get_arches(self, image_conf, arches):
|
||||
if 'arches' in image_conf:
|
||||
arches = set(image_conf.get('arches', [])) & arches
|
||||
if 'arches' in image_conf['image-build']:
|
||||
arches = set(image_conf['image-build'].get('arches', [])) & arches
|
||||
return ','.join(sorted(arches))
|
||||
|
||||
def _set_release(self, image_conf):
|
||||
@ -94,34 +94,33 @@ class ImageBuildPhase(PhaseBase):
|
||||
|
||||
# image_conf is passed to get_image_build_cmd as dict
|
||||
|
||||
image_conf['arches'] = self._get_arches(image_conf, arches)
|
||||
if not image_conf['arches']:
|
||||
image_conf["image-build"]['arches'] = self._get_arches(image_conf, arches)
|
||||
if not image_conf["image-build"]['arches']:
|
||||
continue
|
||||
|
||||
# Replace possible ambiguous ref name with explicit hash.
|
||||
if 'ksurl' in image_conf:
|
||||
image_conf['ksurl'] = resolve_git_url(image_conf['ksurl'])
|
||||
image_conf["image-build"]['ksurl'] = resolve_git_url(image_conf["image-build"]['ksurl'])
|
||||
|
||||
image_conf["variant"] = variant
|
||||
image_conf["image-build"]["variant"] = variant
|
||||
|
||||
image_conf["install_tree"] = self._get_install_tree(image_conf, variant)
|
||||
image_conf["image-build"]["install_tree"] = self._get_install_tree(image_conf, variant)
|
||||
|
||||
self._set_release(image_conf)
|
||||
|
||||
# transform format into right 'format' for image-build
|
||||
# e.g. 'docker,qcow2'
|
||||
format = image_conf["format"]
|
||||
image_conf["format"] = ",".join([x[0] for x in image_conf["format"]])
|
||||
|
||||
image_conf['repo'] = self._get_repo(image_conf, variant)
|
||||
format = image_conf["image-build"]["format"]
|
||||
image_conf["image-build"]["format"] = ",".join([x[0] for x in image_conf["image-build"]["format"]])
|
||||
image_conf["image-build"]['repo'] = self._get_repo(image_conf, variant)
|
||||
|
||||
cmd = {
|
||||
"format": format,
|
||||
"image_conf": image_conf,
|
||||
"conf_file": self.compose.paths.work.image_build_conf(
|
||||
image_conf['variant'],
|
||||
image_name=image_conf['name'],
|
||||
image_type=image_conf['format'].replace(",", "-")
|
||||
image_conf["image-build"]['variant'],
|
||||
image_name=image_conf["image-build"]['name'],
|
||||
image_type=image_conf["image-build"]['format'].replace(",", "-")
|
||||
),
|
||||
"image_dir": self.compose.paths.compose.image_dir(variant),
|
||||
"relative_image_dir": self.compose.paths.compose.image_dir(
|
||||
@ -145,33 +144,32 @@ class CreateImageBuildThread(WorkerThread):
|
||||
try:
|
||||
self.worker(num, compose, cmd)
|
||||
except Exception as exc:
|
||||
if not compose.can_fail(cmd['image_conf']['variant'], '*', 'image-build'):
|
||||
if not compose.can_fail(cmd["image_conf"]["image-build"]['variant'], '*', 'image-build'):
|
||||
raise
|
||||
else:
|
||||
msg = ('[FAIL] image-build for variant %s failed, but going on anyway.\n%s'
|
||||
% (cmd['image_conf']['variant'], exc))
|
||||
% (cmd['image_conf']['image-build']['variant'], exc))
|
||||
self.pool.log_info(msg)
|
||||
|
||||
def worker(self, num, compose, cmd):
|
||||
arches = cmd['image_conf']['arches'].split(',')
|
||||
|
||||
arches = cmd["image_conf"]["image-build"]['arches'].split(',')
|
||||
log_file = compose.paths.log.log_file(
|
||||
cmd["image_conf"]["arches"],
|
||||
cmd["image_conf"]["image-build"]["arches"],
|
||||
"imagebuild-%s-%s-%s" % ('-'.join(arches),
|
||||
cmd["image_conf"]["variant"],
|
||||
cmd['image_conf']['format'].replace(",", "-"))
|
||||
cmd["image_conf"]["image-build"]["variant"],
|
||||
cmd["image_conf"]["image-build"]['format'].replace(",", "-"))
|
||||
)
|
||||
msg = "Creating %s image (arches: %s, variant: %s)" % (cmd["image_conf"]["format"].replace(",", "-"),
|
||||
msg = "Creating %s image (arches: %s, variant: %s)" % (cmd["image_conf"]["image-build"]["format"].replace(",", "-"),
|
||||
'-'.join(arches),
|
||||
cmd["image_conf"]["variant"])
|
||||
cmd["image_conf"]["image-build"]["variant"])
|
||||
self.pool.log_info("[BEGIN] %s" % msg)
|
||||
|
||||
koji_wrapper = KojiWrapper(compose.conf["koji_profile"])
|
||||
|
||||
# writes conf file for koji image-build
|
||||
self.pool.log_info("Writing image-build config for %s.%s into %s" % (
|
||||
cmd["image_conf"]["variant"], '-'.join(arches), cmd["conf_file"]))
|
||||
koji_cmd = koji_wrapper.get_image_build_cmd(cmd['image_conf'],
|
||||
cmd["image_conf"]["image-build"]["variant"], '-'.join(arches), cmd["conf_file"]))
|
||||
koji_cmd = koji_wrapper.get_image_build_cmd(cmd["image_conf"],
|
||||
conf_file_dest=cmd["conf_file"],
|
||||
scratch=cmd['scratch'])
|
||||
|
||||
@ -229,7 +227,7 @@ class CreateImageBuildThread(WorkerThread):
|
||||
img.disc_number = 1 # We don't expect multiple disks
|
||||
img.disc_count = 1
|
||||
img.bootable = False
|
||||
compose.im.add(variant=cmd["image_conf"]["variant"].uid,
|
||||
compose.im.add(variant=cmd["image_conf"]["image-build"]["variant"].uid,
|
||||
arch=image_info['arch'],
|
||||
image=img)
|
||||
|
||||
|
@ -108,9 +108,10 @@ class KojiWrapper(object):
|
||||
min_options = ("name", "version", "target", "install_tree", "arches", "format", "kickstart", "ksurl", "distro")
|
||||
assert set(min_options).issubset(set(config_options.keys())), "image-build requires at least %s got '%s'" % (", ".join(min_options), config_options)
|
||||
cfg_parser = ConfigParser()
|
||||
cfg_parser.add_section(sub_command)
|
||||
for option, value in config_options.iteritems():
|
||||
cfg_parser.set(sub_command, option, value)
|
||||
for section, opts in config_options.iteritems():
|
||||
cfg_parser.add_section(section)
|
||||
for option, value in opts.iteritems():
|
||||
cfg_parser.set(section, option, value)
|
||||
|
||||
fd = open(conf_file_dest, "w")
|
||||
cfg_parser.write(fd)
|
||||
|
Loading…
Reference in New Issue
Block a user