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 = {
|
image_build = {
|
||||||
'^Server$': [
|
'^Server$': [
|
||||||
{
|
{
|
||||||
'format': [('docker', 'tar.gz'), ('qcow2', 'qcow2')]
|
'image-build': {
|
||||||
'name': 'fedora-qcow-and-docker-base',
|
'format': [('docker', 'tar.gz'), ('qcow2', 'qcow2')]
|
||||||
'target': 'koji-target-name',
|
'name': 'fedora-qcow-and-docker-base',
|
||||||
'ksversion': 'F23', # value from pykickstart
|
'target': 'koji-target-name',
|
||||||
'version': '23',
|
'ksversion': 'F23', # value from pykickstart
|
||||||
# correct SHA1 hash will be put into the URL below automatically
|
'version': '23',
|
||||||
'ksurl': 'https://git.fedorahosted.org/git/spin-kickstarts.git?somedirectoryifany#HEAD',
|
# correct SHA1 hash will be put into the URL below automatically
|
||||||
'kickstart': "fedora-docker-base.ks",
|
'ksurl': 'https://git.fedorahosted.org/git/spin-kickstarts.git?somedirectoryifany#HEAD',
|
||||||
'repo': ["http://someextrarepos.org/repo", "ftp://rekcod.oi/repo].
|
'kickstart': "fedora-docker-base.ks",
|
||||||
'distro': 'Fedora-20',
|
'repo': ["http://someextrarepos.org/repo", "ftp://rekcod.oi/repo].
|
||||||
'disk_size': 3,
|
'distro': 'Fedora-20',
|
||||||
|
'disk_size': 3,
|
||||||
|
|
||||||
# this is set automatically by pungi to os_dir for given variant
|
# this is set automatically by pungi to os_dir for given variant
|
||||||
# 'install_tree': 'http://somepath',
|
# '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')]
|
'image-build': {
|
||||||
'name': 'fedora-qcow-base',
|
'format': [('docker', 'tar.gz'), ('qcow2', 'qcow2')]
|
||||||
'target': 'koji-target-name',
|
'name': 'fedora-qcow-and-docker-base',
|
||||||
'ksversion': 'F23', # value from pykickstart
|
'target': 'koji-target-name',
|
||||||
'version': '23',
|
'ksversion': 'F23', # value from pykickstart
|
||||||
'ksurl': 'https://git.fedorahosted.org/git/spin-kickstarts.git?somedirectoryifany#HEAD',
|
'version': '23',
|
||||||
'kickstart': "fedora-docker-base.ks",
|
# correct SHA1 hash will be put into the URL below automatically
|
||||||
'distro': 'Fedora-23',
|
'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
|
# this is set automatically by pungi to os_dir for given variant
|
||||||
'arches': ['x86_64']
|
# '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.
|
# only build this type of image on x86_64
|
||||||
'install_tree_from': 'Everything',
|
'arches': ['x86_64']
|
||||||
'repo_from': ['Everything'],
|
|
||||||
|
|
||||||
# Set release based on date and respin.
|
# Use install tree and repo from Everything variant.
|
||||||
'release': None,
|
'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)
|
return ",".join(repo)
|
||||||
|
|
||||||
def _get_arches(self, image_conf, arches):
|
def _get_arches(self, image_conf, arches):
|
||||||
if 'arches' in image_conf:
|
if 'arches' in image_conf['image-build']:
|
||||||
arches = set(image_conf.get('arches', [])) & arches
|
arches = set(image_conf['image-build'].get('arches', [])) & arches
|
||||||
return ','.join(sorted(arches))
|
return ','.join(sorted(arches))
|
||||||
|
|
||||||
def _set_release(self, image_conf):
|
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 is passed to get_image_build_cmd as dict
|
||||||
|
|
||||||
image_conf['arches'] = self._get_arches(image_conf, arches)
|
image_conf["image-build"]['arches'] = self._get_arches(image_conf, arches)
|
||||||
if not image_conf['arches']:
|
if not image_conf["image-build"]['arches']:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Replace possible ambiguous ref name with explicit hash.
|
# Replace possible ambiguous ref name with explicit hash.
|
||||||
if 'ksurl' in image_conf:
|
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)
|
self._set_release(image_conf)
|
||||||
|
|
||||||
# transform format into right 'format' for image-build
|
# transform format into right 'format' for image-build
|
||||||
# e.g. 'docker,qcow2'
|
# e.g. 'docker,qcow2'
|
||||||
format = image_conf["format"]
|
format = image_conf["image-build"]["format"]
|
||||||
image_conf["format"] = ",".join([x[0] for x in image_conf["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)
|
||||||
image_conf['repo'] = self._get_repo(image_conf, variant)
|
|
||||||
|
|
||||||
cmd = {
|
cmd = {
|
||||||
"format": format,
|
"format": format,
|
||||||
"image_conf": image_conf,
|
"image_conf": image_conf,
|
||||||
"conf_file": self.compose.paths.work.image_build_conf(
|
"conf_file": self.compose.paths.work.image_build_conf(
|
||||||
image_conf['variant'],
|
image_conf["image-build"]['variant'],
|
||||||
image_name=image_conf['name'],
|
image_name=image_conf["image-build"]['name'],
|
||||||
image_type=image_conf['format'].replace(",", "-")
|
image_type=image_conf["image-build"]['format'].replace(",", "-")
|
||||||
),
|
),
|
||||||
"image_dir": self.compose.paths.compose.image_dir(variant),
|
"image_dir": self.compose.paths.compose.image_dir(variant),
|
||||||
"relative_image_dir": self.compose.paths.compose.image_dir(
|
"relative_image_dir": self.compose.paths.compose.image_dir(
|
||||||
@ -145,33 +144,32 @@ class CreateImageBuildThread(WorkerThread):
|
|||||||
try:
|
try:
|
||||||
self.worker(num, compose, cmd)
|
self.worker(num, compose, cmd)
|
||||||
except Exception as exc:
|
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
|
raise
|
||||||
else:
|
else:
|
||||||
msg = ('[FAIL] image-build for variant %s failed, but going on anyway.\n%s'
|
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)
|
self.pool.log_info(msg)
|
||||||
|
|
||||||
def worker(self, num, compose, cmd):
|
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(
|
log_file = compose.paths.log.log_file(
|
||||||
cmd["image_conf"]["arches"],
|
cmd["image_conf"]["image-build"]["arches"],
|
||||||
"imagebuild-%s-%s-%s" % ('-'.join(arches),
|
"imagebuild-%s-%s-%s" % ('-'.join(arches),
|
||||||
cmd["image_conf"]["variant"],
|
cmd["image_conf"]["image-build"]["variant"],
|
||||||
cmd['image_conf']['format'].replace(",", "-"))
|
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),
|
'-'.join(arches),
|
||||||
cmd["image_conf"]["variant"])
|
cmd["image_conf"]["image-build"]["variant"])
|
||||||
self.pool.log_info("[BEGIN] %s" % msg)
|
self.pool.log_info("[BEGIN] %s" % msg)
|
||||||
|
|
||||||
koji_wrapper = KojiWrapper(compose.conf["koji_profile"])
|
koji_wrapper = KojiWrapper(compose.conf["koji_profile"])
|
||||||
|
|
||||||
# writes conf file for koji image-build
|
# writes conf file for koji image-build
|
||||||
self.pool.log_info("Writing image-build config for %s.%s into %s" % (
|
self.pool.log_info("Writing image-build config for %s.%s into %s" % (
|
||||||
cmd["image_conf"]["variant"], '-'.join(arches), cmd["conf_file"]))
|
cmd["image_conf"]["image-build"]["variant"], '-'.join(arches), cmd["conf_file"]))
|
||||||
koji_cmd = koji_wrapper.get_image_build_cmd(cmd['image_conf'],
|
koji_cmd = koji_wrapper.get_image_build_cmd(cmd["image_conf"],
|
||||||
conf_file_dest=cmd["conf_file"],
|
conf_file_dest=cmd["conf_file"],
|
||||||
scratch=cmd['scratch'])
|
scratch=cmd['scratch'])
|
||||||
|
|
||||||
@ -229,7 +227,7 @@ class CreateImageBuildThread(WorkerThread):
|
|||||||
img.disc_number = 1 # We don't expect multiple disks
|
img.disc_number = 1 # We don't expect multiple disks
|
||||||
img.disc_count = 1
|
img.disc_count = 1
|
||||||
img.bootable = False
|
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'],
|
arch=image_info['arch'],
|
||||||
image=img)
|
image=img)
|
||||||
|
|
||||||
|
@ -108,9 +108,10 @@ class KojiWrapper(object):
|
|||||||
min_options = ("name", "version", "target", "install_tree", "arches", "format", "kickstart", "ksurl", "distro")
|
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)
|
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 = ConfigParser()
|
||||||
cfg_parser.add_section(sub_command)
|
for section, opts in config_options.iteritems():
|
||||||
for option, value in config_options.iteritems():
|
cfg_parser.add_section(section)
|
||||||
cfg_parser.set(sub_command, option, value)
|
for option, value in opts.iteritems():
|
||||||
|
cfg_parser.set(section, option, value)
|
||||||
|
|
||||||
fd = open(conf_file_dest, "w")
|
fd = open(conf_file_dest, "w")
|
||||||
cfg_parser.write(fd)
|
cfg_parser.write(fd)
|
||||||
|
Loading…
Reference in New Issue
Block a user