From: "Matt Turner" <mattst88@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/targets/
Date: Fri, 29 Jan 2021 23:50:49 +0000 (UTC) [thread overview]
Message-ID: <1611418747.440a379ae94e6d7df26291bf83657288d1406e98.mattst88@gentoo> (raw)
Message-ID: <20210129235049.bQcCtXOjWGT2jGG171VUDvsUrMQRXo3SphiGmS4FTbc@z> (raw)
commit: 440a379ae94e6d7df26291bf83657288d1406e98
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 17 23:53:21 2021 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> 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 <mattst88 <AT> 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()
next reply other threads:[~2021-01-29 23:50 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-28 1:54 Matt Turner [this message]
2021-01-23 16:22 ` [gentoo-commits] proj/catalyst:master commit in: catalyst/targets/, catalyst/base/ Matt Turner
2021-01-29 23:50 ` [gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/targets/ Matt Turner
-- strict thread matches above, loose matches on Subject: below --
2021-01-18 19:53 [gentoo-commits] proj/catalyst:pending/mattst88 " Matt Turner
2021-01-18 19:53 Matt Turner
2021-01-18 19:53 Matt Turner
2020-10-29 19:05 Matt Turner
2020-10-29 16:34 Matt Turner
2020-10-29 16:14 Matt Turner
2020-10-29 16:14 Matt Turner
2020-10-29 16:14 Matt Turner
2020-10-29 16:04 Matt Turner
2020-10-29 16:04 Matt Turner
2020-10-29 16:04 Matt Turner
2020-10-29 15:47 Matt Turner
2020-10-29 15:47 Matt Turner
2020-10-29 15:47 Matt Turner
2020-10-29 3:33 Matt Turner
2020-10-29 3:33 Matt Turner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1611418747.440a379ae94e6d7df26291bf83657288d1406e98.mattst88@gentoo \
--to=mattst88@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox