public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2020-12-19 19:56 Matt Turner
  0 siblings, 0 replies; 10+ messages in thread
From: Matt Turner @ 2020-12-19 19:56 UTC (permalink / raw
  To: gentoo-commits

commit:     3d85d537b1a00d05234cea064f863602b83ffaab
Author:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 29 03:08:04 2020 +0000
Commit:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Fri Oct 30 22:40:52 2020 +0000
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 <mattst88 <AT> 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_sequence.extend([
+        self.prepare_sequence.extend([
             "unpack",
             "config_profile_link",
             "setup_confdir",
             "portage_overlay",
+        ])
+        self.build_sequence.extend([
             "bind",
             "chroot_setup",
             "setup_environment",
             "build_packages",
             "unbind",
+        ])
+        self.finish_sequence.extend([
             "clean",
         ])
         self.set_completion_action_sequences()

diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py
index c9b5ce08..f6c14919 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -87,11 +87,13 @@ class livecd_stage2(StageBase):
                                     print_traceback=True)
 
     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",
@@ -99,7 +101,7 @@ class livecd_stage2(StageBase):
             "build_kernel"
         ])
         if "fetch" not in self.settings["options"]:
-            self.action_sequence.extend([
+            self.build_sequence.extend([
                 "bootloader",
                 "preclean",
                 "livecd_update",
@@ -108,6 +110,8 @@ class livecd_stage2(StageBase):
                 "rcupdate",
                 "unmerge",
                 "unbind",
+            ])
+            self.finish_sequence.extend([
                 "remove",
                 "empty",
                 "clean",
@@ -115,4 +119,4 @@ class livecd_stage2(StageBase):
                 "setup_overlay",
                 "create_iso",
             ])
-        self.action_sequence.append("clear_autoresume")
+        self.finish_sequence.append("clear_autoresume")

diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index e5c6d43c..9a0a4156 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -160,11 +160,13 @@ class netboot(StageBase):
         self.resume.enable("empty")
 
     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",
@@ -177,6 +179,8 @@ class netboot(StageBase):
             "remove",
             "empty",
             "unbind",
+        ])
+        self.finish_sequence.extend([
             "clean",
             "clear_autoresume",
         ])

diff --git a/catalyst/targets/stage1.py b/catalyst/targets/stage1.py
index 89b30fe1..be3eae93 100644
--- a/catalyst/targets/stage1.py
+++ b/catalyst/targets/stage1.py
@@ -87,15 +87,15 @@ class stage1(StageBase):
         chroot for re-use in stage2 without the need to unpack it.
         '''
         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.action_sequence.append("clean_stage1")
+            self.finish_sequence.append("remove_autoresume")
+            self.finish_sequence.append("clean_stage1")
         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 clean_stage1(self):
         '''seedcache is enabled, so salvage the /tmp/stage1root,

diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py
index bb20be79..78a5c780 100644
--- a/catalyst/targets/stage4.py
+++ b/catalyst/targets/stage4.py
@@ -39,11 +39,13 @@ class stage4(StageBase):
         self.settings["cleanables"].remove('/etc/resolv.conf')
 
     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",
@@ -56,6 +58,8 @@ class stage4(StageBase):
             "rcupdate",
             "unmerge",
             "unbind",
+        ])
+        self.finish_sequence.extend([
             "remove",
             "empty",
             "clean",


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2021-01-18  3:38 Matt Turner
  0 siblings, 0 replies; 10+ messages in thread
From: Matt Turner @ 2021-01-18  3:38 UTC (permalink / raw
  To: gentoo-commits

commit:     4362ffbf257f7d9a05ad81e46b522670e82ad78d
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: Mon Jan 18 03:27:41 2021 +0000
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 <mattst88 <AT> 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,
+            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()


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2021-01-18  3:49 Matt Turner
  0 siblings, 0 replies; 10+ messages in thread
From: Matt Turner @ 2021-01-18  3:49 UTC (permalink / raw
  To: gentoo-commits

commit:     a5f2e195d83f815e303f7bae3f0bb3591369d944
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: Mon Jan 18 03:49:48 2021 +0000
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 <mattst88 <AT> 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,
+            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()


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2021-01-18 16:56 Matt Turner
  0 siblings, 0 replies; 10+ messages in thread
From: Matt Turner @ 2021-01-18 16:56 UTC (permalink / raw
  To: gentoo-commits

commit:     402ac4495d25cbb91f9f81de8150e03428c94ae6
Author:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 18 03:15:02 2021 +0000
Commit:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Mon Jan 18 16:55:29 2021 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=402ac449

catalyst: Deduplicate prepare_sequence assignments

Signed-off-by: Matt Turner <mattst88 <AT> 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,


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2021-01-18 17:06 Matt Turner
  0 siblings, 0 replies; 10+ messages in thread
From: Matt Turner @ 2021-01-18 17:06 UTC (permalink / raw
  To: gentoo-commits

commit:     3bb5ead36cb748af2de00d2c526ac7af2128cc22
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: Mon Jan 18 17:05:43 2021 +0000
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 <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()


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2021-01-18 18:24 Matt Turner
  0 siblings, 0 replies; 10+ messages in thread
From: Matt Turner @ 2021-01-18 18:24 UTC (permalink / raw
  To: gentoo-commits

commit:     9ad4ff837c440d92af2c35d1fe085b0fb6250e2d
Author:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 18 03:15:02 2021 +0000
Commit:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Mon Jan 18 18:01:21 2021 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=9ad4ff83

catalyst: Deduplicate prepare_sequence assignments

Signed-off-by: Matt Turner <mattst88 <AT> 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,


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2021-01-18 18:24 Matt Turner
  0 siblings, 0 replies; 10+ messages in thread
From: Matt Turner @ 2021-01-18 18:24 UTC (permalink / raw
  To: gentoo-commits

commit:     9e6046dd34b6f225d544713ffabe36574cd17143
Author:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 18 03:20:41 2021 +0000
Commit:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Mon Jan 18 18:01:21 2021 +0000
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 <mattst88 <AT> 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,


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2021-01-18 19:38 Matt Turner
  0 siblings, 0 replies; 10+ messages in thread
From: Matt Turner @ 2021-01-18 19:38 UTC (permalink / raw
  To: gentoo-commits

commit:     047d9c1a2a968365b55e5b3b4b3418fd0ef24764
Author:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 18 03:15:02 2021 +0000
Commit:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Mon Jan 18 19:37:55 2021 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=047d9c1a

catalyst: Deduplicate prepare_sequence assignments

Signed-off-by: Matt Turner <mattst88 <AT> 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,


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/targets/
  2021-01-28  1:54 [gentoo-commits] proj/catalyst:pending/mattst88 " Matt Turner
@ 2021-01-29 23:50 ` Matt Turner
  0 siblings, 0 replies; 10+ messages in thread
From: Matt Turner @ 2021-01-29 23:50 UTC (permalink / raw
  To: gentoo-commits

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()


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/base/, catalyst/targets/
  2021-01-28  1:54 [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/targets/, catalyst/base/ Matt Turner
@ 2021-01-29 23:50 ` Matt Turner
  0 siblings, 0 replies; 10+ messages in thread
From: Matt Turner @ 2021-01-29 23:50 UTC (permalink / raw
  To: gentoo-commits

commit:     4f0fa29d5a2499b7178dc4d19f7693e52eb8def9
Author:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 18 03:15:02 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=4f0fa29d

catalyst: Deduplicate prepare_sequence assignments

Signed-off-by: Matt Turner <mattst88 <AT> 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,


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-01-29 23:50 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-18 18:24 [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-28  1:54 [gentoo-commits] proj/catalyst:pending/mattst88 " Matt Turner
2021-01-29 23:50 ` [gentoo-commits] proj/catalyst:wip/mattst88 " Matt Turner
2021-01-28  1:54 [gentoo-commits] proj/catalyst:pending/mattst88 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
2021-01-18 19:38 Matt Turner
2021-01-18 18:24 Matt Turner
2021-01-18 17:06 Matt Turner
2021-01-18 16:56 Matt Turner
2021-01-18  3:49 Matt Turner
2021-01-18  3:38 Matt Turner
2020-12-19 19:56 Matt Turner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox