[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: f3b1647b1e49472803e4dac9f01941f5c9b907db Author: Matt Turner gentoo org> AuthorDate: Tue Nov 22 04:57:44 2022 + Commit: Matt Turner gentoo org> CommitDate: Mon Apr 10 19:48:49 2023 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=f3b1647b catalyst: WIP Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 732c5939..35aa82ba 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -108,13 +108,11 @@ class StageBase(TargetBase, ClearBase, GenBase): host = self.settings["chost"].split("-")[0] else: host = self.settings["subarch"] -self.settings["hostarch"] = host if "cbuild" in self.settings: build = self.settings["cbuild"].split("-")[0] else: build = platform.machine() -self.settings["buildarch"] = build arch_dir = normpath(self.settings['sharedir'] + '/arch/') @@ -139,6 +137,9 @@ class StageBase(TargetBase, ClearBase, GenBase): else: raise CatalystError("Unknown host machine type " + host) +self.settings["hostarch"] = arch +self.settings["buildarch"] = build + if setarch.get('if_build', '') == platform.machine(): chroot = f'setarch {setarch["arch"]} chroot' else:
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: 6ad2bb1cf15a0354cff19ea935d3f3c618aeb614 Author: Matt Turner gentoo org> AuthorDate: Tue Nov 22 04:57:44 2022 + Commit: Matt Turner gentoo org> CommitDate: Tue Nov 22 21:19:03 2022 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=6ad2bb1c catalyst: WIP Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 732c5939..35aa82ba 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -108,13 +108,11 @@ class StageBase(TargetBase, ClearBase, GenBase): host = self.settings["chost"].split("-")[0] else: host = self.settings["subarch"] -self.settings["hostarch"] = host if "cbuild" in self.settings: build = self.settings["cbuild"].split("-")[0] else: build = platform.machine() -self.settings["buildarch"] = build arch_dir = normpath(self.settings['sharedir'] + '/arch/') @@ -139,6 +137,9 @@ class StageBase(TargetBase, ClearBase, GenBase): else: raise CatalystError("Unknown host machine type " + host) +self.settings["hostarch"] = arch +self.settings["buildarch"] = build + if setarch.get('if_build', '') == platform.machine(): chroot = f'setarch {setarch["arch"]} chroot' else:
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: 3e3c257490c4d6cb9d1297f99cc004bfa0bf8621 Author: Matt Turner gentoo org> AuthorDate: Tue Nov 22 04:57:44 2022 + Commit: Matt Turner gentoo org> CommitDate: Tue Nov 22 04:57:59 2022 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=3e3c2574 catalyst: WIP Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 732c5939..35aa82ba 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -108,13 +108,11 @@ class StageBase(TargetBase, ClearBase, GenBase): host = self.settings["chost"].split("-")[0] else: host = self.settings["subarch"] -self.settings["hostarch"] = host if "cbuild" in self.settings: build = self.settings["cbuild"].split("-")[0] else: build = platform.machine() -self.settings["buildarch"] = build arch_dir = normpath(self.settings['sharedir'] + '/arch/') @@ -139,6 +137,9 @@ class StageBase(TargetBase, ClearBase, GenBase): else: raise CatalystError("Unknown host machine type " + host) +self.settings["hostarch"] = arch +self.settings["buildarch"] = build + if setarch.get('if_build', '') == platform.machine(): chroot = f'setarch {setarch["arch"]} chroot' else:
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: fd766b2676b7c2bbc669fb89e6de391466d15f98 Author: Matt Turner gentoo org> AuthorDate: Tue Nov 22 03:26:59 2022 + Commit: Matt Turner gentoo org> CommitDate: Tue Nov 22 03:48:50 2022 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=fd766b26 catalyst: Use correct arch setting for setarch testing Previously we were testing against the 'host' or subarchitecture (e.g. i486) instead of the architecture (e.g. x86). This manifests on x86 builds on x86_64; on ppc on ppc64 and sparc on sparc64 the arch and subarch values happen to line up. Fixes: cd58b37b ("catalyst: Access setarch data correctly") Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 5a3bd375..732c5939 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -129,7 +129,7 @@ class StageBase(TargetBase, ClearBase, GenBase): # Search for a subarchitecture in each arch in the arch_config for arch in [x for x in arch_config if x.startswith(name) and host in arch_config[x]]: self.settings.update(arch_config[arch][host]) -setarch = arch_config.get('setarch', {}).get(host, {}) +setarch = arch_config.get('setarch', {}).get(arch, {}) break else: # Didn't find a matching subarchitecture, keep searching
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: 430a699ca9262b25fea2e8e2f0ce4eea56e6c898 Author: Daniel Cordero 0xdc io> AuthorDate: Thu Apr 21 07:08:25 2022 + Commit: Matt Turner gentoo org> CommitDate: Fri May 13 17:42:41 2022 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=430a699c catalyst/stage4: don't split a single entry A single entry in users is one user who could have multiple groups. Fixes: 5be6069b ("catalyst: support 3 new options") Signed-off-by: Daniel Cordero 0xdc.io> Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 7e6b9e32..d4875491 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -602,7 +602,7 @@ class StageBase(TargetBase, ClearBase, GenBase): if users in self.settings: self.settings["users"] = self.settings[users] if isinstance(self.settings[users], str): -self.settings["users"] = self.settings[users].split(",") +self.settings["users"] = [self.settings[users]] del self.settings[users] else: self.settings["users"] = []
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: f2263466c535d0019be0bcbf1f08128b2399d6ea Author: Andreas K. Hüttel gentoo org> AuthorDate: Mon Nov 14 00:05:58 2022 + Commit: Matt Turner gentoo org> CommitDate: Mon Nov 14 00:09:33 2022 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=f2263466 stagebase: Also clean out profile/package.use.force profile/package.use.mask Signed-off-by: Andreas K. Hüttel gentoo.org> catalyst/base/stagebase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index bcf596ae..5a3bd375 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -1230,7 +1230,7 @@ class StageBase(TargetBase, ClearBase, GenBase): "sticky-config" not in self.settings["options"]): log.debug("clean(), portage_preix = %s, no sticky-config", self.settings["portage_prefix"]) -for _dir in "package.accept_keywords", "package.keywords", "package.mask", "package.unmask", "package.use", "package.env", "env": +for _dir in "package.accept_keywords", "package.keywords", "package.mask", "package.unmask", "package.use", "package.env", "env", "profile/package.use.force", "profile/package.use.mask": target = pjoin(self.settings["stage_path"], "etc/portage/%s" % _dir, self.settings["portage_prefix"])
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: 64d2993d8ca38cefd76df7a69a44accd60284cd4 Author: Andreas K. Hüttel gentoo org> AuthorDate: Sat Nov 12 20:42:03 2022 + Commit: Matt Turner gentoo org> CommitDate: Sun Nov 13 02:17:29 2022 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=64d2993d Allow "interpreter" parameter as space-separated list of files I added this feature to the 3.0 branch long ago and forgot about it. Needed for multilib emulation, e.g., qemu-mips qemu-mipsn32 qemu-mips64 Tested on demeter "in production" Signed-off-by: Andreas K. Hüttel gentoo.org> catalyst/base/stagebase.py | 48 +++--- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index eb869c70..bcf596ae 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -1036,26 +1036,24 @@ class StageBase(TargetBase, ClearBase, GenBase): shutil.copy('/etc/resolv.conf', self.settings['chroot_path'] + '/etc/') -# Copy over the binary interpreter (qemu), if applicable; note that it's given -# as full path and goes to the same place in the chroot +# Copy over the binary interpreter(s) (qemu), if applicable; note that they are given +# as space-separated list of full paths and go to the same place in the chroot if "interpreter" in self.settings: -if not os.path.exists(self.settings["interpreter"]): -raise CatalystError( -"Can't find interpreter " + -self.settings["interpreter"], -print_traceback=True) +if isinstance(self.settings["interpreter"], str): +myints = [self.settings["interpreter"]] +else: +myints = self.settings["interpreter"] -log.notice('Copying binary interpreter %s into chroot', - self.settings['interpreter']) +for myi in myints: +if not os.path.exists(myi): +raise CatalystError("Can't find interpreter " + myi, print_traceback=True) -if os.path.exists(self.settings['chroot_path'] + '/' + self.settings['interpreter']): -os.rename( -self.settings['chroot_path'] + -'/' + self.settings['interpreter'], -self.settings['chroot_path'] + '/' + self.settings['interpreter'] + '.catalyst') +log.notice('Copying binary interpreter %s into chroot', myi) -shutil.copy(self.settings['interpreter'], -self.settings['chroot_path'] + '/' + self.settings['interpreter']) +if os.path.exists(self.settings['chroot_path'] + '/' + myi): +os.rename(self.settings['chroot_path'] + '/' + myi, self.settings['chroot_path'] + '/' + myi + '.catalyst') + +shutil.copy(myi, self.settings['chroot_path'] + '/' + myi) # Copy over the envscript, if applicable if "envscript" in self.settings: @@ -1214,16 +1212,18 @@ class StageBase(TargetBase, ClearBase, GenBase): if os.path.exists(hosts_file + '.catalyst'): os.rename(hosts_file + '.catalyst', hosts_file) -# optionally clean up binary interpreter +# optionally clean up binary interpreter(s) if "interpreter" in self.settings: -if os.path.exists(self.settings['chroot_path'] + '/' + self.settings['interpreter'] + '.catalyst'): -os.rename( -self.settings['chroot_path'] + '/' + -self.settings['interpreter'] + '.catalyst', -self.settings['chroot_path'] + '/' + self.settings['interpreter']) +if isinstance(self.settings["interpreter"], str): +myints = [self.settings["interpreter"]] else: -os.remove( -self.settings['chroot_path'] + '/' + self.settings['interpreter']) +myints = self.settings["interpreter"] + +for myi in myints: +if os.path.exists(self.settings['chroot_path'] + '/' + myi + '.catalyst'): +os.rename(self.settings['chroot_path'] + '/' + myi + '.catalyst', self.settings['chroot_path'] + '/' + myi) +else: +os.remove(self.settings['chroot_path'] + '/' + myi) # optionally clean up portage configs if ("portage_prefix" in self.settings and
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: 214bb3d849d5bf7ce2314aab1858ed6e72b28108 Author: Daniel Cordero 0xdc io> AuthorDate: Thu Apr 21 07:08:24 2022 + Commit: Matt Turner gentoo org> CommitDate: Fri May 13 17:42:15 2022 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=214bb3d8 catalyst/stage4: don't run split on a list "groups" has been normalised into a list and does not have a split() method. Fixes: 5be6069b ("catalyst: support 3 new options") Signed-off-by: Daniel Cordero 0xdc.io> Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 1d71c59d..7e6b9e32 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -931,7 +931,7 @@ class StageBase(TargetBase, ClearBase, GenBase): env=self.env) def groups(self): -for x in self.settings["groups"].split(): +for x in self.settings["groups"]: log.notice("Creating group: '%s'", x) cmd(["groupadd", "-R", self.settings['chroot_path'], x], env=self.env)
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: ae7d28b81ddc5285a210e927bec563065fda7f16 Author: Daniel Cordero 0xdc io> AuthorDate: Thu Apr 21 07:08:23 2022 + Commit: Matt Turner gentoo org> CommitDate: Fri May 13 17:41:47 2022 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=ae7d28b8 catalyst/stage4: fix handling of groups, users and keys Previously, the set_*() functions would always set the result of the toml parsing as the setting. Instead, only override it if it is a string. Fixes: 5be6069b ("catalyst: support 3 new options") Signed-off-by: Daniel Cordero 0xdc.io> Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 5c7e9adb..1d71c59d 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -589,9 +589,9 @@ class StageBase(TargetBase, ClearBase, GenBase): def set_groups(self): groups = self.settings["spec_prefix"] + "/groups" if groups in self.settings: +self.settings["groups"] = self.settings[groups] if isinstance(self.settings[groups], str): self.settings["groups"] = self.settings[groups].split(",") -self.settings["groups"] = self.settings[groups] del self.settings[groups] else: self.settings["groups"] = [] @@ -600,9 +600,9 @@ class StageBase(TargetBase, ClearBase, GenBase): def set_users(self): users = self.settings["spec_prefix"] + "/users" if users in self.settings: +self.settings["users"] = self.settings[users] if isinstance(self.settings[users], str): self.settings["users"] = self.settings[users].split(",") -self.settings["users"] = self.settings[users] del self.settings[users] else: self.settings["users"] = [] @@ -611,9 +611,9 @@ class StageBase(TargetBase, ClearBase, GenBase): def set_ssh_public_keys(self): ssh_public_keys = self.settings["spec_prefix"] + "/ssh_public_keys" if ssh_public_keys in self.settings: +self.settings["ssh_public_keys"] = self.settings[ssh_public_keys] if isinstance(self.settings[ssh_public_keys], str): self.settings["ssh_public_keys"] = self.settings[ssh_public_keys].split(",") -self.settings["ssh_public_keys"] = self.settings[ssh_public_keys] del self.settings[ssh_public_keys] else: self.settings["ssh_public_keys"] = []
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: a21d590f878bf63510aa5692dd5668a56fa9f2db Author: Daniel Cordero 0xdc io> AuthorDate: Mon May 9 11:20:47 2022 + Commit: Matt Turner gentoo org> CommitDate: Fri May 13 17:42:57 2022 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=a21d590f catalyst/stage4: improve log message When creating a user with no additional groups, don't print a misleading message saying the user will be created with an equals sign in the username. Signed-off-by: Daniel Cordero 0xdc.io> Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index d4875491..eb869c70 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -945,9 +945,11 @@ class StageBase(TargetBase, ClearBase, GenBase): log.debug("users: '=' separator not found on line " + x) log.debug("users: missing separator means no groups found") uacmd = ["useradd", "-R", self.settings['chroot_path'], "-m", x] +msg_create_user = "Creating user: '%s'" % usr if grp != '': uacmd = ["useradd", "-R", self.settings['chroot_path'], "-m", "-G", grp, usr] -log.notice("Creating user: '%s'", f"{usr}={grp}") +msg_create_user = "Creating user: '%s' in group(s): %s" % usr, grp +log.notice(msg_create_user) cmd(uacmd, env=self.env) def ssh_public_keys(self):
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/targets/
commit: c2c22f5d07684ed0c6b802254e7b678358111579 Author: Patrice Clement gentoo org> AuthorDate: Tue Mar 8 21:08:09 2022 + Commit: Matt Turner gentoo org> CommitDate: Sat Apr 2 23:50:24 2022 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=c2c22f5d catalyst: add new options to stage4 step list Signed-off-by: Patrice Clement gentoo.org> Signed-off-by: Matt Turner gentoo.org> catalyst/targets/stage4.py | 6 ++ 1 file changed, 6 insertions(+) diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py index ff1d4dca..35309b45 100644 --- a/catalyst/targets/stage4.py +++ b/catalyst/targets/stage4.py @@ -19,13 +19,16 @@ class stage4(StageBase): "stage4/empty", "stage4/fsscript", "stage4/gk_mainargs", +"stage4/groups", "stage4/linuxrc", "stage4/rcadd", "stage4/rcdel", "stage4/rm", "stage4/root_overlay", +"stage4/ssh_public_keys", "stage4/unmerge", "stage4/use", +"stage4/users", ]) def __init__(self, spec, addlargs): @@ -51,6 +54,9 @@ class stage4(StageBase): ]) self.finish_sequence.extend([ self.remove, +self.groups, +self.users, +self.ssh_public_keys, self.empty, self.clean, ])
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: 1c46e66ef2c9ab24f383eebd3c6cb1d02492b8fc Author: Matt Turner gentoo org> AuthorDate: Wed Apr 20 23:23:07 2022 + Commit: Matt Turner gentoo org> CommitDate: Wed Apr 20 23:23:07 2022 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=1c46e66e catalyst: Replace a tab Fixes: 5be6069b ("catalyst: support 3 new options") Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 76feb5f0..5c7e9adb 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -597,7 +597,7 @@ class StageBase(TargetBase, ClearBase, GenBase): self.settings["groups"] = [] log.info('groups to create: %s' % self.settings["groups"]) - def set_users(self): +def set_users(self): users = self.settings["spec_prefix"] + "/users" if users in self.settings: if isinstance(self.settings[users], str):
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/, doc/, catalyst/base/
commit: 67e93e47d30280594c109b8153a83f0a19c027e5 Author: Matt Turner gentoo org> AuthorDate: Sun Jan 30 20:22:43 2022 + Commit: Matt Turner gentoo org> CommitDate: Sun Jan 30 23:17:14 2022 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=67e93e47 catalyst: Switch to tomli The Python community is coalescing around tomli, and tomli is likely to be integrated into the standard library per PEP680. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 6 +++--- catalyst/main.py | 5 +++-- doc/make_subarch_table_guidexml.py | 5 +++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 4a1b4eb6..de1e30ef 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -10,7 +10,7 @@ from pathlib import Path import fasteners import libmount -import toml +import tomli from snakeoil import fileutils from snakeoil.osutils import pjoin @@ -123,8 +123,8 @@ class StageBase(TargetBase, ClearBase, GenBase): log.debug("\tTrying %s", x) name = x[:-len('.toml')] -with open(arch_dir + x) as file: -arch_config = toml.load(file) +with open(arch_dir + x, 'rb') as file: +arch_config = tomli.load(file) # Search for a subarchitecture in each arch in the arch_config for arch in [x for x in arch_config if x.startswith(name) and host in arch_config[x]]: diff --git a/catalyst/main.py b/catalyst/main.py index 0de1040f..6e9a2d3e 100644 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -6,7 +6,7 @@ import os import sys import textwrap -import toml +import tomli from DeComp.definitions import (COMPRESS_DEFINITIONS, DECOMPRESS_DEFINITIONS, CONTENTS_DEFINITIONS) @@ -35,7 +35,8 @@ def parse_config(config_files): for config_file in config_files: log.notice('Loading configuration file: %s', config_file) try: -config = toml.load(config_file) +with open(config_file, 'rb') as f: +config = tomli.load(f) for key in config: if key not in valid_config_file_values: log.critical("Unknown option '%s' in config file %s", diff --git a/doc/make_subarch_table_guidexml.py b/doc/make_subarch_table_guidexml.py index 67ed3ccc..3c03f90c 100755 --- a/doc/make_subarch_table_guidexml.py +++ b/doc/make_subarch_table_guidexml.py @@ -5,7 +5,7 @@ import pathlib import sys import textwrap -import toml +import tomli def write_guidexml(arch_to_subarch): @@ -40,7 +40,8 @@ def main(_argv): p = pathlib.Path('arch') for file in p.glob('*.toml'): -data = toml.load(file) +with file.open('rb') as f: +data = tomli.load(f) for arch in [x for x in data if x != 'setarch']: arch_to_subarch.update({arch: list(data[arch].keys())})
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, doc/, catalyst/
commit: 91cedd2f94909500a97a9a70ee262170b222b668 Author: Matt Turner gentoo org> AuthorDate: Sun Jan 30 20:22:43 2022 + Commit: Matt Turner gentoo org> CommitDate: Sun Jan 30 23:07:00 2022 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=91cedd2f catalyst: Switch to tomli The Python community is coalescing around tomli, and tomli is likely to be integrated into the standard library per PEP680. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 4 ++-- catalyst/main.py | 5 +++-- doc/make_subarch_table_guidexml.py | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 4a1b4eb6..ad96beb7 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -10,7 +10,7 @@ from pathlib import Path import fasteners import libmount -import toml +import tomli from snakeoil import fileutils from snakeoil.osutils import pjoin @@ -124,7 +124,7 @@ class StageBase(TargetBase, ClearBase, GenBase): name = x[:-len('.toml')] with open(arch_dir + x) as file: -arch_config = toml.load(file) +arch_config = tomli.load(file) # Search for a subarchitecture in each arch in the arch_config for arch in [x for x in arch_config if x.startswith(name) and host in arch_config[x]]: diff --git a/catalyst/main.py b/catalyst/main.py index 0de1040f..e51be9d1 100644 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -6,7 +6,7 @@ import os import sys import textwrap -import toml +import tomli from DeComp.definitions import (COMPRESS_DEFINITIONS, DECOMPRESS_DEFINITIONS, CONTENTS_DEFINITIONS) @@ -35,7 +35,8 @@ def parse_config(config_files): for config_file in config_files: log.notice('Loading configuration file: %s', config_file) try: -config = toml.load(config_file) +with open(config_file) as f: +config = tomli.load(f) for key in config: if key not in valid_config_file_values: log.critical("Unknown option '%s' in config file %s", diff --git a/doc/make_subarch_table_guidexml.py b/doc/make_subarch_table_guidexml.py index 67ed3ccc..3c03f90c 100755 --- a/doc/make_subarch_table_guidexml.py +++ b/doc/make_subarch_table_guidexml.py @@ -5,7 +5,7 @@ import pathlib import sys import textwrap -import toml +import tomli def write_guidexml(arch_to_subarch): @@ -40,7 +40,8 @@ def main(_argv): p = pathlib.Path('arch') for file in p.glob('*.toml'): -data = toml.load(file) +with file.open('rb') as f: +data = tomli.load(f) for arch in [x for x in data if x != 'setarch']: arch_to_subarch.update({arch: list(data[arch].keys())})
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/, doc/, catalyst/base/
commit: 0b709ccc9136996e110d2299cddd1ee9b06e5fca Author: Matt Turner gentoo org> AuthorDate: Sun Jan 30 20:22:43 2022 + Commit: Matt Turner gentoo org> CommitDate: Sun Jan 30 23:03:25 2022 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=0b709ccc catalyst: Switch to tomli The Python community is coalescing around tomli, and tomli is likely to be integrated into the standard library per PEP680. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 4 ++-- catalyst/main.py | 4 ++-- doc/make_subarch_table_guidexml.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 4a1b4eb6..ad96beb7 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -10,7 +10,7 @@ from pathlib import Path import fasteners import libmount -import toml +import tomli from snakeoil import fileutils from snakeoil.osutils import pjoin @@ -124,7 +124,7 @@ class StageBase(TargetBase, ClearBase, GenBase): name = x[:-len('.toml')] with open(arch_dir + x) as file: -arch_config = toml.load(file) +arch_config = tomli.load(file) # Search for a subarchitecture in each arch in the arch_config for arch in [x for x in arch_config if x.startswith(name) and host in arch_config[x]]: diff --git a/catalyst/main.py b/catalyst/main.py index 0de1040f..fa668770 100644 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -6,7 +6,7 @@ import os import sys import textwrap -import toml +import tomli from DeComp.definitions import (COMPRESS_DEFINITIONS, DECOMPRESS_DEFINITIONS, CONTENTS_DEFINITIONS) @@ -35,7 +35,7 @@ def parse_config(config_files): for config_file in config_files: log.notice('Loading configuration file: %s', config_file) try: -config = toml.load(config_file) +config = tomli.load(config_file) for key in config: if key not in valid_config_file_values: log.critical("Unknown option '%s' in config file %s", diff --git a/doc/make_subarch_table_guidexml.py b/doc/make_subarch_table_guidexml.py index 67ed3ccc..54aa4307 100755 --- a/doc/make_subarch_table_guidexml.py +++ b/doc/make_subarch_table_guidexml.py @@ -5,7 +5,7 @@ import pathlib import sys import textwrap -import toml +import tomli def write_guidexml(arch_to_subarch): @@ -40,7 +40,7 @@ def main(_argv): p = pathlib.Path('arch') for file in p.glob('*.toml'): -data = toml.load(file) +data = tomli.load(file.open()) for arch in [x for x in data if x != 'setarch']: arch_to_subarch.update({arch: list(data[arch].keys())})
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/, doc/
commit: 4eb118a8712966079d7651619c7e579dbbee1d30 Author: Matt Turner gentoo org> AuthorDate: Sun Jan 30 20:22:43 2022 + Commit: Matt Turner gentoo org> CommitDate: Sun Jan 30 20:22:43 2022 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=4eb118a8 catalyst: Switch to tomli The Python community is coalescing around tomli, and tomli is likely to be integrated into the standard library per PEP680. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 4 ++-- catalyst/main.py | 4 ++-- doc/make_subarch_table_guidexml.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 4a1b4eb6..ad96beb7 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -10,7 +10,7 @@ from pathlib import Path import fasteners import libmount -import toml +import tomli from snakeoil import fileutils from snakeoil.osutils import pjoin @@ -124,7 +124,7 @@ class StageBase(TargetBase, ClearBase, GenBase): name = x[:-len('.toml')] with open(arch_dir + x) as file: -arch_config = toml.load(file) +arch_config = tomli.load(file) # Search for a subarchitecture in each arch in the arch_config for arch in [x for x in arch_config if x.startswith(name) and host in arch_config[x]]: diff --git a/catalyst/main.py b/catalyst/main.py index 0de1040f..fa668770 100644 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -6,7 +6,7 @@ import os import sys import textwrap -import toml +import tomli from DeComp.definitions import (COMPRESS_DEFINITIONS, DECOMPRESS_DEFINITIONS, CONTENTS_DEFINITIONS) @@ -35,7 +35,7 @@ def parse_config(config_files): for config_file in config_files: log.notice('Loading configuration file: %s', config_file) try: -config = toml.load(config_file) +config = tomli.load(config_file) for key in config: if key not in valid_config_file_values: log.critical("Unknown option '%s' in config file %s", diff --git a/doc/make_subarch_table_guidexml.py b/doc/make_subarch_table_guidexml.py index 67ed3ccc..9507177c 100755 --- a/doc/make_subarch_table_guidexml.py +++ b/doc/make_subarch_table_guidexml.py @@ -5,7 +5,7 @@ import pathlib import sys import textwrap -import toml +import tomli def write_guidexml(arch_to_subarch): @@ -40,7 +40,7 @@ def main(_argv): p = pathlib.Path('arch') for file in p.glob('*.toml'): -data = toml.load(file) +data = tomli.load(file) for arch in [x for x in data if x != 'setarch']: arch_to_subarch.update({arch: list(data[arch].keys())})
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, doc/
commit: 7457cd3b1a5f3ed4a566bbf23e36c939af06967c Author: Georgy Yakovlev gentoo org> AuthorDate: Fri Nov 5 02:14:00 2021 + Commit: Matt Turner gentoo org> CommitDate: Thu Nov 25 02:43:21 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=7457cd3b catalyst: generate .sha256 file if any digest is enabled checksum format is simple one, identical to one sha256sum from coreutils produces, lines starting with # are ignored. example:[1] # SHA256 HASH . stage3-tar.xz systemd upstream calls it suse-style .sha256 files.[0] infra already supports inline signing of files. Bug: https://bugs.gentoo.org/821568 [0] https://github.com/systemd/systemd/blob/aedec452b9e5dd197881f2164fb205dfe8bfdcec/src/import/pull-common.c#L236 [1] https://mirrors.edge.kernel.org/opensuse/distribution/leap/15.0/iso/openSUSE-Leap-15.0-DVD-x86_64.iso.sha256 Signed-off-by: Georgy Yakovlev gentoo.org> catalyst/base/genbase.py | 3 +++ doc/catalyst-config.5.txt | 7 --- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/catalyst/base/genbase.py b/catalyst/base/genbase.py index 6d039a8f..1643b1dc 100644 --- a/catalyst/base/genbase.py +++ b/catalyst/base/genbase.py @@ -43,3 +43,6 @@ class GenBase(): for f in [path, path + '.CONTENTS.gz']: for i in self.settings['digests']: file.write(self.generate_hash(f, name=i)) + +with io.open(path + '.sha256', 'w', encoding='utf-8') as sha256file: +sha256file.write(self.generate_hash(path, name='sha256')) diff --git a/doc/catalyst-config.5.txt b/doc/catalyst-config.5.txt index 003d40b6..ca9335d6 100644 --- a/doc/catalyst-config.5.txt +++ b/doc/catalyst-config.5.txt @@ -38,9 +38,10 @@ Basic configuration *digests*:: Create a `.DIGESTS` file containing the hash output from any of the supported options below. Adding them all may take a long time. -(example: `md5 sha1 sha512 whirlpool`). The set of supported hashes -is dependent on the version of Python. To see the set of hashes -supported by the version of Python in use, run +(example: `md5 sha1 sha512 whirlpool`). Enabling ANY digest will +generate `.sha256` file in addition `.DIGESTS` file. The set of +supported hashes is dependent on the version of Python. To see the +set of hashes supported by the version of Python in use, run + - $ python3 -c 'import hashlib; print(hashlib.algorithms_available)'
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, targets/support/
commit: ad04eab48c96350f0866d6c1fe76f289499df21b Author: Matt Turner gentoo org> AuthorDate: Thu Jul 29 01:10:58 2021 + Commit: Matt Turner gentoo org> CommitDate: Thu Jul 29 01:13:52 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=ad04eab4 catalyst: Remove boot/kernel/*/kernelopts support This undocumented option was only wired up for hppa, and was used by the minimal livecd to set panic=30. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 11 --- targets/support/bootloader-setup.sh | 8 +--- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 10cffd4c..4a1b4eb6 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -662,7 +662,6 @@ class StageBase(TargetBase, ClearBase, GenBase): "boot/kernel/" + x + "/gk_action", "boot/kernel/" + x + "/gk_kernargs", "boot/kernel/" + x + "/initramfs_overlay", -"boot/kernel/" + x + "/kernelopts", "boot/kernel/" + x + "/packages", "boot/kernel/" + x + "/softlevel", "boot/kernel/" + x + "/sources", @@ -1508,16 +1507,6 @@ class StageBase(TargetBase, ClearBase, GenBase): return self._copy_kernel_config(kname=kname) -# If we need to pass special options to the bootloader -# for this kernel put them into the environment -key = 'boot/kernel/' + kname + '/kernelopts' -if key in self.settings: -myopts = self.settings[key] - -if not isinstance(myopts, str): -myopts = ' '.join(myopts) -self.env[kname + "_kernelopts"] = myopts - key = 'boot/kernel/' + kname + '/extraversion' self.settings.setdefault(key, '') self.env["clst_kextraversion"] = self.settings[key] diff --git a/targets/support/bootloader-setup.sh b/targets/support/bootloader-setup.sh index a998a420..08d25b59 100755 --- a/targets/support/bootloader-setup.sh +++ b/targets/support/bootloader-setup.sh @@ -70,16 +70,10 @@ case ${clst_hostarch} in boot_kernel_common_name=${first/%32/} boot_kernel_common_name=${boot_kernel_common_name/%64/} - for x in ${clst_boot_kernel} - do - eval kopt=\$clst_boot_kernel_${x}_kernelopts - kopts+=(${kopt}) - done - # copy the bootloader for the final image cp /usr/share/palo/iplboot $1/boot/ - echo "--commandline=0/${boot_kernel_common_name} initrd=${first}.igz ${default_append_line[@]} ${kopts[@]}" >> ${icfg} + echo "--commandline=0/${boot_kernel_common_name} initrd=${first}.igz ${default_append_line[@]}" >> ${icfg} echo "--bootloader=boot/iplboot" >> ${icfg} echo "--ramdisk=boot/${first}.igz" >> ${icfg} for x in ${clst_boot_kernel}
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/, catalyst/targets/
commit: b3c917f7fa73d11c69b7e55dc7a00bc18a18edc7 Author: Matt Turner gentoo org> AuthorDate: Wed Jun 9 06:17:31 2021 + Commit: Matt Turner gentoo org> CommitDate: Thu Jun 10 04:23:54 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=b3c917f7 catalyst: Replace snakeoil's locks with fasteners To no great surprise, the existing locking was broken. For example, clear_chroot() releases the lock. It is called by unpack(), which is part of prepare_sequence. The result is that the whole build could be done without holding the lock. Just lock around run(). It's not apparent that finer-grained locking does anything for us. Bug: https://bugs.gentoo.org/791583 Signed-off-by: Matt Turner gentoo.org> catalyst/base/clearbase.py | 2 -- catalyst/base/stagebase.py | 10 +++- catalyst/lock.py | 58 catalyst/targets/snapshot.py | 6 ++--- 4 files changed, 7 insertions(+), 69 deletions(-) diff --git a/catalyst/base/clearbase.py b/catalyst/base/clearbase.py index dcf6c523..6218330e 100644 --- a/catalyst/base/clearbase.py +++ b/catalyst/base/clearbase.py @@ -27,12 +27,10 @@ class ClearBase(): self.resume.clear_all(remove=True) def clear_chroot(self): -self.chroot_lock.unlock() log.notice('Clearing the chroot path ...') clear_dir(self.settings["chroot_path"], mode=0o755) def remove_chroot(self): -self.chroot_lock.unlock() log.notice('Removing the chroot path ...') clear_dir(self.settings["chroot_path"], mode=0o755, remove=True) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 448d6265..10cffd4c 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -8,6 +8,7 @@ import sys from pathlib import Path +import fasteners import libmount import toml @@ -25,7 +26,6 @@ from catalyst.support import (CatalystError, file_locate, normpath, from catalyst.base.targetbase import TargetBase from catalyst.base.clearbase import ClearBase from catalyst.base.genbase import GenBase -from catalyst.lock import LockDir, LockInUse from catalyst.fileops import ensure_dirs, clear_dir, clear_path from catalyst.base.resume import AutoResume @@ -36,9 +36,6 @@ def run_sequence(sequence): sys.stdout.flush() try: func() -except LockInUse: -log.error('Unable to aquire the lock...') -return False except Exception: log.error('Exception running action sequence %s', func.__name__, exc_info=True) @@ -478,7 +475,6 @@ class StageBase(TargetBase, ClearBase, GenBase): """ self.settings["chroot_path"] = normpath(self.settings["storedir"] + "/tmp/" + self.settings["target_subpath"].rstrip('/')) -self.chroot_lock = LockDir(self.settings["chroot_path"]) def set_autoresume_path(self): self.settings["autoresume_path"] = normpath(pjoin( @@ -1366,8 +1362,10 @@ class StageBase(TargetBase, ClearBase, GenBase): pass def run(self): -self.chroot_lock.write_lock() +with fasteners.InterProcessLock(self.settings["chroot_path"] + '.lock'): +return self._run() +def _run(self): if "clear-autoresume" in self.settings["options"]: self.clear_autoresume() diff --git a/catalyst/lock.py b/catalyst/lock.py deleted file mode 100644 index e31745b2.. --- a/catalyst/lock.py +++ /dev/null @@ -1,58 +0,0 @@ - -import os - -from contextlib import contextmanager - -from snakeoil import fileutils -from snakeoil import osutils -from catalyst.fileops import ensure_dirs - - -LockInUse = osutils.LockException - -class Lock: -""" -A fnctl-based filesystem lock -""" -def __init__(self, lockfile): -fileutils.touch(lockfile, mode=0o664) -os.chown(lockfile, uid=-1, gid=250) -self.lock = osutils.FsLock(lockfile) - -def read_lock(self): -self.lock.acquire_read_lock() - -def write_lock(self): -self.lock.acquire_write_lock() - -def unlock(self): -# Releasing a write lock is the same as a read lock. -self.lock.release_write_lock() - -class LockDir(Lock): -""" -A fnctl-based filesystem lock in a directory -""" -def __init__(self, lockdir): -ensure_dirs(lockdir) -lockfile = os.path.join(lockdir, '.catalyst_lock') - -Lock.__init__(self, lockfile) - -@contextmanager -def read_lock(filename): -lock = Lock(filename) -lock.read_lock() -try: -yield -finally: -lock.unlock() - -@contextmanager -def write_lock(filename): -lock = Lock(filename) -lock.write_lock() -try: -yield -finally: -lock.unlock() diff --git a/catalyst/targets/snapshot.py b/catalyst/targets/snapshot.py index b494575a..ef68765d 1006
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/targets/, catalyst/
commit: ad54d2e7669326cb313cccf281544559463fbcad Author: Matt Turner gentoo org> AuthorDate: Wed Jun 9 06:17:31 2021 + Commit: Matt Turner gentoo org> CommitDate: Thu Jun 10 01:38:47 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=ad54d2e7 catalyst: Replace snakeoil's locks with fasteners To no great surprise, the existing locking was broken. For example, clear_chroot() releases the lock. It is called by unpack(), which is part of prepare_sequence. The result is that the whole build could be done without holding the lock. Just lock around run(). It's not apparent that finer-grained locking does anything for us. Signed-off-by: Matt Turner gentoo.org> catalyst/base/clearbase.py | 2 -- catalyst/base/stagebase.py | 10 +++- catalyst/lock.py | 58 catalyst/targets/snapshot.py | 6 ++--- 4 files changed, 7 insertions(+), 69 deletions(-) diff --git a/catalyst/base/clearbase.py b/catalyst/base/clearbase.py index dcf6c523..6218330e 100644 --- a/catalyst/base/clearbase.py +++ b/catalyst/base/clearbase.py @@ -27,12 +27,10 @@ class ClearBase(): self.resume.clear_all(remove=True) def clear_chroot(self): -self.chroot_lock.unlock() log.notice('Clearing the chroot path ...') clear_dir(self.settings["chroot_path"], mode=0o755) def remove_chroot(self): -self.chroot_lock.unlock() log.notice('Removing the chroot path ...') clear_dir(self.settings["chroot_path"], mode=0o755, remove=True) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 448d6265..10cffd4c 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -8,6 +8,7 @@ import sys from pathlib import Path +import fasteners import libmount import toml @@ -25,7 +26,6 @@ from catalyst.support import (CatalystError, file_locate, normpath, from catalyst.base.targetbase import TargetBase from catalyst.base.clearbase import ClearBase from catalyst.base.genbase import GenBase -from catalyst.lock import LockDir, LockInUse from catalyst.fileops import ensure_dirs, clear_dir, clear_path from catalyst.base.resume import AutoResume @@ -36,9 +36,6 @@ def run_sequence(sequence): sys.stdout.flush() try: func() -except LockInUse: -log.error('Unable to aquire the lock...') -return False except Exception: log.error('Exception running action sequence %s', func.__name__, exc_info=True) @@ -478,7 +475,6 @@ class StageBase(TargetBase, ClearBase, GenBase): """ self.settings["chroot_path"] = normpath(self.settings["storedir"] + "/tmp/" + self.settings["target_subpath"].rstrip('/')) -self.chroot_lock = LockDir(self.settings["chroot_path"]) def set_autoresume_path(self): self.settings["autoresume_path"] = normpath(pjoin( @@ -1366,8 +1362,10 @@ class StageBase(TargetBase, ClearBase, GenBase): pass def run(self): -self.chroot_lock.write_lock() +with fasteners.InterProcessLock(self.settings["chroot_path"] + '.lock'): +return self._run() +def _run(self): if "clear-autoresume" in self.settings["options"]: self.clear_autoresume() diff --git a/catalyst/lock.py b/catalyst/lock.py deleted file mode 100644 index e31745b2.. --- a/catalyst/lock.py +++ /dev/null @@ -1,58 +0,0 @@ - -import os - -from contextlib import contextmanager - -from snakeoil import fileutils -from snakeoil import osutils -from catalyst.fileops import ensure_dirs - - -LockInUse = osutils.LockException - -class Lock: -""" -A fnctl-based filesystem lock -""" -def __init__(self, lockfile): -fileutils.touch(lockfile, mode=0o664) -os.chown(lockfile, uid=-1, gid=250) -self.lock = osutils.FsLock(lockfile) - -def read_lock(self): -self.lock.acquire_read_lock() - -def write_lock(self): -self.lock.acquire_write_lock() - -def unlock(self): -# Releasing a write lock is the same as a read lock. -self.lock.release_write_lock() - -class LockDir(Lock): -""" -A fnctl-based filesystem lock in a directory -""" -def __init__(self, lockdir): -ensure_dirs(lockdir) -lockfile = os.path.join(lockdir, '.catalyst_lock') - -Lock.__init__(self, lockfile) - -@contextmanager -def read_lock(filename): -lock = Lock(filename) -lock.read_lock() -try: -yield -finally: -lock.unlock() - -@contextmanager -def write_lock(filename): -lock = Lock(filename) -lock.write_lock() -try: -yield -finally: -lock.unlock() diff --git a/catalyst/targets/snapshot.py b/catalyst/targets/snapshot.py index b494575a..ef68765d 100644 --- a/catalyst/targets/snapshot.p
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/, catalyst/targets/
commit: 8a9780b8bef53d427fa7d68b7df85e2d34f4dd57 Author: Matt Turner gentoo org> AuthorDate: Wed Jun 9 06:17:31 2021 + Commit: Matt Turner gentoo org> CommitDate: Thu Jun 10 01:35:32 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=8a9780b8 catalyst: Replace snakeoil's locks with fasteners To no great surprise, the existing locking was broken. For example, clear_chroot() releases the lock. It is called by unpack(), which is part of prepare_sequence. The result is that the whole build could be done without holding the lock. Just lock around run(). It's not apparent that finer-grained locking does anything for us. Signed-off-by: Matt Turner gentoo.org> catalyst/base/clearbase.py | 2 -- catalyst/base/stagebase.py | 10 +++- catalyst/lock.py | 58 catalyst/targets/snapshot.py | 6 ++--- 4 files changed, 7 insertions(+), 69 deletions(-) diff --git a/catalyst/base/clearbase.py b/catalyst/base/clearbase.py index dcf6c523..6218330e 100644 --- a/catalyst/base/clearbase.py +++ b/catalyst/base/clearbase.py @@ -27,12 +27,10 @@ class ClearBase(): self.resume.clear_all(remove=True) def clear_chroot(self): -self.chroot_lock.unlock() log.notice('Clearing the chroot path ...') clear_dir(self.settings["chroot_path"], mode=0o755) def remove_chroot(self): -self.chroot_lock.unlock() log.notice('Removing the chroot path ...') clear_dir(self.settings["chroot_path"], mode=0o755, remove=True) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 448d6265..34d10389 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -8,6 +8,7 @@ import sys from pathlib import Path +import fasteners import libmount import toml @@ -25,7 +26,6 @@ from catalyst.support import (CatalystError, file_locate, normpath, from catalyst.base.targetbase import TargetBase from catalyst.base.clearbase import ClearBase from catalyst.base.genbase import GenBase -from catalyst.lock import LockDir, LockInUse from catalyst.fileops import ensure_dirs, clear_dir, clear_path from catalyst.base.resume import AutoResume @@ -36,9 +36,6 @@ def run_sequence(sequence): sys.stdout.flush() try: func() -except LockInUse: -log.error('Unable to aquire the lock...') -return False except Exception: log.error('Exception running action sequence %s', func.__name__, exc_info=True) @@ -478,7 +475,6 @@ class StageBase(TargetBase, ClearBase, GenBase): """ self.settings["chroot_path"] = normpath(self.settings["storedir"] + "/tmp/" + self.settings["target_subpath"].rstrip('/')) -self.chroot_lock = LockDir(self.settings["chroot_path"]) def set_autoresume_path(self): self.settings["autoresume_path"] = normpath(pjoin( @@ -1366,8 +1362,10 @@ class StageBase(TargetBase, ClearBase, GenBase): pass def run(self): -self.chroot_lock.write_lock() +with fasteners.InterProcessLock(self.chroot_path + '.lock'): +return self._run() +def _run(self): if "clear-autoresume" in self.settings["options"]: self.clear_autoresume() diff --git a/catalyst/lock.py b/catalyst/lock.py deleted file mode 100644 index e31745b2.. --- a/catalyst/lock.py +++ /dev/null @@ -1,58 +0,0 @@ - -import os - -from contextlib import contextmanager - -from snakeoil import fileutils -from snakeoil import osutils -from catalyst.fileops import ensure_dirs - - -LockInUse = osutils.LockException - -class Lock: -""" -A fnctl-based filesystem lock -""" -def __init__(self, lockfile): -fileutils.touch(lockfile, mode=0o664) -os.chown(lockfile, uid=-1, gid=250) -self.lock = osutils.FsLock(lockfile) - -def read_lock(self): -self.lock.acquire_read_lock() - -def write_lock(self): -self.lock.acquire_write_lock() - -def unlock(self): -# Releasing a write lock is the same as a read lock. -self.lock.release_write_lock() - -class LockDir(Lock): -""" -A fnctl-based filesystem lock in a directory -""" -def __init__(self, lockdir): -ensure_dirs(lockdir) -lockfile = os.path.join(lockdir, '.catalyst_lock') - -Lock.__init__(self, lockfile) - -@contextmanager -def read_lock(filename): -lock = Lock(filename) -lock.read_lock() -try: -yield -finally: -lock.unlock() - -@contextmanager -def write_lock(filename): -lock = Lock(filename) -lock.write_lock() -try: -yield -finally: -lock.unlock() diff --git a/catalyst/targets/snapshot.py b/catalyst/targets/snapshot.py index b494575a..ef68765d 100644 --- a/catalyst/targets/snapshot.py +++ b/catal
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/targets/, catalyst/, catalyst/base/
commit: b5b921f2e0a490d247e56da635d4d93248a19acc Author: Matt Turner gentoo org> AuthorDate: Wed Jun 9 06:17:31 2021 + Commit: Matt Turner gentoo org> CommitDate: Thu Jun 10 01:15:35 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=b5b921f2 catalyst: Replace snakeoil's locks with fasteners To no great surprise, the existing locking was broken. For example, clear_chroot() releases the lock. It is called by unpack(), which is part of prepare_sequence. The result is that the whole build could be done without holding the lock. Just lock around run(). It's not apparent that finer-grained locking does anything for us. Signed-off-by: Matt Turner gentoo.org> catalyst/base/clearbase.py | 2 -- catalyst/base/stagebase.py | 9 +++ catalyst/lock.py | 58 catalyst/targets/snapshot.py | 6 ++--- 4 files changed, 6 insertions(+), 69 deletions(-) diff --git a/catalyst/base/clearbase.py b/catalyst/base/clearbase.py index dcf6c523..6218330e 100644 --- a/catalyst/base/clearbase.py +++ b/catalyst/base/clearbase.py @@ -27,12 +27,10 @@ class ClearBase(): self.resume.clear_all(remove=True) def clear_chroot(self): -self.chroot_lock.unlock() log.notice('Clearing the chroot path ...') clear_dir(self.settings["chroot_path"], mode=0o755) def remove_chroot(self): -self.chroot_lock.unlock() log.notice('Removing the chroot path ...') clear_dir(self.settings["chroot_path"], mode=0o755, remove=True) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 448d6265..d15a0df8 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -25,7 +25,6 @@ from catalyst.support import (CatalystError, file_locate, normpath, from catalyst.base.targetbase import TargetBase from catalyst.base.clearbase import ClearBase from catalyst.base.genbase import GenBase -from catalyst.lock import LockDir, LockInUse from catalyst.fileops import ensure_dirs, clear_dir, clear_path from catalyst.base.resume import AutoResume @@ -36,9 +35,6 @@ def run_sequence(sequence): sys.stdout.flush() try: func() -except LockInUse: -log.error('Unable to aquire the lock...') -return False except Exception: log.error('Exception running action sequence %s', func.__name__, exc_info=True) @@ -478,7 +474,6 @@ class StageBase(TargetBase, ClearBase, GenBase): """ self.settings["chroot_path"] = normpath(self.settings["storedir"] + "/tmp/" + self.settings["target_subpath"].rstrip('/')) -self.chroot_lock = LockDir(self.settings["chroot_path"]) def set_autoresume_path(self): self.settings["autoresume_path"] = normpath(pjoin( @@ -1366,8 +1361,10 @@ class StageBase(TargetBase, ClearBase, GenBase): pass def run(self): -self.chroot_lock.write_lock() +with fasteners.InterProcessLock(self.chroot_path + '.lock'): +return self._run() +def _run(self): if "clear-autoresume" in self.settings["options"]: self.clear_autoresume() diff --git a/catalyst/lock.py b/catalyst/lock.py deleted file mode 100644 index e31745b2.. --- a/catalyst/lock.py +++ /dev/null @@ -1,58 +0,0 @@ - -import os - -from contextlib import contextmanager - -from snakeoil import fileutils -from snakeoil import osutils -from catalyst.fileops import ensure_dirs - - -LockInUse = osutils.LockException - -class Lock: -""" -A fnctl-based filesystem lock -""" -def __init__(self, lockfile): -fileutils.touch(lockfile, mode=0o664) -os.chown(lockfile, uid=-1, gid=250) -self.lock = osutils.FsLock(lockfile) - -def read_lock(self): -self.lock.acquire_read_lock() - -def write_lock(self): -self.lock.acquire_write_lock() - -def unlock(self): -# Releasing a write lock is the same as a read lock. -self.lock.release_write_lock() - -class LockDir(Lock): -""" -A fnctl-based filesystem lock in a directory -""" -def __init__(self, lockdir): -ensure_dirs(lockdir) -lockfile = os.path.join(lockdir, '.catalyst_lock') - -Lock.__init__(self, lockfile) - -@contextmanager -def read_lock(filename): -lock = Lock(filename) -lock.read_lock() -try: -yield -finally: -lock.unlock() - -@contextmanager -def write_lock(filename): -lock = Lock(filename) -lock.write_lock() -try: -yield -finally: -lock.unlock() diff --git a/catalyst/targets/snapshot.py b/catalyst/targets/snapshot.py index b494575a..ef68765d 100644 --- a/catalyst/targets/snapshot.py +++ b/catalyst/targets/snapshot.py @@ -5,11 +5,12 @@ Snapshot target import subprocess import sys +import fasteners
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/targets/, catalyst/
commit: f535f7c03185442359ab1c5381205de736f547ea Author: Matt Turner gentoo org> AuthorDate: Wed Jun 9 06:17:31 2021 + Commit: Matt Turner gentoo org> CommitDate: Thu Jun 10 00:40:14 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=f535f7c0 catalyst: Replace snakeoil's locks with fasteners To no great surprise, the existing locking was broken. For example, clear_chroot() releases the lock. It is called by unpack(), which is part of prepare_sequence. The result is that the whole build could be done without holding the lock. Just lock around run(). It's not apparent that finer-grained locking does anything for us. Signed-off-by: Matt Turner gentoo.org> catalyst/base/clearbase.py | 2 -- catalyst/base/stagebase.py | 8 +- catalyst/lock.py | 58 catalyst/targets/snapshot.py | 6 ++--- 4 files changed, 4 insertions(+), 70 deletions(-) diff --git a/catalyst/base/clearbase.py b/catalyst/base/clearbase.py index dcf6c523..6218330e 100644 --- a/catalyst/base/clearbase.py +++ b/catalyst/base/clearbase.py @@ -27,12 +27,10 @@ class ClearBase(): self.resume.clear_all(remove=True) def clear_chroot(self): -self.chroot_lock.unlock() log.notice('Clearing the chroot path ...') clear_dir(self.settings["chroot_path"], mode=0o755) def remove_chroot(self): -self.chroot_lock.unlock() log.notice('Removing the chroot path ...') clear_dir(self.settings["chroot_path"], mode=0o755, remove=True) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 448d6265..fac5d790 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -25,7 +25,6 @@ from catalyst.support import (CatalystError, file_locate, normpath, from catalyst.base.targetbase import TargetBase from catalyst.base.clearbase import ClearBase from catalyst.base.genbase import GenBase -from catalyst.lock import LockDir, LockInUse from catalyst.fileops import ensure_dirs, clear_dir, clear_path from catalyst.base.resume import AutoResume @@ -36,9 +35,6 @@ def run_sequence(sequence): sys.stdout.flush() try: func() -except LockInUse: -log.error('Unable to aquire the lock...') -return False except Exception: log.error('Exception running action sequence %s', func.__name__, exc_info=True) @@ -478,7 +474,6 @@ class StageBase(TargetBase, ClearBase, GenBase): """ self.settings["chroot_path"] = normpath(self.settings["storedir"] + "/tmp/" + self.settings["target_subpath"].rstrip('/')) -self.chroot_lock = LockDir(self.settings["chroot_path"]) def set_autoresume_path(self): self.settings["autoresume_path"] = normpath(pjoin( @@ -1365,9 +1360,8 @@ class StageBase(TargetBase, ClearBase, GenBase): except CatalystError: pass +@fasteners.interprocess_locked(self.chroot_path + '.lock') def run(self): -self.chroot_lock.write_lock() - if "clear-autoresume" in self.settings["options"]: self.clear_autoresume() diff --git a/catalyst/lock.py b/catalyst/lock.py deleted file mode 100644 index e31745b2.. --- a/catalyst/lock.py +++ /dev/null @@ -1,58 +0,0 @@ - -import os - -from contextlib import contextmanager - -from snakeoil import fileutils -from snakeoil import osutils -from catalyst.fileops import ensure_dirs - - -LockInUse = osutils.LockException - -class Lock: -""" -A fnctl-based filesystem lock -""" -def __init__(self, lockfile): -fileutils.touch(lockfile, mode=0o664) -os.chown(lockfile, uid=-1, gid=250) -self.lock = osutils.FsLock(lockfile) - -def read_lock(self): -self.lock.acquire_read_lock() - -def write_lock(self): -self.lock.acquire_write_lock() - -def unlock(self): -# Releasing a write lock is the same as a read lock. -self.lock.release_write_lock() - -class LockDir(Lock): -""" -A fnctl-based filesystem lock in a directory -""" -def __init__(self, lockdir): -ensure_dirs(lockdir) -lockfile = os.path.join(lockdir, '.catalyst_lock') - -Lock.__init__(self, lockfile) - -@contextmanager -def read_lock(filename): -lock = Lock(filename) -lock.read_lock() -try: -yield -finally: -lock.unlock() - -@contextmanager -def write_lock(filename): -lock = Lock(filename) -lock.write_lock() -try: -yield -finally: -lock.unlock() diff --git a/catalyst/targets/snapshot.py b/catalyst/targets/snapshot.py index b494575a..ef68765d 100644 --- a/catalyst/targets/snapshot.py +++ b/catalyst/targets/snapshot.py @@ -5,11 +5,12 @@ Snapshot target import subprocess import sys +import fasteners + from pathlib import Path
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/targets/
commit: 6b78a58c9ac825ecd450d100cd269d29761dbe03 Author: Daniel Cordero 0xdc io> AuthorDate: Thu Feb 4 11:07:18 2021 + Commit: Matt Turner gentoo org> CommitDate: Sun Feb 21 02:05:34 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=6b78a58c catalyst: Clean up chroot directory on success The embedded and livecd-stage2 targets override the action sequence without calling set_completion_action_sequences. This would leave the temporary build environment unpacked on the filesystem. Signed-off-by: Daniel Cordero 0xdc.io> Signed-off-by: Matt Turner gentoo.org> catalyst/targets/embedded.py | 2 +- catalyst/targets/livecd_stage2.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py index b677b226..01ad035d 100644 --- a/catalyst/targets/embedded.py +++ b/catalyst/targets/embedded.py @@ -53,8 +53,8 @@ class embedded(StageBase): self.empty, self.clean, self.capture, -self.clear_autoresume, ]) +self.set_completion_action_sequences() def set_root_path(self): self.settings["root_path"] = normpath("/tmp/mergeroot") diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py index 774702f8..832e0998 100644 --- a/catalyst/targets/livecd_stage2.py +++ b/catalyst/targets/livecd_stage2.py @@ -108,4 +108,4 @@ class livecd_stage2(StageBase): self.setup_overlay, self.create_iso, ]) -self.finish_sequence.append(self.clear_autoresume) +self.set_completion_action_sequences()
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: dc22f3540c6879e88e5f3bd2ff8999066387d3ea Author: Matt Turner gentoo org> AuthorDate: Thu Mar 25 03:02:39 2021 + Commit: Matt Turner gentoo org> CommitDate: Thu Mar 25 03:02:39 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=dc22f354 catalyst: Fix indentation Fixes: 48338534 ("Add option to generate BSD-style tagged hashes ...") Signed-off-by: Matt Turner gentoo.org> catalyst/base/genbase.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/catalyst/base/genbase.py b/catalyst/base/genbase.py index 4a4c3efa..b89e7c93 100644 --- a/catalyst/base/genbase.py +++ b/catalyst/base/genbase.py @@ -26,9 +26,9 @@ class GenBase(): filename = os.path.split(filepath)[1] if self.settings['digest_format'] == 'bsd': -return f'# {name.upper()} HASH\n{name.upper()} ({filename}) = {h.hexdigest()}\n' +return f'# {name.upper()} HASH\n{name.upper()} ({filename}) = {h.hexdigest()}\n' else: -return f'# {name.upper()} HASH\n{h.hexdigest()} {filename}\n' +return f'# {name.upper()} HASH\n{h.hexdigest()} {filename}\n' def gen_contents_file(self, path): c = self.settings['contents_map']
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/, catalyst/base/
commit: 483385348b32fab2230f596816b6e1d0b6489962 Author: Andreas K. Hüttel gentoo org> AuthorDate: Wed Feb 24 21:26:58 2021 + Commit: Matt Turner gentoo org> CommitDate: Wed Feb 24 21:26:58 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=48338534 Add option to generate BSD-style tagged hashes (can be verified by modern coreutils) Signed-off-by: Andreas K. Hüttel gentoo.org> catalyst/base/genbase.py | 6 +- catalyst/defaults.py | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/catalyst/base/genbase.py b/catalyst/base/genbase.py index c7dd87bc..52418877 100644 --- a/catalyst/base/genbase.py +++ b/catalyst/base/genbase.py @@ -24,7 +24,11 @@ class GenBase(): h.update(data) filename = os.path.split(filepath)[1] -return f'# {name.upper()} HASH\n{h.hexdigest()} {filename}\n' + + if self.settings['digest_format'] == 'bsd': + return f'# {name.upper()} HASH\n{name.upper()} ({filename}) = {h.hexdigest()}\n' + else: + return f'# {name.upper()} HASH\n{h.hexdigest()} {filename}\n' def gen_contents_file(self, path): c = self.settings['contents_map'] diff --git a/catalyst/defaults.py b/catalyst/defaults.py index ccb0a584..2cede562 100644 --- a/catalyst/defaults.py +++ b/catalyst/defaults.py @@ -11,6 +11,7 @@ from DeComp.definitions import DECOMPRESSOR_PROGRAM_OPTIONS, LIST_XATTRS_OPTIONS valid_config_file_values = frozenset([ "compression_mode", "digests", +"digest_format", "distcc_hosts", "distdir", "envscript", @@ -35,6 +36,7 @@ confdefaults = { "compressor_options": XATTRS_OPTIONS['linux'], "decomp_opt": DECOMPRESSOR_PROGRAM_OPTIONS['linux'], "decompressor_search_order": DECOMPRESSOR_SEARCH_ORDER, +"digest_format": 'linux', "distdir": portage.settings['DISTDIR'], "icecream": "/var/cache/icecream", 'list_xattrs_opt': LIST_XATTRS_OPTIONS['linux'],
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: 5f34226550e221921189ca2184a0afe2de1e8821 Author: Felix Bier rohde-schwarz com> AuthorDate: Thu Feb 4 00:45:27 2021 + Commit: Matt Turner gentoo org> CommitDate: Sat Feb 20 21:27:29 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=5f342265 Drop PORTDIR from make.conf This commit drops PORTDIR from being included in the generated make.conf. The variable is no longer needed, since the existing code will now generate a repos.conf entry for the main repo when needed (i.e. when the location is non-default, which is the same condition that was applied for PORTDIR in the code removed by this commit). The PORTDIR variable is considered deprecated in favor of repos.conf entries (reference: https://wiki.gentoo.org/wiki/PORTDIR). Signed-off-by: Felix Bier rohde-schwarz.com> Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 6 -- 1 file changed, 6 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 97e2318c..bc0eccd0 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -1092,12 +1092,6 @@ class StageBase(TargetBase, ClearBase, GenBase): myf.write(hostuseexpand + '="' + ' '.join(myuseexpandvars[hostuseexpand]) + '"\n') -# Write non-default PORTDIR/DISTDIR/PKGDIR settings to make.conf -if (self.settings['repo_basedir'], self.settings['repo_name']) != \ - (confdefaults['repo_basedir'], confdefaults['repo_name']): -myf.write('PORTDIR="%s/%s"\n' % (self.settings['repo_basedir'], - self.settings['repo_name'])) - for x in ['target_distdir', 'target_pkgdir']: if self.settings[x] != confdefaults[x]: varname = x.split('_')[1].upper()
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: 7c4d1c5f3aab4a32795797332f33d5a759f72a9d Author: Matt Turner gentoo org> AuthorDate: Thu Mar 25 03:02:53 2021 + Commit: Matt Turner gentoo org> CommitDate: Thu Mar 25 03:02:53 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=7c4d1c5f catalyst: Remove @staticmethod from generate_hash() Fixes: 48338534 ("Add option to generate BSD-style tagged hashes ...") Signed-off-by: Matt Turner gentoo.org> catalyst/base/genbase.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/catalyst/base/genbase.py b/catalyst/base/genbase.py index b89e7c93..6d039a8f 100644 --- a/catalyst/base/genbase.py +++ b/catalyst/base/genbase.py @@ -12,8 +12,7 @@ class GenBase(): def __init__(self, myspec): self.settings = myspec -@staticmethod -def generate_hash(filepath, name): +def generate_hash(self, filepath, name): h = hashlib.new(name) with open(filepath, 'rb') as f:
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: 91dba2e6199b24c7d0b52b8bd6204b4a5f6e5137 Author: Matt Turner gentoo org> AuthorDate: Tue Mar 9 16:17:33 2021 + Commit: Matt Turner gentoo org> CommitDate: Tue Mar 9 16:17:33 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=91dba2e6 catalyst: Remove tabs Fixes: 48338534 ("Add option to generate BSD-style tagged hashes ...") Signed-off-by: Matt Turner gentoo.org> catalyst/base/genbase.py | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/catalyst/base/genbase.py b/catalyst/base/genbase.py index 52418877..4a4c3efa 100644 --- a/catalyst/base/genbase.py +++ b/catalyst/base/genbase.py @@ -25,10 +25,10 @@ class GenBase(): filename = os.path.split(filepath)[1] - if self.settings['digest_format'] == 'bsd': - return f'# {name.upper()} HASH\n{name.upper()} ({filename}) = {h.hexdigest()}\n' - else: - return f'# {name.upper()} HASH\n{h.hexdigest()} {filename}\n' +if self.settings['digest_format'] == 'bsd': +return f'# {name.upper()} HASH\n{name.upper()} ({filename}) = {h.hexdigest()}\n' +else: +return f'# {name.upper()} HASH\n{h.hexdigest()} {filename}\n' def gen_contents_file(self, path): c = self.settings['contents_map']
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: c1f5707a9c9f27f730aad908c8f3c86075201fc9 Author: Daniel Cordero 0xdc io> AuthorDate: Thu Feb 4 11:07:19 2021 + Commit: Matt Turner gentoo org> CommitDate: Sun Feb 21 02:05:39 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=c1f5707a catalyst: Remove /etc/machine-id in all stages Machine IDs are unique per installation, but if they are retained in a stage tarball, all installations from that stage share the same machine id. Signed-off-by: Daniel Cordero 0xdc.io> Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 1 + 1 file changed, 1 insertion(+) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index bc0eccd0..a4da7eb3 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -465,6 +465,7 @@ class StageBase(TargetBase, ClearBase, GenBase): def set_cleanables(self): self.settings['cleanables'] = [ +"/etc/machine-id", "/etc/resolv.conf", "/var/tmp/*", "/tmp/*",
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/
commit: 4fd2ac23250ab2ac1f6a506ee433f466a4f9e026 Author: Felix Bier rohde-schwarz com> AuthorDate: Sat Feb 13 23:18:17 2021 + Commit: Matt Turner gentoo org> CommitDate: Sat Feb 20 21:27:29 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=4fd2ac23 Enable recursive globbing for clear_path This commit enables recursive globbing in clear_path, allowing the usage of '**' to match an arbitrary number of sub-directories. Before this commit, clear_path used only non-recursive globbing. This allowed to use '*' to expand names within one directory, e.g. '/a/*/c' can expand to '/a/b/c', but not '/a/b/b/c'. With this commit, '/a/**/c' can be used to expand to '/a/b/c', '/a/b/b/c', '/a/b/b/b/c' etc. This is motivated by wanting to recursively delete all occurences of a filename with the 'stage4/rm' entry of a spec file. The '/rm' entries are processed with 'clear_path' in the existing code. Additionally, 'glob.glob' is replaced with 'glob.iglob', which returns the same files as 'glob.glob', but as an iterator instead of as a list (so it no longer necessary to hold all matches in memory at once). Recursive globbing has been added in Python 3.5. References: https://docs.python.org/3/library/glob.html#glob.glob https://docs.python.org/3/library/glob.html#glob.iglob Signed-off-by: Felix Bier rohde-schwarz.com> Signed-off-by: Matt Turner gentoo.org> catalyst/fileops.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalyst/fileops.py b/catalyst/fileops.py index 5c6f5cd8..59525420 100644 --- a/catalyst/fileops.py +++ b/catalyst/fileops.py @@ -99,7 +99,7 @@ def clear_dir(target, mode=0o755, remove=False, def clear_path(target_path): """Nuke |target_path| regardless of it being a dir, file or glob.""" -targets = glob.glob(target_path) +targets = glob.iglob(target_path, recursive=True) for path in targets: clear_dir(path, remove=True)
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: 71037a931ff23141875c40d37605e8614a31077e Author: Daniel Cordero 0xdc io> AuthorDate: Thu Feb 25 13:09:12 2021 + Commit: Matt Turner gentoo org> CommitDate: Sat Mar 6 16:57:09 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=71037a93 catalyst: Handle specifying target_profiles in repo_name:path format Fixes: a5004005 ("catalyst: Call config_profile_link for all targets") Signed-off-by: Daniel Cordero 0xdc.io> Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index a4da7eb3..448d6265 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -814,10 +814,15 @@ class StageBase(TargetBase, ClearBase, GenBase): make_profile = Path(self.settings['chroot_path'] + self.settings['port_conf'], 'make.profile') make_profile.unlink(missing_ok=True) +try: +repo_name, target_profile = self.settings['target_profile'].split(":", 1) +except ValueError: +repo_name = self.settings['repo_name'] +target_profile = self.settings['target_profile'] make_profile.symlink_to(Path('../..' + self.settings['repo_basedir'], - self.settings['repo_name'], + repo_name, 'profiles', - self.settings['target_profile']), + target_profile), target_is_directory=True) def setup_confdir(self):
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/
commit: fbe56d75989fabf29e7b642515df69737cf62cc1 Author: Matt Turner gentoo org> AuthorDate: Wed Jun 9 04:32:08 2021 + Commit: Matt Turner gentoo org> CommitDate: Wed Jun 9 04:32:08 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=fbe56d75 catalyst: Remove clear_dir's never used clear_nondir parameter Signed-off-by: Matt Turner gentoo.org> catalyst/fileops.py | 11 +++ 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/catalyst/fileops.py b/catalyst/fileops.py index 59525420..4252285e 100644 --- a/catalyst/fileops.py +++ b/catalyst/fileops.py @@ -46,8 +46,7 @@ def ensure_dirs(path, gid=-1, uid=-1, mode=0o755, minimal=True, return succeeded -def clear_dir(target, mode=0o755, remove=False, - clear_nondir=True): +def clear_dir(target, mode=0o755, remove=False): '''Universal directory clearing function @target: string, path to be cleared or removed @@ -74,12 +73,8 @@ def clear_dir(target, mode=0o755, remove=False, log.error('clear_dir failed', exc_info=True) return False elif os.path.exists(target): -if clear_nondir: -log.debug("Clearing (unlinking) non-directory: %s", target) -os.unlink(target) -else: -log.info('clear_dir failed: %s: is not a directory', target) -return False +log.debug("Clearing (unlinking) non-directory: %s", target) +os.unlink(target) else: log.debug("Conditions not met to clear: %s", target) log.debug(" isdir: %s", os.path.isdir(target))
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/
commit: caf55a942580e02e66ed846f5c3ab4ad5ab8846f Author: Felix Bier rohde-schwarz com> AuthorDate: Thu Feb 4 00:37:06 2021 + Commit: Matt Turner gentoo org> CommitDate: Sat Feb 20 21:27:29 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=caf55a94 Extend get_repo_name to handle squashed repos This commit extends the method get_repo_name to also handle squashed repos. This is done by mounting the squash file to a temporary directory and then extracting the repository from that directory with the already existing code. This is motivated by wanting to mount each repo to e.g. /var/db/repos/ in a later commit. For squashed repos, we don't know without mounting the repo first. For this reason, it is mounted to a temporary directory first to extract . Signed-off-by: Felix Bier rohde-schwarz.com> Signed-off-by: Matt Turner gentoo.org> catalyst/support.py | 36 +++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/catalyst/support.py b/catalyst/support.py index fc50fa34..37d53bc4 100644 --- a/catalyst/support.py +++ b/catalyst/support.py @@ -10,10 +10,12 @@ from subprocess import Popen import libmount from portage.repository.config import RepoConfig +from tempfile import TemporaryDirectory from snakeoil.bash import read_bash_dict from catalyst import log +from catalyst.context import namespace BASH_BINARY = "/bin/bash" @@ -148,7 +150,7 @@ def read_makeconf(mymakeconffile): return makeconf -def get_repo_name(repo_path): +def get_repo_name_from_dir(repo_path): """ Get the name of the repo at the given repo_path. References: @@ -164,6 +166,38 @@ def get_repo_name(repo_path): return repo_config.name +def get_repo_name_from_squash(repo_squash_path): +""" Get the name of the repo at the given repo_squash_path. +To obtain the name, the squash file is mounted to a temporary directory. +""" + +repo_name = None + +# Mount squash file to temp directory in separate mount namespace +with TemporaryDirectory() as temp, namespace(mount=True): +try: +source = str(repo_squash_path) +target = str(temp) +fstype = 'squashfs' +options = 'ro,loop' +cxt = libmount.Context(source=source, target=target, + fstype=fstype, options=options) +cxt.mount() +repo_name = get_repo_name_from_dir(target) + +except Exception as e: +raise CatalystError(f"Couldn't mount: {source}, {e}") from e + +return repo_name + + +def get_repo_name(repo_path): +if not Path(repo_path).is_dir(): +return get_repo_name_from_squash(repo_path) + +return get_repo_name_from_dir(repo_path) + + def ismount(path): """Like os.path.ismount, but also support bind mounts""" path = Path(path)
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/
commit: 65d49f1028b49fed6e011526429e553ebb6c903e Author: Felix Bier rohde-schwarz com> AuthorDate: Thu Feb 4 00:38:36 2021 + Commit: Matt Turner gentoo org> CommitDate: Sat Feb 20 21:27:29 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=65d49f10 Unify handling of main repo and other repos This commit unifies the handling of the main repo and the other repos. All are stored in one common list. A mount entry is created for each entry in the list (previously a mount entry was only created for the main repo and the other repos were copied into the chroot). This means each non-main repo can now be either a directory or a squash files (previously the non-main repos had to be directories). The existing mount logic will bind-mount the repos that are stored as directories, removing the need for copying. A repos.conf entry will be created for each entry in the list. This means a repos.conf entry for the main repo can now be created (previously repos.conf entries were only created for the non-main repos). The repos.conf entry will only be created if the target location for the main repo is non-default, i.e. unequal to /var/db/repos/gentoo. This mirrors the behavior of write_make_conf, which only writes the PORTDIR variable to make.conf if the location of the main repo is non-default. As a side effect, the PORTDIR variable is now no longer needed, and will be removed from write_make_conf in a separate commit. Signed-off-by: Felix Bier rohde-schwarz.com> Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 88 +++--- catalyst/defaults.py | 5 --- 2 files changed, 60 insertions(+), 33 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index fedc8f87..97e2318c 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -219,8 +219,17 @@ class StageBase(TargetBase, ClearBase, GenBase): # Setup our mount points. self.mount = copy.deepcopy(MOUNT_DEFAULTS) -self.mount['portdir']['source'] = self.snapshot -self.mount['portdir']['target'] = self.settings['repo_basedir'] + '/' + self.settings['repo_name'] +# Create mount entry for each repository +for path, name, _ in self.repos: +name = get_repo_name(path) +mount_id = f'repo_{name}' + +self.mount[mount_id] = { +'enable': True, +'source': path, +'target': self.get_repo_location(name) +} + self.mount['distdir']['source'] = self.settings['distdir'] self.mount["distdir"]['target'] = self.settings['target_distdir'] @@ -587,13 +596,41 @@ class StageBase(TargetBase, ClearBase, GenBase): "/busybox_config"] def set_repos(self): + +# Each entry in this list will be a tuple of the form +# (source, name, default) +# +# source: the location of the repo on the host system, +# either a directory or a squashfs file. +# +# name: the repository name parsed from the repo. +# This is just a caching mechanism to avoid parsing the name +# every time the source is processed. +# +# default: Default location where the repo is expected in the +# target system. If this matches the path where we mount the repo to +# (as per get_repo_location), then we can skip generating a repos.conf +# entry for that repo. Currently this mechanism is only used for +# the main repo, which has a default location hard-coded in +# /usr/share/portage/config/repos.conf. For the other repos, +# the default is set to None. +self.repos = [] + +# Create entry for snapshot +default_location = Path(confdefaults['repo_basedir'], confdefaults['repo_name']) +self.repos.append((self.snapshot, get_repo_name(self.snapshot), default_location)) + +# Create entry for every other repo if 'repos' in self.settings: if isinstance(self.settings['repos'], str): self.settings['repos'] = \ self.settings['repos'].split() -log.info('repos directories are set to: %s', +log.info('repos are set to: %s', ' '.join(self.settings['repos'])) +get_info = lambda repo: (repo, get_repo_name(repo), None) +self.repos.extend(map(get_info, self.settings['repos'])) + def set_overlay(self): if self.settings["spec_prefix"] + "/overlay" in self.settings: if isinstance(self.settings[self.settings['spec_prefix'] + '/overlay'], str): @@ -832,24 +869,19 @@ class StageBase(TargetBase, ClearBase, GenBase): raise CatalystError(f'Could not write {repo_conf_chroot}: {e}') from e def process_repos(self): -""" We copy the contents of our repos to
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/
commit: e40f31c10a79499a822596948b68fcf6ea3f647f Author: Matt Turner gentoo org> AuthorDate: Mon Nov 2 17:43:34 2020 + Commit: Matt Turner gentoo org> CommitDate: Fri Jan 29 23:48:02 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=e40f31c1 catalyst: Switch spec files to TOML Signed-off-by: Matt Turner gentoo.org> catalyst/config.py | 120 - catalyst/main.py | 26 2 files changed, 9 insertions(+), 137 deletions(-) diff --git a/catalyst/config.py b/catalyst/config.py deleted file mode 100644 index e1963f71.. --- a/catalyst/config.py +++ /dev/null @@ -1,120 +0,0 @@ - -import re - -from catalyst import log -from catalyst.support import CatalystError - - -class ParserBase(): - -filename = "" -lines = None -values = None -key_value_separator = "=" -multiple_values = False -empty_values = True -eval_none = False - -def __getitem__(self, key): -return self.values[key] - -def get_values(self): -return self.values - -def dump(self): -dump = "" -for x in self.values: -dump += x + " = " + repr(self.values[x]) + "\n" -return dump - -def parse_file(self, filename): -try: -with open(filename, "r") as myf: -self.lines = myf.readlines() -except: -raise CatalystError("Could not open file " + filename, -print_traceback=True) -self.filename = filename -self.parse() - -def parse_lines(self, lines): -self.lines = lines -self.parse() - -def parse(self): -values = {} -cur_array = [] - -trailing_comment = re.compile(r'\s*#.*$') - -for x, myline in enumerate(self.lines): -myline = myline.strip() - -# Force the line to be clean -# Remove Comments ( anything following # ) -myline = trailing_comment.sub("", myline) - -# Skip any blank lines -if not myline: -continue - -if self.key_value_separator in myline: -# Split on the first occurence of the separator creating two strings in the array mobjs -mobjs = myline.split(self.key_value_separator, 1) -mobjs[1] = mobjs[1].strip().strip('"') - -# Start a new array using the first element of mobjs -cur_array = [mobjs[0]] -if mobjs[1]: -# do any variable substitiution embeded in it with -# the values already obtained -mobjs[1] = mobjs[1] % values -if self.multiple_values: -# split on white space creating additional array elements -subarray = mobjs[1].split() -cur_array += subarray -else: -cur_array += [mobjs[1]] - -# Else add on to the last key we were working on -else: -if self.multiple_values: -cur_array += myline.split() -else: -raise CatalystError("Syntax error: %s" % -x, print_traceback=True) - -# XXX: Do we really still need this "single value is a string" behavior? -if len(cur_array) == 2: -values[cur_array[0]] = cur_array[1] -else: -values[cur_array[0]] = cur_array[1:] - -if not self.empty_values: -# Make sure the list of keys is static since we modify inside the loop. -for x in list(values.keys()): -# Delete empty key pairs -if not values[x]: -log.warning('No value set for key "%s"; deleting', x) -del values[x] - -if self.eval_none: -# Make sure the list of keys is static since we modify inside the loop. -for x in list(values.keys()): -# reset None values -if isinstance(values[x], str) and values[x].lower() in ['none']: -log.info('None value found for key "%s"; reseting', x) -values[x] = None -self.values = values - - -class SpecParser(ParserBase): - -key_value_separator = ':' -multiple_values = True -empty_values = False -eval_none = True - -def __init__(self, filename=""): -if filename: -self.parse_file(filename) diff --git a/catalyst/main.py b/catalyst/main.py index 0de1040f..81495c62 100644 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -13,7 +13,6 @@ from DeComp.definitions import (COMPRESS_DEFINITIONS, DECOMPRESS_DEFINITIONS, from DeComp.contents import ContentsMap from catalyst import log -import catalyst.config from catalyst.context import namesp
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/targets/, catalyst/base/
commit: 84b2aa86d8a1674b0f7ea90a762b8b5e9a5e456a Author: Matt Turner gentoo org> AuthorDate: Mon Jan 18 03:20:41 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 19:37:55 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=84b2aa86 catalyst: Deduplicate the common build_sequence steps This also provides a single location to add a function to all targets' build_sequence. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py| 11 ++- catalyst/targets/embedded.py | 3 --- catalyst/targets/livecd_stage1.py | 3 --- catalyst/targets/livecd_stage2.py | 3 --- catalyst/targets/netboot.py | 3 --- catalyst/targets/stage4.py| 3 --- 6 files changed, 6 insertions(+), 20 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 3b8d3a6e..40b60af3 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -90,7 +90,11 @@ class StageBase(TargetBase, ClearBase, GenBase): self.setup_confdir, self.portage_overlay, ] -self.build_sequence = [] +self.build_sequence = [ +self.bind, +self.chroot_setup, +self.setup_environment, +] self.finish_sequence = [] self.set_valid_build_kernel_vars(addlargs) @@ -497,16 +501,13 @@ class StageBase(TargetBase, ClearBase, GenBase): Or it calls the normal set_action_sequence() for the target stage. """ if "purgeonly" in self.settings["options"]: -self.build_sequence.append(self.remove_chroot) +self.build_sequence = [self.remove_chroot] return self.set_action_sequence() def set_action_sequence(self): """Set basic stage1, 2, 3 action sequences""" self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.run_local, self.preclean, ]) diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py index 83b17ad2..b677b226 100644 --- a/catalyst/targets/embedded.py +++ b/catalyst/targets/embedded.py @@ -42,9 +42,6 @@ class embedded(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.build_kernel, self.build_packages, self.root_overlay, diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py index 9fe95a00..dbfa54ed 100644 --- a/catalyst/targets/livecd_stage1.py +++ b/catalyst/targets/livecd_stage1.py @@ -24,9 +24,6 @@ class livecd_stage1(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.build_packages, ]) self.finish_sequence.extend([ diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py index ab8f4a0e..e90e9f53 100644 --- a/catalyst/targets/livecd_stage2.py +++ b/catalyst/targets/livecd_stage2.py @@ -87,9 +87,6 @@ class livecd_stage2(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.run_local, self.build_kernel ]) diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py index cb5e7ae4..a2a9fcb3 100644 --- a/catalyst/targets/netboot.py +++ b/catalyst/targets/netboot.py @@ -159,9 +159,6 @@ class netboot(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.build_packages, self.root_overlay, self.copy_files_to_image, diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py index 9e53f070..f8383f75 100644 --- a/catalyst/targets/stage4.py +++ b/catalyst/targets/stage4.py @@ -40,9 +40,6 @@ class stage4(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.build_packages, self.build_kernel, self.bootloader,
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/targets/
commit: 047d9c1a2a968365b55e5b3b4b3418fd0ef24764 Author: Matt Turner gentoo org> AuthorDate: Mon Jan 18 03:15:02 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 19:37:55 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=047d9c1a catalyst: Deduplicate prepare_sequence assignments Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py| 13 ++--- catalyst/targets/embedded.py | 6 -- catalyst/targets/livecd_stage1.py | 6 -- catalyst/targets/livecd_stage2.py | 6 -- catalyst/targets/netboot.py | 6 -- catalyst/targets/stage4.py| 6 -- 6 files changed, 6 insertions(+), 37 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 53b0a224..3b8d3a6e 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -84,7 +84,12 @@ class StageBase(TargetBase, ClearBase, GenBase): "portage_overlay", "portage_prefix", ]) -self.prepare_sequence = [] +self.prepare_sequence = [ +self.unpack, +self.config_profile_link, +self.setup_confdir, +self.portage_overlay, +] self.build_sequence = [] self.finish_sequence = [] @@ -498,12 +503,6 @@ class StageBase(TargetBase, ClearBase, GenBase): def set_action_sequence(self): """Set basic stage1, 2, 3 action sequences""" -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py index 7d328808..83b17ad2 100644 --- a/catalyst/targets/embedded.py +++ b/catalyst/targets/embedded.py @@ -41,12 +41,6 @@ class embedded(StageBase): StageBase.__init__(self, spec, addlargs) def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py index eb6bb0f0..9fe95a00 100644 --- a/catalyst/targets/livecd_stage1.py +++ b/catalyst/targets/livecd_stage1.py @@ -23,12 +23,6 @@ class livecd_stage1(StageBase): StageBase.__init__(self, spec, addlargs) def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py index 5fecff85..ab8f4a0e 100644 --- a/catalyst/targets/livecd_stage2.py +++ b/catalyst/targets/livecd_stage2.py @@ -86,12 +86,6 @@ class livecd_stage2(StageBase): print_traceback=True) def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py index 9a7e59e5..cb5e7ae4 100644 --- a/catalyst/targets/netboot.py +++ b/catalyst/targets/netboot.py @@ -158,12 +158,6 @@ class netboot(StageBase): self.resume.enable("empty") def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py index 997139a5..9e53f070 100644 --- a/catalyst/targets/stage4.py +++ b/catalyst/targets/stage4.py @@ -39,12 +39,6 @@ class stage4(StageBase): self.settings["cleanables"].remove('/etc/resolv.conf') def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup,
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/targets/, catalyst/base/
commit: 97b5409ac92b40016fe9945418570a6c0538c343 Author: Matt Turner gentoo org> AuthorDate: Sun Jan 17 23:53:21 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 18:49:23 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=97b5409a catalyst: Store references to functions ... rather than their names. This makes it possible for tooling to understand the code structure better. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py| 69 --- catalyst/targets/embedded.py | 34 +-- catalyst/targets/livecd_stage1.py | 18 +- catalyst/targets/livecd_stage2.py | 46 +- catalyst/targets/netboot.py | 34 +-- catalyst/targets/stage1.py| 12 +++ catalyst/targets/stage4.py| 36 ++-- 7 files changed, 125 insertions(+), 124 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index ed4d1227..447e073d 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -30,6 +30,23 @@ from catalyst.fileops import ensure_dirs, clear_dir, clear_path from catalyst.base.resume import AutoResume +def run_sequence(sequence): +for func in sequence: +log.notice('--- Running action sequence: %s', func.__name__) +sys.stdout.flush() +try: +func() +except LockInUse: +log.error('Unable to aquire the lock...') +return False +except Exception: +log.error('Exception running action sequence %s', + func.__name__, exc_info=True) +return False + +return True + + class StageBase(TargetBase, ClearBase, GenBase): """ This class does all of the chroot setup, copying of files, etc. It is @@ -475,39 +492,39 @@ class StageBase(TargetBase, ClearBase, GenBase): Or it calls the normal set_action_sequence() for the target stage. """ if "purgeonly" in self.settings["options"]: -self.build_sequence.append("remove_chroot") +self.build_sequence.append(self.remove_chroot) return self.set_action_sequence() def set_action_sequence(self): """Set basic stage1, 2, 3 action sequences""" self.prepare_sequence.extend([ -"unpack", -"setup_confdir", -"portage_overlay", +self.unpack, +self.setup_confdir, +self.portage_overlay, ]) self.build_sequence.extend([ -"bind", -"chroot_setup", -"setup_environment", -"run_local", -"preclean", +self.bind, +self.chroot_setup, +self.setup_environment, +self.run_local, +self.preclean, ]) self.finish_sequence.extend([ -"clean", +self.clean, ]) self.set_completion_action_sequences() def set_completion_action_sequences(self): if "fetch" not in self.settings["options"]: -self.finish_sequence.append("capture") +self.finish_sequence.append(self.capture) if "keepwork" in self.settings["options"]: -self.finish_sequence.append("clear_autoresume") +self.finish_sequence.append(self.clear_autoresume) elif "seedcache" in self.settings["options"]: -self.finish_sequence.append("remove_autoresume") +self.finish_sequence.append(self.remove_autoresume) else: -self.finish_sequence.append("remove_autoresume") -self.finish_sequence.append("remove_chroot") +self.finish_sequence.append(self.remove_autoresume) +self.finish_sequence.append(self.remove_chroot) def set_use(self): use = self.settings["spec_prefix"] + "/use" @@ -1308,22 +1325,6 @@ class StageBase(TargetBase, ClearBase, GenBase): log.debug('setup_environment(); env = %r', self.env) -def run_sequence(self, sequence): -for func in sequence: -log.notice('--- Running action sequence: %s', func) -sys.stdout.flush() -try: -getattr(self, func)() -except LockInUse: -log.error('Unable to aquire the lock...') -return False -except Exception: -log.error('Exception running action sequence %s', - func, exc_info=True) -return False - -return True - def run(self): self.chroot_lock.write_lock() @@ -1342,14 +1343,14 @@ class StageBase(TargetBase, ClearBase, GenBase): log.info('StageBase: run() purge') self.purge() -if not self.run_sequence(self.prepare_sequence): +if not run_sequence(self.prepare_sequence):
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/targets/, targets/stage1/, doc/, targets/support/
commit: 780c78b0024b8d4c99aa2bb725fe74c151a60279 Author: Matt Turner gentoo org> AuthorDate: Sat Jan 16 16:28:59 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 18:12:39 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=780c78b0 catalyst: Remove update_seed Signed-off-by: Matt Turner gentoo.org> catalyst/targets/stage1.py | 2 -- doc/catalyst-spec.5.txt | 10 - targets/stage1/chroot.sh| 43 +++-- targets/support/chroot-functions.sh | 2 +- 4 files changed, 14 insertions(+), 43 deletions(-) diff --git a/catalyst/targets/stage1.py b/catalyst/targets/stage1.py index 5a154e76..f7c723ee 100644 --- a/catalyst/targets/stage1.py +++ b/catalyst/targets/stage1.py @@ -16,8 +16,6 @@ class stage1(StageBase): required_values = frozenset() valid_values = required_values | frozenset([ "chost", -"update_seed", -"update_seed_command", ]) def __init__(self, spec, addlargs): diff --git a/doc/catalyst-spec.5.txt b/doc/catalyst-spec.5.txt index 4c1df857..47a62709 100644 --- a/doc/catalyst-spec.5.txt +++ b/doc/catalyst-spec.5.txt @@ -116,16 +116,6 @@ releases, we use a default README.txt, and this will be used on your CD if you do not provide one yourself. We do not use this for the official releases. This setting is supported by the livecd targets. -*update_seed*:: -This is an optional setting supported by stage1 to tell catalyst if -it should update the seed stage or not (valid values: `yes no`). - -*update_seed_command*:: -This is an optional command to pass to emerge for updating the seed -stage (example: `--update dev-libs/mpfr dev-libs/mpc dev-libs/gmp`) -If not specified, catalyst will update gcc deps. -This setting requires enabling update_seed. - Compilation ~~~ diff --git a/targets/stage1/chroot.sh b/targets/stage1/chroot.sh index ba6bc387..ec4a3eff 100755 --- a/targets/stage1/chroot.sh +++ b/targets/stage1/chroot.sh @@ -24,37 +24,20 @@ BOOTSTRAP_USE="$(portageq envvar BOOTSTRAP_USE)" FEATURES="${FEATURES} nodoc noman noinfo" -# We need to ensure the base stage3 has USE="bindist" -# if BINDIST is set to avoid issues with openssl / openssh -[ -e ${clst_make_conf} ] && echo "USE=\"${BINDIST} ${USE}\"" >> ${clst_make_conf} - -# Update stage3 -if [ -n "${clst_update_seed}" ]; then - if [ "${clst_update_seed}" == "yes" ]; then - echo "Updating seed stage..." - - ROOT=/ USE=-rsync-verify run_merge --update sys-apps/portage - - if [ -n "${clst_update_seed_command}" ]; then - ROOT=/ run_merge --buildpkg=n "${clst_update_seed_command}" - elif grep -q '^\[changed-subslot\]' /usr/share/portage/config/sets/portage.conf; then - ROOT=/ run_merge --ignore-built-slot-operator-deps y @changed-subslot - else - ROOT=/ run_merge --update --deep --newuse --complete-graph --rebuild-if-new-ver gcc - fi - elif [ "${clst_update_seed}" != "no" ]; then - echo "Invalid setting for update_seed: ${clst_update_seed}" - exit 1 +# Update seed stage +echo "Updating seed stage" +( + # Don't build or use binpkgs when updating the seed stage + clst_PKGCACHE= setup_emerge_opts + + export ROOT=/ + USE=-rsync-verify run_merge --update sys-apps/portage + if grep -q '^\[changed-subslot\]' /usr/share/portage/config/sets/portage.conf; then + run_merge --ignore-built-slot-operator-deps y @changed-subslot + else + run_merge --update --deep --newuse --complete-graph --rebuild-if-new-ver gcc fi - - # reset emerge options for the target - clst_update_seed=no setup_emerge_opts -else - echo "Skipping seed stage update..." -fi - -# Clear USE -[ -e ${clst_make_conf} ] && sed -i -e "/^USE=\"${BINDIST} ${USE}\"/d" ${clst_make_conf} +) export ROOT="${clst_root_path}" mkdir -p "$ROOT" diff --git a/targets/support/chroot-functions.sh b/targets/support/chroot-functions.sh index 88465c31..94d7c938 100755 --- a/targets/support/chroot-functions.sh +++ b/targets/support/chroot-functions.sh @@ -136,7 +136,7 @@ setup_emerge_opts() { emerge_opts+=(--load-average "${clst_load_average}") fi - if [ -n "${clst_PKGCACHE}" ] && [ -z "${clst_update_seed}" -o "${clst_update_seed}" = "no" ] + if [ -n "${clst_PKGCACHE}" ] then emerge_opts+=(--usepkg --buildpkg --binpkg-respect-use=y --newuse) bootstrap_opts+=(-r)
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/targets/
commit: 9ad4ff837c440d92af2c35d1fe085b0fb6250e2d Author: Matt Turner gentoo org> AuthorDate: Mon Jan 18 03:15:02 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 18:01:21 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=9ad4ff83 catalyst: Deduplicate prepare_sequence assignments Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py| 13 ++--- catalyst/targets/embedded.py | 6 -- catalyst/targets/livecd_stage1.py | 6 -- catalyst/targets/livecd_stage2.py | 6 -- catalyst/targets/netboot.py | 6 -- catalyst/targets/stage4.py| 6 -- 6 files changed, 6 insertions(+), 37 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 9d72e765..8107ee7a 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -84,7 +84,12 @@ class StageBase(TargetBase, ClearBase, GenBase): "portage_overlay", "portage_prefix", ]) -self.prepare_sequence = [] +self.prepare_sequence = [ +self.unpack, +self.config_profile_link, +self.setup_confdir, +self.portage_overlay, +] self.build_sequence = [] self.finish_sequence = [] @@ -498,12 +503,6 @@ class StageBase(TargetBase, ClearBase, GenBase): def set_action_sequence(self): """Set basic stage1, 2, 3 action sequences""" -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py index 7d328808..83b17ad2 100644 --- a/catalyst/targets/embedded.py +++ b/catalyst/targets/embedded.py @@ -41,12 +41,6 @@ class embedded(StageBase): StageBase.__init__(self, spec, addlargs) def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py index eb6bb0f0..9fe95a00 100644 --- a/catalyst/targets/livecd_stage1.py +++ b/catalyst/targets/livecd_stage1.py @@ -23,12 +23,6 @@ class livecd_stage1(StageBase): StageBase.__init__(self, spec, addlargs) def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py index 5fecff85..ab8f4a0e 100644 --- a/catalyst/targets/livecd_stage2.py +++ b/catalyst/targets/livecd_stage2.py @@ -86,12 +86,6 @@ class livecd_stage2(StageBase): print_traceback=True) def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py index 9a7e59e5..cb5e7ae4 100644 --- a/catalyst/targets/netboot.py +++ b/catalyst/targets/netboot.py @@ -158,12 +158,6 @@ class netboot(StageBase): self.resume.enable("empty") def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py index 997139a5..9e53f070 100644 --- a/catalyst/targets/stage4.py +++ b/catalyst/targets/stage4.py @@ -39,12 +39,6 @@ class stage4(StageBase): self.settings["cleanables"].remove('/etc/resolv.conf') def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup,
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, doc/, catalyst/
commit: 38bf69c851c337a90afa809b9b828667ccad5380 Author: Matt Turner gentoo org> AuthorDate: Mon Jan 18 16:52:20 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 18:12:39 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=38bf69c8 catalyst: Add option to enter the chroot before building With --enter-chroot, after the mounts and environment are set up, catalyst will drop you into a shell inside the chroot. Useful for hacking or debugging. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 17 - catalyst/main.py | 4 doc/catalyst.1.txt | 3 +++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index dfa4680d..669d8546 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -20,7 +20,7 @@ from catalyst import log from catalyst.context import namespace from catalyst.defaults import (confdefaults, MOUNT_DEFAULTS, PORT_LOGDIR_CLEAN) from catalyst.support import (CatalystError, file_locate, normpath, - cmd, read_makeconf, get_repo_name, ismount, + cmd, command, read_makeconf, get_repo_name, file_check, sanitize_name) from catalyst.base.targetbase import TargetBase from catalyst.base.clearbase import ClearBase @@ -94,6 +94,7 @@ class StageBase(TargetBase, ClearBase, GenBase): self.bind, self.chroot_setup, self.setup_environment, +self.enter_chroot, ] self.finish_sequence = [] @@ -1326,6 +1327,20 @@ class StageBase(TargetBase, ClearBase, GenBase): log.debug('setup_environment(); env = %r', self.env) +def enter_chroot(self): +if 'enter-chroot' not in self.settings['options']: +return + +chroot = command('chroot') +bash = command('bash') + +log.notice("Entering chroot") +try: +cmd([chroot, self.settings['chroot_path'], bash, '-l'], +env=self.env) +except CatalystError: +pass + def run(self): self.chroot_lock.write_lock() diff --git a/catalyst/main.py b/catalyst/main.py index 48daf004..b0d9015f 100644 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -120,6 +120,8 @@ def get_parser(): parser.add_argument('-V', '--version', action='version', version=get_version(), help='display version information') +parser.add_argument('--enter-chroot', default=False, action='store_true', +help='Enter chroot before starting the build') group = parser.add_argument_group('Program output options') group.add_argument('-d', '--debug', @@ -293,6 +295,8 @@ def _main(parser, opts): options.append('purgetmponly') if opts.clear_autoresume: options.append('clear-autoresume') +if opts.enter_chroot: +options.append('enter-chroot') # Make sure we have some work before moving further. if not myspecfile and not mycmdline: diff --git a/doc/catalyst.1.txt b/doc/catalyst.1.txt index 90d5a24b..217fc86a 100644 --- a/doc/catalyst.1.txt +++ b/doc/catalyst.1.txt @@ -39,6 +39,9 @@ configuration file is installed at '/etc/catalyst/catalyst.conf'. *-d*:: Enable debugging mode +*--enter-chroot*:: +Enter the chroot before starting the build. + *--fetchonly*:: *-F*:: This tells *catalyst* to only fetch distfiles for the given packages without
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/targets/
commit: 9e6046dd34b6f225d544713ffabe36574cd17143 Author: Matt Turner gentoo org> AuthorDate: Mon Jan 18 03:20:41 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 18:01:21 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=9e6046dd catalyst: Deduplicate the common build_sequence steps This also provides a single location to add a function to all targets' build_sequence. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py| 11 ++- catalyst/targets/embedded.py | 3 --- catalyst/targets/livecd_stage1.py | 3 --- catalyst/targets/livecd_stage2.py | 3 --- catalyst/targets/netboot.py | 3 --- catalyst/targets/stage4.py| 3 --- 6 files changed, 6 insertions(+), 20 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 8107ee7a..dfa4680d 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -90,7 +90,11 @@ class StageBase(TargetBase, ClearBase, GenBase): self.setup_confdir, self.portage_overlay, ] -self.build_sequence = [] +self.build_sequence = [ +self.bind, +self.chroot_setup, +self.setup_environment, +] self.finish_sequence = [] self.set_valid_build_kernel_vars(addlargs) @@ -497,16 +501,13 @@ class StageBase(TargetBase, ClearBase, GenBase): Or it calls the normal set_action_sequence() for the target stage. """ if "purgeonly" in self.settings["options"]: -self.build_sequence.append(self.remove_chroot) +self.build_sequence = [self.remove_chroot] return self.set_action_sequence() def set_action_sequence(self): """Set basic stage1, 2, 3 action sequences""" self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.run_local, self.preclean, ]) diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py index 83b17ad2..b677b226 100644 --- a/catalyst/targets/embedded.py +++ b/catalyst/targets/embedded.py @@ -42,9 +42,6 @@ class embedded(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.build_kernel, self.build_packages, self.root_overlay, diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py index 9fe95a00..dbfa54ed 100644 --- a/catalyst/targets/livecd_stage1.py +++ b/catalyst/targets/livecd_stage1.py @@ -24,9 +24,6 @@ class livecd_stage1(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.build_packages, ]) self.finish_sequence.extend([ diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py index ab8f4a0e..e90e9f53 100644 --- a/catalyst/targets/livecd_stage2.py +++ b/catalyst/targets/livecd_stage2.py @@ -87,9 +87,6 @@ class livecd_stage2(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.run_local, self.build_kernel ]) diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py index cb5e7ae4..a2a9fcb3 100644 --- a/catalyst/targets/netboot.py +++ b/catalyst/targets/netboot.py @@ -159,9 +159,6 @@ class netboot(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.build_packages, self.root_overlay, self.copy_files_to_image, diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py index 9e53f070..f8383f75 100644 --- a/catalyst/targets/stage4.py +++ b/catalyst/targets/stage4.py @@ -40,9 +40,6 @@ class stage4(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.build_packages, self.build_kernel, self.bootloader,
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, targets/support/
commit: adce739a1d4e1c4f5321a705f526ae4759844565 Author: Matt Turner gentoo org> AuthorDate: Mon Jan 18 03:09:30 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 18:01:21 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=adce739a catalyst: Call config_profile_link for all targets This reverts the following two commits, which have no documented rationale. Revert "Set the profile by calling eselect." This reverts commit 90c03f9dc255ba89849e46490f9ead7ab3921950. Revert "Drop config_profile_link from the action_sequence for the generic stage." This reverts commit 3bd10159bf7cfe14b6d8a8218b94eca73be4c997. Doing so improves the code in two ways: 1) it makes prepare_sequence identical across all targets, which will allow deduplicating some code 2) it no longer calls eselect profile each time chroot-functions.sh is sourced (even for those targets that were still calling config_profile_link) Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 1 + targets/support/chroot-functions.sh | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 447e073d..9d72e765 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -500,6 +500,7 @@ class StageBase(TargetBase, ClearBase, GenBase): """Set basic stage1, 2, 3 action sequences""" self.prepare_sequence.extend([ self.unpack, +self.config_profile_link, self.setup_confdir, self.portage_overlay, ]) diff --git a/targets/support/chroot-functions.sh b/targets/support/chroot-functions.sh index 2aec018e..88465c31 100755 --- a/targets/support/chroot-functions.sh +++ b/targets/support/chroot-functions.sh @@ -1,8 +1,5 @@ #!/bin/bash -# Set the profile -eselect profile set ${clst_target_profile} - # Trap these signals and kill ourselves if received # Force ourselves to die if any of these signals are received # most likely our controlling terminal is gone
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/targets/, catalyst/base/
commit: 501529d9d464406db34f10e642ae7b375ccbbe3a Author: Matt Turner gentoo org> AuthorDate: Sun Jan 17 23:53:21 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 18:01:21 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=501529d9 catalyst: Store references to functions ... rather than their names. This makes it possible for tooling to understand the code structure better. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py| 69 --- catalyst/targets/embedded.py | 34 +-- catalyst/targets/livecd_stage1.py | 18 +- catalyst/targets/livecd_stage2.py | 46 +- catalyst/targets/netboot.py | 34 +-- catalyst/targets/stage1.py| 12 +++ catalyst/targets/stage4.py| 36 ++-- 7 files changed, 125 insertions(+), 124 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index ed4d1227..447e073d 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -30,6 +30,23 @@ from catalyst.fileops import ensure_dirs, clear_dir, clear_path from catalyst.base.resume import AutoResume +def run_sequence(sequence): +for func in sequence: +log.notice('--- Running action sequence: %s', func.__name__) +sys.stdout.flush() +try: +func() +except LockInUse: +log.error('Unable to aquire the lock...') +return False +except Exception: +log.error('Exception running action sequence %s', + func.__name__, exc_info=True) +return False + +return True + + class StageBase(TargetBase, ClearBase, GenBase): """ This class does all of the chroot setup, copying of files, etc. It is @@ -475,39 +492,39 @@ class StageBase(TargetBase, ClearBase, GenBase): Or it calls the normal set_action_sequence() for the target stage. """ if "purgeonly" in self.settings["options"]: -self.build_sequence.append("remove_chroot") +self.build_sequence.append(self.remove_chroot) return self.set_action_sequence() def set_action_sequence(self): """Set basic stage1, 2, 3 action sequences""" self.prepare_sequence.extend([ -"unpack", -"setup_confdir", -"portage_overlay", +self.unpack, +self.setup_confdir, +self.portage_overlay, ]) self.build_sequence.extend([ -"bind", -"chroot_setup", -"setup_environment", -"run_local", -"preclean", +self.bind, +self.chroot_setup, +self.setup_environment, +self.run_local, +self.preclean, ]) self.finish_sequence.extend([ -"clean", +self.clean, ]) self.set_completion_action_sequences() def set_completion_action_sequences(self): if "fetch" not in self.settings["options"]: -self.finish_sequence.append("capture") +self.finish_sequence.append(self.capture) if "keepwork" in self.settings["options"]: -self.finish_sequence.append("clear_autoresume") +self.finish_sequence.append(self.clear_autoresume) elif "seedcache" in self.settings["options"]: -self.finish_sequence.append("remove_autoresume") +self.finish_sequence.append(self.remove_autoresume) else: -self.finish_sequence.append("remove_autoresume") -self.finish_sequence.append("remove_chroot") +self.finish_sequence.append(self.remove_autoresume) +self.finish_sequence.append(self.remove_chroot) def set_use(self): use = self.settings["spec_prefix"] + "/use" @@ -1308,22 +1325,6 @@ class StageBase(TargetBase, ClearBase, GenBase): log.debug('setup_environment(); env = %r', self.env) -def run_sequence(self, sequence): -for func in sequence: -log.notice('--- Running action sequence: %s', func) -sys.stdout.flush() -try: -getattr(self, func)() -except LockInUse: -log.error('Unable to aquire the lock...') -return False -except Exception: -log.error('Exception running action sequence %s', - func, exc_info=True) -return False - -return True - def run(self): self.chroot_lock.write_lock() @@ -1342,14 +1343,14 @@ class StageBase(TargetBase, ClearBase, GenBase): log.info('StageBase: run() purge') self.purge() -if not self.run_sequence(self.prepare_sequence): +if not run_sequence(self.prepare_sequence):
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/, doc/
commit: 05b6159516be7915e49399215c94cec7b76cc7db Author: Matt Turner gentoo org> AuthorDate: Mon Jan 18 16:52:20 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 17:08:05 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=05b61595 catalyst: Add option to enter the chroot before building Can be very useful for hacking or debugging. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 14 +- catalyst/main.py | 4 doc/catalyst.1.txt | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index dfa4680d..8b8e47d1 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -20,7 +20,7 @@ from catalyst import log from catalyst.context import namespace from catalyst.defaults import (confdefaults, MOUNT_DEFAULTS, PORT_LOGDIR_CLEAN) from catalyst.support import (CatalystError, file_locate, normpath, - cmd, read_makeconf, get_repo_name, ismount, + cmd, command, read_makeconf, get_repo_name, file_check, sanitize_name) from catalyst.base.targetbase import TargetBase from catalyst.base.clearbase import ClearBase @@ -94,6 +94,7 @@ class StageBase(TargetBase, ClearBase, GenBase): self.bind, self.chroot_setup, self.setup_environment, +self.enter_chroot, ] self.finish_sequence = [] @@ -1326,6 +1327,17 @@ class StageBase(TargetBase, ClearBase, GenBase): log.debug('setup_environment(); env = %r', self.env) +def enter_chroot(self): +if 'enter-chroot' not in self.settings['options']: +return + +chroot = command('chroot') +bash = command('bash') + +log.notice("Entering chroot") +cmd([chroot, self.settings['chroot_path'], bash, '-l'], +env=self.env) + def run(self): self.chroot_lock.write_lock() diff --git a/catalyst/main.py b/catalyst/main.py index 48daf004..b0d9015f 100644 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -120,6 +120,8 @@ def get_parser(): parser.add_argument('-V', '--version', action='version', version=get_version(), help='display version information') +parser.add_argument('--enter-chroot', default=False, action='store_true', +help='Enter chroot before starting the build') group = parser.add_argument_group('Program output options') group.add_argument('-d', '--debug', @@ -293,6 +295,8 @@ def _main(parser, opts): options.append('purgetmponly') if opts.clear_autoresume: options.append('clear-autoresume') +if opts.enter_chroot: +options.append('enter-chroot') # Make sure we have some work before moving further. if not myspecfile and not mycmdline: diff --git a/doc/catalyst.1.txt b/doc/catalyst.1.txt index 90d5a24b..217fc86a 100644 --- a/doc/catalyst.1.txt +++ b/doc/catalyst.1.txt @@ -39,6 +39,9 @@ configuration file is installed at '/etc/catalyst/catalyst.conf'. *-d*:: Enable debugging mode +*--enter-chroot*:: +Enter the chroot before starting the build. + *--fetchonly*:: *-F*:: This tells *catalyst* to only fetch distfiles for the given packages without
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/targets/, catalyst/base/
commit: 0032844ca26e108e69026fa284dabcd969471da1 Author: Matt Turner gentoo org> AuthorDate: Mon Jan 18 03:15:02 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 17:05:45 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=0032844c catalyst: Deduplicate prepare_sequence assignments Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py| 13 ++--- catalyst/targets/embedded.py | 6 -- catalyst/targets/livecd_stage1.py | 6 -- catalyst/targets/livecd_stage2.py | 6 -- catalyst/targets/netboot.py | 6 -- catalyst/targets/stage4.py| 6 -- 6 files changed, 6 insertions(+), 37 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 9d72e765..8107ee7a 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -84,7 +84,12 @@ class StageBase(TargetBase, ClearBase, GenBase): "portage_overlay", "portage_prefix", ]) -self.prepare_sequence = [] +self.prepare_sequence = [ +self.unpack, +self.config_profile_link, +self.setup_confdir, +self.portage_overlay, +] self.build_sequence = [] self.finish_sequence = [] @@ -498,12 +503,6 @@ class StageBase(TargetBase, ClearBase, GenBase): def set_action_sequence(self): """Set basic stage1, 2, 3 action sequences""" -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py index 7d328808..83b17ad2 100644 --- a/catalyst/targets/embedded.py +++ b/catalyst/targets/embedded.py @@ -41,12 +41,6 @@ class embedded(StageBase): StageBase.__init__(self, spec, addlargs) def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py index eb6bb0f0..9fe95a00 100644 --- a/catalyst/targets/livecd_stage1.py +++ b/catalyst/targets/livecd_stage1.py @@ -23,12 +23,6 @@ class livecd_stage1(StageBase): StageBase.__init__(self, spec, addlargs) def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py index 5fecff85..ab8f4a0e 100644 --- a/catalyst/targets/livecd_stage2.py +++ b/catalyst/targets/livecd_stage2.py @@ -86,12 +86,6 @@ class livecd_stage2(StageBase): print_traceback=True) def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py index 9a7e59e5..cb5e7ae4 100644 --- a/catalyst/targets/netboot.py +++ b/catalyst/targets/netboot.py @@ -158,12 +158,6 @@ class netboot(StageBase): self.resume.enable("empty") def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py index 997139a5..9e53f070 100644 --- a/catalyst/targets/stage4.py +++ b/catalyst/targets/stage4.py @@ -39,12 +39,6 @@ class stage4(StageBase): self.settings["cleanables"].remove('/etc/resolv.conf') def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup,
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, targets/support/
commit: e1a706383378a1ed71ea4d4300dfc04b42479390 Author: Matt Turner gentoo org> AuthorDate: Mon Jan 18 03:09:30 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 17:05:45 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=e1a70638 catalyst: Call config_profile_link for all targets This reverts the following two commits, which have no documented rationale. Revert "Set the profile by calling eselect." This reverts commit 90c03f9dc255ba89849e46490f9ead7ab3921950. Revert "Drop config_profile_link from the action_sequence for the generic stage." This reverts commit 3bd10159bf7cfe14b6d8a8218b94eca73be4c997. Doing so improves the code in two ways: 1) it makes prepare_sequence identical across all targets, which will allow me to deduplicate some code 2) it no longer calls eselect profile each time chroot-functions.sh is sourced (even for those targets that were still calling config_profile_link) Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 1 + targets/support/chroot-functions.sh | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 447e073d..9d72e765 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -500,6 +500,7 @@ class StageBase(TargetBase, ClearBase, GenBase): """Set basic stage1, 2, 3 action sequences""" self.prepare_sequence.extend([ self.unpack, +self.config_profile_link, self.setup_confdir, self.portage_overlay, ]) diff --git a/targets/support/chroot-functions.sh b/targets/support/chroot-functions.sh index 2aec018e..88465c31 100755 --- a/targets/support/chroot-functions.sh +++ b/targets/support/chroot-functions.sh @@ -1,8 +1,5 @@ #!/bin/bash -# Set the profile -eselect profile set ${clst_target_profile} - # Trap these signals and kill ourselves if received # Force ourselves to die if any of these signals are received # most likely our controlling terminal is gone
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/targets/, catalyst/base/
commit: 8140e9a1978e9dd9f4f6320f0c3b3f77240940db Author: Matt Turner gentoo org> AuthorDate: Mon Jan 18 03:20:41 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 17:05:45 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=8140e9a1 catalyst: Deduplicate the common build_sequence steps This will also provide a nice spot to add a function to all targets' build_sequence. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py| 11 ++- catalyst/targets/embedded.py | 3 --- catalyst/targets/livecd_stage1.py | 3 --- catalyst/targets/livecd_stage2.py | 3 --- catalyst/targets/netboot.py | 3 --- catalyst/targets/stage4.py| 3 --- 6 files changed, 6 insertions(+), 20 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 8107ee7a..dfa4680d 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -90,7 +90,11 @@ class StageBase(TargetBase, ClearBase, GenBase): self.setup_confdir, self.portage_overlay, ] -self.build_sequence = [] +self.build_sequence = [ +self.bind, +self.chroot_setup, +self.setup_environment, +] self.finish_sequence = [] self.set_valid_build_kernel_vars(addlargs) @@ -497,16 +501,13 @@ class StageBase(TargetBase, ClearBase, GenBase): Or it calls the normal set_action_sequence() for the target stage. """ if "purgeonly" in self.settings["options"]: -self.build_sequence.append(self.remove_chroot) +self.build_sequence = [self.remove_chroot] return self.set_action_sequence() def set_action_sequence(self): """Set basic stage1, 2, 3 action sequences""" self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.run_local, self.preclean, ]) diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py index 83b17ad2..b677b226 100644 --- a/catalyst/targets/embedded.py +++ b/catalyst/targets/embedded.py @@ -42,9 +42,6 @@ class embedded(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.build_kernel, self.build_packages, self.root_overlay, diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py index 9fe95a00..dbfa54ed 100644 --- a/catalyst/targets/livecd_stage1.py +++ b/catalyst/targets/livecd_stage1.py @@ -24,9 +24,6 @@ class livecd_stage1(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.build_packages, ]) self.finish_sequence.extend([ diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py index ab8f4a0e..e90e9f53 100644 --- a/catalyst/targets/livecd_stage2.py +++ b/catalyst/targets/livecd_stage2.py @@ -87,9 +87,6 @@ class livecd_stage2(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.run_local, self.build_kernel ]) diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py index cb5e7ae4..a2a9fcb3 100644 --- a/catalyst/targets/netboot.py +++ b/catalyst/targets/netboot.py @@ -159,9 +159,6 @@ class netboot(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.build_packages, self.root_overlay, self.copy_files_to_image, diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py index 9e53f070..f8383f75 100644 --- a/catalyst/targets/stage4.py +++ b/catalyst/targets/stage4.py @@ -40,9 +40,6 @@ class stage4(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.build_packages, self.build_kernel, self.bootloader,
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/targets/
commit: 3bb5ead36cb748af2de00d2c526ac7af2128cc22 Author: Matt Turner gentoo org> AuthorDate: Sun Jan 17 23:53:21 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 17:05:43 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=3bb5ead3 catalyst: Store references to functions ... rather than their names. This makes it possible for tooling to understand the code structure better. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py| 69 --- catalyst/targets/embedded.py | 34 +-- catalyst/targets/livecd_stage1.py | 18 +- catalyst/targets/livecd_stage2.py | 46 +- catalyst/targets/netboot.py | 34 +-- catalyst/targets/stage1.py| 12 +++ catalyst/targets/stage4.py| 36 ++-- 7 files changed, 125 insertions(+), 124 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index ed4d1227..447e073d 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -30,6 +30,23 @@ from catalyst.fileops import ensure_dirs, clear_dir, clear_path from catalyst.base.resume import AutoResume +def run_sequence(sequence): +for func in sequence: +log.notice('--- Running action sequence: %s', func.__name__) +sys.stdout.flush() +try: +func() +except LockInUse: +log.error('Unable to aquire the lock...') +return False +except Exception: +log.error('Exception running action sequence %s', + func.__name__, exc_info=True) +return False + +return True + + class StageBase(TargetBase, ClearBase, GenBase): """ This class does all of the chroot setup, copying of files, etc. It is @@ -475,39 +492,39 @@ class StageBase(TargetBase, ClearBase, GenBase): Or it calls the normal set_action_sequence() for the target stage. """ if "purgeonly" in self.settings["options"]: -self.build_sequence.append("remove_chroot") +self.build_sequence.append(self.remove_chroot) return self.set_action_sequence() def set_action_sequence(self): """Set basic stage1, 2, 3 action sequences""" self.prepare_sequence.extend([ -"unpack", -"setup_confdir", -"portage_overlay", +self.unpack, +self.setup_confdir, +self.portage_overlay, ]) self.build_sequence.extend([ -"bind", -"chroot_setup", -"setup_environment", -"run_local", -"preclean", +self.bind, +self.chroot_setup, +self.setup_environment, +self.run_local, +self.preclean, ]) self.finish_sequence.extend([ -"clean", +self.clean, ]) self.set_completion_action_sequences() def set_completion_action_sequences(self): if "fetch" not in self.settings["options"]: -self.finish_sequence.append("capture") +self.finish_sequence.append(self.capture) if "keepwork" in self.settings["options"]: -self.finish_sequence.append("clear_autoresume") +self.finish_sequence.append(self.clear_autoresume) elif "seedcache" in self.settings["options"]: -self.finish_sequence.append("remove_autoresume") +self.finish_sequence.append(self.remove_autoresume) else: -self.finish_sequence.append("remove_autoresume") -self.finish_sequence.append("remove_chroot") +self.finish_sequence.append(self.remove_autoresume) +self.finish_sequence.append(self.remove_chroot) def set_use(self): use = self.settings["spec_prefix"] + "/use" @@ -1308,22 +1325,6 @@ class StageBase(TargetBase, ClearBase, GenBase): log.debug('setup_environment(); env = %r', self.env) -def run_sequence(self, sequence): -for func in sequence: -log.notice('--- Running action sequence: %s', func) -sys.stdout.flush() -try: -getattr(self, func)() -except LockInUse: -log.error('Unable to aquire the lock...') -return False -except Exception: -log.error('Exception running action sequence %s', - func, exc_info=True) -return False - -return True - def run(self): self.chroot_lock.write_lock() @@ -1342,14 +1343,14 @@ class StageBase(TargetBase, ClearBase, GenBase): log.info('StageBase: run() purge') self.purge() -if not self.run_sequence(self.prepare_sequence): +if not run_sequence(self.prepare_sequence):
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/targets/, catalyst/base/
commit: 7759f50249609f810139eeaad019bc62af10596b Author: Matt Turner gentoo org> AuthorDate: Sun Jan 17 23:53:21 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 16:55:29 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=7759f502 catalyst: Store references to functions ... rather than their names. This makes it possible for tooling to understand the code structure better. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py| 45 +++--- catalyst/targets/embedded.py | 34 ++--- catalyst/targets/livecd_stage1.py | 18 +++ catalyst/targets/livecd_stage2.py | 46 +++ catalyst/targets/netboot.py | 34 ++--- catalyst/targets/stage1.py| 12 +- catalyst/targets/stage4.py| 36 +++--- 7 files changed, 113 insertions(+), 112 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index ed4d1227..0e742acb 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -475,39 +475,39 @@ class StageBase(TargetBase, ClearBase, GenBase): Or it calls the normal set_action_sequence() for the target stage. """ if "purgeonly" in self.settings["options"]: -self.build_sequence.append("remove_chroot") +self.build_sequence.append(self.remove_chroot) return self.set_action_sequence() def set_action_sequence(self): """Set basic stage1, 2, 3 action sequences""" self.prepare_sequence.extend([ -"unpack", -"setup_confdir", -"portage_overlay", +self.unpack, +self.setup_confdir, +self.portage_overlay, ]) self.build_sequence.extend([ -"bind", -"chroot_setup", -"setup_environment", -"run_local", -"preclean", +self.bind, +self.chroot_setup, +self.setup_environment, +self.run_local, +self.preclean, ]) self.finish_sequence.extend([ -"clean", +self.clean, ]) self.set_completion_action_sequences() def set_completion_action_sequences(self): if "fetch" not in self.settings["options"]: -self.finish_sequence.append("capture") +self.finish_sequence.append(self.capture) if "keepwork" in self.settings["options"]: -self.finish_sequence.append("clear_autoresume") +self.finish_sequence.append(self.clear_autoresume) elif "seedcache" in self.settings["options"]: -self.finish_sequence.append("remove_autoresume") +self.finish_sequence.append(self.remove_autoresume) else: -self.finish_sequence.append("remove_autoresume") -self.finish_sequence.append("remove_chroot") +self.finish_sequence.append(self.remove_autoresume) +self.finish_sequence.append(self.remove_chroot) def set_use(self): use = self.settings["spec_prefix"] + "/use" @@ -1308,18 +1308,19 @@ class StageBase(TargetBase, ClearBase, GenBase): log.debug('setup_environment(); env = %r', self.env) -def run_sequence(self, sequence): +@staticmethod +def run_sequence(sequence): for func in sequence: -log.notice('--- Running action sequence: %s', func) +log.notice('--- Running action sequence: %s', func.__name__) sys.stdout.flush() try: -getattr(self, func)() +func() except LockInUse: log.error('Unable to aquire the lock...') return False except Exception: log.error('Exception running action sequence %s', - func, exc_info=True) + func.__name__, exc_info=True) return False return True @@ -1342,14 +1343,14 @@ class StageBase(TargetBase, ClearBase, GenBase): log.info('StageBase: run() purge') self.purge() -if not self.run_sequence(self.prepare_sequence): +if not run_sequence(self.prepare_sequence): return False with namespace(mount=True): -if not self.run_sequence(self.build_sequence): +if not run_sequence(self.build_sequence): return False -if not self.run_sequence(self.finish_sequence): +if not run_sequence(self.finish_sequence): return False return True diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py index 918b36bf..7d328808 100644 --- a/catalyst/targets/embedded.py +++ b/catalyst/targets/embedded.py @@ -42,27 +42,27 @@ class
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/targets/, catalyst/base/
commit: 1097e58226fe485d172661b43d579fd9babcb900 Author: Matt Turner gentoo org> AuthorDate: Mon Jan 18 03:20:41 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 16:55:29 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=1097e582 catalyst: Deduplicate the common build_sequence steps This will also provide a nice spot to add a function to all targets' build_sequence. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py| 11 ++- catalyst/targets/embedded.py | 3 --- catalyst/targets/livecd_stage1.py | 3 --- catalyst/targets/livecd_stage2.py | 3 --- catalyst/targets/netboot.py | 3 --- catalyst/targets/stage4.py| 3 --- 6 files changed, 6 insertions(+), 20 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 85eb1f6d..a3100723 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -73,7 +73,11 @@ class StageBase(TargetBase, ClearBase, GenBase): self.setup_confdir, self.portage_overlay, ] -self.build_sequence = [] +self.build_sequence = [ +self.bind, +self.chroot_setup, +self.setup_environment, +] self.finish_sequence = [] self.set_valid_build_kernel_vars(addlargs) @@ -480,16 +484,13 @@ class StageBase(TargetBase, ClearBase, GenBase): Or it calls the normal set_action_sequence() for the target stage. """ if "purgeonly" in self.settings["options"]: -self.build_sequence.append(self.remove_chroot) +self.build_sequence = [self.remove_chroot] return self.set_action_sequence() def set_action_sequence(self): """Set basic stage1, 2, 3 action sequences""" self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.run_local, self.preclean, ]) diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py index 83b17ad2..b677b226 100644 --- a/catalyst/targets/embedded.py +++ b/catalyst/targets/embedded.py @@ -42,9 +42,6 @@ class embedded(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.build_kernel, self.build_packages, self.root_overlay, diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py index 9fe95a00..dbfa54ed 100644 --- a/catalyst/targets/livecd_stage1.py +++ b/catalyst/targets/livecd_stage1.py @@ -24,9 +24,6 @@ class livecd_stage1(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.build_packages, ]) self.finish_sequence.extend([ diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py index ab8f4a0e..e90e9f53 100644 --- a/catalyst/targets/livecd_stage2.py +++ b/catalyst/targets/livecd_stage2.py @@ -87,9 +87,6 @@ class livecd_stage2(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.run_local, self.build_kernel ]) diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py index cb5e7ae4..a2a9fcb3 100644 --- a/catalyst/targets/netboot.py +++ b/catalyst/targets/netboot.py @@ -159,9 +159,6 @@ class netboot(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.build_packages, self.root_overlay, self.copy_files_to_image, diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py index 9e53f070..f8383f75 100644 --- a/catalyst/targets/stage4.py +++ b/catalyst/targets/stage4.py @@ -40,9 +40,6 @@ class stage4(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.build_packages, self.build_kernel, self.bootloader,
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, targets/support/
commit: 6e494c8d99072a6a6cb5feeafe893510147e51c1 Author: Matt Turner gentoo org> AuthorDate: Mon Jan 18 03:09:30 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 16:55:29 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=6e494c8d catalyst: Call config_profile_link for all targets This reverts the following two commits, which have no documented rationale. Revert "Set the profile by calling eselect." This reverts commit 90c03f9dc255ba89849e46490f9ead7ab3921950. Revert "Drop config_profile_link from the action_sequence for the generic stage." This reverts commit 3bd10159bf7cfe14b6d8a8218b94eca73be4c997. Doing so improves the code in two ways: 1) it makes prepare_sequence identical across all targets, which will allow me to deduplicate some code 2) it no longer calls eselect profile each time chroot-functions.sh is sourced (even for those targets that were still calling config_profile_link) Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 1 + targets/support/chroot-functions.sh | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 0e742acb..bccba11c 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -483,6 +483,7 @@ class StageBase(TargetBase, ClearBase, GenBase): """Set basic stage1, 2, 3 action sequences""" self.prepare_sequence.extend([ self.unpack, +self.config_profile_link, self.setup_confdir, self.portage_overlay, ]) diff --git a/targets/support/chroot-functions.sh b/targets/support/chroot-functions.sh index 2aec018e..88465c31 100755 --- a/targets/support/chroot-functions.sh +++ b/targets/support/chroot-functions.sh @@ -1,8 +1,5 @@ #!/bin/bash -# Set the profile -eselect profile set ${clst_target_profile} - # Trap these signals and kill ourselves if received # Force ourselves to die if any of these signals are received # most likely our controlling terminal is gone
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/targets/
commit: 402ac4495d25cbb91f9f81de8150e03428c94ae6 Author: Matt Turner gentoo org> AuthorDate: Mon Jan 18 03:15:02 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 16:55:29 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=402ac449 catalyst: Deduplicate prepare_sequence assignments Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py| 13 ++--- catalyst/targets/embedded.py | 6 -- catalyst/targets/livecd_stage1.py | 6 -- catalyst/targets/livecd_stage2.py | 6 -- catalyst/targets/netboot.py | 6 -- catalyst/targets/stage4.py| 6 -- 6 files changed, 6 insertions(+), 37 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index bccba11c..85eb1f6d 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -67,7 +67,12 @@ class StageBase(TargetBase, ClearBase, GenBase): "portage_overlay", "portage_prefix", ]) -self.prepare_sequence = [] +self.prepare_sequence = [ +self.unpack, +self.config_profile_link, +self.setup_confdir, +self.portage_overlay, +] self.build_sequence = [] self.finish_sequence = [] @@ -481,12 +486,6 @@ class StageBase(TargetBase, ClearBase, GenBase): def set_action_sequence(self): """Set basic stage1, 2, 3 action sequences""" -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py index 7d328808..83b17ad2 100644 --- a/catalyst/targets/embedded.py +++ b/catalyst/targets/embedded.py @@ -41,12 +41,6 @@ class embedded(StageBase): StageBase.__init__(self, spec, addlargs) def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py index eb6bb0f0..9fe95a00 100644 --- a/catalyst/targets/livecd_stage1.py +++ b/catalyst/targets/livecd_stage1.py @@ -23,12 +23,6 @@ class livecd_stage1(StageBase): StageBase.__init__(self, spec, addlargs) def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py index 5fecff85..ab8f4a0e 100644 --- a/catalyst/targets/livecd_stage2.py +++ b/catalyst/targets/livecd_stage2.py @@ -86,12 +86,6 @@ class livecd_stage2(StageBase): print_traceback=True) def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py index 9a7e59e5..cb5e7ae4 100644 --- a/catalyst/targets/netboot.py +++ b/catalyst/targets/netboot.py @@ -158,12 +158,6 @@ class netboot(StageBase): self.resume.enable("empty") def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py index 997139a5..9e53f070 100644 --- a/catalyst/targets/stage4.py +++ b/catalyst/targets/stage4.py @@ -39,12 +39,6 @@ class stage4(StageBase): self.settings["cleanables"].remove('/etc/resolv.conf') def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup,
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/targets/, catalyst/base/
commit: 4f90499b7b8adf0da6cee086ea8baffd40b167d7 Author: Matt Turner gentoo org> AuthorDate: Mon Jan 18 03:15:02 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 03:49:48 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=4f90499b catalyst: Deduplicate prepare_sequence assignments Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py| 13 ++--- catalyst/targets/embedded.py | 6 -- catalyst/targets/livecd_stage1.py | 6 -- catalyst/targets/livecd_stage2.py | 6 -- catalyst/targets/netboot.py | 6 -- catalyst/targets/stage4.py| 6 -- 6 files changed, 6 insertions(+), 37 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 753f378e..fa9f1f64 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -67,7 +67,12 @@ class StageBase(TargetBase, ClearBase, GenBase): "portage_overlay", "portage_prefix", ]) -self.prepare_sequence = [] +self.prepare_sequence = [ +self.unpack, +self.config_profile_link, +self.setup_confdir, +self.portage_overlay, +] self.build_sequence = [] self.finish_sequence = [] @@ -481,12 +486,6 @@ class StageBase(TargetBase, ClearBase, GenBase): def set_action_sequence(self): """Set basic stage1, 2, 3 action sequences""" -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py index 7d328808..83b17ad2 100644 --- a/catalyst/targets/embedded.py +++ b/catalyst/targets/embedded.py @@ -41,12 +41,6 @@ class embedded(StageBase): StageBase.__init__(self, spec, addlargs) def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py index eb6bb0f0..9fe95a00 100644 --- a/catalyst/targets/livecd_stage1.py +++ b/catalyst/targets/livecd_stage1.py @@ -23,12 +23,6 @@ class livecd_stage1(StageBase): StageBase.__init__(self, spec, addlargs) def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py index 5fecff85..ab8f4a0e 100644 --- a/catalyst/targets/livecd_stage2.py +++ b/catalyst/targets/livecd_stage2.py @@ -86,12 +86,6 @@ class livecd_stage2(StageBase): print_traceback=True) def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py index 9a7e59e5..cb5e7ae4 100644 --- a/catalyst/targets/netboot.py +++ b/catalyst/targets/netboot.py @@ -158,12 +158,6 @@ class netboot(StageBase): self.resume.enable("empty") def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py index 997139a5..9e53f070 100644 --- a/catalyst/targets/stage4.py +++ b/catalyst/targets/stage4.py @@ -39,12 +39,6 @@ class stage4(StageBase): self.settings["cleanables"].remove('/etc/resolv.conf') def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup,
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/targets/
commit: a5f2e195d83f815e303f7bae3f0bb3591369d944 Author: Matt Turner gentoo org> AuthorDate: Sun Jan 17 23:53:21 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 03:49:48 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=a5f2e195 catalyst: Store references to functions ... rather than their names. This makes it possible for tooling to understand the code structure better. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py| 41 +- catalyst/targets/embedded.py | 34 ++--- catalyst/targets/livecd_stage1.py | 18 +++ catalyst/targets/livecd_stage2.py | 46 +++ catalyst/targets/netboot.py | 34 ++--- catalyst/targets/stage1.py| 12 +- catalyst/targets/stage4.py| 36 +++--- 7 files changed, 111 insertions(+), 110 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index ed4d1227..ae13e35f 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -475,39 +475,39 @@ class StageBase(TargetBase, ClearBase, GenBase): Or it calls the normal set_action_sequence() for the target stage. """ if "purgeonly" in self.settings["options"]: -self.build_sequence.append("remove_chroot") +self.build_sequence.append(self.remove_chroot) return self.set_action_sequence() def set_action_sequence(self): """Set basic stage1, 2, 3 action sequences""" self.prepare_sequence.extend([ -"unpack", -"setup_confdir", -"portage_overlay", +self.unpack, +self.setup_confdir, +self.portage_overlay, ]) self.build_sequence.extend([ -"bind", -"chroot_setup", -"setup_environment", -"run_local", -"preclean", +self.bind, +self.chroot_setup, +self.setup_environment, +self.run_local, +self.preclean, ]) self.finish_sequence.extend([ -"clean", +self.clean, ]) self.set_completion_action_sequences() def set_completion_action_sequences(self): if "fetch" not in self.settings["options"]: -self.finish_sequence.append("capture") +self.finish_sequence.append(self.capture) if "keepwork" in self.settings["options"]: -self.finish_sequence.append("clear_autoresume") +self.finish_sequence.append(self.clear_autoresume) elif "seedcache" in self.settings["options"]: -self.finish_sequence.append("remove_autoresume") +self.finish_sequence.append(self.remove_autoresume) else: -self.finish_sequence.append("remove_autoresume") -self.finish_sequence.append("remove_chroot") +self.finish_sequence.append(self.remove_autoresume) +self.finish_sequence.append(self.remove_chroot) def set_use(self): use = self.settings["spec_prefix"] + "/use" @@ -1308,12 +1308,13 @@ class StageBase(TargetBase, ClearBase, GenBase): log.debug('setup_environment(); env = %r', self.env) -def run_sequence(self, sequence): +@staticmethod +def run_sequence(sequence): for func in sequence: log.notice('--- Running action sequence: %s', func) sys.stdout.flush() try: -getattr(self, func)() +func() except LockInUse: log.error('Unable to aquire the lock...') return False @@ -1342,14 +1343,14 @@ class StageBase(TargetBase, ClearBase, GenBase): log.info('StageBase: run() purge') self.purge() -if not self.run_sequence(self.prepare_sequence): +if not run_sequence(self.prepare_sequence): return False with namespace(mount=True): -if not self.run_sequence(self.build_sequence): +if not run_sequence(self.build_sequence): return False -if not self.run_sequence(self.finish_sequence): +if not run_sequence(self.finish_sequence): return False return True diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py index 918b36bf..7d328808 100644 --- a/catalyst/targets/embedded.py +++ b/catalyst/targets/embedded.py @@ -42,27 +42,27 @@ class embedded(StageBase): def set_action_sequence(self): self.prepare_sequence.extend([ -"unpack", -"config_profile_link", -"setup_confdir", -"portage_overlay", +self.unpack, +self.config_profile_link, +self.setup_confdir, +se
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, targets/support/
commit: e55b5bce1dfd69e767cd17c961267e9bc113ea47 Author: Matt Turner gentoo org> AuthorDate: Mon Jan 18 03:09:30 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 03:49:48 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=e55b5bce catalyst: Call config_profile_link for all targets This reverts the following two commits, which have no documented rationale. Revert "Set the profile by calling eselect." This reverts commit 90c03f9dc255ba89849e46490f9ead7ab3921950. Revert "Drop config_profile_link from the action_sequence for the generic stage." This reverts commit 3bd10159bf7cfe14b6d8a8218b94eca73be4c997. Doing so improves the code in two ways: 1) it makes prepare_sequence identical across all targets, which will allow me to deduplicate some code 2) it no longer calls eselect profile each time chroot-functions.sh is sourced (even for those targets that were still calling config_profile_link) Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 1 + targets/support/chroot-functions.sh | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index ae13e35f..753f378e 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -483,6 +483,7 @@ class StageBase(TargetBase, ClearBase, GenBase): """Set basic stage1, 2, 3 action sequences""" self.prepare_sequence.extend([ self.unpack, +self.config_profile_link, self.setup_confdir, self.portage_overlay, ]) diff --git a/targets/support/chroot-functions.sh b/targets/support/chroot-functions.sh index 2aec018e..88465c31 100755 --- a/targets/support/chroot-functions.sh +++ b/targets/support/chroot-functions.sh @@ -1,8 +1,5 @@ #!/bin/bash -# Set the profile -eselect profile set ${clst_target_profile} - # Trap these signals and kill ourselves if received # Force ourselves to die if any of these signals are received # most likely our controlling terminal is gone
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/targets/, catalyst/base/
commit: e8574605f16ec995dafef34004d92ea03c870399 Author: Matt Turner gentoo org> AuthorDate: Mon Jan 18 03:20:41 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 03:49:48 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=e8574605 catalyst: Deduplicate the common build_sequence steps This will also provide a nice spot to add a function to all targets' build_sequence. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py| 11 ++- catalyst/targets/embedded.py | 3 --- catalyst/targets/livecd_stage1.py | 3 --- catalyst/targets/livecd_stage2.py | 3 --- catalyst/targets/netboot.py | 3 --- catalyst/targets/stage4.py| 3 --- 6 files changed, 6 insertions(+), 20 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index fa9f1f64..d3048d31 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -73,7 +73,11 @@ class StageBase(TargetBase, ClearBase, GenBase): self.setup_confdir, self.portage_overlay, ] -self.build_sequence = [] +self.build_sequence = [ +self.bind, +self.chroot_setup, +self.setup_environment, +] self.finish_sequence = [] self.set_valid_build_kernel_vars(addlargs) @@ -480,16 +484,13 @@ class StageBase(TargetBase, ClearBase, GenBase): Or it calls the normal set_action_sequence() for the target stage. """ if "purgeonly" in self.settings["options"]: -self.build_sequence.append(self.remove_chroot) +self.build_sequence = [self.remove_chroot] return self.set_action_sequence() def set_action_sequence(self): """Set basic stage1, 2, 3 action sequences""" self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.run_local, self.preclean, ]) diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py index 83b17ad2..b677b226 100644 --- a/catalyst/targets/embedded.py +++ b/catalyst/targets/embedded.py @@ -42,9 +42,6 @@ class embedded(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.build_kernel, self.build_packages, self.root_overlay, diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py index 9fe95a00..dbfa54ed 100644 --- a/catalyst/targets/livecd_stage1.py +++ b/catalyst/targets/livecd_stage1.py @@ -24,9 +24,6 @@ class livecd_stage1(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.build_packages, ]) self.finish_sequence.extend([ diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py index ab8f4a0e..e90e9f53 100644 --- a/catalyst/targets/livecd_stage2.py +++ b/catalyst/targets/livecd_stage2.py @@ -87,9 +87,6 @@ class livecd_stage2(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.run_local, self.build_kernel ]) diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py index cb5e7ae4..a2a9fcb3 100644 --- a/catalyst/targets/netboot.py +++ b/catalyst/targets/netboot.py @@ -159,9 +159,6 @@ class netboot(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.build_packages, self.root_overlay, self.copy_files_to_image, diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py index 9e53f070..f8383f75 100644 --- a/catalyst/targets/stage4.py +++ b/catalyst/targets/stage4.py @@ -40,9 +40,6 @@ class stage4(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.build_packages, self.build_kernel, self.bootloader,
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/targets/, catalyst/base/
commit: f5a3b566042ea4bf65e0ddada96b083504d68bc1 Author: Matt Turner gentoo org> AuthorDate: Mon Jan 18 03:20:41 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 03:31:42 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=f5a3b566 catalyst: Deduplicate the common build_sequence steps This will also provide a nice spot to add a function to all targets' build_sequence. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py| 11 ++- catalyst/targets/embedded.py | 3 --- catalyst/targets/livecd_stage1.py | 3 --- catalyst/targets/livecd_stage2.py | 3 --- catalyst/targets/netboot.py | 3 --- catalyst/targets/stage4.py| 3 --- 6 files changed, 6 insertions(+), 20 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 1aab4d95..552a6658 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -73,7 +73,11 @@ class StageBase(TargetBase, ClearBase, GenBase): self.setup_confdir, self.portage_overlay, ] -self.build_sequence = [] +self.build_sequence = [ +self.bind, +self.chroot_setup, +self.setup_environment, +] self.finish_sequence = [] self.set_valid_build_kernel_vars(addlargs) @@ -480,16 +484,13 @@ class StageBase(TargetBase, ClearBase, GenBase): Or it calls the normal set_action_sequence() for the target stage. """ if "purgeonly" in self.settings["options"]: -self.build_sequence.append(self.remove_chroot) +self.build_sequence = [self.remove_chroot] return self.set_action_sequence() def set_action_sequence(self): """Set basic stage1, 2, 3 action sequences""" self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.run_local, self.preclean, ]) diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py index 83b17ad2..b677b226 100644 --- a/catalyst/targets/embedded.py +++ b/catalyst/targets/embedded.py @@ -42,9 +42,6 @@ class embedded(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.build_kernel, self.build_packages, self.root_overlay, diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py index 9fe95a00..dbfa54ed 100644 --- a/catalyst/targets/livecd_stage1.py +++ b/catalyst/targets/livecd_stage1.py @@ -24,9 +24,6 @@ class livecd_stage1(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.build_packages, ]) self.finish_sequence.extend([ diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py index ab8f4a0e..e90e9f53 100644 --- a/catalyst/targets/livecd_stage2.py +++ b/catalyst/targets/livecd_stage2.py @@ -87,9 +87,6 @@ class livecd_stage2(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.run_local, self.build_kernel ]) diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py index cb5e7ae4..a2a9fcb3 100644 --- a/catalyst/targets/netboot.py +++ b/catalyst/targets/netboot.py @@ -159,9 +159,6 @@ class netboot(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.build_packages, self.root_overlay, self.copy_files_to_image, diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py index 9e53f070..f8383f75 100644 --- a/catalyst/targets/stage4.py +++ b/catalyst/targets/stage4.py @@ -40,9 +40,6 @@ class stage4(StageBase): def set_action_sequence(self): self.build_sequence.extend([ -self.bind, -self.chroot_setup, -self.setup_environment, self.build_packages, self.build_kernel, self.bootloader,
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/targets/, targets/stage1/, targets/support/, doc/
commit: f2b996f7fe005704c51fde56738870d776cf6119 Author: Matt Turner gentoo org> AuthorDate: Sat Jan 16 16:28:59 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 03:32:47 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=f2b996f7 catalyst: Remove update_seed Signed-off-by: Matt Turner gentoo.org> catalyst/targets/stage1.py | 2 -- doc/catalyst-spec.5.txt | 10 -- targets/stage1/chroot.sh| 34 -- targets/support/chroot-functions.sh | 2 +- 4 files changed, 9 insertions(+), 39 deletions(-) diff --git a/catalyst/targets/stage1.py b/catalyst/targets/stage1.py index 5a154e76..f7c723ee 100644 --- a/catalyst/targets/stage1.py +++ b/catalyst/targets/stage1.py @@ -16,8 +16,6 @@ class stage1(StageBase): required_values = frozenset() valid_values = required_values | frozenset([ "chost", -"update_seed", -"update_seed_command", ]) def __init__(self, spec, addlargs): diff --git a/doc/catalyst-spec.5.txt b/doc/catalyst-spec.5.txt index 4c1df857..47a62709 100644 --- a/doc/catalyst-spec.5.txt +++ b/doc/catalyst-spec.5.txt @@ -116,16 +116,6 @@ releases, we use a default README.txt, and this will be used on your CD if you do not provide one yourself. We do not use this for the official releases. This setting is supported by the livecd targets. -*update_seed*:: -This is an optional setting supported by stage1 to tell catalyst if -it should update the seed stage or not (valid values: `yes no`). - -*update_seed_command*:: -This is an optional command to pass to emerge for updating the seed -stage (example: `--update dev-libs/mpfr dev-libs/mpc dev-libs/gmp`) -If not specified, catalyst will update gcc deps. -This setting requires enabling update_seed. - Compilation ~~~ diff --git a/targets/stage1/chroot.sh b/targets/stage1/chroot.sh index f5002d75..e6ace213 100755 --- a/targets/stage1/chroot.sh +++ b/targets/stage1/chroot.sh @@ -24,32 +24,14 @@ BOOTSTRAP_USE="$(portageq envvar BOOTSTRAP_USE)" FEATURES="${FEATURES} nodoc noman noinfo" -# We need to ensure the base stage3 has USE="bindist" -# if BINDIST is set to avoid issues with openssl / openssh -[ -e ${clst_make_conf} ] && echo "USE=\"${BINDIST} ${USE}\"" >> ${clst_make_conf} - -# Update stage3 -if [ -n "${clst_update_seed}" ]; then - if [ "${clst_update_seed}" == "yes" ]; then - echo "Updating seed stage..." - if [ -n "${clst_update_seed_command}" ]; then - ROOT=/ run_merge --buildpkg=n "${clst_update_seed_command}" - else - ROOT=/ run_merge --buildpkg=n --ignore-built-slot-operator-deps y @changed-subslot - fi - elif [ "${clst_update_seed}" != "no" ]; then - echo "Invalid setting for update_seed: ${clst_update_seed}" - exit 1 - fi - - # reset emerge options for the target - clst_update_seed=no setup_emerge_opts -else - echo "Skipping seed stage update..." -fi - -# Clear USE -[ -e ${clst_make_conf} ] && sed -i -e "/^USE=\"${BINDIST} ${USE}\"/d" ${clst_make_conf} +# Update seed stage +echo "Updating seed stage" +( + # Don't build or use binpkgs + clst_PKGCACHE= setup_emerge_opts + + ROOT=/ run_merge --buildpkg n --ignore-built-slot-operator-deps y @changed-subslot +) export ROOT="${clst_root_path}" mkdir -p "$ROOT" diff --git a/targets/support/chroot-functions.sh b/targets/support/chroot-functions.sh index 88465c31..94d7c938 100755 --- a/targets/support/chroot-functions.sh +++ b/targets/support/chroot-functions.sh @@ -136,7 +136,7 @@ setup_emerge_opts() { emerge_opts+=(--load-average "${clst_load_average}") fi - if [ -n "${clst_PKGCACHE}" ] && [ -z "${clst_update_seed}" -o "${clst_update_seed}" = "no" ] + if [ -n "${clst_PKGCACHE}" ] then emerge_opts+=(--usepkg --buildpkg --binpkg-respect-use=y --newuse) bootstrap_opts+=(-r)
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/targets/, catalyst/base/
commit: b3ebb48647737eb74eb9773d9231f38a8635e4b4 Author: Matt Turner gentoo org> AuthorDate: Mon Jan 18 03:15:02 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 03:31:42 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=b3ebb486 catalyst: Deduplicate prepare_sequence assignments Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py| 13 ++--- catalyst/targets/embedded.py | 6 -- catalyst/targets/livecd_stage1.py | 6 -- catalyst/targets/livecd_stage2.py | 6 -- catalyst/targets/netboot.py | 6 -- catalyst/targets/stage4.py| 6 -- 6 files changed, 6 insertions(+), 37 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 5115d029..1aab4d95 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -67,7 +67,12 @@ class StageBase(TargetBase, ClearBase, GenBase): "portage_overlay", "portage_prefix", ]) -self.prepare_sequence = [] +self.prepare_sequence = [ +self.unpack, +self.config_profile_link, +self.setup_confdir, +self.portage_overlay, +] self.build_sequence = [] self.finish_sequence = [] @@ -481,12 +486,6 @@ class StageBase(TargetBase, ClearBase, GenBase): def set_action_sequence(self): """Set basic stage1, 2, 3 action sequences""" -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py index 7d328808..83b17ad2 100644 --- a/catalyst/targets/embedded.py +++ b/catalyst/targets/embedded.py @@ -41,12 +41,6 @@ class embedded(StageBase): StageBase.__init__(self, spec, addlargs) def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py index eb6bb0f0..9fe95a00 100644 --- a/catalyst/targets/livecd_stage1.py +++ b/catalyst/targets/livecd_stage1.py @@ -23,12 +23,6 @@ class livecd_stage1(StageBase): StageBase.__init__(self, spec, addlargs) def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py index 5fecff85..ab8f4a0e 100644 --- a/catalyst/targets/livecd_stage2.py +++ b/catalyst/targets/livecd_stage2.py @@ -86,12 +86,6 @@ class livecd_stage2(StageBase): print_traceback=True) def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py index 9a7e59e5..cb5e7ae4 100644 --- a/catalyst/targets/netboot.py +++ b/catalyst/targets/netboot.py @@ -158,12 +158,6 @@ class netboot(StageBase): self.resume.enable("empty") def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup, diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py index 997139a5..9e53f070 100644 --- a/catalyst/targets/stage4.py +++ b/catalyst/targets/stage4.py @@ -39,12 +39,6 @@ class stage4(StageBase): self.settings["cleanables"].remove('/etc/resolv.conf') def set_action_sequence(self): -self.prepare_sequence.extend([ -self.unpack, -self.config_profile_link, -self.setup_confdir, -self.portage_overlay, -]) self.build_sequence.extend([ self.bind, self.chroot_setup,
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/targets/
commit: 4362ffbf257f7d9a05ad81e46b522670e82ad78d Author: Matt Turner gentoo org> AuthorDate: Sun Jan 17 23:53:21 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 03:27:41 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=4362ffbf catalyst: Store references to functions ... rather than their names. This makes it possible for tooling to understand the code structure better. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py| 41 +- catalyst/targets/embedded.py | 34 ++--- catalyst/targets/livecd_stage1.py | 18 +++ catalyst/targets/livecd_stage2.py | 46 +++ catalyst/targets/netboot.py | 34 ++--- catalyst/targets/stage1.py| 12 +- catalyst/targets/stage4.py| 36 +++--- 7 files changed, 111 insertions(+), 110 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 8d8d01d1..79f00149 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -475,39 +475,39 @@ class StageBase(TargetBase, ClearBase, GenBase): Or it calls the normal set_action_sequence() for the target stage. """ if "purgeonly" in self.settings["options"]: -self.build_sequence.append("remove_chroot") +self.build_sequence.append(self.remove_chroot) return self.set_action_sequence() def set_action_sequence(self): """Set basic stage1, 2, 3 action sequences""" self.prepare_sequence.extend([ -"unpack", -"setup_confdir", -"portage_overlay", +self.unpack, +self.setup_confdir, +self.portage_overlay, ]) self.build_sequence.extend([ -"bind", -"chroot_setup", -"setup_environment", -"run_local", -"preclean", +self.bind, +self.chroot_setup, +self.setup_environment, +self.run_local, +self.preclean, ]) self.finish_sequence.extend([ -"clean", +self.clean, ]) self.set_completion_action_sequences() def set_completion_action_sequences(self): if "fetch" not in self.settings["options"]: -self.finish_sequence.append("capture") +self.finish_sequence.append(self.capture) if "keepwork" in self.settings["options"]: -self.finish_sequence.append("clear_autoresume") +self.finish_sequence.append(self.clear_autoresume) elif "seedcache" in self.settings["options"]: -self.finish_sequence.append("remove_autoresume") +self.finish_sequence.append(self.remove_autoresume) else: -self.finish_sequence.append("remove_autoresume") -self.finish_sequence.append("remove_chroot") +self.finish_sequence.append(self.remove_autoresume) +self.finish_sequence.append(self.remove_chroot) def set_use(self): use = self.settings["spec_prefix"] + "/use" @@ -1308,12 +1308,13 @@ class StageBase(TargetBase, ClearBase, GenBase): log.debug('setup_environment(); env = %r', self.env) -def run_sequence(self, sequence): +@staticmethod +def run_sequence(sequence): for func in sequence: log.notice('--- Running action sequence: %s', func) sys.stdout.flush() try: -getattr(self, func)() +func() except LockInUse: log.error('Unable to aquire the lock...') return False @@ -1342,14 +1343,14 @@ class StageBase(TargetBase, ClearBase, GenBase): log.info('StageBase: run() purge') self.purge() -if not self.run_sequence(self.prepare_sequence): +if not run_sequence(self.prepare_sequence): return False with namespace(mount=True): -if not self.run_sequence(self.build_sequence): +if not run_sequence(self.build_sequence): return False -if not self.run_sequence(self.finish_sequence): +if not run_sequence(self.finish_sequence): return False return True diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py index 918b36bf..7d328808 100644 --- a/catalyst/targets/embedded.py +++ b/catalyst/targets/embedded.py @@ -42,27 +42,27 @@ class embedded(StageBase): def set_action_sequence(self): self.prepare_sequence.extend([ -"unpack", -"config_profile_link", -"setup_confdir", -"portage_overlay", +self.unpack, +self.config_profile_link, +self.setup_confdir, +se
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, targets/support/
commit: 88f38bc955b664741b2473a4316c0b55d622b8ad Author: Matt Turner gentoo org> AuthorDate: Mon Jan 18 03:09:30 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 03:27:41 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=88f38bc9 catalyst: Call config_profile_link for all targets This reverts the following two commits, which have no documented rationale. Revert "Set the profile by calling eselect." This reverts commit 90c03f9dc255ba89849e46490f9ead7ab3921950. Revert "Drop config_profile_link from the action_sequence for the generic stage." This reverts commit 3bd10159bf7cfe14b6d8a8218b94eca73be4c997. Doing so improves the code in two ways: 1) it makes prepare_sequence identical across all targets, which will allow me to deduplicate some code 2) it no longer calls eselect profile each time chroot-functions.sh is sourced (even for those targets that were still calling config_profile_link) Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 1 + targets/support/chroot-functions.sh | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 79f00149..5115d029 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -483,6 +483,7 @@ class StageBase(TargetBase, ClearBase, GenBase): """Set basic stage1, 2, 3 action sequences""" self.prepare_sequence.extend([ self.unpack, +self.config_profile_link, self.setup_confdir, self.portage_overlay, ]) diff --git a/targets/support/chroot-functions.sh b/targets/support/chroot-functions.sh index 2aec018e..88465c31 100755 --- a/targets/support/chroot-functions.sh +++ b/targets/support/chroot-functions.sh @@ -1,8 +1,5 @@ #!/bin/bash -# Set the profile -eselect profile set ${clst_target_profile} - # Trap these signals and kill ourselves if received # Force ourselves to die if any of these signals are received # most likely our controlling terminal is gone
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: f140497351d9e4323853ddb15f904092e574c11b Author: Matt Turner gentoo org> AuthorDate: Sat Jan 16 22:04:26 2021 + Commit: Matt Turner gentoo org> CommitDate: Mon Jan 18 03:27:41 2021 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=f1404973 catalyst: Make arch_dir a Path Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index ed4d1227..8d8d01d1 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -90,14 +90,14 @@ class StageBase(TargetBase, ClearBase, GenBase): build = platform.machine() self.settings["buildarch"] = build -arch_dir = normpath(self.settings['sharedir'] + '/arch/') +arch_dir = Path(self.settings['sharedir']) / 'arch' log.debug("Searching arch definitions...") -for x in [x for x in os.listdir(arch_dir) if x.endswith('.toml')]: +for x in [x for x in arch_dir.iterdir() if x.suffix == 'toml']: log.debug("\tTrying %s", x) -name = x[:-len('.toml')] +name = x.stem -with open(arch_dir + x) as file: +with x.open() as file: arch_config = toml.load(file) # Search for a subarchitecture in each arch in the arch_config
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, targets/support/
commit: 03914bb12003cbf1b34be07f356b97c9c06d10fe Author: Matt Turner gentoo org> AuthorDate: Sat Dec 19 00:23:32 2020 + Commit: Matt Turner gentoo org> CommitDate: Sat Dec 19 02:56:52 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=03914bb1 catalyst: Remove set_dest_path() root_path is always set, so half of this function was dead. The other half set the same thing as set_stage_path(). Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py| 20 ++-- targets/support/target_image_setup.sh | 4 ++-- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index ba6b1a1b..ed4d1227 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -154,7 +154,6 @@ class StageBase(TargetBase, ClearBase, GenBase): self.set_source_path() self.set_chroot_path() self.set_autoresume_path() -self.set_dest_path() self.set_stage_path() self.set_target_path() @@ -426,13 +425,6 @@ class StageBase(TargetBase, ClearBase, GenBase): self.generate_hash(self.settings["source_path"], "sha1") log.notice('Source path set to %s', self.settings['source_path']) -def set_dest_path(self): -if "root_path" in self.settings: -self.settings["destpath"] = normpath(self.settings["chroot_path"] + - self.settings["root_path"]) -else: -self.settings["destpath"] = normpath(self.settings["chroot_path"]) - def set_cleanables(self): self.settings['cleanables'] = [ "/etc/resolv.conf", @@ -845,7 +837,7 @@ class StageBase(TargetBase, ClearBase, GenBase): "/root_overlay"]: if os.path.exists(x): log.info('Copying root_overlay: %s', x) -cmd(['rsync', '-a', x + '/', self.settings['destpath']], +cmd(['rsync', '-a', x + '/', self.settings['stage_path']], env=self.env) def bind(self): @@ -1095,7 +1087,7 @@ class StageBase(TargetBase, ClearBase, GenBase): else: for x in self.settings["cleanables"]: log.notice('Cleaning chroot: %s', x) -clear_path(normpath(self.settings["destpath"] + x)) +clear_path(normpath(self.settings["stage_path"] + x)) # Put /etc/hosts back into place hosts_file = self.settings['chroot_path'] + '/etc/hosts' @@ -1119,14 +,14 @@ class StageBase(TargetBase, ClearBase, GenBase): log.debug("clean(), portage_preix = %s, no sticky-config", self.settings["portage_prefix"]) for _dir in "package.accept_keywords", "package.keywords", "package.mask", "package.unmask", "package.use", "package.env", "env": -target = pjoin(self.settings["destpath"], +target = pjoin(self.settings["stage_path"], "etc/portage/%s" % _dir, self.settings["portage_prefix"]) log.notice("Clearing portage_prefix target: %s", target) clear_path(target) # Remove hacks that should *never* go into stages -target = pjoin(self.settings["destpath"], "etc/portage/patches") +target = pjoin(self.settings["stage_path"], "etc/portage/patches") if os.path.exists(target): log.warning("You've been hacking. Clearing target patches: %s", target) clear_path(target) @@ -1172,7 +1164,7 @@ class StageBase(TargetBase, ClearBase, GenBase): self.settings[self.settings["spec_prefix"] + "/empty"].split() for x in self.settings[self.settings["spec_prefix"] + "/empty"]: -myemp = self.settings["destpath"] + x +myemp = self.settings["stage_path"] + x if not os.path.isdir(myemp) or os.path.islink(myemp): log.warning('not a directory or does not exist, ' 'skipping "empty" operation: %s', x) @@ -1192,7 +1184,7 @@ class StageBase(TargetBase, ClearBase, GenBase): # We're going to shell out for all these cleaning # operations, so we get easy glob handling. log.notice('%s: removing %s', self.settings["spec_prefix"], x) -clear_path(self.settings["destpath"] + x) +clear_path(self.settings["stage_path"] + x) try: if os.path.exists(self.settings["controller_file"]): cmd([self.settings['controller_file'], 'clean'], diff --git a/targets/support/target_image_setup.sh b/targets/support/target_image_setup.sh index fdc4a234..f9427eaf 100755 --- a/targets/support/target_image_s
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/targets/
commit: 6ef1d63861248098654bd8f211f929f8c6b6c63b Author: Matt Turner gentoo org> AuthorDate: Sat Dec 19 01:58:42 2020 + Commit: Matt Turner gentoo org> CommitDate: Sat Dec 19 02:56:52 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=6ef1d638 catalyst: Remove some redundant set_stage_path()s We only need to override root_path, and stage_path will be configured properly. Signed-off-by: Matt Turner gentoo.org> catalyst/targets/embedded.py | 5 - catalyst/targets/stage1.py | 5 - 2 files changed, 10 deletions(-) diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py index e9138437..918b36bf 100644 --- a/catalyst/targets/embedded.py +++ b/catalyst/targets/embedded.py @@ -65,11 +65,6 @@ class embedded(StageBase): "clear_autoresume", ]) -def set_stage_path(self): -self.settings["stage_path"] = normpath( -self.settings["chroot_path"]+"/tmp/mergeroot") -log.info('embedded stage path is %s', self.settings['stage_path']) - def set_root_path(self): self.settings["root_path"] = normpath("/tmp/mergeroot") log.info('embedded root path is %s', self.settings['root_path']) diff --git a/catalyst/targets/stage1.py b/catalyst/targets/stage1.py index be3eae93..5aa27bb9 100644 --- a/catalyst/targets/stage1.py +++ b/catalyst/targets/stage1.py @@ -23,11 +23,6 @@ class stage1(StageBase): def __init__(self, spec, addlargs): StageBase.__init__(self, spec, addlargs) -def set_stage_path(self): -self.settings["stage_path"] = normpath( -self.settings["chroot_path"]+self.settings["root_path"]) -log.notice('stage1 stage path is %s', self.settings['stage_path']) - def set_root_path(self): # sets the root path, relative to 'chroot_path', of the stage1 root self.settings["root_path"] = normpath("/tmp/stage1root")
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: a0f348e99151277cfd52ce1343777844dae5e0e8 Author: Matt Turner gentoo org> AuthorDate: Sat Dec 19 01:58:21 2020 + Commit: Matt Turner gentoo org> CommitDate: Sat Dec 19 02:56:52 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=a0f348e9 catalyst: Set stage_path = chroot_path + root_path Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index fe79b55a..ba6b1a1b 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -545,7 +545,8 @@ class StageBase(TargetBase, ClearBase, GenBase): self.settings["catalyst_use"].append("bindist") def set_stage_path(self): -self.settings["stage_path"] = normpath(self.settings["chroot_path"]) +self.settings["stage_path"] = normpath(self.settings["chroot_path"] + + self.settings["root_path"]) def set_packages(self): pass
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/targets/, catalyst/base/
commit: 4b5ff905a7ad2ffe1ed8c863b91e9d0ce6981f5f Author: Matt Turner gentoo org> AuthorDate: Thu Oct 22 20:37:54 2020 + Commit: Matt Turner gentoo org> CommitDate: Fri Oct 30 22:40:52 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=4b5ff905 catalyst: Drop unbind() mount_namespaces(7) says A mount ceases to be a member of a peer group when either the mount is explicitly unmounted, or when the mount is implicitly unmounted because a mount namespace is removed (because it has no more member processes). As a result, we can rely on exiting the mount namespace to unmount the bind mounts. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py| 44 +-- catalyst/targets/embedded.py | 1 - catalyst/targets/livecd_stage1.py | 1 - catalyst/targets/livecd_stage2.py | 2 -- catalyst/targets/netboot.py | 3 --- catalyst/targets/stage4.py| 1 - 6 files changed, 1 insertion(+), 51 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index b9c220d0..a75dbdf9 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -498,7 +498,6 @@ class StageBase(TargetBase, ClearBase, GenBase): "setup_environment", "run_local", "preclean", -"unbind", ]) self.finish_sequence.extend([ "clean", @@ -853,40 +852,8 @@ class StageBase(TargetBase, ClearBase, GenBase): fstype=fstype, options=options) cxt.mount() except OSError as e: -self.unbind() raise CatalystError(f"Couldn't mount: {source}, {e.strerror}") -def unbind(self): -chroot_path = self.settings["chroot_path"] -umount_failed = False - -# Unmount in reverse order -for target in [Path(chroot_path + self.mount[x]['target']) - for x in reversed(self.mount) - if self.mount[x]['enable']]: -if not target.exists(): -log.debug('%s does not exist. Skipping', target) -continue - -if not ismount(target): -log.debug('%s is not a mount point. Skipping', target) -continue - -try: -cxt = libmount.Context(target=str(target)) -cxt.umount() -except OSError as e: -log.warning("Couldn't umount: %s, %s", target, -e.strerror) -umount_failed = True - -if umount_failed: -# if any bind mounts really failed, then we need to raise -# this to potentially prevent an upcoming bash stage cleanup script -# from wiping our bind mounts. -raise CatalystError( -"Couldn't umount one or more bind-mounts; aborting for safety.") - def chroot_setup(self): self.makeconf = read_makeconf(normpath(self.settings["chroot_path"] + self.settings["make_conf"])) @@ -1190,7 +1157,6 @@ class StageBase(TargetBase, ClearBase, GenBase): env=self.env) self.resume.enable("remove") except: -self.unbind() raise def preclean(self): @@ -1206,7 +1172,6 @@ class StageBase(TargetBase, ClearBase, GenBase): self.resume.enable("preclean") except: -self.unbind() raise CatalystError("Build failed, could not execute preclean") def capture(self): @@ -1269,7 +1234,6 @@ class StageBase(TargetBase, ClearBase, GenBase): self.settings['controller_file']) except CatalystError: -self.unbind() raise CatalystError("Stage build aborting due to error.", print_traceback=False) @@ -1374,7 +1338,6 @@ class StageBase(TargetBase, ClearBase, GenBase): env=self.env) log.info('unmerge shell script') except CatalystError: -self.unbind() raise self.resume.enable("unmerge") @@ -1449,7 +1412,6 @@ class StageBase(TargetBase, ClearBase, GenBase): fileutils.touch(build_packages_resume) self.resume.enable("build_packages") except CatalystError: -self.unbind() raise CatalystError( self.settings["spec_prefix"] + "build aborting due to error.") @@ -1473,7 +1435,6 @@ class StageBase(TargetBase, ClearBase, GenBase): self._build_kernel(kname=kname) self.resume.enable("build_kernel") except CatalystError: -self.unbind()
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/, catalyst/base/
commit: 37a386056f77f7cc8f1c2bdfe680b13bd806b4e6 Author: Felix Bier rohde-schwarz com> AuthorDate: Tue Nov 10 01:03:03 2020 + Commit: Matt Turner gentoo org> CommitDate: Sat Nov 14 16:34:57 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=37a38605 Move from PORTDIR_OVERLAY to repos.conf This commit fixes the following issues: * The PORTDIR_OVERLAY variable has been deprecated by Gentoo. With this commit, the variable is no longer written to the generated make.conf. Instead, a config file /etc/portage/repos.conf/.conf is generated for each overlay. The repo name is read from the overlay using the portage API. Internally, portage parses metadata/layout.conf and profiles/repo_name to obtain the name. References: https://wiki.gentoo.org/wiki//etc/portage/make.conf https://wiki.gentoo.org/wiki//etc/portage/repos.conf * All overlays were copied into the same target directory. If the same file name occurred in multiple overlays, the last overlay would overwrite all previous files with this name. In particular, only the metadata/layout.conf of the last overlay was retained, so it was not possible to reference the other overlays e.g. via the masters entry in the layout.conf or the portage-2 syntax for specifying a parent profile from another overlay. Also, this created problems when the overlays contained ebuilds for the same package, but with differing versions, because after copying, the target directory contained both versions of the ebuild but only the manifest file of the last overlay. With this commit, each overlay is copied into a separate sub-directory, e.g. /var/db/repos/. This directory is referenced via the location entry in the generated /etc/portage/repos.conf/.conf. Signed-off-by: Felix Bier rohde-schwarz.com> Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 84 ++ catalyst/defaults.py | 2 +- catalyst/support.py| 18 ++ 3 files changed, 81 insertions(+), 23 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 21cf96a0..fe79b55a 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -1,4 +1,5 @@ +import configparser import copy import os import platform @@ -19,8 +20,8 @@ from catalyst import log from catalyst.context import namespace from catalyst.defaults import (confdefaults, MOUNT_DEFAULTS, PORT_LOGDIR_CLEAN) from catalyst.support import (CatalystError, file_locate, normpath, - cmd, read_makeconf, ismount, file_check, - sanitize_name) + cmd, read_makeconf, get_repo_name, ismount, + file_check, sanitize_name) from catalyst.base.targetbase import TargetBase from catalyst.base.clearbase import ClearBase from catalyst.base.genbase import GenBase @@ -786,17 +787,55 @@ class StageBase(TargetBase, ClearBase, GenBase): env=self.env) self.resume.enable("setup_confdir") +def to_chroot(self, path): +""" Prepend chroot path to the given path. """ + +chroot = Path(self.settings['chroot_path']) +return chroot / path.relative_to(path.anchor) + +def get_repo_conf_path(self, repo_name): +""" Construct repo conf path: {repos_conf}/{name}.conf """ +return Path(self.settings['repos_conf'], repo_name + ".conf") + +def get_repo_location(self, repo_name): +""" Construct overlay repo path: {repo_basedir}/{name} """ +return Path(self.settings['repo_basedir'], repo_name) + +def write_repo_conf(self, repo_name, config): +""" Write ConfigParser to {chroot}/{repos_conf}/{name}.conf """ + +repo_conf = self.get_repo_conf_path(repo_name) + +repo_conf_chroot = self.to_chroot(repo_conf) +repo_conf_chroot.parent.mkdir(mode=0o755, parents=True, exist_ok=True) + +log.info(f'Creating repo config {repo_conf_chroot}.') + +try: +with open(repo_conf_chroot, 'w') as f: +config.write(f) +except OSError as e: +raise CatalystError(f'Could not write {repo_conf_chroot}: {e}') from e + def portage_overlay(self): -""" We copy the contents of our overlays to /usr/local/portage """ +""" We copy the contents of our repos to get_repo_location(repo_name) """ if "portage_overlay" in self.settings: for x in self.settings["portage_overlay"]: if os.path.exists(x): -log.info('Copying overlay dir %s', x) -ensure_dirs( -self.settings['chroot_path'] + self.settings['local_overlay']) -cmd("cp -a " + x + "/* " + self.settings["chroot_path"] + -self.settings["local_overlay"], -
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/
commit: dccfafea4e8b4622a7527a764d581ac0123b107e Author: Felix Bier rohde-schwarz com> AuthorDate: Mon Nov 9 19:36:33 2020 + Commit: Matt Turner gentoo org> CommitDate: Sat Nov 14 16:34:57 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=dccfafea catalyst: Restore root and cwd after exiting mount namespace This commit saves the file descriptor of /proc/self/{root,cwd} before entering into the new mount namespace. When restoring the previous mount namespace, it restores /proc/self/{root,cwd} based on the saved file descriptors. Without this change, catalyst cannot be run in a chroot when using the recent changes regarding mount namespaces: After the mount namespace has been exited, /proc/self/root points to the "/" of the host system, not the "/" of the chroot. Therefore, the cleanup phase of catalyst runs outside of the chroot. The code is similar to how nsenter(1) sets root and cwd: https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/tree/sys-utils/nsenter.c#n452 Tested in a Gentoo chroot and in Gentoo VM (non-chroot). Signed-off-by: Felix Bier rohde-schwarz.com> Signed-off-by: Matt Turner gentoo.org> catalyst/context.py | 22 ++ 1 file changed, 22 insertions(+) diff --git a/catalyst/context.py b/catalyst/context.py index 8a58f33d..01a6d930 100644 --- a/catalyst/context.py +++ b/catalyst/context.py @@ -16,11 +16,21 @@ def namespace(mount=False, uts=False, ipc=False, net=False, pid=False, (user, "user"): None, } +dirs = { +"root": None, +"cwd": None, +} + # Save fds of current namespaces for ns in [ns for ns in namespaces if ns[0]]: fp = open(f"/proc/self/ns/{ns[1]}") namespaces[ns] = fp +# Save fds of current directories +if mount: +for d in dirs: +dirs[d] = os.open(f"/proc/self/{d}", os.O_RDONLY) + simple_unshare(mount=mount, uts=uts, ipc=ipc, net=net, pid=pid, user=user, hostname=hostname) try: @@ -30,3 +40,15 @@ def namespace(mount=False, uts=False, ipc=False, net=False, pid=False, fp = namespaces[ns] setns(fp.fileno(), 0) fp.close() + +if mount: +# Restore original root and cwd. Since we cannot directly chroot to +# a fd, first change the current directory to the fd of the +# original root, then chroot to "." + +os.fchdir(dirs["root"]) +os.chroot(".") +os.fchdir(dirs["cwd"]) + +for fd in dirs.values(): +os.close(fd)
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/
commit: 4bcc64dcf2b27ab3d0effed0fa2516e3513a9171 Author: Matt Turner gentoo org> AuthorDate: Wed Oct 28 21:59:17 2020 + Commit: Matt Turner gentoo org> CommitDate: Fri Oct 30 22:40:52 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=4bcc64dc catalyst: Add and use namespace context manager Wraps snakeoil's simple_unshare; returns to the previous namespaces on context exit. Will be used by the next commit. Signed-off-by: Matt Turner gentoo.org> catalyst/context.py | 32 catalyst/main.py| 17 +++-- 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/catalyst/context.py b/catalyst/context.py new file mode 100644 index ..8a58f33d --- /dev/null +++ b/catalyst/context.py @@ -0,0 +1,32 @@ + +import contextlib +import os + +from snakeoil.process.namespaces import setns, simple_unshare + +@contextlib.contextmanager +def namespace(mount=False, uts=False, ipc=False, net=False, pid=False, + user=False, hostname=None): +namespaces = { +(mount, "mnt"): None, +(uts, "uts"): None, +(ipc, "ipc"): None, +(net, "net"): None, +(pid, "pid"): None, +(user, "user"): None, +} + +# Save fds of current namespaces +for ns in [ns for ns in namespaces if ns[0]]: +fp = open(f"/proc/self/ns/{ns[1]}") +namespaces[ns] = fp + +simple_unshare(mount=mount, uts=uts, ipc=ipc, net=net, pid=pid, user=user, + hostname=hostname) +try: +yield +finally: +for ns in [ns for ns in namespaces if ns[0]]: +fp = namespaces[ns] +setns(fp.fileno(), 0) +fp.close() diff --git a/catalyst/main.py b/catalyst/main.py index 543895c6..93a4a0d3 100644 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -7,14 +7,13 @@ import textwrap import toml -from snakeoil.process import namespaces - from DeComp.definitions import (COMPRESS_DEFINITIONS, DECOMPRESS_DEFINITIONS, CONTENTS_DEFINITIONS) from DeComp.contents import ContentsMap from catalyst import log import catalyst.config +from catalyst.context import namespace from catalyst.defaults import (confdefaults, option_messages, DEFAULT_CONFIG_FILE, valid_config_file_values) from catalyst.support import CatalystError @@ -356,15 +355,13 @@ def _main(parser, opts): # use pid & user namespaces, but snakeoil's namespace module has signal # transfer issues (CTRL+C doesn't propagate), and user namespaces need # more work due to Gentoo build process (uses sudo/root/portage). -namespaces.simple_unshare( -mount=True, uts=True, ipc=True, pid=False, net=False, user=False, -hostname='catalyst') +with namespace(mount=True, uts=True, ipc=True, hostname='catalyst'): +# everything is setup, so the build is a go +try: +success = build_target(addlargs) +except KeyboardInterrupt: +log.critical('Catalyst build aborted due to user interrupt (Ctrl-C)') -# everything is setup, so the build is a go -try: -success = build_target(addlargs) -except KeyboardInterrupt: -log.critical('Catalyst build aborted due to user interrupt (Ctrl-C)') if not success: sys.exit(2) sys.exit(0)
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: 595ab9922f4ed8f88148ca7fbc9fe533db63fb4c Author: Matt Turner gentoo org> AuthorDate: Thu Oct 29 14:39:35 2020 + Commit: Matt Turner gentoo org> CommitDate: Fri Oct 30 22:40:52 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=595ab992 catalyst: Remove mount_safety_check() mount_safety_check() exists to prevent bad things from happening if a previous catalyst invocation left bind mounts active in the chroot. E.g., a previous catalyst invocation is interrupted without unmounting the bind mounts. A new catalyst invocation runs and cleans the old chroot, which inadvertently deletes files outside of the chroot via the bind mounts. With all the mounts now inside a namespace, it is no longer possible to have mounts accessible outside the build sequence. In fact, I think this code has been unnecessary since commit e5a53e42 ("catalyst: create namespaces for building"). Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 37 - 1 file changed, 37 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index bd5ba8d0..b9c220d0 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -638,39 +638,7 @@ class StageBase(TargetBase, ClearBase, GenBase): assert self.settings[verify] == "blake2" self.settings.setdefault("gk_mainargs", []).append("--b2sum") -def mount_safety_check(self): -""" -Check and verify that none of our paths in mypath are mounted. We don't -want to clean up with things still mounted, and this allows us to check. -Returns 1 on ok, 0 on "something is still mounted" case. -""" - -if not os.path.exists(self.settings["chroot_path"]): -return - -log.debug('self.mount = %s', self.mount) -for x in [x for x in self.mount if self.mount[x]['enable']]: -target = normpath(self.settings['chroot_path'] + - self.mount[x]['target']) -log.debug('mount_safety_check() x = %s %s', x, target) -if not os.path.exists(target): -continue - -if ismount(target): -# Something is still mounted -try: -log.warning( -'%s is still mounted; performing auto-bind-umount...', target) -# Try to umount stuff ourselves -self.unbind() -if ismount(target): -raise CatalystError("Auto-unbind failed for " + target) -log.notice('Auto-unbind successful...') -except CatalystError: -raise CatalystError("Unable to auto-unbind " + target) - def unpack(self): - clst_unpack_hash = self.resume.get("unpack") # Set up all unpack info settings @@ -755,8 +723,6 @@ class StageBase(TargetBase, ClearBase, GenBase): % self.settings["source_path"]) if _unpack: -self.mount_safety_check() - if invalid_chroot: if "autoresume" in self.settings["options"]: log.notice( @@ -1363,9 +1329,6 @@ class StageBase(TargetBase, ClearBase, GenBase): def run(self): self.chroot_lock.write_lock() -# Check for mounts right away and abort if we cannot unmount them -self.mount_safety_check() - if "clear-autoresume" in self.settings["options"]: self.clear_autoresume()
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/, catalyst/base/
commit: b556ff31b8d4caaef6c0e7612a70f5f0c397b02c Author: Felix Bier rohde-schwarz com> AuthorDate: Tue Nov 10 00:59:01 2020 + Commit: Matt Turner gentoo org> CommitDate: Sat Nov 14 16:34:57 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=b556ff31 Ensure deep copying of config defaults This commit adds deep copying operations when initializing config objects from a default config. This prevents the config from being a shallow copy of the default, ensuring that modifications to the config do not modify the default. In particular, this fixes a check in write_make_conf, where the PORTDIR variable is supposed to be only written to the generated make.conf when a non-default repo_basedir is set in /etc/catalyst/catalyst.conf. This check is never satisfied, because confvalues is a shallow copy of confdefaults, therefore both will always hold the same value for repo_basedir. For self.mounts / MOUNT_DEFAULTS this problem can also be observed, the modifications done to self.mounts are also visible in MOUNT_DEFAULTS. I am not aware of any bugs due to this shallow copy, but I would prefer adding a deep copy to prevent future bugs, in case a comparision against the default mounts is ever needed. Signed-off-by: Felix Bier rohde-schwarz.com> Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 3 ++- catalyst/main.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index a75dbdf9..21cf96a0 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -1,4 +1,5 @@ +import copy import os import platform import shutil @@ -187,7 +188,7 @@ class StageBase(TargetBase, ClearBase, GenBase): file_locate(self.settings, ["portage_confdir"], expand=0) # Setup our mount points. -self.mount = MOUNT_DEFAULTS.copy() +self.mount = copy.deepcopy(MOUNT_DEFAULTS) self.mount['portdir']['source'] = self.snapshot self.mount['portdir']['target'] = self.settings['repo_basedir'] + '/' + self.settings['repo_name'] diff --git a/catalyst/main.py b/catalyst/main.py index 5536471a..48daf004 100644 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -1,4 +1,5 @@ import argparse +import copy import datetime import hashlib import os @@ -19,7 +20,7 @@ from catalyst.defaults import (confdefaults, option_messages, from catalyst.support import CatalystError from catalyst.version import get_version -conf_values = confdefaults +conf_values = copy.deepcopy(confdefaults) def version():
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/
commit: 488b06bf5dbe1eba68ac11de95f56feeb6cead83 Author: Matt Turner gentoo org> AuthorDate: Thu Oct 29 15:00:42 2020 + Commit: Matt Turner gentoo org> CommitDate: Fri Oct 30 22:40:52 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=488b06bf catalyst: Run the build sequence in new mount namespace Catalyst has a lot of code to unmount the bind mounts it's made, and then more to try harder when something fails. This is important because if bind mounts still exist within the chroot when clean up happens, files outside of the chroot on the host system can inadvertently be deleted. E.g., distfiles, binpkgs, kerncache. Running the build sequence (the steps that need bind mounts) within a mount namespace and exiting the mount namespace when finished ensures that clean up can never accidentally delete files outside the chroot. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 7 --- catalyst/main.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 06ec8727..caec5935 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -15,6 +15,7 @@ from snakeoil.osutils import pjoin from DeComp.compress import CompressMap from catalyst import log +from catalyst.context import namespace from catalyst.defaults import (confdefaults, MOUNT_DEFAULTS, PORT_LOGDIR_CLEAN) from catalyst.support import (CatalystError, file_locate, normpath, cmd, read_makeconf, ismount, file_check, @@ -1405,9 +1406,9 @@ class StageBase(TargetBase, ClearBase, GenBase): if not self.run_sequence(self.prepare_sequence): return False -if not self.run_sequence(self.build_sequence): -self.unbind() -return False +with namespace(mount=True): +if not self.run_sequence(self.build_sequence): +return False if not self.run_sequence(self.finish_sequence): return False diff --git a/catalyst/main.py b/catalyst/main.py index 93a4a0d3..5536471a 100644 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -355,7 +355,7 @@ def _main(parser, opts): # use pid & user namespaces, but snakeoil's namespace module has signal # transfer issues (CTRL+C doesn't propagate), and user namespaces need # more work due to Gentoo build process (uses sudo/root/portage). -with namespace(mount=True, uts=True, ipc=True, hostname='catalyst'): +with namespace(uts=True, ipc=True, hostname='catalyst'): # everything is setup, so the build is a go try: success = build_target(addlargs)
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/targets/
commit: 3d85d537b1a00d05234cea064f863602b83ffaab Author: Matt Turner gentoo org> AuthorDate: Thu Oct 29 03:08:04 2020 + Commit: Matt Turner gentoo org> CommitDate: Fri Oct 30 22:40:52 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=3d85d537 catalyst: Split action_sequence into prepare/build/finish We want to run the "build" sequence in a different mount namespace from the "prepare" and "finish" sequences, so this splits action_sequence into those groupings. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py| 24 +++- catalyst/targets/embedded.py | 6 +- catalyst/targets/livecd_stage1.py | 6 +- catalyst/targets/livecd_stage2.py | 10 +++--- catalyst/targets/netboot.py | 6 +- catalyst/targets/stage1.py| 12 ++-- catalyst/targets/stage4.py| 6 +- 7 files changed, 48 insertions(+), 22 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 46b7c59c..75c84baa 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -64,7 +64,9 @@ class StageBase(TargetBase, ClearBase, GenBase): "portage_overlay", "portage_prefix", ]) -self.action_sequence = [] +self.prepare_sequence = [] +self.build_sequence = [] +self.finish_sequence = [] self.set_valid_build_kernel_vars(addlargs) TargetBase.__init__(self, myspec, addlargs) @@ -478,36 +480,40 @@ class StageBase(TargetBase, ClearBase, GenBase): Or it calls the normal set_action_sequence() for the target stage. """ if "purgeonly" in self.settings["options"]: -self.action_sequence.append("remove_chroot") +self.build_sequence.append("remove_chroot") return self.set_action_sequence() def set_action_sequence(self): """Set basic stage1, 2, 3 action sequences""" -self.action_sequence.extend([ +self.prepare_sequence.extend([ "unpack", "setup_confdir", "portage_overlay", +]) +self.build_sequence.extend([ "bind", "chroot_setup", "setup_environment", "run_local", "preclean", "unbind", +]) +self.finish_sequence.extend([ "clean", ]) self.set_completion_action_sequences() def set_completion_action_sequences(self): if "fetch" not in self.settings["options"]: -self.action_sequence.append("capture") +self.finish_sequence.append("capture") if "keepwork" in self.settings["options"]: -self.action_sequence.append("clear_autoresume") +self.finish_sequence.append("clear_autoresume") elif "seedcache" in self.settings["options"]: -self.action_sequence.append("remove_autoresume") +self.finish_sequence.append("remove_autoresume") else: -self.action_sequence.append("remove_autoresume") -self.action_sequence.append("remove_chroot") +self.finish_sequence.append("remove_autoresume") +self.finish_sequence.append("remove_chroot") def set_use(self): use = self.settings["spec_prefix"] + "/use" @@ -1381,7 +1387,7 @@ class StageBase(TargetBase, ClearBase, GenBase): self.purge() failure = False -for x in self.action_sequence: +for x in self.prepare_sequence + self.build_sequence + self.finish_sequence: log.notice('--- Running action sequence: %s', x) sys.stdout.flush() try: diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py index 75eb68e4..1314ce7c 100644 --- a/catalyst/targets/embedded.py +++ b/catalyst/targets/embedded.py @@ -41,11 +41,13 @@ class embedded(StageBase): StageBase.__init__(self, spec, addlargs) def set_action_sequence(self): -self.action_sequence.extend([ +self.prepare_sequence.extend([ "unpack", "config_profile_link", "setup_confdir", "portage_overlay", +]) +self.build_sequence.extend([ "bind", "chroot_setup", "setup_environment", @@ -55,6 +57,8 @@ class embedded(StageBase): "fsscript", "unmerge", "unbind", +]) +self.finish_sequence.extend([ "remove", "empty", "clean", diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py index 9dbfa506..81367053 100644 --- a/catalyst/targets/livecd_stage1.py +++ b/catalyst/targets/livecd_stage1.py @@ -23,16 +23,20 @@ class livecd_stage1(StageBase): StageBase.__init__(self, spec, addlargs) def set_action_sequence(self): -self.action_
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/targets/, catalyst/base/
commit: 2c28062446246e246c992ea7084a3950b1337827 Author: Matt Turner gentoo org> AuthorDate: Thu Oct 29 00:32:34 2020 + Commit: Matt Turner gentoo org> CommitDate: Fri Oct 30 22:40:52 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=2c280624 catalyst: Use .extend() and .append() for action_sequence Ensures that we don't overwrite and lose some settings. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py| 6 +++--- catalyst/targets/embedded.py | 4 ++-- catalyst/targets/livecd_stage1.py | 4 ++-- catalyst/targets/livecd_stage2.py | 8 catalyst/targets/netboot.py | 4 ++-- catalyst/targets/stage4.py| 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 801df2fb..46b7c59c 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -478,13 +478,13 @@ class StageBase(TargetBase, ClearBase, GenBase): Or it calls the normal set_action_sequence() for the target stage. """ if "purgeonly" in self.settings["options"]: -self.action_sequence = ["remove_chroot"] +self.action_sequence.append("remove_chroot") return self.set_action_sequence() def set_action_sequence(self): """Set basic stage1, 2, 3 action sequences""" -self.action_sequence = [ +self.action_sequence.extend([ "unpack", "setup_confdir", "portage_overlay", @@ -495,7 +495,7 @@ class StageBase(TargetBase, ClearBase, GenBase): "preclean", "unbind", "clean", -] +]) self.set_completion_action_sequences() def set_completion_action_sequences(self): diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py index 3899cf1b..75eb68e4 100644 --- a/catalyst/targets/embedded.py +++ b/catalyst/targets/embedded.py @@ -41,7 +41,7 @@ class embedded(StageBase): StageBase.__init__(self, spec, addlargs) def set_action_sequence(self): -self.action_sequence = [ +self.action_sequence.extend([ "unpack", "config_profile_link", "setup_confdir", @@ -60,7 +60,7 @@ class embedded(StageBase): "clean", "capture", "clear_autoresume", -] +]) def set_stage_path(self): self.settings["stage_path"] = normpath( diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py index b8c26cb1..9dbfa506 100644 --- a/catalyst/targets/livecd_stage1.py +++ b/catalyst/targets/livecd_stage1.py @@ -23,7 +23,7 @@ class livecd_stage1(StageBase): StageBase.__init__(self, spec, addlargs) def set_action_sequence(self): -self.action_sequence = [ +self.action_sequence.extend([ "unpack", "config_profile_link", "setup_confdir", @@ -34,7 +34,7 @@ class livecd_stage1(StageBase): "build_packages", "unbind", "clean", -] +]) self.set_completion_action_sequences() def set_spec_prefix(self): diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py index cac16b6e..c9b5ce08 100644 --- a/catalyst/targets/livecd_stage2.py +++ b/catalyst/targets/livecd_stage2.py @@ -87,7 +87,7 @@ class livecd_stage2(StageBase): print_traceback=True) def set_action_sequence(self): -self.action_sequence = [ +self.action_sequence.extend([ "unpack", "config_profile_link", "setup_confdir", @@ -97,9 +97,9 @@ class livecd_stage2(StageBase): "setup_environment", "run_local", "build_kernel" -] +]) if "fetch" not in self.settings["options"]: -self.action_sequence += [ +self.action_sequence.extend([ "bootloader", "preclean", "livecd_update", @@ -114,5 +114,5 @@ class livecd_stage2(StageBase): "target_setup", "setup_overlay", "create_iso", -] +]) self.action_sequence.append("clear_autoresume") diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py index 61583f0d..e5c6d43c 100644 --- a/catalyst/targets/netboot.py +++ b/catalyst/targets/netboot.py @@ -160,7 +160,7 @@ class netboot(StageBase): self.resume.enable("empty") def set_action_sequence(self): -self.action_sequence = [ +self.action_sequence.extend([ "unpack", "config_profile_link", "setup_confdir", @@ -179,4 +179,4 @@ class netboot(StageBase): "unbind", "clean", "clear_autoresume", -] +]) dif
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: d9010dead74470b2be148412e5b9ed9cca7a8b45 Author: Matt Turner gentoo org> AuthorDate: Thu Oct 29 13:03:33 2020 + Commit: Matt Turner gentoo org> CommitDate: Fri Oct 30 22:40:52 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=d9010dea catalyst: Factor out run_sequence() This is preparation for the next patch, which will run the build sequence in a separate mount namespace. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 40 +++- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 75c84baa..06ec8727 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -1362,6 +1362,22 @@ class StageBase(TargetBase, ClearBase, GenBase): log.debug('setup_environment(); env = %r', self.env) +def run_sequence(self, sequence): +for func in sequence: +log.notice('--- Running action sequence: %s', func) +sys.stdout.flush() +try: +getattr(self, func)() +except LockInUse: +log.error('Unable to aquire the lock...') +return False +except Exception: +log.error('Exception running action sequence %s', + func, exc_info=True) +return False + +return True + def run(self): self.chroot_lock.write_lock() @@ -1386,26 +1402,16 @@ class StageBase(TargetBase, ClearBase, GenBase): log.info('StageBase: run() purge') self.purge() -failure = False -for x in self.prepare_sequence + self.build_sequence + self.finish_sequence: -log.notice('--- Running action sequence: %s', x) -sys.stdout.flush() -try: -getattr(self, x)() -except LockInUse: -log.error('Unable to aquire the lock...') -failure = True -break -except Exception: -log.error('Exception running action sequence %s', - x, exc_info=True) -failure = True -break +if not self.run_sequence(self.prepare_sequence): +return False -if failure: -log.notice('Cleaning up... Running unbind()') +if not self.run_sequence(self.build_sequence): self.unbind() return False + +if not self.run_sequence(self.finish_sequence): +return False + return True def unmerge(self):
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/targets/, /
commit: d8e3b697d02d170179a87de66a46130c66ccb3b6 Author: Matt Turner gentoo org> AuthorDate: Fri Oct 30 00:31:10 2020 + Commit: Matt Turner gentoo org> CommitDate: Fri Oct 30 00:52:39 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=d8e3b697 wip Signed-off-by: Matt Turner gentoo.org> catalyst/base/__init__.py| 0 catalyst/targets/__init__.py | 0 setup.py | 19 +-- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/catalyst/base/__init__.py b/catalyst/base/__init__.py deleted file mode 100644 index e69de29b.. diff --git a/catalyst/targets/__init__.py b/catalyst/targets/__init__.py deleted file mode 100644 index e69de29b.. diff --git a/setup.py b/setup.py index d807ea02..d2fc3781 100755 --- a/setup.py +++ b/setup.py @@ -1,18 +1,9 @@ #!/usr/bin/env python -from glob import glob - from ppsetuptools import setup -data_files = [ -('/etc/catalyst', ['etc/catalyst.conf', 'etc/catalystrc']), -('/usr/share/man/man1', ['files/catalyst.1']), -('/usr/share/man/man5', - ['files/catalyst-config.5', 'files/catalyst-spec.5'] -), -('share/catalyst/arch', glob('arch/*')), -('share/catalyst/livecd', glob('livecd/**/*', recursive=True)), -('share/catalyst/targets', glob('targets/**', recursive=True)), -] - -setup(data_files=data_files) +setup( +packages=[ +'catalyst', 'catalyst/base', 'catalyst/targets' +], +)
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, /, catalyst/targets/
commit: 1b9f81017f6653480f1e514d1d1c24ba3fa24fdd Author: Matt Turner gentoo org> AuthorDate: Thu Oct 29 23:33:27 2020 + Commit: Matt Turner gentoo org> CommitDate: Fri Oct 30 00:30:31 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=1b9f8101 wip Signed-off-by: Matt Turner gentoo.org> catalyst/base/__init__.py| 0 catalyst/targets/__init__.py | 0 setup.py | 19 --- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/catalyst/base/__init__.py b/catalyst/base/__init__.py deleted file mode 100644 index e69de29b.. diff --git a/catalyst/targets/__init__.py b/catalyst/targets/__init__.py deleted file mode 100644 index e69de29b.. diff --git a/setup.py b/setup.py index d807ea02..02c96dcf 100755 --- a/setup.py +++ b/setup.py @@ -1,18 +1,7 @@ #!/usr/bin/env python -from glob import glob +from ppsetuptools import setup, find_namespace_packages -from ppsetuptools import setup - -data_files = [ -('/etc/catalyst', ['etc/catalyst.conf', 'etc/catalystrc']), -('/usr/share/man/man1', ['files/catalyst.1']), -('/usr/share/man/man5', - ['files/catalyst-config.5', 'files/catalyst-spec.5'] -), -('share/catalyst/arch', glob('arch/*')), -('share/catalyst/livecd', glob('livecd/**/*', recursive=True)), -('share/catalyst/targets', glob('targets/**', recursive=True)), -] - -setup(data_files=data_files) +setup( +packages=find_namespace_packages('catalyst'), +)
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/, /
commit: 79422a5256927c8121cfa296132d8a6dcee4b8e6 Author: Matt Turner gentoo org> AuthorDate: Fri Oct 9 03:47:22 2020 + Commit: Matt Turner gentoo org> CommitDate: Thu Oct 29 22:08:57 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=79422a52 catalyst: Use pyproject.toml See PEPs 517, 518, and (Draft) 621. Signed-off-by: Matt Turner gentoo.org> .gitattributes | 1 - .gitignore | 2 +- AUTHORS | 54 -- MANIFEST.in | 6 --- catalyst/__init__.py | 10 +--- catalyst/main.py | 4 +- catalyst/version.py | 65 -- pyproject.toml | 77 +++ setup.py | 127 ++- 9 files changed, 93 insertions(+), 253 deletions(-) diff --git a/.gitattributes b/.gitattributes index 19ad929b..0b2b43fc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,3 @@ -AUTHORS ident ChangeLog ident README ident TODO ident diff --git a/.gitignore b/.gitignore index 649b79ab..8979e259 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ *.py[co] +/catalyst/version.py /build/ /dist/ /files/ -/MANIFEST diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index 41366b8c.. --- a/AUTHORS +++ /dev/null @@ -1,54 +0,0 @@ -The copyright for catalyst is held by the Gentoo Foundation and by each -of the individual contributors. - - -Original Authors: -- -John Davis -Daniel Robbins - - -Significant contributors (including the first catalyst3 rewrite): -- -Andrew Gaffney -Chris Gianelloni - - -Contributors: -- -Eric Edgar -Andrew Gaffney -Chris Gianelloni -David Bryson -Mike Frysinger -Rob Holland -Robin H. Johnson -Joshua Kinard -Stuart Longland -Guy Martin -Daniel Ostrow -Robert Paskowitz -Diego Pettenò -Matsuu Takuto -Lars Weiler -Gustavo Zacarias -Raúl Porcel -Jorge Manuel B. S. Vicetto -W. Trevor King -Matt Turner -Anthony G. Basile -Ben Kohler -Brian Dolbec -Douglas Freed -Dylan Baker -Jeremy Olexa -Kevin Zhao -Rick Farina (Zero_Chaos) -Sebastian Pipping -Yuta SATOH -William Hubbs - -Maintainers: - -Catalyst maintainers -Release Engineering diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 4274094a.. --- a/MANIFEST.in +++ /dev/null @@ -1,6 +0,0 @@ -include AUTHORS -include ChangeLog -include COPYING -include Makefile -recursive-include doc *.conf *.py HOWTO.txt catalyst*.txt -recursive-include examples README *.example *.spec diff --git a/catalyst/__init__.py b/catalyst/__init__.py index 143bdf81..13a72c07 100644 --- a/catalyst/__init__.py +++ b/catalyst/__init__.py @@ -1,10 +1,2 @@ -"Catalyst is the release building tool used by Gentoo Linux" -__maintainer__ = 'Catalyst ' - -try: -from .verinfo import version as fullversion -__version__ = fullversion.split('\n')[0].split()[1] -except ImportError: -from .version import get_version, __version__ -fullversion = get_version(reset=True) +from .version import version as __version__ diff --git a/catalyst/main.py b/catalyst/main.py index 543895c6..ab5c2a01 100644 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -18,13 +18,11 @@ import catalyst.config from catalyst.defaults import (confdefaults, option_messages, DEFAULT_CONFIG_FILE, valid_config_file_values) from catalyst.support import CatalystError -from catalyst.version import get_version conf_values = confdefaults def version(): -log.info(get_version()) log.info('Copyright 2003-%s Gentoo Foundation', datetime.datetime.now().year) log.info('Copyright 2008-2012 various authors') @@ -118,7 +116,7 @@ def get_parser(): epilog=epilog, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('-V', '--version', -action='version', version=get_version(), +action='version', version=catalyst.__version__, help='display version information') group = parser.add_argument_group('Program output options') diff --git a/catalyst/version.py b/catalyst/version.py deleted file mode 100644 index dbada51a.. --- a/catalyst/version.py +++ /dev/null @@ -1,65 +0,0 @@ -'''Version information and/or git version information -''' - -import os - -from snakeoil.version import get_git_version as get_ver - -__version__ = "3.0.7" -_ver = None - - -def get_git_version(version=__version__): -"""Return: a string describing our version.""" -# pylint: disable=global-statement -global _ver -cwd = os.path.dirname(os.path.abspath(__file__)) -version_info = get_ver(cwd) - -if not version_info: -s = "extended version info unavailable" -elif version_info['tag'] == __version__: -s = 'released %s' % (version_info['date
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/, /
commit: f76d86530bd676051841aef7d1ee958b59812a76 Author: Matt Turner gentoo org> AuthorDate: Fri Oct 9 03:47:22 2020 + Commit: Matt Turner gentoo org> CommitDate: Thu Oct 29 21:51:55 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=f76d8653 catalyst: Use pyproject.toml See PEPs 517, 518, and (Draft) 621. Signed-off-by: Matt Turner gentoo.org> .gitattributes | 1 - .gitignore | 2 +- AUTHORS | 54 -- MANIFEST.in | 6 --- catalyst/__init__.py | 10 +--- catalyst/main.py | 4 +- catalyst/version.py | 65 -- pyproject.toml | 77 +++ setup.py | 127 ++- 9 files changed, 93 insertions(+), 253 deletions(-) diff --git a/.gitattributes b/.gitattributes index 19ad929b..0b2b43fc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,3 @@ -AUTHORS ident ChangeLog ident README ident TODO ident diff --git a/.gitignore b/.gitignore index 649b79ab..8979e259 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ *.py[co] +/catalyst/version.py /build/ /dist/ /files/ -/MANIFEST diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index 41366b8c.. --- a/AUTHORS +++ /dev/null @@ -1,54 +0,0 @@ -The copyright for catalyst is held by the Gentoo Foundation and by each -of the individual contributors. - - -Original Authors: -- -John Davis -Daniel Robbins - - -Significant contributors (including the first catalyst3 rewrite): -- -Andrew Gaffney -Chris Gianelloni - - -Contributors: -- -Eric Edgar -Andrew Gaffney -Chris Gianelloni -David Bryson -Mike Frysinger -Rob Holland -Robin H. Johnson -Joshua Kinard -Stuart Longland -Guy Martin -Daniel Ostrow -Robert Paskowitz -Diego Pettenò -Matsuu Takuto -Lars Weiler -Gustavo Zacarias -Raúl Porcel -Jorge Manuel B. S. Vicetto -W. Trevor King -Matt Turner -Anthony G. Basile -Ben Kohler -Brian Dolbec -Douglas Freed -Dylan Baker -Jeremy Olexa -Kevin Zhao -Rick Farina (Zero_Chaos) -Sebastian Pipping -Yuta SATOH -William Hubbs - -Maintainers: - -Catalyst maintainers -Release Engineering diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 4274094a.. --- a/MANIFEST.in +++ /dev/null @@ -1,6 +0,0 @@ -include AUTHORS -include ChangeLog -include COPYING -include Makefile -recursive-include doc *.conf *.py HOWTO.txt catalyst*.txt -recursive-include examples README *.example *.spec diff --git a/catalyst/__init__.py b/catalyst/__init__.py index 143bdf81..13a72c07 100644 --- a/catalyst/__init__.py +++ b/catalyst/__init__.py @@ -1,10 +1,2 @@ -"Catalyst is the release building tool used by Gentoo Linux" -__maintainer__ = 'Catalyst ' - -try: -from .verinfo import version as fullversion -__version__ = fullversion.split('\n')[0].split()[1] -except ImportError: -from .version import get_version, __version__ -fullversion = get_version(reset=True) +from .version import version as __version__ diff --git a/catalyst/main.py b/catalyst/main.py index 543895c6..ab5c2a01 100644 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -18,13 +18,11 @@ import catalyst.config from catalyst.defaults import (confdefaults, option_messages, DEFAULT_CONFIG_FILE, valid_config_file_values) from catalyst.support import CatalystError -from catalyst.version import get_version conf_values = confdefaults def version(): -log.info(get_version()) log.info('Copyright 2003-%s Gentoo Foundation', datetime.datetime.now().year) log.info('Copyright 2008-2012 various authors') @@ -118,7 +116,7 @@ def get_parser(): epilog=epilog, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('-V', '--version', -action='version', version=get_version(), +action='version', version=catalyst.__version__, help='display version information') group = parser.add_argument_group('Program output options') diff --git a/catalyst/version.py b/catalyst/version.py deleted file mode 100644 index dbada51a.. --- a/catalyst/version.py +++ /dev/null @@ -1,65 +0,0 @@ -'''Version information and/or git version information -''' - -import os - -from snakeoil.version import get_git_version as get_ver - -__version__ = "3.0.7" -_ver = None - - -def get_git_version(version=__version__): -"""Return: a string describing our version.""" -# pylint: disable=global-statement -global _ver -cwd = os.path.dirname(os.path.abspath(__file__)) -version_info = get_ver(cwd) - -if not version_info: -s = "extended version info unavailable" -elif version_info['tag'] == __version__: -s = 'released %s' % (version_info['date
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/, /
commit: f83caf98cbd6e02bd1b8d1f21cd9f8803dd46fb4 Author: Matt Turner gentoo org> AuthorDate: Fri Oct 9 03:47:22 2020 + Commit: Matt Turner gentoo org> CommitDate: Thu Oct 29 21:30:31 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=f83caf98 catalyst: Use pyproject.toml See PEPs 517, 518, and (Draft) 621. Signed-off-by: Matt Turner gentoo.org> .gitattributes | 1 - .gitignore | 2 +- AUTHORS | 54 -- MANIFEST.in | 6 catalyst/__init__.py | 10 +- catalyst/main.py | 4 +-- catalyst/version.py | 65 pyproject.toml | 77 +++ setup.py | 93 +--- 9 files changed, 89 insertions(+), 223 deletions(-) diff --git a/.gitattributes b/.gitattributes index 19ad929b..0b2b43fc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,3 @@ -AUTHORS ident ChangeLog ident README ident TODO ident diff --git a/.gitignore b/.gitignore index 649b79ab..8979e259 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ *.py[co] +/catalyst/version.py /build/ /dist/ /files/ -/MANIFEST diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index 41366b8c.. --- a/AUTHORS +++ /dev/null @@ -1,54 +0,0 @@ -The copyright for catalyst is held by the Gentoo Foundation and by each -of the individual contributors. - - -Original Authors: -- -John Davis -Daniel Robbins - - -Significant contributors (including the first catalyst3 rewrite): -- -Andrew Gaffney -Chris Gianelloni - - -Contributors: -- -Eric Edgar -Andrew Gaffney -Chris Gianelloni -David Bryson -Mike Frysinger -Rob Holland -Robin H. Johnson -Joshua Kinard -Stuart Longland -Guy Martin -Daniel Ostrow -Robert Paskowitz -Diego Pettenò -Matsuu Takuto -Lars Weiler -Gustavo Zacarias -Raúl Porcel -Jorge Manuel B. S. Vicetto -W. Trevor King -Matt Turner -Anthony G. Basile -Ben Kohler -Brian Dolbec -Douglas Freed -Dylan Baker -Jeremy Olexa -Kevin Zhao -Rick Farina (Zero_Chaos) -Sebastian Pipping -Yuta SATOH -William Hubbs - -Maintainers: - -Catalyst maintainers -Release Engineering diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 4274094a.. --- a/MANIFEST.in +++ /dev/null @@ -1,6 +0,0 @@ -include AUTHORS -include ChangeLog -include COPYING -include Makefile -recursive-include doc *.conf *.py HOWTO.txt catalyst*.txt -recursive-include examples README *.example *.spec diff --git a/catalyst/__init__.py b/catalyst/__init__.py index 143bdf81..13a72c07 100644 --- a/catalyst/__init__.py +++ b/catalyst/__init__.py @@ -1,10 +1,2 @@ -"Catalyst is the release building tool used by Gentoo Linux" -__maintainer__ = 'Catalyst ' - -try: -from .verinfo import version as fullversion -__version__ = fullversion.split('\n')[0].split()[1] -except ImportError: -from .version import get_version, __version__ -fullversion = get_version(reset=True) +from .version import version as __version__ diff --git a/catalyst/main.py b/catalyst/main.py index 543895c6..ab5c2a01 100644 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -18,13 +18,11 @@ import catalyst.config from catalyst.defaults import (confdefaults, option_messages, DEFAULT_CONFIG_FILE, valid_config_file_values) from catalyst.support import CatalystError -from catalyst.version import get_version conf_values = confdefaults def version(): -log.info(get_version()) log.info('Copyright 2003-%s Gentoo Foundation', datetime.datetime.now().year) log.info('Copyright 2008-2012 various authors') @@ -118,7 +116,7 @@ def get_parser(): epilog=epilog, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('-V', '--version', -action='version', version=get_version(), +action='version', version=catalyst.__version__, help='display version information') group = parser.add_argument_group('Program output options') diff --git a/catalyst/version.py b/catalyst/version.py deleted file mode 100644 index dbada51a.. --- a/catalyst/version.py +++ /dev/null @@ -1,65 +0,0 @@ -'''Version information and/or git version information -''' - -import os - -from snakeoil.version import get_git_version as get_ver - -__version__ = "3.0.7" -_ver = None - - -def get_git_version(version=__version__): -"""Return: a string describing our version.""" -# pylint: disable=global-statement -global _ver -cwd = os.path.dirname(os.path.abspath(__file__)) -version_info = get_ver(cwd) - -if not version_info: -s = "extended version info unavailable" -elif version_info['tag'] == __version__: -s = 'released
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/, /
commit: 89debce72a0620a8f562207a7e108a2fa9b29d20 Author: Matt Turner gentoo org> AuthorDate: Fri Oct 9 03:47:22 2020 + Commit: Matt Turner gentoo org> CommitDate: Thu Oct 29 20:58:49 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=89debce7 catalyst: Use pyproject.toml See PEPs 517, 518, and (Draft) 621. Signed-off-by: Matt Turner gentoo.org> .gitattributes | 1 - .gitignore | 2 +- AUTHORS | 54 --- MANIFEST.in | 6 --- catalyst/__init__.py | 10 + catalyst/main.py | 4 +- catalyst/version.py | 65 pyproject.toml | 77 + setup.py | 118 +-- 9 files changed, 82 insertions(+), 255 deletions(-) diff --git a/.gitattributes b/.gitattributes index 19ad929b..0b2b43fc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,3 @@ -AUTHORS ident ChangeLog ident README ident TODO ident diff --git a/.gitignore b/.gitignore index 649b79ab..8979e259 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ *.py[co] +/catalyst/version.py /build/ /dist/ /files/ -/MANIFEST diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index 41366b8c.. --- a/AUTHORS +++ /dev/null @@ -1,54 +0,0 @@ -The copyright for catalyst is held by the Gentoo Foundation and by each -of the individual contributors. - - -Original Authors: -- -John Davis -Daniel Robbins - - -Significant contributors (including the first catalyst3 rewrite): -- -Andrew Gaffney -Chris Gianelloni - - -Contributors: -- -Eric Edgar -Andrew Gaffney -Chris Gianelloni -David Bryson -Mike Frysinger -Rob Holland -Robin H. Johnson -Joshua Kinard -Stuart Longland -Guy Martin -Daniel Ostrow -Robert Paskowitz -Diego Pettenò -Matsuu Takuto -Lars Weiler -Gustavo Zacarias -Raúl Porcel -Jorge Manuel B. S. Vicetto -W. Trevor King -Matt Turner -Anthony G. Basile -Ben Kohler -Brian Dolbec -Douglas Freed -Dylan Baker -Jeremy Olexa -Kevin Zhao -Rick Farina (Zero_Chaos) -Sebastian Pipping -Yuta SATOH -William Hubbs - -Maintainers: - -Catalyst maintainers -Release Engineering diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 4274094a.. --- a/MANIFEST.in +++ /dev/null @@ -1,6 +0,0 @@ -include AUTHORS -include ChangeLog -include COPYING -include Makefile -recursive-include doc *.conf *.py HOWTO.txt catalyst*.txt -recursive-include examples README *.example *.spec diff --git a/catalyst/__init__.py b/catalyst/__init__.py index 143bdf81..13a72c07 100644 --- a/catalyst/__init__.py +++ b/catalyst/__init__.py @@ -1,10 +1,2 @@ -"Catalyst is the release building tool used by Gentoo Linux" -__maintainer__ = 'Catalyst ' - -try: -from .verinfo import version as fullversion -__version__ = fullversion.split('\n')[0].split()[1] -except ImportError: -from .version import get_version, __version__ -fullversion = get_version(reset=True) +from .version import version as __version__ diff --git a/catalyst/main.py b/catalyst/main.py index 543895c6..ab5c2a01 100644 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -18,13 +18,11 @@ import catalyst.config from catalyst.defaults import (confdefaults, option_messages, DEFAULT_CONFIG_FILE, valid_config_file_values) from catalyst.support import CatalystError -from catalyst.version import get_version conf_values = confdefaults def version(): -log.info(get_version()) log.info('Copyright 2003-%s Gentoo Foundation', datetime.datetime.now().year) log.info('Copyright 2008-2012 various authors') @@ -118,7 +116,7 @@ def get_parser(): epilog=epilog, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('-V', '--version', -action='version', version=get_version(), +action='version', version=catalyst.__version__, help='display version information') group = parser.add_argument_group('Program output options') diff --git a/catalyst/version.py b/catalyst/version.py deleted file mode 100644 index dbada51a.. --- a/catalyst/version.py +++ /dev/null @@ -1,65 +0,0 @@ -'''Version information and/or git version information -''' - -import os - -from snakeoil.version import get_git_version as get_ver - -__version__ = "3.0.7" -_ver = None - - -def get_git_version(version=__version__): -"""Return: a string describing our version.""" -# pylint: disable=global-statement -global _ver -cwd = os.path.dirname(os.path.abspath(__file__)) -version_info = get_ver(cwd) - -if not version_info: -s = "extended version info unavailable" -elif version_info['tag'] == __version__: -s = 'released %s' % (version_info
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/, catalyst/base/
commit: 4df7daf31c225910ef711aa980e9822c37018ed9 Author: Matt Turner gentoo org> AuthorDate: Sat May 16 21:44:37 2020 + Commit: Matt Turner gentoo org> CommitDate: Wed May 27 06:22:51 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=4df7daf3 catalyst: Add and use support API for handling mounts Handle the mounts/unmounts in all in process rather than shelling out (pun intended!) to an external program. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 28 ++-- catalyst/mount.py | 32 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 00efd252..aa5cafd0 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -15,6 +15,7 @@ from DeComp.compress import CompressMap from catalyst import log from catalyst.defaults import (confdefaults, MOUNT_DEFAULTS, PORT_LOGDIR_CLEAN) +from catalyst.mount import MS, mount, umount from catalyst.support import (CatalystError, file_locate, normpath, cmd, read_makeconf, ismount, file_check) from catalyst.base.targetbase import TargetBase @@ -847,7 +848,9 @@ class StageBase(TargetBase, ClearBase, GenBase): source = str(self.mount[x]['source']) target = self.settings['chroot_path'] + str(self.mount[x]['target']) -mount = ['mount'] +filesystem = '' +flags = MS.NONE +options = '' log.debug('bind %s: "%s" -> "%s"', x, source, target) @@ -855,18 +858,19 @@ class StageBase(TargetBase, ClearBase, GenBase): if 'var_tmpfs_portage' not in self.settings: continue -mount += ['-t', 'tmpfs', '-o', - f"size={self.settings['var_tmpfs_portage']}G"] +filesystem = 'tmpfs' +options = f"size={self.settings['var_tmpfs_portage']}G" elif source == 'tmpfs': -mount += ['-t', 'tmpfs'] +filesystem = 'tmpfs' elif source == 'shm': -mount += ['-t', 'tmpfs', '-o', 'noexec,nosuid,nodev'] +filesystem = 'tmpfs' +flags = MS.NOEXEC | MS.NOSUID | MS.NODEV else: source_path = Path(self.mount[x]['source']) if source_path.suffix == '.sqfs': -mount += ['-o', 'ro'] +flags = MS.RDONLY else: -mount.append('--bind') +flags = MS.BIND # We may need to create the source of the bind mount. E.g., in the # case of an empty package cache we must create the directory that @@ -875,7 +879,11 @@ class StageBase(TargetBase, ClearBase, GenBase): Path(target).mkdir(mode=0o755, parents=True, exist_ok=True) -cmd(mount + [source, target], env=self.env, fail_func=self.unbind) +try: +mount(source, target, filesystem, flags, options) +except OSError as e: +self.unbind() +raise CatalystError def unbind(self): ouch = 0 @@ -893,7 +901,7 @@ class StageBase(TargetBase, ClearBase, GenBase): continue try: -cmd(['umount', target], env=self.env) +umount(target) except CatalystError: log.warning('First attempt to unmount failed: %s', target) log.warning('Killing any pids still running in the chroot') @@ -901,7 +909,7 @@ class StageBase(TargetBase, ClearBase, GenBase): self.kill_chroot_pids() try: -cmd(['umount', target], env=self.env) +umount(target) except CatalystError: ouch = 1 log.warning("Couldn't umount bind mount: %s", target) diff --git a/catalyst/mount.py b/catalyst/mount.py new file mode 100644 index ..21e974b1 --- /dev/null +++ b/catalyst/mount.py @@ -0,0 +1,32 @@ +import ctypes +import ctypes.util +import enum +import os + +libc = ctypes.CDLL(ctypes.util.find_library('c'), use_errno=True) +libc.mount.argtypes = (ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_ulong, ctypes.c_char_p) +libc.umount.argtypes = (ctypes.c_char_p,) + +class MS(enum.IntFlag): +NONE = 0x0 +RDONLY = 0x1 +NOSUID = 0x2 +NODEV = 0x4 +NOEXEC = 0x8 +BIND = 0x1000 + +def mount(source: str, target: str, fs: str, flags: MS = MS.NONE, options: str = '') -> None: +ret = libc.mount(source.encode(), target.encode(), fs.encode(), flags, + options.encode()) +if ret < 0: +errno = ctypes.get_errno() +raise OSError(errno, + f"Error mounting {source} ({fs}) on {t
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/
commit: fcf1829e26eb901354958e92d48f214f2475aff4 Author: Matt Turner gentoo org> AuthorDate: Sat May 16 21:44:37 2020 + Commit: Matt Turner gentoo org> CommitDate: Wed May 27 06:21:10 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=fcf1829e catalyst: Add and use support API for handling mounts Handle the mounts/unmounts in all in process rather than shelling out (pun intended!) to an external program. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 28 ++-- catalyst/mount.py | 32 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 00efd252..aa5cafd0 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -15,6 +15,7 @@ from DeComp.compress import CompressMap from catalyst import log from catalyst.defaults import (confdefaults, MOUNT_DEFAULTS, PORT_LOGDIR_CLEAN) +from catalyst.mount import MS, mount, umount from catalyst.support import (CatalystError, file_locate, normpath, cmd, read_makeconf, ismount, file_check) from catalyst.base.targetbase import TargetBase @@ -847,7 +848,9 @@ class StageBase(TargetBase, ClearBase, GenBase): source = str(self.mount[x]['source']) target = self.settings['chroot_path'] + str(self.mount[x]['target']) -mount = ['mount'] +filesystem = '' +flags = MS.NONE +options = '' log.debug('bind %s: "%s" -> "%s"', x, source, target) @@ -855,18 +858,19 @@ class StageBase(TargetBase, ClearBase, GenBase): if 'var_tmpfs_portage' not in self.settings: continue -mount += ['-t', 'tmpfs', '-o', - f"size={self.settings['var_tmpfs_portage']}G"] +filesystem = 'tmpfs' +options = f"size={self.settings['var_tmpfs_portage']}G" elif source == 'tmpfs': -mount += ['-t', 'tmpfs'] +filesystem = 'tmpfs' elif source == 'shm': -mount += ['-t', 'tmpfs', '-o', 'noexec,nosuid,nodev'] +filesystem = 'tmpfs' +flags = MS.NOEXEC | MS.NOSUID | MS.NODEV else: source_path = Path(self.mount[x]['source']) if source_path.suffix == '.sqfs': -mount += ['-o', 'ro'] +flags = MS.RDONLY else: -mount.append('--bind') +flags = MS.BIND # We may need to create the source of the bind mount. E.g., in the # case of an empty package cache we must create the directory that @@ -875,7 +879,11 @@ class StageBase(TargetBase, ClearBase, GenBase): Path(target).mkdir(mode=0o755, parents=True, exist_ok=True) -cmd(mount + [source, target], env=self.env, fail_func=self.unbind) +try: +mount(source, target, filesystem, flags, options) +except OSError as e: +self.unbind() +raise CatalystError def unbind(self): ouch = 0 @@ -893,7 +901,7 @@ class StageBase(TargetBase, ClearBase, GenBase): continue try: -cmd(['umount', target], env=self.env) +umount(target) except CatalystError: log.warning('First attempt to unmount failed: %s', target) log.warning('Killing any pids still running in the chroot') @@ -901,7 +909,7 @@ class StageBase(TargetBase, ClearBase, GenBase): self.kill_chroot_pids() try: -cmd(['umount', target], env=self.env) +umount(target) except CatalystError: ouch = 1 log.warning("Couldn't umount bind mount: %s", target) diff --git a/catalyst/mount.py b/catalyst/mount.py new file mode 100644 index ..0125353b --- /dev/null +++ b/catalyst/mount.py @@ -0,0 +1,32 @@ +import ctypes +import ctypes.util +import enum +import os + +libc = ctypes.CDLL(ctypes.util.find_library('c'), use_errno=True) +libc.mount.argtypes = (ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_ulong, ctypes.c_char_p) +libc.umount.argtypes = (ctypes.c_char_p) + +class MS(enum.IntFlag): +NONE = 0x0 +RDONLY = 0x1 +NOSUID = 0x2 +NODEV = 0x4 +NOEXEC = 0x8 +BIND = 0x1000 + +def mount(source: str, target: str, fs: str, flags: MS = MS.NONE, options: str = '') -> None: +ret = libc.mount(source.encode(), target.encode(), fs.encode(), flags, + options.encode()) +if ret < 0: +errno = ctypes.get_errno() +raise OSError(errno, + f"Error mounting {source} ({fs}) on {ta
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, targets/support/
commit: 576cbab37a1a6a52b9409c2bf0dfa81c5e36e947 Author: Matt Turner gentoo org> AuthorDate: Thu May 21 22:37:29 2020 + Commit: Matt Turner gentoo org> CommitDate: Wed May 27 06:21:10 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=576cbab3 catalyst: Clean up unbind() function Does a couple of things: - drops log.notice -> log.warning - Removes the kill_chroot_pids support code since namespaces? Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 45 +++ targets/support/kill-chroot-pids.sh | 62 - 2 files changed, 12 insertions(+), 95 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index aa5cafd0..d92f3ffb 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -625,17 +625,6 @@ class StageBase(TargetBase, ClearBase, GenBase): assert self.settings[verify] == "blake2" self.settings.setdefault("gk_mainargs", []).append("--b2sum") -def kill_chroot_pids(self): -log.info('Checking for processes running in chroot and killing them.') - -# Force environment variables to be exported so script can see them -self.setup_environment() - -killcmd = normpath(self.settings["sharedir"] + - self.settings["shdir"] + "/support/kill-chroot-pids.sh") -if os.path.exists(killcmd): -cmd([killcmd], env=self.env) - def mount_safety_check(self): """ Check and verify that none of our paths in mypath are mounted. We don't @@ -886,35 +875,28 @@ class StageBase(TargetBase, ClearBase, GenBase): raise CatalystError def unbind(self): -ouch = 0 -mypath = self.settings["chroot_path"] +chroot_path = self.settings["chroot_path"] +umount_failed = False # Unmount in reverse order -for x in [x for x in reversed(self.mount) if self.mount[x]['enable']]: -target = normpath(mypath + self.mount[x]['target']) -if not os.path.exists(target): -log.notice('%s does not exist. Skipping', target) +for target in [Path(chroot_path + self.mount[x]['target']) + for x in reversed(self.mount) + if self.mount[x]['enable']]: +if not target.exists(): +log.debug('%s does not exist. Skipping', target) continue if not ismount(target): -log.notice('%s is not a mount point. Skipping', target) +log.debug('%s is not a mount point. Skipping', target) continue try: umount(target) -except CatalystError: -log.warning('First attempt to unmount failed: %s', target) -log.warning('Killing any pids still running in the chroot') - -self.kill_chroot_pids() - -try: -umount(target) -except CatalystError: -ouch = 1 -log.warning("Couldn't umount bind mount: %s", target) +except OSError as e: +log.warning("Couldn't umount bind mount: %s", target) +umount_failed = True -if ouch: +if umount_failed: # if any bind mounts really failed, then we need to raise # this to potentially prevent an upcoming bash stage cleanup script # from wiping our bind mounts. @@ -1307,9 +1289,6 @@ class StageBase(TargetBase, ClearBase, GenBase): def run(self): self.chroot_lock.write_lock() -# Kill any pids in the chroot -self.kill_chroot_pids() - # Check for mounts right away and abort if we cannot unmount them self.mount_safety_check() diff --git a/targets/support/kill-chroot-pids.sh b/targets/support/kill-chroot-pids.sh deleted file mode 100755 index ea8ee402.. --- a/targets/support/kill-chroot-pids.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash -# Script to kill processes found running in the chroot. - -if [ "${clst_chroot_path}" == "/" ] -then - echo "Aborting clst_chroot_path is set to /" - echo "This is very dangerous" - exit 1 -fi - -if [ "${clst_chroot_path}" == "" ] -then - echo "Aborting clst_chroot_path is NOT set" - echo "This is very dangerous" - exit 1 -fi - -j=0 -declare -a pids -# Get files and dirs in /proc -for i in `ls /proc` -do - # Test for directories - if [ -d /proc/$i ] - then - # Search for exe containing string inside ${clst_chroot_path} - ls -la --color=never /proc/$i 2>&1 |grep exe|grep ${clst_chroot_path} > /dev/null - - # If found - if [ $? == 0 ] - then - # Assign the pid into the pids array - pids[$
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/
commit: b11d30977dd90954357722f488e37ad3cd257ff4 Author: Matt Turner gentoo org> AuthorDate: Sat May 16 21:44:37 2020 + Commit: Matt Turner gentoo org> CommitDate: Thu May 21 22:07:41 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=b11d3097 catalyst: Add and use support API for handling mounts Handle the mounts/unmounts in all in process rather than shelling out (pun intended!) to an external program. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 28 ++-- catalyst/mount.py | 32 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 00efd252..aa5cafd0 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -15,6 +15,7 @@ from DeComp.compress import CompressMap from catalyst import log from catalyst.defaults import (confdefaults, MOUNT_DEFAULTS, PORT_LOGDIR_CLEAN) +from catalyst.mount import MS, mount, umount from catalyst.support import (CatalystError, file_locate, normpath, cmd, read_makeconf, ismount, file_check) from catalyst.base.targetbase import TargetBase @@ -847,7 +848,9 @@ class StageBase(TargetBase, ClearBase, GenBase): source = str(self.mount[x]['source']) target = self.settings['chroot_path'] + str(self.mount[x]['target']) -mount = ['mount'] +filesystem = '' +flags = MS.NONE +options = '' log.debug('bind %s: "%s" -> "%s"', x, source, target) @@ -855,18 +858,19 @@ class StageBase(TargetBase, ClearBase, GenBase): if 'var_tmpfs_portage' not in self.settings: continue -mount += ['-t', 'tmpfs', '-o', - f"size={self.settings['var_tmpfs_portage']}G"] +filesystem = 'tmpfs' +options = f"size={self.settings['var_tmpfs_portage']}G" elif source == 'tmpfs': -mount += ['-t', 'tmpfs'] +filesystem = 'tmpfs' elif source == 'shm': -mount += ['-t', 'tmpfs', '-o', 'noexec,nosuid,nodev'] +filesystem = 'tmpfs' +flags = MS.NOEXEC | MS.NOSUID | MS.NODEV else: source_path = Path(self.mount[x]['source']) if source_path.suffix == '.sqfs': -mount += ['-o', 'ro'] +flags = MS.RDONLY else: -mount.append('--bind') +flags = MS.BIND # We may need to create the source of the bind mount. E.g., in the # case of an empty package cache we must create the directory that @@ -875,7 +879,11 @@ class StageBase(TargetBase, ClearBase, GenBase): Path(target).mkdir(mode=0o755, parents=True, exist_ok=True) -cmd(mount + [source, target], env=self.env, fail_func=self.unbind) +try: +mount(source, target, filesystem, flags, options) +except OSError as e: +self.unbind() +raise CatalystError def unbind(self): ouch = 0 @@ -893,7 +901,7 @@ class StageBase(TargetBase, ClearBase, GenBase): continue try: -cmd(['umount', target], env=self.env) +umount(target) except CatalystError: log.warning('First attempt to unmount failed: %s', target) log.warning('Killing any pids still running in the chroot') @@ -901,7 +909,7 @@ class StageBase(TargetBase, ClearBase, GenBase): self.kill_chroot_pids() try: -cmd(['umount', target], env=self.env) +umount(target) except CatalystError: ouch = 1 log.warning("Couldn't umount bind mount: %s", target) diff --git a/catalyst/mount.py b/catalyst/mount.py new file mode 100644 index ..58b953fc --- /dev/null +++ b/catalyst/mount.py @@ -0,0 +1,32 @@ +import ctypes +import ctypes.util +import enum +import os + +libc = ctypes.CDLL(ctypes.util.find_library('c'), use_errno=True) +libc.mount.argtypes = (ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_ulong, ctypes.c_char_p) +libc.umount.argtypes = (ctypes.c_char_p) + +class MS(enum.IntFlag): +NONE = 0x0 +RDONLY = 0x1 +NOSUID = 0x2 +NODEV = 0x4 +NOEXEC = 0x8 +BIND = 0x1000 + +def mount(source: str, target: str, fs: str, flags: MS = MS.NONE, options: str = '') -> None: +ret = libc.mount(source.encode(), target.encode(), fs.encode(), flags, + options.encode()) +if ret < 0: +errno = ctypes.get_errno() +raise OSError(errno, + f"Error mounting {source} ({fs}) on {ta
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/
commit: 103ae1aaa8a363b0cf2abb667ed13c624b3c431a Author: Matt Turner gentoo org> AuthorDate: Tue May 19 19:14:29 2020 + Commit: Matt Turner gentoo org> CommitDate: Wed May 20 03:39:21 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=103ae1aa catalyst: Drop ConfigParser Signed-off-by: Matt Turner gentoo.org> catalyst/config.py | 11 --- 1 file changed, 11 deletions(-) diff --git a/catalyst/config.py b/catalyst/config.py index b527ada0..e1963f71 100644 --- a/catalyst/config.py +++ b/catalyst/config.py @@ -118,14 +118,3 @@ class SpecParser(ParserBase): def __init__(self, filename=""): if filename: self.parse_file(filename) - - -class ConfigParser(ParserBase): - -key_value_separator = '=' -multiple_values = False -empty_values = True - -def __init__(self, filename=""): -if filename: -self.parse_file(filename)
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: ff0b574a509e9b2796d25dabdcfb473ffa673fd1 Author: Matt Turner gentoo org> AuthorDate: Wed May 20 02:26:52 2020 + Commit: Matt Turner gentoo org> CommitDate: Wed May 20 03:15:02 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=ff0b574a catalyst: Support emitting int/float envars Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 645a9f61..5a8cd1df 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -1283,6 +1283,8 @@ class StageBase(TargetBase, ClearBase, GenBase): elif isinstance(self.settings[x], bool): if self.settings[x]: self.env[varname] = "true" +elif isinstance(self.settings[x], (int, float)): +self.env[varname] = str(self.settings[x]) elif isinstance(self.settings[x], dict): if x in ['compress_definitions', 'decompress_definitions']: continue
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: d97ef9d0879cc935258f5d30b84dd31d464abc9f Author: Matt Turner gentoo org> AuthorDate: Wed May 20 02:55:15 2020 + Commit: Matt Turner gentoo org> CommitDate: Wed May 20 02:58:07 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=d97ef9d0 catalyst: Don't even try to make envars from dicts With the removal of the arch modules (presumably), the two exceptions (compress_definitions and decompress_definitions) are the only dicts in self.settings. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 22 ++ 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 9410f151..8e2b08da 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -1285,28 +1285,10 @@ class StageBase(TargetBase, ClearBase, GenBase): self.env[varname] = "true" else: self.env[varname] = "false" -# This handles a dictionary of objects just one level deep and no deeper! -# Its currently used only for USE_EXPAND flags which are dictionaries of -# lists in arch/amd64.py and friends. If we wanted self.settigs[var] -# of any depth, we should make this function recursive. elif isinstance(self.settings[x], dict): -if x in ["compress_definitions", - "decompress_definitions"]: +if x in ['compress_definitions', 'decompress_definitions']: continue -self.env[varname] = ' '.join(self.settings[x].keys()) -for y in self.settings[x].keys(): -varname2 = "clst_" + y.replace("/", "_") -varname2 = varname2.replace("-", "_") -varname2 = varname2.replace(".", "_") -if isinstance(self.settings[x][y], str): -self.env[varname2] = self.settings[x][y] -elif isinstance(self.settings[x][y], list): -self.env[varname2] = ' '.join(self.settings[x][y]) -elif isinstance(self.settings[x][y], bool): -if self.settings[x][y]: -self.env[varname] = "true" -else: -self.env[varname] = "false" +log.warning("Not making envar for '%s', is a dict", x) if "makeopts" in self.settings: if isinstance(self.settings["makeopts"], str):
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/
commit: 3d3a1b1b23adff8d97ca746c10d97bb4a02f88bb Author: Matt Turner gentoo org> AuthorDate: Tue May 19 19:14:29 2020 + Commit: Matt Turner gentoo org> CommitDate: Wed May 20 02:33:46 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=3d3a1b1b catalyst: Drop ConfigParser Signed-off-by: Matt Turner gentoo.org> catalyst/config.py | 11 --- 1 file changed, 11 deletions(-) diff --git a/catalyst/config.py b/catalyst/config.py index b527ada0..e1963f71 100644 --- a/catalyst/config.py +++ b/catalyst/config.py @@ -118,14 +118,3 @@ class SpecParser(ParserBase): def __init__(self, filename=""): if filename: self.parse_file(filename) - - -class ConfigParser(ParserBase): - -key_value_separator = '=' -multiple_values = False -empty_values = True - -def __init__(self, filename=""): -if filename: -self.parse_file(filename)
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/, etc/, catalyst/base/, targets/support/, doc/
commit: 96cc906860f38bf015b0fa0ea3cd9d256e73b568 Author: Matt Turner gentoo org> AuthorDate: Thu May 14 02:37:11 2020 + Commit: Matt Turner gentoo org> CommitDate: Wed May 20 02:33:46 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=96cc9068 catalyst: Set jobs/load-average via catalyst.conf We currently have two mechanisms of setting MAKEOPTS: in spec files and in catalystrc. Setting makeopts in spec files doesn't make sense. The spec should describe the thing that's being built and not contain options that are specific to the build system. Setting makeopts via catalystrc is better, but it only applies to the actual build system invocations, leaving emerge to run jobs serially or again requiring configuration specific to the build machine to be put into the spec file. For example: update_seed_command: ... --jobs 5 --load-average 5 With jobs and load-average specified in catalyst.conf, catalyst has the information required to configure both emerge and the build systems emerge executes. This removes the undocumented makeopts spec file option and replaces it with jobs and load-average settings in catalyst.conf. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 12 +--- catalyst/defaults.py| 2 ++ doc/catalyst-config.5.txt | 15 --- etc/catalystrc | 3 --- targets/support/chroot-functions.sh | 8 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 9ea72b48..9506e6b3 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -56,7 +56,6 @@ class StageBase(TargetBase, ClearBase, GenBase): "hostuse", "kerncache_path", "ldflags", -"makeopts", "pkgcache_path", "portage_confdir", "portage_overlay", @@ -1305,12 +1304,11 @@ class StageBase(TargetBase, ClearBase, GenBase): else: self.env[varname] = "false" -if "makeopts" in self.settings: -if isinstance(self.settings["makeopts"], str): -self.env["MAKEOPTS"] = self.settings["makeopts"] -else: -# ensure makeopts is a string -self.env["MAKEOPTS"] = ' '.join(self.settings["makeopts"]) +makeopts = [] +for flag, setting in {'j': 'jobs', 'l': 'load-average'}.items(): +if setting in self.settings: +makeopts.append(f'-{flag}{self.settings[setting]}') +self.env['MAKEOPTS'] = ' '.join(makeopts) log.debug('setup_environment(); env = %r', self.env) diff --git a/catalyst/defaults.py b/catalyst/defaults.py index 14f671fe..b31d5b50 100644 --- a/catalyst/defaults.py +++ b/catalyst/defaults.py @@ -12,6 +12,8 @@ valid_config_file_values = frozenset([ "digests", "distdir", "envscript", +"jobs", +"load-average", "options", "port_logdir", "repo_basedir", diff --git a/doc/catalyst-config.5.txt b/doc/catalyst-config.5.txt index 7ac9a2a3..cbef6092 100644 --- a/doc/catalyst-config.5.txt +++ b/doc/catalyst-config.5.txt @@ -48,9 +48,9 @@ $ python3 -c 'import hashlib; print(hashlib.algorithms_available)' *envscript*:: Environment script location, which allows users to set options such as -HTTP proxies, `MAKEOPTS`, `GENTOO_MIRRORS`, or any other environment -variables needed for building. The envscript file sets environment -variables using POSIX shell notation: +HTTP proxies, `GENTOO_MIRRORS`, or any other environment variables +needed for building. The envscript file sets environment variables +using POSIX shell notation: + - export FOO="bar" @@ -136,6 +136,15 @@ written to the target's make.conf if it is not the default value of Other settings ~~ +*jobs*:: +Integral value passed to *emerge(1)* as the parameter to --jobs and is +used to define *MAKEOPTS* during the target build. + +*load-average*:: +Floating-point value passed to *emerge(1)* as the parameter to +--load-average and is used to define *MAKEOPTS* during the target +build. + *sharedir*:: Catalyst runtime script location. `/usr/share/catalyst` should work for most default installations. If you are running catalyst from a Git diff --git a/etc/catalystrc b/etc/catalystrc index bcd729af..e7904128 100755 --- a/etc/catalystrc +++ b/etc/catalystrc @@ -1,5 +1,2 @@ #!/bin/bash # This is an example catalystrc. As such, it doesn't actually *do* anything. - -# Uncomment the following to increase the number of threads used to compile. -# export MAKEOPTS="-j16" diff --git a/targets/support/chroot-functions.sh b/targets/support/chroot-functions.sh index 47239b96..d4c50983 100755 --- a/targets/support/chroot-functions.sh +++ b/targets/support/chroot-functions.sh @@ -130,6 +130,14 @@ setup_emerge_o
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/
commit: 200c12f64d3ed28747e8498ede15cbbacf9af6bf Author: Matt Turner gentoo org> AuthorDate: Tue May 19 19:14:29 2020 + Commit: Matt Turner gentoo org> CommitDate: Wed May 20 02:29:23 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=200c12f6 catalyst: Drop ConfigParser Signed-off-by: Matt Turner gentoo.org> catalyst/config.py | 11 --- 1 file changed, 11 deletions(-) diff --git a/catalyst/config.py b/catalyst/config.py index b527ada0..e1963f71 100644 --- a/catalyst/config.py +++ b/catalyst/config.py @@ -118,14 +118,3 @@ class SpecParser(ParserBase): def __init__(self, filename=""): if filename: self.parse_file(filename) - - -class ConfigParser(ParserBase): - -key_value_separator = '=' -multiple_values = False -empty_values = True - -def __init__(self, filename=""): -if filename: -self.parse_file(filename)
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: 4ce21a9b855a20d8391f4d1aa866e76f01c51397 Author: Matt Turner gentoo org> AuthorDate: Wed May 20 02:26:52 2020 + Commit: Matt Turner gentoo org> CommitDate: Wed May 20 02:29:23 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=4ce21a9b catalyst: Support emitting int/float envars Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index e87f181d..9ea72b48 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -1280,7 +1280,7 @@ class StageBase(TargetBase, ClearBase, GenBase): self.env[varname] = self.settings[x] elif isinstance(self.settings[x], list): self.env[varname] = ' '.join(self.settings[x]) -elif isinstance(self.settings[x], bool): +elif isinstance(self.settings[x], (int, float, bool)): self.env[varname] = str(self.settings[x]) # This handles a dictionary of objects just one level deep and no deeper! # Its currently used only for USE_EXPAND flags which are dictionaries of
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/, etc/
commit: 66e78a8d55d0ab99b48c7fe7a327aab9b05b2586 Author: Matt Turner gentoo org> AuthorDate: Sat May 16 03:18:21 2020 + Commit: Matt Turner gentoo org> CommitDate: Wed May 20 01:49:37 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=66e78a8d catalyst: Convert catalyst.conf to TOML Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 4 +-- catalyst/main.py | 47 +++-- etc/catalyst.conf | 88 +++--- 3 files changed, 67 insertions(+), 72 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index febaf969..9410f151 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -857,8 +857,8 @@ class StageBase(TargetBase, ClearBase, GenBase): if 'var_tmpfs_portage' not in self.settings: continue -mount += ['-t', 'tmpfs', '-o', 'size=' + - self.settings['var_tmpfs_portage'] + 'G'] +mount += ['-t', 'tmpfs', '-o', + f"size={self.settings['var_tmpfs_portage']}G"] elif source == 'tmpfs': mount += ['-t', 'tmpfs'] elif source == 'shm': diff --git a/catalyst/main.py b/catalyst/main.py index be06ccd7..159fe454 100644 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -5,6 +5,8 @@ import os import sys import textwrap +import toml + from snakeoil.process import namespaces from DeComp.definitions import (COMPRESS_DEFINITIONS, DECOMPRESS_DEFINITIONS, @@ -17,8 +19,7 @@ from catalyst.defaults import confdefaults, option_messages, DEFAULT_CONFIG_FILE from catalyst.support import CatalystError from catalyst.version import get_version - -conf_values = {} +conf_values = confdefaults def version(): @@ -30,42 +31,20 @@ def version(): def parse_config(config_files): -# search a couple of different areas for the main config file -myconf = {} - -# try and parse the config file "config_file" for config_file in config_files: log.notice('Loading configuration file: %s', config_file) try: -config = catalyst.config.ConfigParser(config_file) -myconf.update(config.get_values()) +conf_values.update(toml.load(config_file)) except Exception as e: log.critical('Could not find parse configuration file: %s: %s', config_file, e) -# now, load up the values into conf_values so that we can use them -for x in list(confdefaults): -if x in myconf: -if x == 'options': -conf_values[x] = set(myconf[x].split()) -elif x in ["decompressor_search_order"]: -conf_values[x] = myconf[x].split() -else: -conf_values[x] = myconf[x] -else: -conf_values[x] = confdefaults[x] - # print out any options messages for opt in conf_values['options']: if opt in option_messages: log.info(option_messages[opt]) -for key in ["digests", "envscript", "var_tmpfs_portage", "port_logdir", -"local_overlay", "repos"]: -if key in myconf: -conf_values[key] = myconf[key] - -if "envscript" in myconf: +if "envscript" in conf_values: log.info('Envscript support enabled.') # take care of any variable substitutions that may be left @@ -297,17 +276,17 @@ def _main(parser, opts): conf_values['DEBUG'] = opts.debug conf_values['VERBOSE'] = opts.debug or opts.verbose -options = set() +options = [] if opts.fetchonly: -options.add('fetch') +options.append('fetch') if opts.purge: -options.add('purge') +options.append('purge') if opts.purgeonly: -options.add('purgeonly') +options.append('purgeonly') if opts.purgetmponly: -options.add('purgetmponly') +options.append('purgetmponly') if opts.clear_autoresume: -options.add('clear-autoresume') +options.append('clear-autoresume') # Make sure we have some work before moving further. if not myspecfile and not mycmdline: @@ -318,7 +297,7 @@ def _main(parser, opts): # import configuration file and import our main module using those settings parse_config(myconfigs) -conf_values["options"].update(options) +conf_values["options"].extend(options) log.notice('conf_values[options] = %s', conf_values['options']) # initialize our contents generator @@ -335,7 +314,7 @@ def _main(parser, opts): if "digests" in conf_values: valid_digests = hashlib.algorithms_available -digests = set(conf_values['digests'].split()) +digests = set(conf_values['digests']) conf_values['digests'] = digests # First validate all the requested digests are valid keys. diff --git
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/
commit: 6ed67c24fe3bb8e3baa8c936249e4507c45f86a2 Author: Matt Turner gentoo org> AuthorDate: Mon May 18 23:48:22 2020 + Commit: Matt Turner gentoo org> CommitDate: Wed May 20 01:49:37 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=6ed67c24 catalyst: Remove spec file options from valid_config_file_values Signed-off-by: Matt Turner gentoo.org> catalyst/defaults.py | 5 - 1 file changed, 5 deletions(-) diff --git a/catalyst/defaults.py b/catalyst/defaults.py index ccabd88d..2f2c907f 100644 --- a/catalyst/defaults.py +++ b/catalyst/defaults.py @@ -17,12 +17,7 @@ required_config_file_values = [ valid_config_file_values = required_config_file_values[:] valid_config_file_values.extend([ -"compression_mode", -"compressor_arch", -"compressor_options", -"decompressor_search_order", "digests", -"distcc", "envscript", "options", ])
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/
commit: f40238e0c5644db5dcaaab9f0305cc9d62b144a1 Author: Matt Turner gentoo org> AuthorDate: Mon May 18 22:52:36 2020 + Commit: Matt Turner gentoo org> CommitDate: Wed May 20 01:49:37 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=f40238e0 catalyst: Remove PythonDir setting Was used to find the arch directory containing, e.g., sparc.py, but all that code is gone now after the modules were converted to TOML. Signed-off-by: Matt Turner gentoo.org> catalyst/defaults.py | 1 - catalyst/main.py | 3 --- 2 files changed, 4 deletions(-) diff --git a/catalyst/defaults.py b/catalyst/defaults.py index 404f4892..f6bc1e14 100644 --- a/catalyst/defaults.py +++ b/catalyst/defaults.py @@ -64,7 +64,6 @@ confdefaults = { "options": set(), "pkgdir": "/var/cache/binpkgs", "port_tmpdir": "/var/tmp/portage", -"PythonDir": "./catalyst", "repo_basedir": "/var/db/repos", "repo_name": "gentoo", "repos": "%(storedir)s/repos", diff --git a/catalyst/main.py b/catalyst/main.py index bad712fa..b01d7a6a 100644 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -55,9 +55,6 @@ def parse_config(config_files): else: conf_values[x] = confdefaults[x] -# add our python base directory to use for loading target arch's -conf_values["PythonDir"] = os.path.dirname(os.path.realpath(__file__)) - # print out any options messages for opt in conf_values['options']: if opt in option_messages:
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/
commit: 3b721ac38a6d86c952e8d65e0bba942aa49a3628 Author: Matt Turner gentoo org> AuthorDate: Mon May 18 22:41:54 2020 + Commit: Matt Turner gentoo org> CommitDate: Wed May 20 01:49:37 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=3b721ac3 catalyst: Switch internal snapshot option parsing to SpecParser The --snapshot/-s option internally creates a .spec file but uses the ConfigParser (nominally used for parsing catalyst.conf) rather than SpecParser (used for parsing .spec files) and as a result has to use '=' rather than ':' as the key/value delimiter. Signed-off-by: Matt Turner gentoo.org> catalyst/main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/catalyst/main.py b/catalyst/main.py index b01d7a6a..be06ccd7 100644 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -291,8 +291,8 @@ def _main(parser, opts): mycmdline = list() if opts.snapshot: -mycmdline.append('target=snapshot') -mycmdline.append('snapshot_treeish=' + opts.snapshot) +mycmdline.append('target: snapshot') +mycmdline.append('snapshot_treeish: ' + opts.snapshot) conf_values['DEBUG'] = opts.debug conf_values['VERBOSE'] = opts.debug or opts.verbose @@ -354,7 +354,7 @@ def _main(parser, opts): if mycmdline: try: -cmdline = catalyst.config.ConfigParser() +cmdline = catalyst.config.SpecParser() cmdline.parse_lines(mycmdline) addlargs.update(cmdline.get_values()) except CatalystError:
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/
commit: f300760bd89aef89810c3ebf6570df1ccd3379c2 Author: Matt Turner gentoo org> AuthorDate: Tue May 19 19:14:29 2020 + Commit: Matt Turner gentoo org> CommitDate: Wed May 20 01:52:18 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=f300760b catalyst: Drop ConfigParser Signed-off-by: Matt Turner gentoo.org> catalyst/config.py | 11 --- 1 file changed, 11 deletions(-) diff --git a/catalyst/config.py b/catalyst/config.py index b527ada0..e1963f71 100644 --- a/catalyst/config.py +++ b/catalyst/config.py @@ -118,14 +118,3 @@ class SpecParser(ParserBase): def __init__(self, filename=""): if filename: self.parse_file(filename) - - -class ConfigParser(ParserBase): - -key_value_separator = '=' -multiple_values = False -empty_values = True - -def __init__(self, filename=""): -if filename: -self.parse_file(filename)
[gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/
commit: 6bacd678bab3be95318fe4dcd432ad627a3f2b3e Author: Matt Turner gentoo org> AuthorDate: Wed May 20 00:23:42 2020 + Commit: Matt Turner gentoo org> CommitDate: Wed May 20 01:49:37 2020 + URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=6bacd678 catalyst: Add decompressor_search_order as valid spec option The next commit is going to remove this from the list of valid config file options, where it should not be, and that list currently is used to populate the list of valid spec options. Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 1 + 1 file changed, 1 insertion(+) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 0c311515..f39895fe 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -49,6 +49,7 @@ class StageBase(TargetBase, ClearBase, GenBase): "common_flags", "compression_mode", "cxxflags", +"decompressor_search_order", "distcc_hosts", "fcflags", "fflags",