Remove debug mode
This was already discouraged to not be used, and is a bad idea in current setup anyway. Removing this can simplify the code. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
0891bfbe59
commit
6efaae19fd
@ -76,12 +76,6 @@ def main():
|
|||||||
action="append",
|
action="append",
|
||||||
help="Path to directory with old composes. Reuse an existing repodata from the most recent compose.",
|
help="Path to directory with old composes. Reuse an existing repodata from the most recent compose.",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
|
||||||
"--debug-mode",
|
|
||||||
action="store_true",
|
|
||||||
default=False,
|
|
||||||
help="run pungi in DEBUG mode (DANGEROUS!)",
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--config",
|
"--config",
|
||||||
help="Config file",
|
help="Config file",
|
||||||
@ -252,7 +246,6 @@ def main():
|
|||||||
|
|
||||||
compose = Compose(conf,
|
compose = Compose(conf,
|
||||||
topdir=compose_dir,
|
topdir=compose_dir,
|
||||||
debug=opts.debug_mode,
|
|
||||||
skip_phases=opts.skip_phase,
|
skip_phases=opts.skip_phase,
|
||||||
just_phases=opts.just_phase,
|
just_phases=opts.just_phase,
|
||||||
old_composes=opts.old_composes,
|
old_composes=opts.old_composes,
|
||||||
|
@ -106,7 +106,7 @@ def get_compose_dir(topdir, conf, compose_type="production", compose_date=None,
|
|||||||
|
|
||||||
|
|
||||||
class Compose(kobo.log.LoggingBase):
|
class Compose(kobo.log.LoggingBase):
|
||||||
def __init__(self, conf, topdir, debug=False, skip_phases=None, just_phases=None, old_composes=None, koji_event=None, supported=False, logger=None, notifier=None):
|
def __init__(self, conf, topdir, skip_phases=None, just_phases=None, old_composes=None, koji_event=None, supported=False, logger=None, notifier=None):
|
||||||
kobo.log.LoggingBase.__init__(self, logger)
|
kobo.log.LoggingBase.__init__(self, logger)
|
||||||
# TODO: check if minimal conf values are set
|
# TODO: check if minimal conf values are set
|
||||||
self.conf = conf
|
self.conf = conf
|
||||||
@ -122,9 +122,6 @@ class Compose(kobo.log.LoggingBase):
|
|||||||
self.koji_event = koji_event or conf.get("koji_event")
|
self.koji_event = koji_event or conf.get("koji_event")
|
||||||
self.notifier = notifier
|
self.notifier = notifier
|
||||||
|
|
||||||
# intentionally upper-case (visible in the code)
|
|
||||||
self.DEBUG = debug
|
|
||||||
|
|
||||||
# path definitions
|
# path definitions
|
||||||
self.paths = Paths(self)
|
self.paths = Paths(self)
|
||||||
|
|
||||||
@ -142,17 +139,6 @@ class Compose(kobo.log.LoggingBase):
|
|||||||
self.supported = True
|
self.supported = True
|
||||||
|
|
||||||
self.im = Images()
|
self.im = Images()
|
||||||
if self.DEBUG:
|
|
||||||
try:
|
|
||||||
self.im.load(self.paths.compose.metadata("images.json"))
|
|
||||||
except RuntimeError:
|
|
||||||
pass
|
|
||||||
# images.json doesn't exists
|
|
||||||
except IOError:
|
|
||||||
pass
|
|
||||||
# images.json is not a valid json file, for example, it's an empty file
|
|
||||||
except ValueError:
|
|
||||||
pass
|
|
||||||
self.im.compose.id = self.compose_id
|
self.im.compose.id = self.compose_id
|
||||||
self.im.compose.type = self.compose_type
|
self.im.compose.type = self.compose_type
|
||||||
self.im.compose.date = self.compose_date
|
self.im.compose.date = self.compose_date
|
||||||
@ -235,14 +221,13 @@ class Compose(kobo.log.LoggingBase):
|
|||||||
variants_file = self.paths.work.variants_file(arch="global")
|
variants_file = self.paths.work.variants_file(arch="global")
|
||||||
msg = "Writing variants file: %s" % variants_file
|
msg = "Writing variants file: %s" % variants_file
|
||||||
|
|
||||||
if self.DEBUG and os.path.isfile(variants_file):
|
|
||||||
self.log_warning("[SKIP ] %s" % msg)
|
|
||||||
else:
|
|
||||||
scm_dict = self.conf["variants_file"]
|
scm_dict = self.conf["variants_file"]
|
||||||
if isinstance(scm_dict, dict):
|
if isinstance(scm_dict, dict):
|
||||||
file_name = os.path.basename(scm_dict["file"])
|
file_name = os.path.basename(scm_dict["file"])
|
||||||
if scm_dict["scm"] == "file":
|
if scm_dict["scm"] == "file":
|
||||||
scm_dict["file"] = os.path.join(self.config_dir, os.path.basename(scm_dict["file"]))
|
scm_dict["file"] = os.path.join(
|
||||||
|
self.config_dir, os.path.basename(scm_dict["file"])
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
file_name = os.path.basename(scm_dict)
|
file_name = os.path.basename(scm_dict)
|
||||||
scm_dict = os.path.join(self.config_dir, os.path.basename(scm_dict))
|
scm_dict = os.path.join(self.config_dir, os.path.basename(scm_dict))
|
||||||
|
@ -122,10 +122,6 @@ def create_variant_repo(compose, arch, variant, pkg_type, modules_metadata=None)
|
|||||||
return
|
return
|
||||||
createrepo_dirs.add(repo_dir)
|
createrepo_dirs.add(repo_dir)
|
||||||
|
|
||||||
if compose.DEBUG and os.path.isdir(os.path.join(repo_dir, "repodata")):
|
|
||||||
compose.log_warning("[SKIP ] %s" % msg)
|
|
||||||
return
|
|
||||||
|
|
||||||
compose.log_info("[BEGIN] %s" % msg)
|
compose.log_info("[BEGIN] %s" % msg)
|
||||||
|
|
||||||
# We only want delta RPMs for binary repos.
|
# We only want delta RPMs for binary repos.
|
||||||
|
@ -91,11 +91,6 @@ class GatherPhase(PhaseBase):
|
|||||||
raise ValueError('\n'.join(errors))
|
raise ValueError('\n'.join(errors))
|
||||||
|
|
||||||
def _write_manifest(self):
|
def _write_manifest(self):
|
||||||
if self.compose.DEBUG and os.path.isfile(self.manifest_file):
|
|
||||||
self.compose.log_info(
|
|
||||||
"Skipping writing RPM manifest, already exists: %s" % self.manifest_file
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
self.compose.log_info("Writing RPM manifest: %s" % self.manifest_file)
|
self.compose.log_info("Writing RPM manifest: %s" % self.manifest_file)
|
||||||
self.manifest.dump(self.manifest_file)
|
self.manifest.dump(self.manifest_file)
|
||||||
|
|
||||||
@ -517,9 +512,6 @@ def write_prepopulate_file(compose):
|
|||||||
prepopulate_file = os.path.join(compose.paths.work.topdir(arch="global"), "prepopulate.json")
|
prepopulate_file = os.path.join(compose.paths.work.topdir(arch="global"), "prepopulate.json")
|
||||||
msg = "Writing prepopulate file: %s" % prepopulate_file
|
msg = "Writing prepopulate file: %s" % prepopulate_file
|
||||||
|
|
||||||
if compose.DEBUG and os.path.isfile(prepopulate_file):
|
|
||||||
compose.log_warning("[SKIP ] %s" % msg)
|
|
||||||
else:
|
|
||||||
scm_dict = compose.conf["gather_prepopulate"]
|
scm_dict = compose.conf["gather_prepopulate"]
|
||||||
if isinstance(scm_dict, dict):
|
if isinstance(scm_dict, dict):
|
||||||
file_name = os.path.basename(scm_dict["file"])
|
file_name = os.path.basename(scm_dict["file"])
|
||||||
|
@ -89,10 +89,6 @@ def write_pungi_config(compose, arch, variant, packages, groups, filter_packages
|
|||||||
pungi_cfg = compose.paths.work.pungi_conf(variant=variant, arch=arch, source_name=source_name)
|
pungi_cfg = compose.paths.work.pungi_conf(variant=variant, arch=arch, source_name=source_name)
|
||||||
msg = "Writing pungi config (arch: %s, variant: %s): %s" % (arch, variant, pungi_cfg)
|
msg = "Writing pungi config (arch: %s, variant: %s): %s" % (arch, variant, pungi_cfg)
|
||||||
|
|
||||||
if compose.DEBUG and os.path.isfile(pungi_cfg):
|
|
||||||
compose.log_warning("[SKIP ] %s" % msg)
|
|
||||||
return
|
|
||||||
|
|
||||||
compose.log_info(msg)
|
compose.log_info(msg)
|
||||||
|
|
||||||
repos = {
|
repos = {
|
||||||
@ -160,11 +156,6 @@ def resolve_deps(compose, arch, variant, source_name=None):
|
|||||||
pungi_log = compose.paths.work.pungi_log(arch, variant, source_name=source_name)
|
pungi_log = compose.paths.work.pungi_log(arch, variant, source_name=source_name)
|
||||||
|
|
||||||
msg = "Running pungi (arch: %s, variant: %s)" % (arch, variant)
|
msg = "Running pungi (arch: %s, variant: %s)" % (arch, variant)
|
||||||
if compose.DEBUG and os.path.exists(pungi_log):
|
|
||||||
compose.log_warning("[SKIP ] %s" % msg)
|
|
||||||
with open(pungi_log, "r") as f:
|
|
||||||
res, broken_deps, _ = pungi_wrapper.parse_log(f)
|
|
||||||
return res, broken_deps
|
|
||||||
|
|
||||||
compose.log_info("[BEGIN] %s" % msg)
|
compose.log_info("[BEGIN] %s" % msg)
|
||||||
pungi_conf = compose.paths.work.pungi_conf(arch, variant, source_name=source_name)
|
pungi_conf = compose.paths.work.pungi_conf(arch, variant, source_name=source_name)
|
||||||
|
@ -90,9 +90,6 @@ def write_global_comps(compose):
|
|||||||
comps_file_global = compose.paths.work.comps(arch="global")
|
comps_file_global = compose.paths.work.comps(arch="global")
|
||||||
msg = "Writing global comps file: %s" % comps_file_global
|
msg = "Writing global comps file: %s" % comps_file_global
|
||||||
|
|
||||||
if compose.DEBUG and os.path.isfile(comps_file_global):
|
|
||||||
compose.log_warning("[SKIP ] %s" % msg)
|
|
||||||
else:
|
|
||||||
scm_dict = compose.conf["comps_file"]
|
scm_dict = compose.conf["comps_file"]
|
||||||
if isinstance(scm_dict, dict):
|
if isinstance(scm_dict, dict):
|
||||||
comps_name = os.path.basename(scm_dict["file"])
|
comps_name = os.path.basename(scm_dict["file"])
|
||||||
@ -115,10 +112,6 @@ def write_arch_comps(compose, arch):
|
|||||||
comps_file_arch = compose.paths.work.comps(arch=arch)
|
comps_file_arch = compose.paths.work.comps(arch=arch)
|
||||||
msg = "Writing comps file for arch '%s': %s" % (arch, comps_file_arch)
|
msg = "Writing comps file for arch '%s': %s" % (arch, comps_file_arch)
|
||||||
|
|
||||||
if compose.DEBUG and os.path.isfile(comps_file_arch):
|
|
||||||
compose.log_warning("[SKIP ] %s" % msg)
|
|
||||||
return
|
|
||||||
|
|
||||||
compose.log_debug(msg)
|
compose.log_debug(msg)
|
||||||
run(["comps_filter", "--arch=%s" % arch, "--no-cleanup",
|
run(["comps_filter", "--arch=%s" % arch, "--no-cleanup",
|
||||||
"--output=%s" % comps_file_arch,
|
"--output=%s" % comps_file_arch,
|
||||||
@ -145,17 +138,6 @@ def write_variant_comps(compose, arch, variant):
|
|||||||
comps_file = compose.paths.work.comps(arch=arch, variant=variant)
|
comps_file = compose.paths.work.comps(arch=arch, variant=variant)
|
||||||
msg = "Writing comps file (arch: %s, variant: %s): %s" % (arch, variant, comps_file)
|
msg = "Writing comps file (arch: %s, variant: %s): %s" % (arch, variant, comps_file)
|
||||||
|
|
||||||
if compose.DEBUG and os.path.isfile(comps_file):
|
|
||||||
# read display_order and groups for environments (needed for live images)
|
|
||||||
comps = CompsWrapper(comps_file)
|
|
||||||
# groups = variant.groups
|
|
||||||
comps.filter_groups(variant.groups)
|
|
||||||
if compose.conf["comps_filter_environments"]:
|
|
||||||
comps.filter_environments(variant.environments)
|
|
||||||
|
|
||||||
compose.log_warning("[SKIP ] %s" % msg)
|
|
||||||
return
|
|
||||||
|
|
||||||
compose.log_debug(msg)
|
compose.log_debug(msg)
|
||||||
cmd = [
|
cmd = [
|
||||||
"comps_filter",
|
"comps_filter",
|
||||||
@ -194,16 +176,16 @@ def create_comps_repo(compose, arch, variant):
|
|||||||
comps_repo = compose.paths.work.comps_repo(arch=arch, variant=variant)
|
comps_repo = compose.paths.work.comps_repo(arch=arch, variant=variant)
|
||||||
comps_path = compose.paths.work.comps(arch=arch, variant=variant)
|
comps_path = compose.paths.work.comps(arch=arch, variant=variant)
|
||||||
msg = "Creating comps repo for arch '%s' variant '%s'" % (arch, variant.uid if variant else None)
|
msg = "Creating comps repo for arch '%s' variant '%s'" % (arch, variant.uid if variant else None)
|
||||||
if compose.DEBUG and os.path.isdir(os.path.join(comps_repo, "repodata")):
|
|
||||||
compose.log_warning("[SKIP ] %s" % msg)
|
|
||||||
else:
|
|
||||||
compose.log_info("[BEGIN] %s" % msg)
|
compose.log_info("[BEGIN] %s" % msg)
|
||||||
cmd = repo.get_createrepo_cmd(comps_repo, database=False,
|
cmd = repo.get_createrepo_cmd(
|
||||||
outputdir=comps_repo, groupfile=comps_path,
|
comps_repo, database=False,
|
||||||
checksum=createrepo_checksum)
|
outputdir=comps_repo,
|
||||||
logfile = 'comps_repo-%s' % variant if variant else 'comps_repo'
|
groupfile=comps_path,
|
||||||
run(cmd, logfile=compose.paths.log.log_file(arch, logfile),
|
checksum=createrepo_checksum,
|
||||||
show_cmd=True)
|
)
|
||||||
|
logfile = "comps_repo-%s" % variant if variant else "comps_repo"
|
||||||
|
run(cmd, logfile=compose.paths.log.log_file(arch, logfile), show_cmd=True)
|
||||||
compose.log_info("[DONE ] %s" % msg)
|
compose.log_info("[DONE ] %s" % msg)
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,10 +48,6 @@ def get_create_global_repo_cmd(compose, path_prefix):
|
|||||||
repo = CreaterepoWrapper(createrepo_c=createrepo_c)
|
repo = CreaterepoWrapper(createrepo_c=createrepo_c)
|
||||||
repo_dir_global = compose.paths.work.arch_repo(arch="global")
|
repo_dir_global = compose.paths.work.arch_repo(arch="global")
|
||||||
|
|
||||||
if compose.DEBUG and os.path.isdir(os.path.join(repo_dir_global, "repodata")):
|
|
||||||
compose.log_warning("[SKIP ] Running createrepo for the global package set")
|
|
||||||
return
|
|
||||||
|
|
||||||
# find an old compose suitable for repodata reuse
|
# find an old compose suitable for repodata reuse
|
||||||
old_compose_path = None
|
old_compose_path = None
|
||||||
update_md_path = None
|
update_md_path = None
|
||||||
@ -108,10 +104,6 @@ def _create_arch_repo(worker_thread, args, task_num):
|
|||||||
repo_dir = compose.paths.work.arch_repo(arch=arch)
|
repo_dir = compose.paths.work.arch_repo(arch=arch)
|
||||||
msg = "Running createrepo for arch '%s'" % arch
|
msg = "Running createrepo for arch '%s'" % arch
|
||||||
|
|
||||||
if compose.DEBUG and os.path.isdir(os.path.join(repo_dir, "repodata")):
|
|
||||||
compose.log_warning("[SKIP ] %s" % msg)
|
|
||||||
return
|
|
||||||
|
|
||||||
compose.log_info("[BEGIN] %s" % msg)
|
compose.log_info("[BEGIN] %s" % msg)
|
||||||
cmd = repo.get_createrepo_cmd(path_prefix, update=True, database=False, skip_stat=True,
|
cmd = repo.get_createrepo_cmd(path_prefix, update=True, database=False, skip_stat=True,
|
||||||
pkglist=compose.paths.work.package_list(arch=arch), outputdir=repo_dir,
|
pkglist=compose.paths.work.package_list(arch=arch), outputdir=repo_dir,
|
||||||
|
@ -600,14 +600,7 @@ def populate_global_pkgset(compose, koji_wrapper, path_prefix, event):
|
|||||||
|
|
||||||
inherit = compose.conf["pkgset_koji_inherit"]
|
inherit = compose.conf["pkgset_koji_inherit"]
|
||||||
inherit_modules = compose.conf["pkgset_koji_inherit_modules"]
|
inherit_modules = compose.conf["pkgset_koji_inherit_modules"]
|
||||||
global_pkgset_path = os.path.join(
|
|
||||||
compose.paths.work.topdir(arch="global"), "pkgset_global.pickle")
|
|
||||||
if compose.DEBUG and os.path.isfile(global_pkgset_path):
|
|
||||||
msg = "Populating the global package set from tag '%s'" % compose_tags
|
|
||||||
compose.log_warning("[SKIP ] %s" % msg)
|
|
||||||
with open(global_pkgset_path, "rb") as f:
|
|
||||||
global_pkgset = pickle.load(f)
|
|
||||||
else:
|
|
||||||
global_pkgset = pungi.phases.pkgset.pkgsets.KojiPackageSet(
|
global_pkgset = pungi.phases.pkgset.pkgsets.KojiPackageSet(
|
||||||
koji_wrapper, compose.conf["sigkeys"], logger=compose._logger,
|
koji_wrapper, compose.conf["sigkeys"], logger=compose._logger,
|
||||||
arches=all_arches)
|
arches=all_arches)
|
||||||
@ -625,8 +618,9 @@ def populate_global_pkgset(compose, koji_wrapper, path_prefix, event):
|
|||||||
# list. Also prepare per-variant pkgset, because we do not have list
|
# list. Also prepare per-variant pkgset, because we do not have list
|
||||||
# of binary RPMs in module definition - there is just list of SRPMs.
|
# of binary RPMs in module definition - there is just list of SRPMs.
|
||||||
for compose_tag in compose_tags:
|
for compose_tag in compose_tags:
|
||||||
compose.log_info("Populating the global package set from tag "
|
compose.log_info(
|
||||||
"'%s'" % compose_tag)
|
"Populating the global package set from tag '%s'" % compose_tag
|
||||||
|
)
|
||||||
if compose_tag in pkgset_koji_tags:
|
if compose_tag in pkgset_koji_tags:
|
||||||
extra_builds = force_list(compose.conf.get("pkgset_koji_builds", []))
|
extra_builds = force_list(compose.conf.get("pkgset_koji_builds", []))
|
||||||
else:
|
else:
|
||||||
@ -644,8 +638,9 @@ def populate_global_pkgset(compose, koji_wrapper, path_prefix, event):
|
|||||||
# name is included in filename, so any slashes in it are replaced
|
# name is included in filename, so any slashes in it are replaced
|
||||||
# with underscores just to be safe.
|
# with underscores just to be safe.
|
||||||
logfile = compose.paths.log.log_file(
|
logfile = compose.paths.log.log_file(
|
||||||
None, 'packages_from_%s' % compose_tag.replace('/', '_'))
|
None, "packages_from_%s" % compose_tag.replace("/", "_")
|
||||||
is_traditional = compose_tag in compose.conf.get('pkgset_koji_tag', [])
|
)
|
||||||
|
is_traditional = compose_tag in compose.conf.get("pkgset_koji_tag", [])
|
||||||
should_inherit = inherit if is_traditional else inherit_modules
|
should_inherit = inherit if is_traditional else inherit_modules
|
||||||
|
|
||||||
# If we're processing a modular tag, we have an exact list of
|
# If we're processing a modular tag, we have an exact list of
|
||||||
@ -695,7 +690,11 @@ def populate_global_pkgset(compose, koji_wrapper, path_prefix, event):
|
|||||||
global_pkgset = pkgset
|
global_pkgset = pkgset
|
||||||
else:
|
else:
|
||||||
global_pkgset.fast_merge(pkgset)
|
global_pkgset.fast_merge(pkgset)
|
||||||
with open(global_pkgset_path, 'wb') as f:
|
|
||||||
|
global_pkgset_path = os.path.join(
|
||||||
|
compose.paths.work.topdir(arch="global"), "pkgset_global.pickle"
|
||||||
|
)
|
||||||
|
with open(global_pkgset_path, "wb") as f:
|
||||||
data = pickle.dumps(global_pkgset, protocol=pickle.HIGHEST_PROTOCOL)
|
data = pickle.dumps(global_pkgset, protocol=pickle.HIGHEST_PROTOCOL)
|
||||||
f.write(data)
|
f.write(data)
|
||||||
|
|
||||||
@ -711,10 +710,6 @@ def get_koji_event_info(compose, koji_wrapper):
|
|||||||
event_file = os.path.join(compose.paths.work.topdir(arch="global"), "koji-event")
|
event_file = os.path.join(compose.paths.work.topdir(arch="global"), "koji-event")
|
||||||
|
|
||||||
msg = "Getting koji event"
|
msg = "Getting koji event"
|
||||||
if compose.DEBUG and os.path.exists(event_file):
|
|
||||||
compose.log_warning("[SKIP ] %s" % msg)
|
|
||||||
result = json.load(open(event_file, "r"))
|
|
||||||
else:
|
|
||||||
result = get_koji_event_raw(koji_wrapper, compose.koji_event, event_file)
|
result = get_koji_event_raw(koji_wrapper, compose.koji_event, event_file)
|
||||||
if compose.koji_event:
|
if compose.koji_event:
|
||||||
compose.log_info("Setting koji event to a custom value: %s" % compose.koji_event)
|
compose.log_info("Setting koji event to a custom value: %s" % compose.koji_event)
|
||||||
|
@ -140,13 +140,11 @@ def populate_global_pkgset(compose, file_list, path_prefix):
|
|||||||
|
|
||||||
msg = "Populating the global package set from a file list"
|
msg = "Populating the global package set from a file list"
|
||||||
global_pkgset_path = os.path.join(compose.paths.work.topdir(arch="global"), "packages.pickle")
|
global_pkgset_path = os.path.join(compose.paths.work.topdir(arch="global"), "packages.pickle")
|
||||||
if compose.DEBUG and os.path.isfile(global_pkgset_path):
|
|
||||||
compose.log_warning("[SKIP ] %s" % msg)
|
|
||||||
with open(global_pkgset_path, "rb") as f:
|
|
||||||
pkgset = pickle.load(f)
|
|
||||||
else:
|
|
||||||
compose.log_info(msg)
|
compose.log_info(msg)
|
||||||
pkgset = pungi.phases.pkgset.pkgsets.FilelistPackageSet(compose.conf["sigkeys"], logger=compose._logger, arches=ALL_ARCHES)
|
pkgset = pungi.phases.pkgset.pkgsets.FilelistPackageSet(
|
||||||
|
compose.conf["sigkeys"], logger=compose._logger, arches=ALL_ARCHES
|
||||||
|
)
|
||||||
pkgset.populate(file_list)
|
pkgset.populate(file_list)
|
||||||
with open(global_pkgset_path, "wb") as f:
|
with open(global_pkgset_path, "wb") as f:
|
||||||
pickle.dump(pkgset, f, protocol=pickle.HIGHEST_PROTOCOL)
|
pickle.dump(pkgset, f, protocol=pickle.HIGHEST_PROTOCOL)
|
||||||
@ -162,10 +160,6 @@ def write_pungi_config(compose, arch, variant, repos=None, comps_repo=None, pack
|
|||||||
pungi_cfg = compose.paths.work.pungi_conf(variant=variant, arch=arch)
|
pungi_cfg = compose.paths.work.pungi_conf(variant=variant, arch=arch)
|
||||||
msg = "Writing pungi config (arch: %s, variant: %s): %s" % (arch, variant, pungi_cfg)
|
msg = "Writing pungi config (arch: %s, variant: %s): %s" % (arch, variant, pungi_cfg)
|
||||||
|
|
||||||
if compose.DEBUG and os.path.isfile(pungi_cfg):
|
|
||||||
compose.log_warning("[SKIP ] %s" % msg)
|
|
||||||
return
|
|
||||||
|
|
||||||
compose.log_info(msg)
|
compose.log_info(msg)
|
||||||
packages, grps = get_packages_to_gather(compose, arch, variant)
|
packages, grps = get_packages_to_gather(compose, arch, variant)
|
||||||
|
|
||||||
|
@ -175,8 +175,6 @@ class DummyCompose(object):
|
|||||||
self.should_create_yum_database = True
|
self.should_create_yum_database = True
|
||||||
self.cache_region = None
|
self.cache_region = None
|
||||||
|
|
||||||
self.DEBUG = False
|
|
||||||
|
|
||||||
def setup_optional(self):
|
def setup_optional(self):
|
||||||
self.all_variants['Server-optional'] = MockVariant(
|
self.all_variants['Server-optional'] = MockVariant(
|
||||||
uid='Server-optional', arches=['x86_64'], type='optional')
|
uid='Server-optional', arches=['x86_64'], type='optional')
|
||||||
|
@ -861,26 +861,6 @@ class TestGatherPhase(helpers.PungiTestCase):
|
|||||||
self.assertEqual(gather_wrapper.call_args_list, [])
|
self.assertEqual(gather_wrapper.call_args_list, [])
|
||||||
self.assertTrue(os.path.isfile(os.path.join(self.topdir, 'compose', 'metadata', 'rpms.json')))
|
self.assertTrue(os.path.isfile(os.path.join(self.topdir, 'compose', 'metadata', 'rpms.json')))
|
||||||
|
|
||||||
@mock.patch('pungi.phases.gather.link_files')
|
|
||||||
@mock.patch('pungi.phases.gather.gather_wrapper')
|
|
||||||
def test_does_not_write_in_debug_mode(self, gather_wrapper, link_files):
|
|
||||||
pkgset_phase = mock.Mock()
|
|
||||||
compose = helpers.DummyCompose(self.topdir, {})
|
|
||||||
compose.notifier = mock.Mock()
|
|
||||||
compose.DEBUG = True
|
|
||||||
|
|
||||||
rpms_file = helpers.touch(
|
|
||||||
os.path.join(self.topdir, 'compose', 'metadata', 'rpms.json'), "hello"
|
|
||||||
)
|
|
||||||
|
|
||||||
phase = gather.GatherPhase(compose, pkgset_phase)
|
|
||||||
phase.stop()
|
|
||||||
|
|
||||||
self.assertEqual(gather_wrapper.call_args_list, [])
|
|
||||||
self.assertTrue(os.path.isfile(rpms_file))
|
|
||||||
with open(rpms_file) as fh:
|
|
||||||
self.assertEqual(fh.read(), "hello")
|
|
||||||
|
|
||||||
def test_validates_wrong_requiring_variant(self):
|
def test_validates_wrong_requiring_variant(self):
|
||||||
pkgset_phase = mock.Mock()
|
pkgset_phase = mock.Mock()
|
||||||
compose = helpers.DummyCompose(
|
compose = helpers.DummyCompose(
|
||||||
|
@ -185,16 +185,6 @@ class TestWriteArchComps(PungiTestCase):
|
|||||||
'--output=%s/work/x86_64/comps/comps-x86_64.xml' % self.topdir,
|
'--output=%s/work/x86_64/comps/comps-x86_64.xml' % self.topdir,
|
||||||
self.topdir + '/work/global/comps/comps-global.xml'])])
|
self.topdir + '/work/global/comps/comps-global.xml'])])
|
||||||
|
|
||||||
@mock.patch('pungi.phases.init.run')
|
|
||||||
def test_run_in_debug(self, run):
|
|
||||||
compose = DummyCompose(self.topdir, {})
|
|
||||||
compose.DEBUG = True
|
|
||||||
touch(self.topdir + '/work/x86_64/comps/comps-x86_64.xml')
|
|
||||||
|
|
||||||
init.write_arch_comps(compose, 'x86_64')
|
|
||||||
|
|
||||||
self.assertEqual(run.mock_calls, [])
|
|
||||||
|
|
||||||
|
|
||||||
class TestCreateCompsRepo(PungiTestCase):
|
class TestCreateCompsRepo(PungiTestCase):
|
||||||
|
|
||||||
@ -232,33 +222,9 @@ class TestCreateCompsRepo(PungiTestCase):
|
|||||||
logfile=self.topdir + '/logs/x86_64/comps_repo-Server.x86_64.log',
|
logfile=self.topdir + '/logs/x86_64/comps_repo-Server.x86_64.log',
|
||||||
show_cmd=True)])
|
show_cmd=True)])
|
||||||
|
|
||||||
@mock.patch('pungi.phases.init.run')
|
|
||||||
def test_run_in_debug(self, run):
|
|
||||||
compose = DummyCompose(self.topdir, {
|
|
||||||
'createrepo_checksum': 'sha256',
|
|
||||||
})
|
|
||||||
compose.DEBUG = True
|
|
||||||
os.makedirs(self.topdir + '/work/x86_64/comps_repo/repodata')
|
|
||||||
|
|
||||||
init.create_comps_repo(compose, 'x86_64', None)
|
|
||||||
|
|
||||||
self.assertEqual(run.mock_calls, [])
|
|
||||||
|
|
||||||
|
|
||||||
class TestWriteGlobalComps(PungiTestCase):
|
class TestWriteGlobalComps(PungiTestCase):
|
||||||
|
|
||||||
@mock.patch('shutil.copy2')
|
|
||||||
@mock.patch('pungi.phases.init.get_file_from_scm')
|
|
||||||
def test_run_in_debug(self, get_file, copy2):
|
|
||||||
compose = DummyCompose(self.topdir, {'comps_file': 'some-file.xml'})
|
|
||||||
compose.DEBUG = True
|
|
||||||
touch(self.topdir + '/work/global/comps/comps-global.xml')
|
|
||||||
|
|
||||||
init.write_global_comps(compose)
|
|
||||||
|
|
||||||
self.assertEqual(get_file.mock_calls, [])
|
|
||||||
self.assertEqual(copy2.mock_calls, [])
|
|
||||||
|
|
||||||
@mock.patch('pungi.phases.init.get_file_from_scm')
|
@mock.patch('pungi.phases.init.get_file_from_scm')
|
||||||
def test_run_local_file(self, get_file):
|
def test_run_local_file(self, get_file):
|
||||||
compose = DummyCompose(self.topdir, {'comps_file': 'some-file.xml'})
|
compose = DummyCompose(self.topdir, {'comps_file': 'some-file.xml'})
|
||||||
@ -417,25 +383,6 @@ class TestWriteVariantComps(PungiTestCase):
|
|||||||
[mock.call(init.UNMATCHED_GROUP_MSG % ('Server', 'x86_64', 'foo')),
|
[mock.call(init.UNMATCHED_GROUP_MSG % ('Server', 'x86_64', 'foo')),
|
||||||
mock.call(init.UNMATCHED_GROUP_MSG % ('Server', 'x86_64', 'bar'))])
|
mock.call(init.UNMATCHED_GROUP_MSG % ('Server', 'x86_64', 'bar'))])
|
||||||
|
|
||||||
@mock.patch('pungi.phases.init.run')
|
|
||||||
@mock.patch('pungi.phases.init.CompsWrapper')
|
|
||||||
def test_run_in_debug(self, CompsWrapper, run):
|
|
||||||
compose = DummyCompose(self.topdir, {})
|
|
||||||
compose.DEBUG = True
|
|
||||||
variant = compose.variants['Server']
|
|
||||||
touch(self.topdir + '/work/x86_64/comps/comps-Server.x86_64.xml')
|
|
||||||
|
|
||||||
init.write_variant_comps(compose, 'x86_64', variant)
|
|
||||||
|
|
||||||
self.assertEqual(run.mock_calls, [])
|
|
||||||
self.assertEqual(CompsWrapper.call_args_list,
|
|
||||||
[mock.call(self.topdir + '/work/x86_64/comps/comps-Server.x86_64.xml')])
|
|
||||||
comps = CompsWrapper.return_value
|
|
||||||
self.assertEqual(comps.filter_groups.mock_calls, [mock.call(variant.groups)])
|
|
||||||
self.assertEqual(comps.filter_environments.mock_calls,
|
|
||||||
[mock.call(variant.environments)])
|
|
||||||
self.assertEqual(comps.write_comps.mock_calls, [])
|
|
||||||
|
|
||||||
|
|
||||||
class TestGetLookasideGroups(PungiTestCase):
|
class TestGetLookasideGroups(PungiTestCase):
|
||||||
def test_toplevel_variant(self):
|
def test_toplevel_variant(self):
|
||||||
|
@ -72,19 +72,6 @@ class TestGetKojiEvent(helpers.PungiTestCase):
|
|||||||
with open(self.event_file) as f:
|
with open(self.event_file) as f:
|
||||||
self.assertEqual(json.load(f), EVENT_INFO)
|
self.assertEqual(json.load(f), EVENT_INFO)
|
||||||
|
|
||||||
def test_gets_last_event_in_debug_mode(self):
|
|
||||||
self.compose.DEBUG = True
|
|
||||||
self.compose.koji_event = None
|
|
||||||
koji_wrapper = mock.Mock()
|
|
||||||
helpers.touch(self.event_file, json.dumps(EVENT_INFO))
|
|
||||||
|
|
||||||
event = source_koji.get_koji_event_info(self.compose, koji_wrapper)
|
|
||||||
|
|
||||||
self.assertEqual(event, EVENT_INFO)
|
|
||||||
self.assertItemsEqual(koji_wrapper.mock_calls, [])
|
|
||||||
with open(self.event_file) as f:
|
|
||||||
self.assertEqual(json.load(f), EVENT_INFO)
|
|
||||||
|
|
||||||
|
|
||||||
class TestPopulateGlobalPkgset(helpers.PungiTestCase):
|
class TestPopulateGlobalPkgset(helpers.PungiTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -180,27 +167,6 @@ class TestPopulateGlobalPkgset(helpers.PungiTestCase):
|
|||||||
with open(self.pkgset_path) as f:
|
with open(self.pkgset_path) as f:
|
||||||
self.assertEqual(f.read(), 'DATA')
|
self.assertEqual(f.read(), 'DATA')
|
||||||
|
|
||||||
@mock.patch('six.moves.cPickle.load')
|
|
||||||
def test_populate_in_debug_mode(self, pickle_load):
|
|
||||||
helpers.touch(self.pkgset_path, 'DATA')
|
|
||||||
self.compose.DEBUG = True
|
|
||||||
|
|
||||||
pickle_load.return_value
|
|
||||||
|
|
||||||
with mock.patch('pungi.phases.pkgset.sources.source_koji.open',
|
|
||||||
mock.mock_open(), create=True) as m:
|
|
||||||
pkgset = source_koji.populate_global_pkgset(
|
|
||||||
self.compose, self.koji_wrapper, '/prefix', 123456)
|
|
||||||
|
|
||||||
self.assertEqual(pickle_load.call_args_list,
|
|
||||||
[mock.call(m.return_value)])
|
|
||||||
self.assertIs(pkgset, pickle_load.return_value)
|
|
||||||
self.assertEqual(
|
|
||||||
pkgset.mock_calls,
|
|
||||||
[mock.call.save_file_list(self.topdir + '/work/global/package_list/global.conf',
|
|
||||||
remove_path_prefix='/prefix'),
|
|
||||||
mock.call.save_file_cache(self.topdir + '/work/global/pkgset_file_cache.pickle')])
|
|
||||||
|
|
||||||
@mock.patch('six.moves.cPickle.dumps')
|
@mock.patch('six.moves.cPickle.dumps')
|
||||||
@mock.patch('pungi.phases.pkgset.pkgsets.KojiPackageSet.populate')
|
@mock.patch('pungi.phases.pkgset.pkgsets.KojiPackageSet.populate')
|
||||||
@mock.patch('pungi.phases.pkgset.pkgsets.KojiPackageSet.save_file_list')
|
@mock.patch('pungi.phases.pkgset.pkgsets.KojiPackageSet.save_file_list')
|
||||||
|
Loading…
Reference in New Issue
Block a user