2015-11-25 15:14:35 +00:00
|
|
|
#!/usr/bin/env python
|
2015-03-12 18:15:29 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2017-08-23 07:39:17 +00:00
|
|
|
from __future__ import print_function
|
2015-03-12 18:15:29 +00:00
|
|
|
|
2017-06-22 14:29:45 +00:00
|
|
|
import argparse
|
2015-03-12 18:15:29 +00:00
|
|
|
import getpass
|
2018-05-15 11:30:00 +00:00
|
|
|
import json
|
|
|
|
import locale
|
|
|
|
import logging
|
|
|
|
import os
|
2015-03-12 18:15:29 +00:00
|
|
|
import socket
|
2018-05-11 14:49:01 +00:00
|
|
|
import signal
|
2018-05-15 11:30:00 +00:00
|
|
|
import sys
|
2018-05-11 14:49:01 +00:00
|
|
|
import traceback
|
2018-07-26 21:55:13 +00:00
|
|
|
import shutil
|
2018-05-15 11:30:00 +00:00
|
|
|
|
2017-09-21 07:29:53 +00:00
|
|
|
from six.moves import shlex_quote
|
2015-03-12 18:15:29 +00:00
|
|
|
|
|
|
|
here = sys.path[0]
|
|
|
|
if here != '/usr/bin':
|
|
|
|
# Git checkout
|
|
|
|
sys.path[0] = os.path.dirname(here)
|
|
|
|
|
2018-05-15 11:30:00 +00:00
|
|
|
from pungi.phases import PHASES_NAMES
|
2018-05-30 14:09:31 +00:00
|
|
|
from pungi import get_full_version, util
|
2015-03-12 18:15:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
# force C locales
|
2019-05-10 13:24:29 +00:00
|
|
|
try:
|
|
|
|
locale.setlocale(locale.LC_ALL, "C.UTF-8")
|
|
|
|
except locale.Error:
|
|
|
|
# RHEL < 8 does not have C.UTF-8 locale...
|
|
|
|
locale.setlocale(locale.LC_ALL, "C")
|
2015-03-12 18:15:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
COMPOSE = None
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
global COMPOSE
|
|
|
|
|
2017-06-22 14:29:45 +00:00
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
group = parser.add_mutually_exclusive_group(required=True)
|
|
|
|
group.add_argument(
|
2015-03-12 18:15:29 +00:00
|
|
|
"--target-dir",
|
|
|
|
metavar="PATH",
|
|
|
|
help="a compose is created under this directory",
|
|
|
|
)
|
2017-06-22 14:29:45 +00:00
|
|
|
group.add_argument(
|
|
|
|
"--compose-dir",
|
|
|
|
metavar="PATH",
|
|
|
|
help="reuse an existing compose directory (DANGEROUS!)",
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
2015-03-12 18:15:29 +00:00
|
|
|
"--label",
|
|
|
|
help="specify compose label (example: Snapshot-1.0); required for production composes"
|
|
|
|
)
|
2017-06-22 14:29:45 +00:00
|
|
|
parser.add_argument(
|
2015-03-12 18:15:29 +00:00
|
|
|
"--no-label",
|
|
|
|
action="store_true",
|
|
|
|
default=False,
|
|
|
|
help="make a production compose without label"
|
|
|
|
)
|
2017-06-22 14:29:45 +00:00
|
|
|
parser.add_argument(
|
2015-03-12 18:15:29 +00:00
|
|
|
"--supported",
|
|
|
|
action="store_true",
|
|
|
|
default=False,
|
|
|
|
help="set supported flag on media (automatically on for 'RC-x.y' labels)"
|
|
|
|
)
|
2017-06-22 14:29:45 +00:00
|
|
|
parser.add_argument(
|
2015-03-12 18:15:29 +00:00
|
|
|
"--old-composes",
|
|
|
|
metavar="PATH",
|
|
|
|
dest="old_composes",
|
|
|
|
default=[],
|
|
|
|
action="append",
|
|
|
|
help="Path to directory with old composes. Reuse an existing repodata from the most recent compose.",
|
|
|
|
)
|
2017-06-22 14:29:45 +00:00
|
|
|
parser.add_argument(
|
2015-03-12 18:15:29 +00:00
|
|
|
"--debug-mode",
|
|
|
|
action="store_true",
|
|
|
|
default=False,
|
|
|
|
help="run pungi in DEBUG mode (DANGEROUS!)",
|
|
|
|
)
|
2017-06-22 14:29:45 +00:00
|
|
|
parser.add_argument(
|
2015-03-12 18:15:29 +00:00
|
|
|
"--config",
|
2017-06-22 14:29:45 +00:00
|
|
|
help="Config file",
|
|
|
|
required=True
|
2015-03-12 18:15:29 +00:00
|
|
|
)
|
2017-06-22 14:29:45 +00:00
|
|
|
parser.add_argument(
|
2015-03-12 18:15:29 +00:00
|
|
|
"--skip-phase",
|
|
|
|
metavar="PHASE",
|
2018-05-15 11:30:00 +00:00
|
|
|
choices=PHASES_NAMES,
|
2015-03-12 18:15:29 +00:00
|
|
|
action="append",
|
|
|
|
default=[],
|
|
|
|
help="skip a compose phase",
|
|
|
|
)
|
2017-06-22 14:29:45 +00:00
|
|
|
parser.add_argument(
|
2015-03-12 18:15:29 +00:00
|
|
|
"--just-phase",
|
|
|
|
metavar="PHASE",
|
2018-05-15 11:30:00 +00:00
|
|
|
choices=PHASES_NAMES,
|
2015-03-12 18:15:29 +00:00
|
|
|
action="append",
|
|
|
|
default=[],
|
|
|
|
help="run only a specified compose phase",
|
|
|
|
)
|
2017-06-22 14:29:45 +00:00
|
|
|
parser.add_argument(
|
2015-03-12 18:15:29 +00:00
|
|
|
"--nightly",
|
|
|
|
action="store_const",
|
|
|
|
const="nightly",
|
|
|
|
dest="compose_type",
|
|
|
|
help="make a nightly compose",
|
|
|
|
)
|
2017-06-22 14:29:45 +00:00
|
|
|
parser.add_argument(
|
2015-03-12 18:15:29 +00:00
|
|
|
"--test",
|
|
|
|
action="store_const",
|
|
|
|
const="test",
|
|
|
|
dest="compose_type",
|
|
|
|
help="make a test compose",
|
|
|
|
)
|
2017-06-22 14:29:45 +00:00
|
|
|
parser.add_argument(
|
2016-11-29 07:28:35 +00:00
|
|
|
"--ci",
|
|
|
|
action="store_const",
|
|
|
|
const="ci",
|
|
|
|
dest="compose_type",
|
|
|
|
help="make a CI compose",
|
|
|
|
)
|
2017-08-25 08:07:33 +00:00
|
|
|
parser.add_argument(
|
|
|
|
"--production",
|
|
|
|
action="store_const",
|
|
|
|
const="production",
|
|
|
|
dest="compose_type",
|
|
|
|
help="make production compose (default unless config specifies otherwise)",
|
|
|
|
)
|
2017-06-22 14:29:45 +00:00
|
|
|
parser.add_argument(
|
2015-03-12 18:15:29 +00:00
|
|
|
"--koji-event",
|
|
|
|
metavar="ID",
|
2018-05-30 14:09:31 +00:00
|
|
|
type=util.parse_koji_event,
|
|
|
|
help="specify a koji event for populating package set, either as event ID "
|
|
|
|
"or a path to a compose from which to reuse the event",
|
2015-03-12 18:15:29 +00:00
|
|
|
)
|
2017-06-22 14:29:45 +00:00
|
|
|
parser.add_argument(
|
2015-03-12 18:15:29 +00:00
|
|
|
"--version",
|
2017-09-11 06:15:34 +00:00
|
|
|
action="version",
|
|
|
|
version=get_full_version(),
|
2015-03-12 18:15:29 +00:00
|
|
|
help="output version information and exit",
|
|
|
|
)
|
2017-06-22 14:29:45 +00:00
|
|
|
parser.add_argument(
|
2015-11-26 07:45:33 +00:00
|
|
|
"--notification-script",
|
2017-06-28 08:26:29 +00:00
|
|
|
action="append",
|
|
|
|
default=[],
|
2015-11-26 07:45:33 +00:00
|
|
|
help="script for sending progress notification messages"
|
|
|
|
)
|
2017-06-22 14:29:45 +00:00
|
|
|
parser.add_argument(
|
2016-10-25 04:34:36 +00:00
|
|
|
"--no-latest-link",
|
|
|
|
action="store_true",
|
|
|
|
default=False,
|
|
|
|
dest="no_latest_link",
|
|
|
|
help="don't create latest symbol link to this compose"
|
|
|
|
)
|
2017-06-22 14:29:45 +00:00
|
|
|
parser.add_argument(
|
2017-03-17 15:53:16 +00:00
|
|
|
"--latest-link-status",
|
|
|
|
metavar="STATUS",
|
|
|
|
action="append",
|
|
|
|
default=[],
|
|
|
|
help="only create latest symbol link to this compose when compose status matches specified status",
|
|
|
|
)
|
2017-10-24 01:58:36 +00:00
|
|
|
parser.add_argument(
|
|
|
|
"--print-output-dir",
|
|
|
|
action="store_true",
|
|
|
|
default=False,
|
|
|
|
help="print the compose directory"
|
|
|
|
)
|
2017-06-22 14:29:45 +00:00
|
|
|
parser.add_argument(
|
2017-02-17 19:28:30 +00:00
|
|
|
"--quiet",
|
|
|
|
action="store_true",
|
|
|
|
default=False,
|
|
|
|
help="quiet mode, don't print log on screen"
|
|
|
|
)
|
2015-03-12 18:15:29 +00:00
|
|
|
|
2017-06-22 14:29:45 +00:00
|
|
|
opts = parser.parse_args()
|
2016-10-20 07:23:10 +00:00
|
|
|
import pungi.notifier
|
|
|
|
notifier = pungi.notifier.PungiNotifier(opts.notification_script)
|
|
|
|
|
|
|
|
def fail_to_start(msg, **kwargs):
|
|
|
|
notifier.send('fail-to-start', workdir=opts.target_dir,
|
|
|
|
command=sys.argv, target_dir=opts.target_dir,
|
|
|
|
config=opts.config, detail=msg, **kwargs)
|
|
|
|
|
|
|
|
def abort(msg):
|
|
|
|
fail_to_start(msg)
|
|
|
|
parser.error(msg)
|
2015-03-12 18:15:29 +00:00
|
|
|
|
|
|
|
if opts.target_dir and not opts.compose_dir:
|
|
|
|
opts.target_dir = os.path.abspath(opts.target_dir)
|
|
|
|
if not os.path.isdir(opts.target_dir):
|
2016-10-20 07:23:10 +00:00
|
|
|
abort("The target directory does not exist or is not a directory: %s" % opts.target_dir)
|
2015-03-12 18:15:29 +00:00
|
|
|
else:
|
|
|
|
opts.compose_dir = os.path.abspath(opts.compose_dir)
|
|
|
|
if not os.path.isdir(opts.compose_dir):
|
2016-10-20 07:23:10 +00:00
|
|
|
abort("The compose directory does not exist or is not a directory: %s" % opts.compose_dir)
|
2015-03-12 18:15:29 +00:00
|
|
|
|
|
|
|
opts.config = os.path.abspath(opts.config)
|
|
|
|
|
2016-10-25 04:34:36 +00:00
|
|
|
create_latest_link = not opts.no_latest_link
|
2017-03-17 15:53:16 +00:00
|
|
|
latest_link_status = opts.latest_link_status or None
|
2016-10-25 04:34:36 +00:00
|
|
|
|
2015-03-12 18:15:29 +00:00
|
|
|
import kobo.conf
|
|
|
|
import kobo.log
|
2015-04-24 22:58:25 +00:00
|
|
|
import productmd.composeinfo
|
2015-03-12 18:15:29 +00:00
|
|
|
|
|
|
|
if opts.label:
|
|
|
|
try:
|
2015-06-07 18:05:15 +00:00
|
|
|
productmd.composeinfo.verify_label(opts.label)
|
2015-03-12 18:15:29 +00:00
|
|
|
except ValueError as ex:
|
2016-10-20 07:23:10 +00:00
|
|
|
abort(str(ex))
|
2015-03-12 18:15:29 +00:00
|
|
|
|
|
|
|
from pungi.compose import Compose
|
|
|
|
|
2017-02-23 10:04:32 +00:00
|
|
|
logger = logging.getLogger("pungi")
|
2016-11-18 20:33:03 +00:00
|
|
|
logger.setLevel(logging.DEBUG)
|
2017-02-17 19:28:30 +00:00
|
|
|
if not opts.quiet:
|
|
|
|
kobo.log.add_stderr_logger(logger)
|
2015-03-12 18:15:29 +00:00
|
|
|
|
2019-03-06 12:35:04 +00:00
|
|
|
conf = util.load_config(opts.config)
|
2016-03-10 08:08:19 +00:00
|
|
|
|
2017-08-25 08:07:33 +00:00
|
|
|
compose_type = opts.compose_type or conf.get('compose_type', 'production')
|
|
|
|
if compose_type == "production" and not opts.label and not opts.no_label:
|
|
|
|
abort("must specify label for a production compose")
|
|
|
|
|
2016-03-10 08:08:19 +00:00
|
|
|
# check if all requirements are met
|
|
|
|
import pungi.checks
|
|
|
|
if not pungi.checks.check(conf):
|
|
|
|
sys.exit(1)
|
2016-03-31 07:45:50 +00:00
|
|
|
pungi.checks.check_umask(logger)
|
2016-12-07 14:57:35 +00:00
|
|
|
errors, warnings = pungi.checks.validate(conf)
|
2018-05-28 11:38:19 +00:00
|
|
|
if not opts.quiet:
|
|
|
|
for warning in warnings:
|
|
|
|
print(warning, file=sys.stderr)
|
2016-08-22 14:08:25 +00:00
|
|
|
if errors:
|
|
|
|
for error in errors:
|
2017-08-23 07:39:17 +00:00
|
|
|
print(error, file=sys.stderr)
|
2016-10-20 07:23:10 +00:00
|
|
|
fail_to_start('Config validation failed', errors=errors)
|
2016-08-22 14:08:25 +00:00
|
|
|
sys.exit(1)
|
2015-03-12 18:15:29 +00:00
|
|
|
|
|
|
|
if opts.target_dir:
|
|
|
|
compose_dir = Compose.get_compose_dir(opts.target_dir, conf, compose_type=compose_type, compose_label=opts.label)
|
|
|
|
else:
|
|
|
|
compose_dir = opts.compose_dir
|
|
|
|
|
2017-10-24 01:58:36 +00:00
|
|
|
if opts.print_output_dir:
|
|
|
|
print('Compose dir: %s' % compose_dir)
|
|
|
|
|
2015-11-26 07:45:33 +00:00
|
|
|
compose = Compose(conf,
|
|
|
|
topdir=compose_dir,
|
|
|
|
debug=opts.debug_mode,
|
|
|
|
skip_phases=opts.skip_phase,
|
|
|
|
just_phases=opts.just_phase,
|
|
|
|
old_composes=opts.old_composes,
|
|
|
|
koji_event=opts.koji_event,
|
|
|
|
supported=opts.supported,
|
|
|
|
logger=logger,
|
|
|
|
notifier=notifier)
|
|
|
|
notifier.compose = compose
|
2015-03-12 18:15:29 +00:00
|
|
|
COMPOSE = compose
|
2017-08-24 12:49:08 +00:00
|
|
|
run_compose(compose, create_latest_link=create_latest_link, latest_link_status=latest_link_status)
|
2015-03-12 18:15:29 +00:00
|
|
|
|
|
|
|
|
2017-03-17 15:53:16 +00:00
|
|
|
def run_compose(compose, create_latest_link=True, latest_link_status=None):
|
2015-03-12 18:15:29 +00:00
|
|
|
import pungi.phases
|
|
|
|
import pungi.metadata
|
2017-09-11 08:23:07 +00:00
|
|
|
import pungi.util
|
2015-11-23 15:09:01 +00:00
|
|
|
|
|
|
|
errors = []
|
|
|
|
|
2015-03-12 18:15:29 +00:00
|
|
|
compose.write_status("STARTED")
|
|
|
|
compose.log_info("Host: %s" % socket.gethostname())
|
2016-08-16 06:02:15 +00:00
|
|
|
compose.log_info("Pungi version: %s" % get_full_version())
|
2015-03-12 18:15:29 +00:00
|
|
|
compose.log_info("User name: %s" % getpass.getuser())
|
|
|
|
compose.log_info("Working directory: %s" % os.getcwd())
|
2017-09-21 07:29:53 +00:00
|
|
|
compose.log_info("Command line: %s" % " ".join([shlex_quote(arg) for arg in sys.argv]))
|
2015-03-12 18:15:29 +00:00
|
|
|
compose.log_info("Compose top directory: %s" % compose.topdir)
|
2017-09-11 08:23:07 +00:00
|
|
|
compose.log_info("Current timezone offset: %s" % pungi.util.get_tz_offset())
|
2015-03-12 18:15:29 +00:00
|
|
|
compose.read_variants()
|
|
|
|
|
|
|
|
# dump the config file
|
2018-07-26 21:55:13 +00:00
|
|
|
config_copy_path = os.path.join(compose.paths.log.topdir(), "config-copy")
|
|
|
|
if not os.path.exists(config_copy_path):
|
|
|
|
os.makedirs(config_copy_path)
|
2017-09-08 07:33:06 +00:00
|
|
|
for config_file in compose.conf.opened_files:
|
2018-07-26 21:55:13 +00:00
|
|
|
shutil.copy2(config_file, config_copy_path)
|
2018-11-15 12:26:16 +00:00
|
|
|
config_dump_full = compose.paths.log.log_file("global", "config-dump")
|
2016-09-21 06:09:34 +00:00
|
|
|
with open(config_dump_full, "w") as f:
|
|
|
|
json.dump(compose.conf, f, sort_keys=True, indent=4)
|
2015-03-12 18:15:29 +00:00
|
|
|
|
|
|
|
# initialize all phases
|
|
|
|
init_phase = pungi.phases.InitPhase(compose)
|
|
|
|
pkgset_phase = pungi.phases.PkgsetPhase(compose)
|
|
|
|
buildinstall_phase = pungi.phases.BuildinstallPhase(compose)
|
|
|
|
gather_phase = pungi.phases.GatherPhase(compose, pkgset_phase)
|
|
|
|
extrafiles_phase = pungi.phases.ExtraFilesPhase(compose, pkgset_phase)
|
2015-09-09 11:58:18 +00:00
|
|
|
createrepo_phase = pungi.phases.CreaterepoPhase(compose)
|
2018-05-07 08:47:48 +00:00
|
|
|
ostree_installer_phase = pungi.phases.OstreeInstallerPhase(compose, buildinstall_phase)
|
2016-03-23 09:38:34 +00:00
|
|
|
ostree_phase = pungi.phases.OSTreePhase(compose)
|
2015-09-09 11:58:18 +00:00
|
|
|
productimg_phase = pungi.phases.ProductimgPhase(compose, pkgset_phase)
|
2018-05-04 06:41:23 +00:00
|
|
|
createiso_phase = pungi.phases.CreateisoPhase(compose, buildinstall_phase)
|
2018-05-09 13:39:36 +00:00
|
|
|
extra_isos_phase = pungi.phases.ExtraIsosPhase(compose)
|
2015-03-12 18:15:29 +00:00
|
|
|
liveimages_phase = pungi.phases.LiveImagesPhase(compose)
|
2016-01-28 15:03:20 +00:00
|
|
|
livemedia_phase = pungi.phases.LiveMediaPhase(compose)
|
2015-09-01 08:03:34 +00:00
|
|
|
image_build_phase = pungi.phases.ImageBuildPhase(compose)
|
2016-06-20 13:43:55 +00:00
|
|
|
osbs_phase = pungi.phases.OSBSPhase(compose)
|
2015-11-20 09:40:54 +00:00
|
|
|
image_checksum_phase = pungi.phases.ImageChecksumPhase(compose)
|
2015-03-12 18:15:29 +00:00
|
|
|
test_phase = pungi.phases.TestPhase(compose)
|
|
|
|
|
|
|
|
# check if all config options are set
|
2015-09-10 11:12:08 +00:00
|
|
|
for phase in (init_phase, pkgset_phase, createrepo_phase,
|
|
|
|
buildinstall_phase, productimg_phase, gather_phase,
|
|
|
|
extrafiles_phase, createiso_phase, liveimages_phase,
|
2016-01-28 15:03:20 +00:00
|
|
|
livemedia_phase, image_build_phase, image_checksum_phase,
|
2016-06-20 13:43:55 +00:00
|
|
|
test_phase, ostree_phase, ostree_installer_phase,
|
2018-05-09 13:39:36 +00:00
|
|
|
extra_isos_phase, osbs_phase):
|
2015-03-12 18:15:29 +00:00
|
|
|
if phase.skip():
|
|
|
|
continue
|
|
|
|
try:
|
|
|
|
phase.validate()
|
|
|
|
except ValueError as ex:
|
|
|
|
for i in str(ex).splitlines():
|
|
|
|
errors.append("%s: %s" % (phase.name.upper(), i))
|
|
|
|
if errors:
|
|
|
|
for i in errors:
|
|
|
|
compose.log_error(i)
|
|
|
|
print(i)
|
2018-04-26 12:09:26 +00:00
|
|
|
raise RuntimeError('Configuration is not valid')
|
2015-03-12 18:15:29 +00:00
|
|
|
|
2016-02-12 12:00:19 +00:00
|
|
|
# PREP
|
|
|
|
|
|
|
|
# Note: This may be put into a new method of phase classes (e.g. .prep())
|
|
|
|
# in same way as .validate() or .run()
|
|
|
|
|
|
|
|
# Prep for liveimages - Obtain a password for signing rpm wrapped images
|
|
|
|
if ("signing_key_password_file" in compose.conf
|
|
|
|
and "signing_command" in compose.conf
|
|
|
|
and "%(signing_key_password)s" in compose.conf["signing_command"]
|
|
|
|
and not liveimages_phase.skip()):
|
|
|
|
# TODO: Don't require key if signing is turned off
|
|
|
|
# Obtain signing key password
|
|
|
|
signing_key_password = None
|
|
|
|
|
|
|
|
# Use appropriate method
|
|
|
|
if compose.conf["signing_key_password_file"] == "-":
|
|
|
|
# Use stdin (by getpass module)
|
|
|
|
try:
|
|
|
|
signing_key_password = getpass.getpass("Signing key password: ")
|
|
|
|
except EOFError:
|
|
|
|
compose.log_debug("Ignoring signing key password")
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
# Use text file with password
|
|
|
|
try:
|
|
|
|
signing_key_password = open(compose.conf["signing_key_password_file"], "r").readline().rstrip('\n')
|
|
|
|
except IOError:
|
|
|
|
# Filename is not print intentionally in case someone puts password directly into the option
|
|
|
|
err_msg = "Cannot load password from file specified by 'signing_key_password_file' option"
|
|
|
|
compose.log_error(err_msg)
|
|
|
|
print(err_msg)
|
2018-04-26 12:09:26 +00:00
|
|
|
raise RuntimeError(err_msg)
|
2016-02-12 12:00:19 +00:00
|
|
|
|
|
|
|
if signing_key_password:
|
|
|
|
# Store the password
|
|
|
|
compose.conf["signing_key_password"] = signing_key_password
|
|
|
|
|
2015-03-12 18:15:29 +00:00
|
|
|
init_phase.start()
|
|
|
|
init_phase.stop()
|
|
|
|
|
|
|
|
pkgset_phase.start()
|
|
|
|
pkgset_phase.stop()
|
|
|
|
|
2018-02-16 12:40:54 +00:00
|
|
|
# WEAVER phase - launches other phases which can safely run in parallel
|
|
|
|
essentials_schema = (
|
|
|
|
buildinstall_phase,
|
|
|
|
(gather_phase, extrafiles_phase, createrepo_phase),
|
|
|
|
(ostree_phase, ostree_installer_phase),
|
|
|
|
)
|
|
|
|
essentials_phase = pungi.phases.WeaverPhase(compose, essentials_schema)
|
|
|
|
essentials_phase.start()
|
|
|
|
essentials_phase.stop()
|
2015-03-12 18:15:29 +00:00
|
|
|
|
2018-02-16 12:40:54 +00:00
|
|
|
productimg_phase.start()
|
|
|
|
productimg_phase.stop()
|
2015-03-12 18:15:29 +00:00
|
|
|
|
|
|
|
# write treeinfo before ISOs are created
|
|
|
|
for variant in compose.get_variants():
|
|
|
|
for arch in variant.arches + ["src"]:
|
2017-11-08 13:24:01 +00:00
|
|
|
pungi.metadata.write_tree_info(compose, arch, variant, bi=buildinstall_phase)
|
2015-03-12 18:15:29 +00:00
|
|
|
|
|
|
|
# write .discinfo and media.repo before ISOs are created
|
2016-11-09 12:39:01 +00:00
|
|
|
for variant in compose.get_variants():
|
2016-02-16 09:23:08 +00:00
|
|
|
if variant.type == "addon" or variant.is_empty:
|
2015-03-12 18:15:29 +00:00
|
|
|
continue
|
|
|
|
for arch in variant.arches + ["src"]:
|
|
|
|
timestamp = pungi.metadata.write_discinfo(compose, arch, variant)
|
|
|
|
pungi.metadata.write_media_repo(compose, arch, variant, timestamp)
|
|
|
|
|
2017-05-29 07:56:23 +00:00
|
|
|
# Start all phases for image artifacts
|
2018-02-16 12:40:54 +00:00
|
|
|
compose_images_schema = (
|
|
|
|
createiso_phase,
|
2018-05-09 13:39:36 +00:00
|
|
|
extra_isos_phase,
|
2018-02-16 12:40:54 +00:00
|
|
|
liveimages_phase,
|
|
|
|
image_build_phase,
|
|
|
|
livemedia_phase,
|
|
|
|
osbs_phase,
|
|
|
|
)
|
|
|
|
compose_images_phase = pungi.phases.WeaverPhase(compose, compose_images_schema)
|
|
|
|
compose_images_phase.start()
|
|
|
|
compose_images_phase.stop()
|
2015-03-12 18:15:29 +00:00
|
|
|
|
2015-11-20 09:40:54 +00:00
|
|
|
image_checksum_phase.start()
|
|
|
|
image_checksum_phase.stop()
|
2015-03-12 18:15:29 +00:00
|
|
|
|
|
|
|
pungi.metadata.write_compose_info(compose)
|
2016-10-19 13:02:33 +00:00
|
|
|
compose.im.dump(compose.paths.compose.metadata("images.json"))
|
2016-06-20 13:43:55 +00:00
|
|
|
osbs_phase.dump_metadata()
|
2015-03-12 18:15:29 +00:00
|
|
|
|
|
|
|
test_phase.start()
|
|
|
|
test_phase.stop()
|
|
|
|
|
2017-03-17 15:53:16 +00:00
|
|
|
compose.write_status("FINISHED")
|
2019-02-07 13:17:09 +00:00
|
|
|
osbs_phase.request_push()
|
2017-03-17 15:53:16 +00:00
|
|
|
latest_link = False
|
2016-10-25 04:34:36 +00:00
|
|
|
if create_latest_link:
|
2017-03-17 15:53:16 +00:00
|
|
|
if latest_link_status is None:
|
|
|
|
# create latest symbol link by default if latest_link_status is not specified
|
|
|
|
latest_link = True
|
|
|
|
else:
|
|
|
|
latest_link_status = [s.upper() for s in latest_link_status]
|
|
|
|
if compose.get_status() in [s.upper() for s in latest_link_status]:
|
|
|
|
latest_link = True
|
|
|
|
else:
|
|
|
|
compose.log_warning("Compose status (%s) doesn't match with specified latest-link-status (%s), not create latest link."
|
|
|
|
% (compose.get_status(), str(latest_link_status)))
|
|
|
|
|
|
|
|
if latest_link:
|
2016-10-25 04:34:36 +00:00
|
|
|
compose_dir = os.path.basename(compose.topdir)
|
|
|
|
if len(compose.conf["release_version"].split(".")) == 1:
|
|
|
|
symlink_name = "latest-%s-%s" % (compose.conf["release_short"], compose.conf["release_version"])
|
|
|
|
else:
|
|
|
|
symlink_name = "latest-%s-%s" % (compose.conf["release_short"], ".".join(compose.conf["release_version"].split(".")[:-1]))
|
2019-06-03 06:55:40 +00:00
|
|
|
if compose.conf.get("base_product_name", ""):
|
2016-10-25 04:34:36 +00:00
|
|
|
symlink_name += "-%s-%s" % (compose.conf["base_product_short"], compose.conf["base_product_version"])
|
|
|
|
symlink = os.path.join(compose.topdir, "..", symlink_name)
|
2015-03-12 18:15:29 +00:00
|
|
|
|
2016-10-25 04:34:36 +00:00
|
|
|
try:
|
|
|
|
os.unlink(symlink)
|
|
|
|
except OSError as ex:
|
|
|
|
if ex.errno != 2:
|
|
|
|
raise
|
|
|
|
try:
|
|
|
|
os.symlink(compose_dir, symlink)
|
|
|
|
except Exception as ex:
|
|
|
|
compose.log_error("Couldn't create latest symlink: %s" % ex)
|
2017-10-12 20:39:41 +00:00
|
|
|
raise
|
2015-03-12 18:15:29 +00:00
|
|
|
|
|
|
|
compose.log_info("Compose finished: %s" % compose.topdir)
|
|
|
|
|
|
|
|
|
2018-05-11 14:49:01 +00:00
|
|
|
def sigterm_handler(signum, frame):
|
|
|
|
if COMPOSE:
|
|
|
|
COMPOSE.log_error("Compose run failed: signal %s" % signum)
|
|
|
|
COMPOSE.log_error("Traceback:\n%s"
|
|
|
|
% '\n'.join(traceback.format_stack(frame)))
|
|
|
|
COMPOSE.log_critical("Compose failed: %s" % COMPOSE.topdir)
|
|
|
|
COMPOSE.write_status("TERMINATED")
|
|
|
|
else:
|
|
|
|
print("Signal %s captured" % signum)
|
|
|
|
sys.stdout.flush()
|
|
|
|
sys.stderr.flush()
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
2015-03-12 18:15:29 +00:00
|
|
|
if __name__ == "__main__":
|
2018-05-11 14:49:01 +00:00
|
|
|
signal.signal(signal.SIGTERM, sigterm_handler)
|
|
|
|
|
2015-03-12 18:15:29 +00:00
|
|
|
try:
|
|
|
|
main()
|
|
|
|
except (Exception, KeyboardInterrupt) as ex:
|
|
|
|
if COMPOSE:
|
|
|
|
tb_path = COMPOSE.paths.log.log_file("global", "traceback")
|
2017-08-24 12:49:08 +00:00
|
|
|
COMPOSE.log_error("Compose run failed: %s" % ex)
|
2015-03-12 18:15:29 +00:00
|
|
|
COMPOSE.log_error("Extended traceback in: %s" % tb_path)
|
|
|
|
COMPOSE.log_critical("Compose failed: %s" % COMPOSE.topdir)
|
|
|
|
COMPOSE.write_status("DOOMED")
|
|
|
|
import kobo.tback
|
2017-09-05 08:01:21 +00:00
|
|
|
with open(tb_path, "wb") as f:
|
2017-10-10 16:47:21 +00:00
|
|
|
f.write(kobo.tback.Traceback().get_traceback())
|
2015-03-12 18:15:29 +00:00
|
|
|
else:
|
|
|
|
print("Exception: %s" % ex)
|
2015-08-25 12:11:14 +00:00
|
|
|
raise
|
2015-03-12 18:15:29 +00:00
|
|
|
sys.stdout.flush()
|
|
|
|
sys.stderr.flush()
|
2015-08-25 12:11:14 +00:00
|
|
|
sys.exit(1)
|