phase1: prepare to parse branches
authorThibaut VARÈNE <hacks@slashdirt.org>
Fri, 21 Oct 2022 16:54:10 +0000 (18:54 +0200)
committerPetr Štetiar <ynezz@true.cz>
Mon, 15 May 2023 15:36:01 +0000 (17:36 +0200)
This commit breaks config

Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
phase1/master.cfg

index c6edad33dd4e9a34192a57ce4f4310ae4bc39b66..13dc14841fd31849e678ad684750d975c539737e 100644 (file)
@@ -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):