|
|
f116d93 |
# -*- coding: utf-8 -*-
|
|
|
f116d93 |
|
|
|
f116d93 |
|
|
|
f116d93 |
# This program is free software; you can redistribute it and/or modify
|
|
|
f116d93 |
# it under the terms of the GNU General Public License as published by
|
|
|
f116d93 |
# the Free Software Foundation; version 2 of the License.
|
|
|
f116d93 |
#
|
|
|
f116d93 |
# This program is distributed in the hope that it will be useful,
|
|
|
f116d93 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f116d93 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
f116d93 |
# GNU Library General Public License for more details.
|
|
|
f116d93 |
#
|
|
|
f116d93 |
# You should have received a copy of the GNU General Public License
|
|
|
d6dc269 |
# along with this program; if not, see <https://gnu.org/licenses/>.
|
|
|
f116d93 |
|
|
|
f116d93 |
|
|
|
f116d93 |
import errno
|
|
|
f116d93 |
import os
|
|
|
f116d93 |
import time
|
|
|
f116d93 |
import pipes
|
|
|
f116d93 |
import shutil
|
|
|
f116d93 |
import re
|
|
|
f116d93 |
|
|
|
f116d93 |
from kobo.threads import ThreadPool, WorkerThread
|
|
|
636ac79 |
from kobo.shortcuts import run
|
|
Adam Miller |
5fa5fcd |
from productmd.images import Image
|
|
|
f116d93 |
|
|
|
b85307c |
from pungi.arch import get_valid_arches
|
|
|
7028399 |
from pungi.util import get_volid, get_arch_variant_data
|
|
|
306f7e6 |
from pungi.util import get_file_size, get_mtime, failable, makedirs
|
|
|
07e90f0 |
from pungi.wrappers.lorax import LoraxWrapper
|
|
|
7028399 |
from pungi.wrappers.kojiwrapper import get_buildroot_rpms, KojiWrapper
|
|
|
e58c78f |
from pungi.wrappers import iso
|
|
|
07e90f0 |
from pungi.wrappers.scm import get_file_from_scm
|
|
|
07e90f0 |
from pungi.phases.base import PhaseBase
|
|
|
f116d93 |
|
|
|
f116d93 |
|
|
|
f116d93 |
class BuildinstallPhase(PhaseBase):
|
|
|
f116d93 |
name = "buildinstall"
|
|
|
f116d93 |
|
|
|
f116d93 |
def __init__(self, compose):
|
|
|
f116d93 |
PhaseBase.__init__(self, compose)
|
|
|
f116d93 |
self.pool = ThreadPool(logger=self.compose._logger)
|
|
|
f116d93 |
|
|
|
f116d93 |
def skip(self):
|
|
|
f116d93 |
if PhaseBase.skip(self):
|
|
|
f116d93 |
return True
|
|
|
f116d93 |
if not self.compose.conf.get("bootable"):
|
|
|
f116d93 |
msg = "Not a bootable product. Skipping buildinstall."
|
|
|
f116d93 |
self.compose.log_debug(msg)
|
|
|
f116d93 |
return True
|
|
|
f116d93 |
return False
|
|
|
f116d93 |
|
|
|
716b2d5 |
def _get_lorax_cmd(self, repo_baseurl, output_dir, variant, arch, buildarch, volid):
|
|
|
716b2d5 |
noupgrade = True
|
|
|
716b2d5 |
bugurl = None
|
|
|
716b2d5 |
nomacboot = True
|
|
|
716b2d5 |
for data in get_arch_variant_data(self.compose.conf, 'lorax_options', arch, variant):
|
|
|
716b2d5 |
if not data.get('noupgrade', True):
|
|
|
716b2d5 |
noupgrade = False
|
|
|
716b2d5 |
if data.get('bugurl'):
|
|
|
716b2d5 |
bugurl = data.get('bugurl')
|
|
|
716b2d5 |
if not data.get('nomacboot', True):
|
|
|
716b2d5 |
nomacboot = False
|
|
|
b862fc5 |
output_dir = os.path.join(output_dir, variant.uid)
|
|
|
9a72ea8 |
|
|
|
9a72ea8 |
# The paths module will modify the filename (by inserting arch). But we
|
|
|
9a72ea8 |
# only care about the directory anyway.
|
|
|
9a72ea8 |
log_filename = 'buildinstall-%s-logs/dumym' % variant.uid
|
|
|
9a72ea8 |
log_dir = os.path.dirname(self.compose.paths.log.log_file(arch, log_filename))
|
|
|
9a72ea8 |
makedirs(log_dir)
|
|
|
9a72ea8 |
|
|
|
716b2d5 |
lorax = LoraxWrapper()
|
|
|
b862fc5 |
lorax_cmd = lorax.get_lorax_cmd(self.compose.conf["release_name"],
|
|
|
b862fc5 |
self.compose.conf["release_version"],
|
|
|
b862fc5 |
self.compose.conf["release_version"],
|
|
|
b862fc5 |
repo_baseurl,
|
|
|
b862fc5 |
output_dir,
|
|
|
b862fc5 |
variant=variant.uid,
|
|
|
b862fc5 |
buildinstallpackages=variant.buildinstallpackages,
|
|
|
b862fc5 |
is_final=self.compose.supported,
|
|
|
b862fc5 |
buildarch=buildarch,
|
|
|
b862fc5 |
volid=volid,
|
|
|
b862fc5 |
nomacboot=nomacboot,
|
|
|
b862fc5 |
bugurl=bugurl,
|
|
|
9a72ea8 |
noupgrade=noupgrade,
|
|
|
9a72ea8 |
log_dir=log_dir)
|
|
|
b862fc5 |
return 'rm -rf %s && %s' % (pipes.quote(output_dir),
|
|
|
b862fc5 |
' '.join([pipes.quote(x) for x in lorax_cmd]))
|
|
|
716b2d5 |
|
|
|
f116d93 |
def run(self):
|
|
|
f116d93 |
lorax = LoraxWrapper()
|
|
|
72302bd |
product = self.compose.conf["release_name"]
|
|
|
72302bd |
version = self.compose.conf["release_version"]
|
|
|
72302bd |
release = self.compose.conf["release_version"]
|
|
|
f116d93 |
buildinstall_method = self.compose.conf["buildinstall_method"]
|
|
|
f9a6c84 |
disc_type = self.compose.conf['disc_types'].get('dvd', 'dvd')
|
|
|
f116d93 |
|
|
|
f116d93 |
for arch in self.compose.get_arches():
|
|
|
4b37427 |
commands = []
|
|
|
4b37427 |
|
|
|
f116d93 |
repo_baseurl = self.compose.paths.work.arch_repo(arch)
|
|
|
f116d93 |
output_dir = self.compose.paths.work.buildinstall_dir(arch)
|
|
|
f116d93 |
|
|
|
f116d93 |
if buildinstall_method == "lorax":
|
|
|
02ddcf7 |
buildarch = get_valid_arches(arch)[0]
|
|
|
cdec198 |
for variant in self.compose.get_variants(arch=arch, types=['variant']):
|
|
|
1b6688d |
if variant.is_empty:
|
|
|
1b6688d |
continue
|
|
|
aa38eb1 |
volid = get_volid(self.compose, arch, variant=variant, disc_type=disc_type)
|
|
|
cdec198 |
commands.append(
|
|
|
f57665f |
(variant,
|
|
|
f57665f |
self._get_lorax_cmd(repo_baseurl, output_dir, variant, arch, buildarch, volid))
|
|
|
716b2d5 |
)
|
|
|
f116d93 |
elif buildinstall_method == "buildinstall":
|
|
|
aa38eb1 |
volid = get_volid(self.compose, arch, disc_type=disc_type)
|
|
|
f57665f |
commands.append(
|
|
|
f57665f |
(None,
|
|
|
f57665f |
lorax.get_buildinstall_cmd(product,
|
|
|
f57665f |
version,
|
|
|
f57665f |
release,
|
|
|
f57665f |
repo_baseurl,
|
|
|
f57665f |
output_dir,
|
|
|
f57665f |
is_final=self.compose.supported,
|
|
|
02ddcf7 |
buildarch=arch,
|
|
|
f57665f |
volid=volid))
|
|
|
f57665f |
)
|
|
|
f116d93 |
else:
|
|
|
f116d93 |
raise ValueError("Unsupported buildinstall method: %s" % buildinstall_method)
|
|
|
cdec198 |
|
|
|
f57665f |
for (variant, cmd) in commands:
|
|
|
4b37427 |
self.pool.add(BuildinstallThread(self.pool))
|
|
|
f57665f |
self.pool.queue_put((self.compose, arch, variant, cmd))
|
|
|
f116d93 |
|
|
|
f116d93 |
self.pool.start()
|
|
|
f116d93 |
|
|
|
f116d93 |
def copy_files(self):
|
|
|
4a96e8e |
buildinstall_method = self.compose.conf["buildinstall_method"]
|
|
|
f9a6c84 |
disc_type = self.compose.conf['disc_types'].get('dvd', 'dvd')
|
|
|
4a96e8e |
|
|
|
f116d93 |
# copy buildinstall files to the 'os' dir
|
|
|
f116d93 |
kickstart_file = get_kickstart_file(self.compose)
|
|
|
f116d93 |
for arch in self.compose.get_arches():
|
|
|
f116d93 |
for variant in self.compose.get_variants(arch=arch, types=["self", "variant"]):
|
|
|
98a9e02 |
if variant.is_empty:
|
|
|
98a9e02 |
continue
|
|
|
98a9e02 |
|
|
|
f116d93 |
buildinstall_dir = self.compose.paths.work.buildinstall_dir(arch)
|
|
|
4a96e8e |
|
|
|
4a96e8e |
# Lorax runs per-variant, so we need to tweak the source path
|
|
|
4a96e8e |
# to include variant.
|
|
|
4a96e8e |
if buildinstall_method == 'lorax':
|
|
|
4a96e8e |
buildinstall_dir = os.path.join(buildinstall_dir, variant.uid)
|
|
|
4a96e8e |
|
|
|
f116d93 |
if not os.path.isdir(buildinstall_dir) or not os.listdir(buildinstall_dir):
|
|
|
f116d93 |
continue
|
|
|
f116d93 |
|
|
|
f116d93 |
os_tree = self.compose.paths.compose.os_tree(arch, variant)
|
|
|
f116d93 |
# TODO: label is not used
|
|
|
f116d93 |
label = ""
|
|
|
aa38eb1 |
volid = get_volid(self.compose, arch, variant, escape_spaces=False, disc_type=disc_type)
|
|
|
463088d |
can_fail = self.compose.can_fail(variant, arch, 'buildinstall')
|
|
|
463088d |
with failable(self.compose, can_fail, variant, arch, 'buildinstall'):
|
|
|
6fbf1e8 |
tweak_buildinstall(self.compose, buildinstall_dir, os_tree, arch, variant.uid, label, volid, kickstart_file)
|
|
|
463088d |
link_boot_iso(self.compose, arch, variant, can_fail)
|
|
|
f116d93 |
|
|
|
f116d93 |
|
|
|
f116d93 |
def get_kickstart_file(compose):
|
|
|
f9a6c84 |
scm_dict = compose.conf.get("buildinstall_kickstart")
|
|
|
f116d93 |
if not scm_dict:
|
|
|
f116d93 |
compose.log_debug("Path to ks.cfg (buildinstall_kickstart) not specified.")
|
|
|
f116d93 |
return
|
|
|
f116d93 |
|
|
|
f116d93 |
msg = "Getting ks.cfg"
|
|
|
f116d93 |
kickstart_path = os.path.join(compose.paths.work.topdir(arch="global"), "ks.cfg")
|
|
|
f116d93 |
if os.path.exists(kickstart_path):
|
|
|
80fa723 |
compose.log_warning("[SKIP ] %s" % msg)
|
|
|
f116d93 |
return kickstart_path
|
|
|
f116d93 |
|
|
|
f116d93 |
compose.log_info("[BEGIN] %s" % msg)
|
|
|
f116d93 |
if isinstance(scm_dict, dict):
|
|
|
f116d93 |
kickstart_name = os.path.basename(scm_dict["file"])
|
|
|
f116d93 |
if scm_dict["scm"] == "file":
|
|
|
f116d93 |
scm_dict["file"] = os.path.join(compose.config_dir, scm_dict["file"])
|
|
|
f116d93 |
else:
|
|
|
f116d93 |
kickstart_name = os.path.basename(scm_dict)
|
|
|
f116d93 |
scm_dict = os.path.join(compose.config_dir, scm_dict)
|
|
|
f116d93 |
|
|
|
6fbf1e8 |
tmp_dir = compose.mkdtemp(prefix="buildinstall_kickstart_")
|
|
|
f116d93 |
get_file_from_scm(scm_dict, tmp_dir, logger=compose._logger)
|
|
|
f116d93 |
src = os.path.join(tmp_dir, kickstart_name)
|
|
|
f116d93 |
shutil.copy2(src, kickstart_path)
|
|
|
f116d93 |
compose.log_info("[DONE ] %s" % msg)
|
|
|
f116d93 |
return kickstart_path
|
|
|
f116d93 |
|
|
|
f116d93 |
|
|
|
05a666f |
BOOT_CONFIGS = [
|
|
|
05a666f |
"isolinux/isolinux.cfg",
|
|
|
05a666f |
"etc/yaboot.conf",
|
|
|
05a666f |
"ppc/ppc64/yaboot.conf",
|
|
|
05a666f |
"EFI/BOOT/BOOTX64.conf",
|
|
|
05a666f |
"EFI/BOOT/grub.cfg",
|
|
|
05a666f |
]
|
|
|
05a666f |
|
|
|
05a666f |
|
|
|
05a666f |
def tweak_configs(path, volid, ks_file, configs=BOOT_CONFIGS):
|
|
|
05a666f |
volid_escaped = volid.replace(" ", r"\x20").replace("\\", "\\\\")
|
|
|
05a666f |
volid_escaped_2 = volid_escaped.replace("\\", "\\\\")
|
|
|
05a666f |
found_configs = []
|
|
|
05a666f |
for config in configs:
|
|
|
05a666f |
config_path = os.path.join(path, config)
|
|
|
05a666f |
if not os.path.exists(config_path):
|
|
|
05a666f |
continue
|
|
|
05a666f |
found_configs.append(config)
|
|
|
05a666f |
|
|
|
05a666f |
with open(config_path, "r") as f:
|
|
|
05a666f |
data = f.read()
|
|
|
05a666f |
os.unlink(config_path) # break hadlink by removing file writing a new one
|
|
|
05a666f |
|
|
|
05a666f |
# double-escape volid in yaboot.conf
|
|
|
05a666f |
new_volid = volid_escaped_2 if 'yaboot' in config else volid_escaped
|
|
|
05a666f |
|
|
|
05a666f |
ks = (" ks=hd:LABEL=%s:/ks.cfg" % new_volid) if ks_file else ""
|
|
|
05a666f |
|
|
|
05a666f |
# pre-f18
|
|
|
05a666f |
data = re.sub(r":CDLABEL=[^ \n]*", r":CDLABEL=%s%s" % (new_volid, ks), data)
|
|
|
05a666f |
# f18+
|
|
|
05a666f |
data = re.sub(r":LABEL=[^ \n]*", r":LABEL=%s%s" % (new_volid, ks), data)
|
|
|
05a666f |
data = re.sub(r"(search .* -l) '[^'\n]*'", r"\1 '%s'" % volid, data)
|
|
|
05a666f |
|
|
|
05a666f |
with open(config_path, "w") as f:
|
|
|
05a666f |
f.write(data)
|
|
|
05a666f |
|
|
|
05a666f |
return found_configs
|
|
|
05a666f |
|
|
|
05a666f |
|
|
|
f116d93 |
# HACK: this is a hack!
|
|
|
f116d93 |
# * it's quite trivial to replace volids
|
|
|
f116d93 |
# * it's not easy to replace menu titles
|
|
|
f116d93 |
# * we probably need to get this into lorax
|
|
|
6fbf1e8 |
def tweak_buildinstall(compose, src, dst, arch, variant, label, volid, kickstart_file=None):
|
|
|
6fbf1e8 |
tmp_dir = compose.mkdtemp(prefix="tweak_buildinstall_")
|
|
|
f116d93 |
|
|
|
f116d93 |
# verify src
|
|
|
f116d93 |
if not os.path.isdir(src):
|
|
|
f116d93 |
raise OSError(errno.ENOENT, "Directory does not exist: %s" % src)
|
|
|
f116d93 |
|
|
|
f116d93 |
# create dst
|
|
|
f116d93 |
try:
|
|
|
f116d93 |
os.makedirs(dst)
|
|
|
f116d93 |
except OSError as ex:
|
|
|
f116d93 |
if ex.errno != errno.EEXIST:
|
|
|
f116d93 |
raise
|
|
|
f116d93 |
|
|
|
f116d93 |
# copy src to temp
|
|
|
f116d93 |
# TODO: place temp on the same device as buildinstall dir so we can hardlink
|
|
|
f116d93 |
cmd = "cp -av --remove-destination %s/* %s/" % (pipes.quote(src), pipes.quote(tmp_dir))
|
|
|
f116d93 |
run(cmd)
|
|
|
f116d93 |
|
|
|
05a666f |
found_configs = tweak_configs(tmp_dir, volid, kickstart_file)
|
|
|
05a666f |
if kickstart_file and found_configs:
|
|
|
05a666f |
shutil.copy2(kickstart_file, os.path.join(dst, "ks.cfg"))
|
|
|
f116d93 |
|
|
|
f116d93 |
images = [
|
|
|
f116d93 |
os.path.join(tmp_dir, "images", "efiboot.img"),
|
|
|
f116d93 |
]
|
|
|
f116d93 |
for image in images:
|
|
|
f116d93 |
if not os.path.isfile(image):
|
|
|
f116d93 |
continue
|
|
|
306f7e6 |
|
|
|
306f7e6 |
with iso.mount(image, logger=compose._logger) as mount_tmp_dir:
|
|
|
306f7e6 |
for config in BOOT_CONFIGS:
|
|
|
306f7e6 |
config_path = os.path.join(tmp_dir, config)
|
|
|
306f7e6 |
config_in_image = os.path.join(mount_tmp_dir, config)
|
|
|
306f7e6 |
|
|
|
306f7e6 |
if os.path.isfile(config_in_image):
|
|
|
306f7e6 |
cmd = ["cp", "-v", "--remove-destination", config_path, config_in_image]
|
|
|
306f7e6 |
run(cmd)
|
|
|
f116d93 |
|
|
|
f116d93 |
# HACK: make buildinstall files world readable
|
|
|
f116d93 |
run("chmod -R a+rX %s" % pipes.quote(tmp_dir))
|
|
|
f116d93 |
|
|
|
f116d93 |
# copy temp to dst
|
|
|
f116d93 |
cmd = "cp -av --remove-destination %s/* %s/" % (pipes.quote(tmp_dir), pipes.quote(dst))
|
|
|
f116d93 |
run(cmd)
|
|
|
f116d93 |
|
|
|
f116d93 |
shutil.rmtree(tmp_dir)
|
|
|
f116d93 |
|
|
|
f116d93 |
|
|
|
463088d |
def link_boot_iso(compose, arch, variant, can_fail):
|
|
|
f116d93 |
if arch == "src":
|
|
|
f116d93 |
return
|
|
|
f116d93 |
|
|
|
f9a6c84 |
disc_type = compose.conf['disc_types'].get('boot', 'boot')
|
|
|
0c9ad96 |
|
|
|
f9a6c84 |
symlink_isos_to = compose.conf.get("symlink_isos_to")
|
|
|
f116d93 |
os_tree = compose.paths.compose.os_tree(arch, variant)
|
|
|
f116d93 |
# TODO: find in treeinfo?
|
|
|
f116d93 |
boot_iso_path = os.path.join(os_tree, "images", "boot.iso")
|
|
|
f116d93 |
if not os.path.isfile(boot_iso_path):
|
|
|
f116d93 |
return
|
|
|
f116d93 |
|
|
|
ad104f9 |
msg = "Linking boot.iso (arch: %s, variant: %s)" % (arch, variant)
|
|
|
0c9ad96 |
filename = compose.get_image_name(arch, variant, disc_type=disc_type,
|
|
|
0e237db |
disc_num=None, suffix=".iso")
|
|
|
0e237db |
new_boot_iso_path = compose.paths.compose.iso_path(arch, variant, filename,
|
|
|
0e237db |
symlink_to=symlink_isos_to)
|
|
|
0e237db |
new_boot_iso_relative_path = compose.paths.compose.iso_path(arch,
|
|
|
0e237db |
variant,
|
|
|
0e237db |
filename,
|
|
|
0e237db |
relative=True)
|
|
|
f116d93 |
if os.path.exists(new_boot_iso_path):
|
|
|
f116d93 |
# TODO: log
|
|
|
f116d93 |
compose.log_warning("[SKIP ] %s" % msg)
|
|
|
f116d93 |
return
|
|
|
f116d93 |
|
|
|
f116d93 |
compose.log_info("[BEGIN] %s" % msg)
|
|
|
636ac79 |
# Try to hardlink, and copy if that fails
|
|
|
636ac79 |
try:
|
|
|
636ac79 |
os.link(boot_iso_path, new_boot_iso_path)
|
|
|
636ac79 |
except OSError:
|
|
|
636ac79 |
shutil.copy2(boot_iso_path, new_boot_iso_path)
|
|
|
f116d93 |
|
|
|
f116d93 |
implant_md5 = iso.get_implanted_md5(new_boot_iso_path)
|
|
|
f116d93 |
iso_name = os.path.basename(new_boot_iso_path)
|
|
|
f116d93 |
iso_dir = os.path.dirname(new_boot_iso_path)
|
|
|
f116d93 |
|
|
|
f116d93 |
# create iso manifest
|
|
|
f116d93 |
run(iso.get_manifest_cmd(iso_name), workdir=iso_dir)
|
|
|
f116d93 |
|
|
|
f116d93 |
img = Image(compose.im)
|
|
|
f116d93 |
img.path = new_boot_iso_relative_path
|
|
|
636ac79 |
img.mtime = get_mtime(new_boot_iso_path)
|
|
|
636ac79 |
img.size = get_file_size(new_boot_iso_path)
|
|
|
f116d93 |
img.arch = arch
|
|
|
f116d93 |
img.type = "boot"
|
|
|
f116d93 |
img.format = "iso"
|
|
|
f116d93 |
img.disc_number = 1
|
|
|
f116d93 |
img.disc_count = 1
|
|
|
f116d93 |
img.bootable = True
|
|
|
254bfb8 |
img.subvariant = variant.name
|
|
|
f116d93 |
img.implant_md5 = implant_md5
|
|
|
463088d |
setattr(img, 'can_fail', can_fail)
|
|
|
4e3d87e |
setattr(img, 'deliverable', 'buildinstall')
|
|
|
f116d93 |
try:
|
|
|
f116d93 |
img.volume_id = iso.get_volume_id(new_boot_iso_path)
|
|
|
f116d93 |
except RuntimeError:
|
|
|
f116d93 |
pass
|
|
|
fd8cd62 |
compose.im.add(variant.uid, arch, img)
|
|
|
f116d93 |
compose.log_info("[DONE ] %s" % msg)
|
|
|
f116d93 |
|
|
|
f116d93 |
|
|
|
f116d93 |
class BuildinstallThread(WorkerThread):
|
|
|
f116d93 |
def process(self, item, num):
|
|
|
f57665f |
# The variant is None unless lorax is used as buildinstall method.
|
|
|
f57665f |
compose, arch, variant, cmd = item
|
|
|
463088d |
can_fail = compose.can_fail(variant, arch, 'buildinstall')
|
|
|
463088d |
with failable(compose, can_fail, variant, arch, 'buildinstall'):
|
|
|
f57665f |
self.worker(compose, arch, variant, cmd, num)
|
|
|
a6b673d |
|
|
|
f57665f |
def worker(self, compose, arch, variant, cmd, num):
|
|
|
f9a6c84 |
runroot = compose.conf["runroot"]
|
|
|
f116d93 |
buildinstall_method = compose.conf["buildinstall_method"]
|
|
|
f57665f |
log_filename = ('buildinstall-%s' % variant.uid) if variant else 'buildinstall'
|
|
|
f57665f |
log_file = compose.paths.log.log_file(arch, log_filename)
|
|
|
f116d93 |
|
|
|
b862fc5 |
msg = "Running buildinstall for arch %s, variant %s" % (arch, variant)
|
|
|
f116d93 |
|
|
|
f116d93 |
output_dir = compose.paths.work.buildinstall_dir(arch)
|
|
|
b862fc5 |
if variant:
|
|
|
b862fc5 |
output_dir = os.path.join(output_dir, variant.uid)
|
|
|
b862fc5 |
|
|
|
b862fc5 |
if os.path.isdir(output_dir) and os.listdir(output_dir):
|
|
|
b862fc5 |
# output dir is *not* empty -> SKIP
|
|
|
b862fc5 |
self.pool.log_warning(
|
|
|
b862fc5 |
'[SKIP ] Buildinstall for arch %s, variant %s' % (arch, variant))
|
|
|
b862fc5 |
return
|
|
|
f116d93 |
|
|
|
f116d93 |
self.pool.log_info("[BEGIN] %s" % msg)
|
|
|
f116d93 |
|
|
|
f116d93 |
task_id = None
|
|
|
f116d93 |
if runroot:
|
|
|
f116d93 |
# run in a koji build root
|
|
|
e9699b7 |
packages = ["strace"]
|
|
|
f116d93 |
if buildinstall_method == "lorax":
|
|
|
f116d93 |
packages += ["lorax"]
|
|
|
f116d93 |
elif buildinstall_method == "buildinstall":
|
|
|
f116d93 |
packages += ["anaconda"]
|
|
|
f9a6c84 |
runroot_channel = compose.conf.get("runroot_channel")
|
|
|
f116d93 |
runroot_tag = compose.conf["runroot_tag"]
|
|
|
f116d93 |
|
|
|
f116d93 |
koji_wrapper = KojiWrapper(compose.conf["koji_profile"])
|
|
|
4ea1916 |
koji_cmd = koji_wrapper.get_runroot_cmd(
|
|
|
4ea1916 |
runroot_tag, arch, cmd,
|
|
|
4ea1916 |
channel=runroot_channel,
|
|
|
4ea1916 |
use_shell=True, task_id=True,
|
|
|
4ea1916 |
packages=packages, mounts=[compose.topdir],
|
|
|
4ea1916 |
weight=compose.conf['runroot_weights'].get('buildinstall'))
|
|
|
f116d93 |
|
|
|
f116d93 |
# avoid race conditions?
|
|
|
f116d93 |
# Kerberos authentication failed: Permission denied in replay cache code (-1765328215)
|
|
|
f116d93 |
time.sleep(num * 3)
|
|
|
f116d93 |
|
|
|
f116d93 |
output = koji_wrapper.run_runroot_cmd(koji_cmd, log_file=log_file)
|
|
|
f116d93 |
if output["retcode"] != 0:
|
|
|
f57665f |
raise RuntimeError("Runroot task failed: %s. See %s for more details."
|
|
|
f57665f |
% (output["task_id"], log_file))
|
|
|
abcc51f |
task_id = output["task_id"]
|
|
|
f116d93 |
|
|
|
f116d93 |
else:
|
|
|
f116d93 |
# run locally
|
|
|
f116d93 |
run(cmd, show_cmd=True, logfile=log_file)
|
|
|
f116d93 |
|
|
|
f57665f |
log_file = compose.paths.log.log_file(arch, log_filename + '-RPMs')
|
|
|
f116d93 |
rpms = get_buildroot_rpms(compose, task_id)
|
|
|
f116d93 |
open(log_file, "w").write("\n".join(rpms))
|
|
|
f116d93 |
|
|
|
f116d93 |
self.pool.log_info("[DONE ] %s" % msg)
|