From 70a79d557502a1477a6baf2bb7a9fc036cc2b03b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thibaut=20VAR=C3=88NE?= Date: Fri, 21 Oct 2022 18:54:10 +0200 Subject: [PATCH] phase1: prepare to parse branches MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This commit breaks config Signed-off-by: Thibaut VARÈNE --- phase1/master.cfg | 51 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/phase1/master.cfg b/phase1/master.cfg index c6edad3..13dc148 100644 --- a/phase1/master.cfg +++ b/phase1/master.cfg @@ -60,33 +60,49 @@ inip1 = ini['phase1'] work_dir = os.path.abspath(ini['general'].get("workdir", ".")) scripts_dir = os.path.abspath("../scripts") -config_seed = inip1.get("config_seed", "") - repo_url = ini['repo'].get("url") repo_branch = ini['repo'].get("branch", "master") -rsync_bin_url = ini['rsync'].get("binary_url") -rsync_bin_key = ini['rsync'].get("binary_password") rsync_bin_defopts = ["-v", "-4", "--timeout=120"] -if rsync_bin_url.find("::") > 0 or rsync_bin_url.find("rsync://") == 0: - rsync_bin_defopts += ["--contimeout=20"] +#if rsync_bin_url.find("::") > 0 or rsync_bin_url.find("rsync://") == 0: +# rsync_bin_defopts += ["--contimeout=20"] -rsync_src_url = ini['rsync'].get("source_url") -rsync_src_key = ini['rsync'].get("source_password") rsync_src_defopts = ["-v", "-4", "--timeout=120"] -if rsync_src_url.find("::") > 0 or rsync_src_url.find("rsync://") == 0: - rsync_src_defopts += ["--contimeout=20"] +#if rsync_src_url.find("::") > 0 or rsync_src_url.find("rsync://") == 0: +# rsync_src_defopts += ["--contimeout=20"] + +branches = {} + +def ini_parse_branch(section): + b = {} + name = section.get("name") + + if not name: + raise ValueError("missing 'name' in " + repr(section)) + if name in branches: + raise ValueError("duplicate branch name in " + repr(section)) + + b["name"] = name + b["bin_url"] = section.get("binary_url") + b["bin_key"] = section.get("binary_password") -usign_key = None -usign_comment = "untrusted comment: " + repo_branch.replace("-", " ").title() + " key" + b["src_url"] = section.get("source_url") + b["src_key"] = section.get("source_password") -if ini.has_section("usign"): - usign_key = ini['usign'].get("key") - usign_comment = ini['usign'].get("comment", usign_comment) + b["gpg_key"] = section.get("gpg_key") -enable_kmod_archive = inip1.getboolean("kmod_archive", False) + b["usign_key"] = section.get("usign_key") + usign_comment = "untrusted comment: " + name.replace("-", " ").title() + " key" + b["usign_comment"] = section.get("usign_comment", usign_comment) + + b["config_seed"] = section.get("config_seed") + + b["kmod_archive"] = section.getboolean("kmod_archive", False) + + branches[name] = b + log.msg("Configured branch: {}".format(name)) # PB port can be either a numeric port or a connection string pb_port = inip1.get("port") or 9989 @@ -122,6 +138,9 @@ c['workers'] = [] NetLocks = dict() for section in ini.sections(): + if section.startswith("branch "): + ini_parse_branch(ini[section]) + if section.startswith("worker "): if ini.has_option(section, "name") and ini.has_option(section, "password") and \ (not ini.has_option(section, "phase") or ini.getint(section, "phase") == 1): -- 2.30.2