From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 5492413835A for ; Thu, 28 Jan 2021 01:54:59 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5DB8EE09AB; Thu, 28 Jan 2021 01:54:58 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 3B316E09AB for ; Thu, 28 Jan 2021 01:54:58 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id F25CD3410A7 for ; Thu, 28 Jan 2021 01:54:56 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 5840E4AA for ; Thu, 28 Jan 2021 01:54:55 +0000 (UTC) From: "Matt Turner" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Turner" Message-ID: <1611418747.440a379ae94e6d7df26291bf83657288d1406e98.mattst88@gentoo> Subject: [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, catalyst/targets/ X-VCS-Repository: proj/catalyst X-VCS-Files: catalyst/base/stagebase.py catalyst/targets/embedded.py catalyst/targets/livecd_stage1.py catalyst/targets/livecd_stage2.py catalyst/targets/netboot.py catalyst/targets/stage1.py catalyst/targets/stage4.py X-VCS-Directories: catalyst/targets/ catalyst/base/ X-VCS-Committer: mattst88 X-VCS-Committer-Name: Matt Turner X-VCS-Revision: 440a379ae94e6d7df26291bf83657288d1406e98 X-VCS-Branch: pending/mattst88 Date: Thu, 28 Jan 2021 01:54:55 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: b3ef71c6-4f93-4c9d-a60d-a6c5295cce8a X-Archives-Hash: 022a782a42dc168c25a92c7511c51815 commit: 440a379ae94e6d7df26291bf83657288d1406e98 Author: Matt Turner gentoo org> AuthorDate: Sun Jan 17 23:53:21 2021 +0000 Commit: Matt Turner gentoo org> CommitDate: Sat Jan 23 16:19:07 2021 +0000 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=440a379a 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): 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, + self.portage_overlay, ]) self.build_sequence.extend([ - "bind", - "chroot_setup", - "setup_environment", - "build_kernel", - "build_packages", - "root_overlay", - "fsscript", - "unmerge", + self.bind, + self.chroot_setup, + self.setup_environment, + self.build_kernel, + self.build_packages, + self.root_overlay, + self.fsscript, + self.unmerge, ]) self.finish_sequence.extend([ - "remove", - "empty", - "clean", - "capture", - "clear_autoresume", + self.remove, + self.empty, + self.clean, + self.capture, + self.clear_autoresume, ]) def set_root_path(self): diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py index 5c5e9f58..eb6bb0f0 100644 --- a/catalyst/targets/livecd_stage1.py +++ b/catalyst/targets/livecd_stage1.py @@ -24,19 +24,19 @@ class livecd_stage1(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, + self.portage_overlay, ]) self.build_sequence.extend([ - "bind", - "chroot_setup", - "setup_environment", - "build_packages", + self.bind, + self.chroot_setup, + self.setup_environment, + self.build_packages, ]) self.finish_sequence.extend([ - "clean", + self.clean, ]) self.set_completion_action_sequences() diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py index 3606047f..5fecff85 100644 --- a/catalyst/targets/livecd_stage2.py +++ b/catalyst/targets/livecd_stage2.py @@ -87,34 +87,34 @@ class livecd_stage2(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, + self.portage_overlay, ]) self.build_sequence.extend([ - "bind", - "chroot_setup", - "setup_environment", - "run_local", - "build_kernel" + self.bind, + self.chroot_setup, + self.setup_environment, + self.run_local, + self.build_kernel ]) if "fetch" not in self.settings["options"]: self.build_sequence.extend([ - "bootloader", - "preclean", - "livecd_update", - "root_overlay", - "fsscript", - "rcupdate", - "unmerge", + self.bootloader, + self.preclean, + self.livecd_update, + self.root_overlay, + self.fsscript, + self.rcupdate, + self.unmerge, ]) self.finish_sequence.extend([ - "remove", - "empty", - "clean", - "target_setup", - "setup_overlay", - "create_iso", + self.remove, + self.empty, + self.clean, + self.target_setup, + self.setup_overlay, + self.create_iso, ]) - self.finish_sequence.append("clear_autoresume") + self.finish_sequence.append(self.clear_autoresume) diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py index 55f4dff1..9a7e59e5 100644 --- a/catalyst/targets/netboot.py +++ b/catalyst/targets/netboot.py @@ -159,25 +159,25 @@ class netboot(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, + self.portage_overlay, ]) self.build_sequence.extend([ - "bind", - "chroot_setup", - "setup_environment", - "build_packages", - "root_overlay", - "copy_files_to_image", - "setup_overlay", - "build_kernel", - "move_kernels", - "remove", - "empty", + self.bind, + self.chroot_setup, + self.setup_environment, + self.build_packages, + self.root_overlay, + self.copy_files_to_image, + self.setup_overlay, + self.build_kernel, + self.move_kernels, + self.remove, + self.empty, ]) self.finish_sequence.extend([ - "clean", - "clear_autoresume", + self.clean, + self.clear_autoresume, ]) diff --git a/catalyst/targets/stage1.py b/catalyst/targets/stage1.py index 5aa27bb9..5a154e76 100644 --- a/catalyst/targets/stage1.py +++ b/catalyst/targets/stage1.py @@ -82,15 +82,15 @@ class stage1(StageBase): chroot for re-use in stage2 without the need to unpack it. ''' 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("clean_stage1") + self.finish_sequence.append(self.remove_autoresume) + self.finish_sequence.append(self.clean_stage1) 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 clean_stage1(self): '''seedcache is enabled, so salvage the /tmp/stage1root, diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py index b7f74b01..997139a5 100644 --- a/catalyst/targets/stage4.py +++ b/catalyst/targets/stage4.py @@ -40,27 +40,27 @@ class stage4(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, + self.portage_overlay, ]) self.build_sequence.extend([ - "bind", - "chroot_setup", - "setup_environment", - "build_packages", - "build_kernel", - "bootloader", - "root_overlay", - "fsscript", - "preclean", - "rcupdate", - "unmerge", + self.bind, + self.chroot_setup, + self.setup_environment, + self.build_packages, + self.build_kernel, + self.bootloader, + self.root_overlay, + self.fsscript, + self.preclean, + self.rcupdate, + self.unmerge, ]) self.finish_sequence.extend([ - "remove", - "empty", - "clean", + self.remove, + self.empty, + self.clean, ]) self.set_completion_action_sequences() From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id BC77213835A for ; Sat, 23 Jan 2021 16:23:00 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D101CE0BE0; Sat, 23 Jan 2021 16:22:59 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A597BE0BE0 for ; Sat, 23 Jan 2021 16:22:59 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 6C337340F89 for ; Sat, 23 Jan 2021 16:22:58 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id C88F44A6 for ; Sat, 23 Jan 2021 16:22:56 +0000 (UTC) From: "Matt Turner" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Turner" Message-ID: <1611418747.440a379ae94e6d7df26291bf83657288d1406e98.mattst88@gentoo> Subject: [gentoo-commits] proj/catalyst:master commit in: catalyst/targets/, catalyst/base/ X-VCS-Repository: proj/catalyst X-VCS-Files: catalyst/base/stagebase.py catalyst/targets/embedded.py catalyst/targets/livecd_stage1.py catalyst/targets/livecd_stage2.py catalyst/targets/netboot.py catalyst/targets/stage1.py catalyst/targets/stage4.py X-VCS-Directories: catalyst/targets/ catalyst/base/ X-VCS-Committer: mattst88 X-VCS-Committer-Name: Matt Turner X-VCS-Revision: 440a379ae94e6d7df26291bf83657288d1406e98 X-VCS-Branch: master Date: Sat, 23 Jan 2021 16:22:56 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 3eb34993-e997-473c-a7e5-0ed47b098850 X-Archives-Hash: 62fc4183b37913c86b35b3316371ce74 Message-ID: <20210123162256.ssv42dTc6OeLi59srUWLS2l_KfSPk_c-3TkJOPq5D90@z> commit: 440a379ae94e6d7df26291bf83657288d1406e98 Author: Matt Turner gentoo org> AuthorDate: Sun Jan 17 23:53:21 2021 +0000 Commit: Matt Turner gentoo org> CommitDate: Sat Jan 23 16:19:07 2021 +0000 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=440a379a 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): 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, + self.portage_overlay, ]) self.build_sequence.extend([ - "bind", - "chroot_setup", - "setup_environment", - "build_kernel", - "build_packages", - "root_overlay", - "fsscript", - "unmerge", + self.bind, + self.chroot_setup, + self.setup_environment, + self.build_kernel, + self.build_packages, + self.root_overlay, + self.fsscript, + self.unmerge, ]) self.finish_sequence.extend([ - "remove", - "empty", - "clean", - "capture", - "clear_autoresume", + self.remove, + self.empty, + self.clean, + self.capture, + self.clear_autoresume, ]) def set_root_path(self): diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py index 5c5e9f58..eb6bb0f0 100644 --- a/catalyst/targets/livecd_stage1.py +++ b/catalyst/targets/livecd_stage1.py @@ -24,19 +24,19 @@ class livecd_stage1(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, + self.portage_overlay, ]) self.build_sequence.extend([ - "bind", - "chroot_setup", - "setup_environment", - "build_packages", + self.bind, + self.chroot_setup, + self.setup_environment, + self.build_packages, ]) self.finish_sequence.extend([ - "clean", + self.clean, ]) self.set_completion_action_sequences() diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py index 3606047f..5fecff85 100644 --- a/catalyst/targets/livecd_stage2.py +++ b/catalyst/targets/livecd_stage2.py @@ -87,34 +87,34 @@ class livecd_stage2(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, + self.portage_overlay, ]) self.build_sequence.extend([ - "bind", - "chroot_setup", - "setup_environment", - "run_local", - "build_kernel" + self.bind, + self.chroot_setup, + self.setup_environment, + self.run_local, + self.build_kernel ]) if "fetch" not in self.settings["options"]: self.build_sequence.extend([ - "bootloader", - "preclean", - "livecd_update", - "root_overlay", - "fsscript", - "rcupdate", - "unmerge", + self.bootloader, + self.preclean, + self.livecd_update, + self.root_overlay, + self.fsscript, + self.rcupdate, + self.unmerge, ]) self.finish_sequence.extend([ - "remove", - "empty", - "clean", - "target_setup", - "setup_overlay", - "create_iso", + self.remove, + self.empty, + self.clean, + self.target_setup, + self.setup_overlay, + self.create_iso, ]) - self.finish_sequence.append("clear_autoresume") + self.finish_sequence.append(self.clear_autoresume) diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py index 55f4dff1..9a7e59e5 100644 --- a/catalyst/targets/netboot.py +++ b/catalyst/targets/netboot.py @@ -159,25 +159,25 @@ class netboot(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, + self.portage_overlay, ]) self.build_sequence.extend([ - "bind", - "chroot_setup", - "setup_environment", - "build_packages", - "root_overlay", - "copy_files_to_image", - "setup_overlay", - "build_kernel", - "move_kernels", - "remove", - "empty", + self.bind, + self.chroot_setup, + self.setup_environment, + self.build_packages, + self.root_overlay, + self.copy_files_to_image, + self.setup_overlay, + self.build_kernel, + self.move_kernels, + self.remove, + self.empty, ]) self.finish_sequence.extend([ - "clean", - "clear_autoresume", + self.clean, + self.clear_autoresume, ]) diff --git a/catalyst/targets/stage1.py b/catalyst/targets/stage1.py index 5aa27bb9..5a154e76 100644 --- a/catalyst/targets/stage1.py +++ b/catalyst/targets/stage1.py @@ -82,15 +82,15 @@ class stage1(StageBase): chroot for re-use in stage2 without the need to unpack it. ''' 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("clean_stage1") + self.finish_sequence.append(self.remove_autoresume) + self.finish_sequence.append(self.clean_stage1) 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 clean_stage1(self): '''seedcache is enabled, so salvage the /tmp/stage1root, diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py index b7f74b01..997139a5 100644 --- a/catalyst/targets/stage4.py +++ b/catalyst/targets/stage4.py @@ -40,27 +40,27 @@ class stage4(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, + self.portage_overlay, ]) self.build_sequence.extend([ - "bind", - "chroot_setup", - "setup_environment", - "build_packages", - "build_kernel", - "bootloader", - "root_overlay", - "fsscript", - "preclean", - "rcupdate", - "unmerge", + self.bind, + self.chroot_setup, + self.setup_environment, + self.build_packages, + self.build_kernel, + self.bootloader, + self.root_overlay, + self.fsscript, + self.preclean, + self.rcupdate, + self.unmerge, ]) self.finish_sequence.extend([ - "remove", - "empty", - "clean", + self.remove, + self.empty, + self.clean, ]) self.set_completion_action_sequences() From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id B09C11382C5 for ; Fri, 29 Jan 2021 23:50:54 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 129ACE0AB2; Fri, 29 Jan 2021 23:50:53 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A4B3BE0AAE for ; Fri, 29 Jan 2021 23:50:52 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id ED4B3340FF0 for ; Fri, 29 Jan 2021 23:50:50 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 526624AB for ; Fri, 29 Jan 2021 23:50:49 +0000 (UTC) From: "Matt Turner" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Turner" Message-ID: <1611418747.440a379ae94e6d7df26291bf83657288d1406e98.mattst88@gentoo> Subject: [gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/targets/ X-VCS-Repository: proj/catalyst X-VCS-Files: catalyst/base/stagebase.py catalyst/targets/embedded.py catalyst/targets/livecd_stage1.py catalyst/targets/livecd_stage2.py catalyst/targets/netboot.py catalyst/targets/stage1.py catalyst/targets/stage4.py X-VCS-Directories: catalyst/targets/ catalyst/base/ X-VCS-Committer: mattst88 X-VCS-Committer-Name: Matt Turner X-VCS-Revision: 440a379ae94e6d7df26291bf83657288d1406e98 X-VCS-Branch: wip/mattst88 Date: Fri, 29 Jan 2021 23:50:49 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 1e59f600-f542-4189-8890-b7fb8532c891 X-Archives-Hash: c9f577fee9d2655aa56c1155e4d34a1a Message-ID: <20210129235049.bQcCtXOjWGT2jGG171VUDvsUrMQRXo3SphiGmS4FTbc@z> commit: 440a379ae94e6d7df26291bf83657288d1406e98 Author: Matt Turner gentoo org> AuthorDate: Sun Jan 17 23:53:21 2021 +0000 Commit: Matt Turner gentoo org> CommitDate: Sat Jan 23 16:19:07 2021 +0000 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=440a379a 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): 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, + self.portage_overlay, ]) self.build_sequence.extend([ - "bind", - "chroot_setup", - "setup_environment", - "build_kernel", - "build_packages", - "root_overlay", - "fsscript", - "unmerge", + self.bind, + self.chroot_setup, + self.setup_environment, + self.build_kernel, + self.build_packages, + self.root_overlay, + self.fsscript, + self.unmerge, ]) self.finish_sequence.extend([ - "remove", - "empty", - "clean", - "capture", - "clear_autoresume", + self.remove, + self.empty, + self.clean, + self.capture, + self.clear_autoresume, ]) def set_root_path(self): diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py index 5c5e9f58..eb6bb0f0 100644 --- a/catalyst/targets/livecd_stage1.py +++ b/catalyst/targets/livecd_stage1.py @@ -24,19 +24,19 @@ class livecd_stage1(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, + self.portage_overlay, ]) self.build_sequence.extend([ - "bind", - "chroot_setup", - "setup_environment", - "build_packages", + self.bind, + self.chroot_setup, + self.setup_environment, + self.build_packages, ]) self.finish_sequence.extend([ - "clean", + self.clean, ]) self.set_completion_action_sequences() diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py index 3606047f..5fecff85 100644 --- a/catalyst/targets/livecd_stage2.py +++ b/catalyst/targets/livecd_stage2.py @@ -87,34 +87,34 @@ class livecd_stage2(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, + self.portage_overlay, ]) self.build_sequence.extend([ - "bind", - "chroot_setup", - "setup_environment", - "run_local", - "build_kernel" + self.bind, + self.chroot_setup, + self.setup_environment, + self.run_local, + self.build_kernel ]) if "fetch" not in self.settings["options"]: self.build_sequence.extend([ - "bootloader", - "preclean", - "livecd_update", - "root_overlay", - "fsscript", - "rcupdate", - "unmerge", + self.bootloader, + self.preclean, + self.livecd_update, + self.root_overlay, + self.fsscript, + self.rcupdate, + self.unmerge, ]) self.finish_sequence.extend([ - "remove", - "empty", - "clean", - "target_setup", - "setup_overlay", - "create_iso", + self.remove, + self.empty, + self.clean, + self.target_setup, + self.setup_overlay, + self.create_iso, ]) - self.finish_sequence.append("clear_autoresume") + self.finish_sequence.append(self.clear_autoresume) diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py index 55f4dff1..9a7e59e5 100644 --- a/catalyst/targets/netboot.py +++ b/catalyst/targets/netboot.py @@ -159,25 +159,25 @@ class netboot(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, + self.portage_overlay, ]) self.build_sequence.extend([ - "bind", - "chroot_setup", - "setup_environment", - "build_packages", - "root_overlay", - "copy_files_to_image", - "setup_overlay", - "build_kernel", - "move_kernels", - "remove", - "empty", + self.bind, + self.chroot_setup, + self.setup_environment, + self.build_packages, + self.root_overlay, + self.copy_files_to_image, + self.setup_overlay, + self.build_kernel, + self.move_kernels, + self.remove, + self.empty, ]) self.finish_sequence.extend([ - "clean", - "clear_autoresume", + self.clean, + self.clear_autoresume, ]) diff --git a/catalyst/targets/stage1.py b/catalyst/targets/stage1.py index 5aa27bb9..5a154e76 100644 --- a/catalyst/targets/stage1.py +++ b/catalyst/targets/stage1.py @@ -82,15 +82,15 @@ class stage1(StageBase): chroot for re-use in stage2 without the need to unpack it. ''' 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("clean_stage1") + self.finish_sequence.append(self.remove_autoresume) + self.finish_sequence.append(self.clean_stage1) 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 clean_stage1(self): '''seedcache is enabled, so salvage the /tmp/stage1root, diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py index b7f74b01..997139a5 100644 --- a/catalyst/targets/stage4.py +++ b/catalyst/targets/stage4.py @@ -40,27 +40,27 @@ class stage4(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, + self.portage_overlay, ]) self.build_sequence.extend([ - "bind", - "chroot_setup", - "setup_environment", - "build_packages", - "build_kernel", - "bootloader", - "root_overlay", - "fsscript", - "preclean", - "rcupdate", - "unmerge", + self.bind, + self.chroot_setup, + self.setup_environment, + self.build_packages, + self.build_kernel, + self.bootloader, + self.root_overlay, + self.fsscript, + self.preclean, + self.rcupdate, + self.unmerge, ]) self.finish_sequence.extend([ - "remove", - "empty", - "clean", + self.remove, + self.empty, + self.clean, ]) self.set_completion_action_sequences()