* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2020-10-29 3:33 Matt Turner
0 siblings, 0 replies; 17+ messages in thread
From: Matt Turner @ 2020-10-29 3:33 UTC (permalink / raw
To: gentoo-commits
commit: 90b9462f2ef64f6147433da967af2f51c7b42fc5
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 29 00:32:34 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 00:33:26 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=90b9462f
catalyst: Use .extend() and .append() for action_sequence
Ensures that we don't overwrite and lose some settings.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 6 +++---
catalyst/targets/embedded.py | 4 ++--
catalyst/targets/livecd_stage1.py | 4 ++--
catalyst/targets/livecd_stage2.py | 8 ++++----
catalyst/targets/netboot.py | 4 ++--
catalyst/targets/stage4.py | 4 ++--
6 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 19c248e3..2e06a988 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -477,13 +477,13 @@ class StageBase(TargetBase, ClearBase, GenBase):
Or it calls the normal set_action_sequence() for the target stage.
"""
if "purgeonly" in self.settings["options"]:
- self.action_sequence = ["remove_chroot"]
+ self.action_sequence.append("remove_chroot")
return
self.set_action_sequence()
def set_action_sequence(self):
"""Set basic stage1, 2, 3 action sequences"""
- self.action_sequence = [
+ self.action_sequence.extend([
"unpack",
"setup_confdir",
"portage_overlay",
@@ -494,7 +494,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
"preclean",
"unbind",
"clean",
- ]
+ ])
self.set_completion_action_sequences()
def set_completion_action_sequences(self):
diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py
index 3899cf1b..75eb68e4 100644
--- a/catalyst/targets/embedded.py
+++ b/catalyst/targets/embedded.py
@@ -41,7 +41,7 @@ class embedded(StageBase):
StageBase.__init__(self, spec, addlargs)
def set_action_sequence(self):
- self.action_sequence = [
+ self.action_sequence.extend([
"unpack",
"config_profile_link",
"setup_confdir",
@@ -60,7 +60,7 @@ class embedded(StageBase):
"clean",
"capture",
"clear_autoresume",
- ]
+ ])
def set_stage_path(self):
self.settings["stage_path"] = normpath(
diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py
index b8c26cb1..9dbfa506 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -23,7 +23,7 @@ class livecd_stage1(StageBase):
StageBase.__init__(self, spec, addlargs)
def set_action_sequence(self):
- self.action_sequence = [
+ self.action_sequence.extend([
"unpack",
"config_profile_link",
"setup_confdir",
@@ -34,7 +34,7 @@ class livecd_stage1(StageBase):
"build_packages",
"unbind",
"clean",
- ]
+ ])
self.set_completion_action_sequences()
def set_spec_prefix(self):
diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py
index cac16b6e..c9b5ce08 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -87,7 +87,7 @@ class livecd_stage2(StageBase):
print_traceback=True)
def set_action_sequence(self):
- self.action_sequence = [
+ self.action_sequence.extend([
"unpack",
"config_profile_link",
"setup_confdir",
@@ -97,9 +97,9 @@ class livecd_stage2(StageBase):
"setup_environment",
"run_local",
"build_kernel"
- ]
+ ])
if "fetch" not in self.settings["options"]:
- self.action_sequence += [
+ self.action_sequence.extend([
"bootloader",
"preclean",
"livecd_update",
@@ -114,5 +114,5 @@ class livecd_stage2(StageBase):
"target_setup",
"setup_overlay",
"create_iso",
- ]
+ ])
self.action_sequence.append("clear_autoresume")
diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index 61583f0d..e5c6d43c 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -160,7 +160,7 @@ class netboot(StageBase):
self.resume.enable("empty")
def set_action_sequence(self):
- self.action_sequence = [
+ self.action_sequence.extend([
"unpack",
"config_profile_link",
"setup_confdir",
@@ -179,4 +179,4 @@ class netboot(StageBase):
"unbind",
"clean",
"clear_autoresume",
- ]
+ ])
diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py
index eef24a73..bb20be79 100644
--- a/catalyst/targets/stage4.py
+++ b/catalyst/targets/stage4.py
@@ -39,7 +39,7 @@ class stage4(StageBase):
self.settings["cleanables"].remove('/etc/resolv.conf')
def set_action_sequence(self):
- self.action_sequence = [
+ self.action_sequence.extend([
"unpack",
"config_profile_link",
"setup_confdir",
@@ -59,5 +59,5 @@ class stage4(StageBase):
"remove",
"empty",
"clean",
- ]
+ ])
self.set_completion_action_sequences()
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2020-10-29 3:33 Matt Turner
0 siblings, 0 replies; 17+ messages in thread
From: Matt Turner @ 2020-10-29 3:33 UTC (permalink / raw
To: gentoo-commits
commit: 13d714d9ba25377b2d071ed17c2a301814321d3b
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: Thu Oct 29 03:23:26 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=13d714d9
catalyst: Split action_sequence into prepare/build/finish
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 2e06a988..cdc5a8a9 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -63,7 +63,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)
@@ -477,36 +479,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"
@@ -1368,7 +1374,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] 17+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2020-10-29 15:47 Matt Turner
0 siblings, 0 replies; 17+ messages in thread
From: Matt Turner @ 2020-10-29 15:47 UTC (permalink / raw
To: gentoo-commits
commit: 9db9735a51152a0be92177f22ddaa9dc6ca70163
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 29 00:28:24 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 14:48:58 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=9db9735a
catalyst: Move action_sequence out of self.settings[]
This self.settings[] dictionary is very similar to the god object
anti-pattern. Moving action_sequence out it starts us down the road of
fixing this.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 17 +++++++++--------
catalyst/targets/embedded.py | 2 +-
catalyst/targets/livecd_stage1.py | 2 +-
catalyst/targets/livecd_stage2.py | 6 +++---
catalyst/targets/netboot.py | 2 +-
catalyst/targets/stage1.py | 12 ++++++------
catalyst/targets/stage4.py | 2 +-
7 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index e71ce344..19c248e3 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -63,6 +63,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
"portage_overlay",
"portage_prefix",
])
+ self.action_sequence = []
self.set_valid_build_kernel_vars(addlargs)
TargetBase.__init__(self, myspec, addlargs)
@@ -476,13 +477,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.settings["action_sequence"] = ["remove_chroot"]
+ self.action_sequence = ["remove_chroot"]
return
self.set_action_sequence()
def set_action_sequence(self):
"""Set basic stage1, 2, 3 action sequences"""
- self.settings['action_sequence'] = [
+ self.action_sequence = [
"unpack",
"setup_confdir",
"portage_overlay",
@@ -498,14 +499,14 @@ class StageBase(TargetBase, ClearBase, GenBase):
def set_completion_action_sequences(self):
if "fetch" not in self.settings["options"]:
- self.settings["action_sequence"].append("capture")
+ self.action_sequence.append("capture")
if "keepwork" in self.settings["options"]:
- self.settings["action_sequence"].append("clear_autoresume")
+ self.action_sequence.append("clear_autoresume")
elif "seedcache" in self.settings["options"]:
- self.settings["action_sequence"].append("remove_autoresume")
+ self.action_sequence.append("remove_autoresume")
else:
- self.settings["action_sequence"].append("remove_autoresume")
- self.settings["action_sequence"].append("remove_chroot")
+ self.action_sequence.append("remove_autoresume")
+ self.action_sequence.append("remove_chroot")
def set_use(self):
use = self.settings["spec_prefix"] + "/use"
@@ -1367,7 +1368,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.purge()
failure = False
- for x in self.settings["action_sequence"]:
+ for x in self.action_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 99739512..3899cf1b 100644
--- a/catalyst/targets/embedded.py
+++ b/catalyst/targets/embedded.py
@@ -41,7 +41,7 @@ class embedded(StageBase):
StageBase.__init__(self, spec, addlargs)
def set_action_sequence(self):
- self.settings['action_sequence'] = [
+ self.action_sequence = [
"unpack",
"config_profile_link",
"setup_confdir",
diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py
index f0b6be8b..b8c26cb1 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -23,7 +23,7 @@ class livecd_stage1(StageBase):
StageBase.__init__(self, spec, addlargs)
def set_action_sequence(self):
- self.settings['action_sequence'] = [
+ self.action_sequence = [
"unpack",
"config_profile_link",
"setup_confdir",
diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py
index 88c0d95c..cac16b6e 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -87,7 +87,7 @@ class livecd_stage2(StageBase):
print_traceback=True)
def set_action_sequence(self):
- self.settings['action_sequence'] = [
+ self.action_sequence = [
"unpack",
"config_profile_link",
"setup_confdir",
@@ -99,7 +99,7 @@ class livecd_stage2(StageBase):
"build_kernel"
]
if "fetch" not in self.settings["options"]:
- self.settings['action_sequence'] += [
+ self.action_sequence += [
"bootloader",
"preclean",
"livecd_update",
@@ -115,4 +115,4 @@ class livecd_stage2(StageBase):
"setup_overlay",
"create_iso",
]
- self.settings["action_sequence"].append("clear_autoresume")
+ self.action_sequence.append("clear_autoresume")
diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index 5620e0d3..61583f0d 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -160,7 +160,7 @@ class netboot(StageBase):
self.resume.enable("empty")
def set_action_sequence(self):
- self.settings['action_sequence'] = [
+ self.action_sequence = [
"unpack",
"config_profile_link",
"setup_confdir",
diff --git a/catalyst/targets/stage1.py b/catalyst/targets/stage1.py
index 2c09a41f..89b30fe1 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.settings["action_sequence"].append("capture")
+ self.action_sequence.append("capture")
if "keepwork" in self.settings["options"]:
- self.settings["action_sequence"].append("clear_autoresume")
+ self.action_sequence.append("clear_autoresume")
elif "seedcache" in self.settings["options"]:
- self.settings["action_sequence"].append("remove_autoresume")
- self.settings["action_sequence"].append("clean_stage1")
+ self.action_sequence.append("remove_autoresume")
+ self.action_sequence.append("clean_stage1")
else:
- self.settings["action_sequence"].append("remove_autoresume")
- self.settings["action_sequence"].append("remove_chroot")
+ self.action_sequence.append("remove_autoresume")
+ self.action_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 346c0845..eef24a73 100644
--- a/catalyst/targets/stage4.py
+++ b/catalyst/targets/stage4.py
@@ -39,7 +39,7 @@ class stage4(StageBase):
self.settings["cleanables"].remove('/etc/resolv.conf')
def set_action_sequence(self):
- self.settings['action_sequence'] = [
+ self.action_sequence = [
"unpack",
"config_profile_link",
"setup_confdir",
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2020-10-29 15:47 Matt Turner
0 siblings, 0 replies; 17+ messages in thread
From: Matt Turner @ 2020-10-29 15:47 UTC (permalink / raw
To: gentoo-commits
commit: 8c0790f4eed3899d98c459a7f03fca7a8774d543
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 29 00:32:34 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 14:49:29 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=8c0790f4
catalyst: Use .extend() and .append() for action_sequence
Ensures that we don't overwrite and lose some settings.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 6 +++---
catalyst/targets/embedded.py | 4 ++--
catalyst/targets/livecd_stage1.py | 4 ++--
catalyst/targets/livecd_stage2.py | 8 ++++----
catalyst/targets/netboot.py | 4 ++--
catalyst/targets/stage4.py | 4 ++--
6 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 19c248e3..2e06a988 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -477,13 +477,13 @@ class StageBase(TargetBase, ClearBase, GenBase):
Or it calls the normal set_action_sequence() for the target stage.
"""
if "purgeonly" in self.settings["options"]:
- self.action_sequence = ["remove_chroot"]
+ self.action_sequence.append("remove_chroot")
return
self.set_action_sequence()
def set_action_sequence(self):
"""Set basic stage1, 2, 3 action sequences"""
- self.action_sequence = [
+ self.action_sequence.extend([
"unpack",
"setup_confdir",
"portage_overlay",
@@ -494,7 +494,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
"preclean",
"unbind",
"clean",
- ]
+ ])
self.set_completion_action_sequences()
def set_completion_action_sequences(self):
diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py
index 3899cf1b..75eb68e4 100644
--- a/catalyst/targets/embedded.py
+++ b/catalyst/targets/embedded.py
@@ -41,7 +41,7 @@ class embedded(StageBase):
StageBase.__init__(self, spec, addlargs)
def set_action_sequence(self):
- self.action_sequence = [
+ self.action_sequence.extend([
"unpack",
"config_profile_link",
"setup_confdir",
@@ -60,7 +60,7 @@ class embedded(StageBase):
"clean",
"capture",
"clear_autoresume",
- ]
+ ])
def set_stage_path(self):
self.settings["stage_path"] = normpath(
diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py
index b8c26cb1..9dbfa506 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -23,7 +23,7 @@ class livecd_stage1(StageBase):
StageBase.__init__(self, spec, addlargs)
def set_action_sequence(self):
- self.action_sequence = [
+ self.action_sequence.extend([
"unpack",
"config_profile_link",
"setup_confdir",
@@ -34,7 +34,7 @@ class livecd_stage1(StageBase):
"build_packages",
"unbind",
"clean",
- ]
+ ])
self.set_completion_action_sequences()
def set_spec_prefix(self):
diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py
index cac16b6e..c9b5ce08 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -87,7 +87,7 @@ class livecd_stage2(StageBase):
print_traceback=True)
def set_action_sequence(self):
- self.action_sequence = [
+ self.action_sequence.extend([
"unpack",
"config_profile_link",
"setup_confdir",
@@ -97,9 +97,9 @@ class livecd_stage2(StageBase):
"setup_environment",
"run_local",
"build_kernel"
- ]
+ ])
if "fetch" not in self.settings["options"]:
- self.action_sequence += [
+ self.action_sequence.extend([
"bootloader",
"preclean",
"livecd_update",
@@ -114,5 +114,5 @@ class livecd_stage2(StageBase):
"target_setup",
"setup_overlay",
"create_iso",
- ]
+ ])
self.action_sequence.append("clear_autoresume")
diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index 61583f0d..e5c6d43c 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -160,7 +160,7 @@ class netboot(StageBase):
self.resume.enable("empty")
def set_action_sequence(self):
- self.action_sequence = [
+ self.action_sequence.extend([
"unpack",
"config_profile_link",
"setup_confdir",
@@ -179,4 +179,4 @@ class netboot(StageBase):
"unbind",
"clean",
"clear_autoresume",
- ]
+ ])
diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py
index eef24a73..bb20be79 100644
--- a/catalyst/targets/stage4.py
+++ b/catalyst/targets/stage4.py
@@ -39,7 +39,7 @@ class stage4(StageBase):
self.settings["cleanables"].remove('/etc/resolv.conf')
def set_action_sequence(self):
- self.action_sequence = [
+ self.action_sequence.extend([
"unpack",
"config_profile_link",
"setup_confdir",
@@ -59,5 +59,5 @@ class stage4(StageBase):
"remove",
"empty",
"clean",
- ]
+ ])
self.set_completion_action_sequences()
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2020-10-29 15:47 Matt Turner
0 siblings, 0 replies; 17+ messages in thread
From: Matt Turner @ 2020-10-29 15:47 UTC (permalink / raw
To: gentoo-commits
commit: 110551d185e7f3d2c40baed594e9a7e87745188e
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: Thu Oct 29 14:49:40 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=110551d1
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 2e06a988..cdc5a8a9 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -63,7 +63,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)
@@ -477,36 +479,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"
@@ -1368,7 +1374,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] 17+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2020-10-29 16:04 Matt Turner
0 siblings, 0 replies; 17+ messages in thread
From: Matt Turner @ 2020-10-29 16:04 UTC (permalink / raw
To: gentoo-commits
commit: 4cac82c0678ae882fb2371b9499d15eff2ecf140
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 29 00:32:34 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 16:03:41 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=4cac82c0
catalyst: Use .extend() and .append() for action_sequence
Ensures that we don't overwrite and lose some settings.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 6 +++---
catalyst/targets/embedded.py | 4 ++--
catalyst/targets/livecd_stage1.py | 4 ++--
catalyst/targets/livecd_stage2.py | 8 ++++----
catalyst/targets/netboot.py | 4 ++--
catalyst/targets/stage4.py | 4 ++--
6 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index bee8b57a..5f40d3e9 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -478,13 +478,13 @@ class StageBase(TargetBase, ClearBase, GenBase):
Or it calls the normal set_action_sequence() for the target stage.
"""
if "purgeonly" in self.settings["options"]:
- self.action_sequence = ["remove_chroot"]
+ self.action_sequence.append("remove_chroot")
return
self.set_action_sequence()
def set_action_sequence(self):
"""Set basic stage1, 2, 3 action sequences"""
- self.action_sequence = [
+ self.action_sequence.extend([
"unpack",
"setup_confdir",
"portage_overlay",
@@ -495,7 +495,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
"preclean",
"unbind",
"clean",
- ]
+ ])
self.set_completion_action_sequences()
def set_completion_action_sequences(self):
diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py
index 3899cf1b..75eb68e4 100644
--- a/catalyst/targets/embedded.py
+++ b/catalyst/targets/embedded.py
@@ -41,7 +41,7 @@ class embedded(StageBase):
StageBase.__init__(self, spec, addlargs)
def set_action_sequence(self):
- self.action_sequence = [
+ self.action_sequence.extend([
"unpack",
"config_profile_link",
"setup_confdir",
@@ -60,7 +60,7 @@ class embedded(StageBase):
"clean",
"capture",
"clear_autoresume",
- ]
+ ])
def set_stage_path(self):
self.settings["stage_path"] = normpath(
diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py
index b8c26cb1..9dbfa506 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -23,7 +23,7 @@ class livecd_stage1(StageBase):
StageBase.__init__(self, spec, addlargs)
def set_action_sequence(self):
- self.action_sequence = [
+ self.action_sequence.extend([
"unpack",
"config_profile_link",
"setup_confdir",
@@ -34,7 +34,7 @@ class livecd_stage1(StageBase):
"build_packages",
"unbind",
"clean",
- ]
+ ])
self.set_completion_action_sequences()
def set_spec_prefix(self):
diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py
index cac16b6e..c9b5ce08 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -87,7 +87,7 @@ class livecd_stage2(StageBase):
print_traceback=True)
def set_action_sequence(self):
- self.action_sequence = [
+ self.action_sequence.extend([
"unpack",
"config_profile_link",
"setup_confdir",
@@ -97,9 +97,9 @@ class livecd_stage2(StageBase):
"setup_environment",
"run_local",
"build_kernel"
- ]
+ ])
if "fetch" not in self.settings["options"]:
- self.action_sequence += [
+ self.action_sequence.extend([
"bootloader",
"preclean",
"livecd_update",
@@ -114,5 +114,5 @@ class livecd_stage2(StageBase):
"target_setup",
"setup_overlay",
"create_iso",
- ]
+ ])
self.action_sequence.append("clear_autoresume")
diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index 61583f0d..e5c6d43c 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -160,7 +160,7 @@ class netboot(StageBase):
self.resume.enable("empty")
def set_action_sequence(self):
- self.action_sequence = [
+ self.action_sequence.extend([
"unpack",
"config_profile_link",
"setup_confdir",
@@ -179,4 +179,4 @@ class netboot(StageBase):
"unbind",
"clean",
"clear_autoresume",
- ]
+ ])
diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py
index eef24a73..bb20be79 100644
--- a/catalyst/targets/stage4.py
+++ b/catalyst/targets/stage4.py
@@ -39,7 +39,7 @@ class stage4(StageBase):
self.settings["cleanables"].remove('/etc/resolv.conf')
def set_action_sequence(self):
- self.action_sequence = [
+ self.action_sequence.extend([
"unpack",
"config_profile_link",
"setup_confdir",
@@ -59,5 +59,5 @@ class stage4(StageBase):
"remove",
"empty",
"clean",
- ]
+ ])
self.set_completion_action_sequences()
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2020-10-29 16:04 Matt Turner
0 siblings, 0 replies; 17+ messages in thread
From: Matt Turner @ 2020-10-29 16:04 UTC (permalink / raw
To: gentoo-commits
commit: d088802ec7b0e01fda7ccbbf121097cb52929966
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 29 00:28:24 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 16:03:41 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=d088802e
catalyst: Move action_sequence out of self.settings[]
This self.settings[] dictionary is very similar to the god object
anti-pattern. Moving action_sequence out it starts us down the road of
fixing this.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 17 +++++++++--------
catalyst/targets/embedded.py | 2 +-
catalyst/targets/livecd_stage1.py | 2 +-
catalyst/targets/livecd_stage2.py | 6 +++---
catalyst/targets/netboot.py | 2 +-
catalyst/targets/stage1.py | 12 ++++++------
catalyst/targets/stage4.py | 2 +-
7 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index edf950e2..bee8b57a 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -64,6 +64,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
"portage_overlay",
"portage_prefix",
])
+ self.action_sequence = []
self.set_valid_build_kernel_vars(addlargs)
TargetBase.__init__(self, myspec, addlargs)
@@ -477,13 +478,13 @@ class StageBase(TargetBase, ClearBase, GenBase):
Or it calls the normal set_action_sequence() for the target stage.
"""
if "purgeonly" in self.settings["options"]:
- self.settings["action_sequence"] = ["remove_chroot"]
+ self.action_sequence = ["remove_chroot"]
return
self.set_action_sequence()
def set_action_sequence(self):
"""Set basic stage1, 2, 3 action sequences"""
- self.settings['action_sequence'] = [
+ self.action_sequence = [
"unpack",
"setup_confdir",
"portage_overlay",
@@ -499,14 +500,14 @@ class StageBase(TargetBase, ClearBase, GenBase):
def set_completion_action_sequences(self):
if "fetch" not in self.settings["options"]:
- self.settings["action_sequence"].append("capture")
+ self.action_sequence.append("capture")
if "keepwork" in self.settings["options"]:
- self.settings["action_sequence"].append("clear_autoresume")
+ self.action_sequence.append("clear_autoresume")
elif "seedcache" in self.settings["options"]:
- self.settings["action_sequence"].append("remove_autoresume")
+ self.action_sequence.append("remove_autoresume")
else:
- self.settings["action_sequence"].append("remove_autoresume")
- self.settings["action_sequence"].append("remove_chroot")
+ self.action_sequence.append("remove_autoresume")
+ self.action_sequence.append("remove_chroot")
def set_use(self):
use = self.settings["spec_prefix"] + "/use"
@@ -1380,7 +1381,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.purge()
failure = False
- for x in self.settings["action_sequence"]:
+ for x in self.action_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 99739512..3899cf1b 100644
--- a/catalyst/targets/embedded.py
+++ b/catalyst/targets/embedded.py
@@ -41,7 +41,7 @@ class embedded(StageBase):
StageBase.__init__(self, spec, addlargs)
def set_action_sequence(self):
- self.settings['action_sequence'] = [
+ self.action_sequence = [
"unpack",
"config_profile_link",
"setup_confdir",
diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py
index f0b6be8b..b8c26cb1 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -23,7 +23,7 @@ class livecd_stage1(StageBase):
StageBase.__init__(self, spec, addlargs)
def set_action_sequence(self):
- self.settings['action_sequence'] = [
+ self.action_sequence = [
"unpack",
"config_profile_link",
"setup_confdir",
diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py
index 88c0d95c..cac16b6e 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -87,7 +87,7 @@ class livecd_stage2(StageBase):
print_traceback=True)
def set_action_sequence(self):
- self.settings['action_sequence'] = [
+ self.action_sequence = [
"unpack",
"config_profile_link",
"setup_confdir",
@@ -99,7 +99,7 @@ class livecd_stage2(StageBase):
"build_kernel"
]
if "fetch" not in self.settings["options"]:
- self.settings['action_sequence'] += [
+ self.action_sequence += [
"bootloader",
"preclean",
"livecd_update",
@@ -115,4 +115,4 @@ class livecd_stage2(StageBase):
"setup_overlay",
"create_iso",
]
- self.settings["action_sequence"].append("clear_autoresume")
+ self.action_sequence.append("clear_autoresume")
diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index 5620e0d3..61583f0d 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -160,7 +160,7 @@ class netboot(StageBase):
self.resume.enable("empty")
def set_action_sequence(self):
- self.settings['action_sequence'] = [
+ self.action_sequence = [
"unpack",
"config_profile_link",
"setup_confdir",
diff --git a/catalyst/targets/stage1.py b/catalyst/targets/stage1.py
index 2c09a41f..89b30fe1 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.settings["action_sequence"].append("capture")
+ self.action_sequence.append("capture")
if "keepwork" in self.settings["options"]:
- self.settings["action_sequence"].append("clear_autoresume")
+ self.action_sequence.append("clear_autoresume")
elif "seedcache" in self.settings["options"]:
- self.settings["action_sequence"].append("remove_autoresume")
- self.settings["action_sequence"].append("clean_stage1")
+ self.action_sequence.append("remove_autoresume")
+ self.action_sequence.append("clean_stage1")
else:
- self.settings["action_sequence"].append("remove_autoresume")
- self.settings["action_sequence"].append("remove_chroot")
+ self.action_sequence.append("remove_autoresume")
+ self.action_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 346c0845..eef24a73 100644
--- a/catalyst/targets/stage4.py
+++ b/catalyst/targets/stage4.py
@@ -39,7 +39,7 @@ class stage4(StageBase):
self.settings["cleanables"].remove('/etc/resolv.conf')
def set_action_sequence(self):
- self.settings['action_sequence'] = [
+ self.action_sequence = [
"unpack",
"config_profile_link",
"setup_confdir",
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2020-10-29 16:04 Matt Turner
0 siblings, 0 replies; 17+ messages in thread
From: Matt Turner @ 2020-10-29 16:04 UTC (permalink / raw
To: gentoo-commits
commit: 3983182670352f0ee204a9567bf6357ac89c75ce
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 22 20:37:54 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 16:04:12 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=39831826
catalyst: Drop unbind()
mount_namespaces(7) says
A mount ceases to be a member of a peer group when either the
mount is explicitly unmounted, or when the mount is implicitly
unmounted because a mount namespace is removed (because it has
no more member processes).
As a result, we can rely on exiting the mount namespace to unmount the
bind mounts.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 45 +--------------------------------------
catalyst/targets/embedded.py | 1 -
catalyst/targets/livecd_stage1.py | 1 -
catalyst/targets/livecd_stage2.py | 2 --
catalyst/targets/netboot.py | 3 ---
catalyst/targets/stage4.py | 1 -
6 files changed, 1 insertion(+), 52 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 1f84965a..2de3d955 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -498,7 +498,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
"setup_environment",
"run_local",
"preclean",
- "unbind",
])
self.finish_sequence.extend([
"clean",
@@ -853,40 +852,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
fstype=fstype, options=options)
cxt.mount()
except OSError as e:
- self.unbind()
raise CatalystError(f"Couldn't mount: {source}, {e.strerror}")
- def unbind(self):
- chroot_path = self.settings["chroot_path"]
- umount_failed = False
-
- # Unmount in reverse order
- for target in [Path(chroot_path + self.mount[x]['target'])
- for x in reversed(self.mount)
- if self.mount[x]['enable']]:
- if not target.exists():
- log.debug('%s does not exist. Skipping', target)
- continue
-
- if not ismount(target):
- log.debug('%s is not a mount point. Skipping', target)
- continue
-
- try:
- cxt = libmount.Context(target=str(target))
- cxt.umount()
- except OSError as e:
- log.warning("Couldn't umount: %s, %s", target,
- e.strerror)
- umount_failed = True
-
- if umount_failed:
- # if any bind mounts really failed, then we need to raise
- # this to potentially prevent an upcoming bash stage cleanup script
- # from wiping our bind mounts.
- raise CatalystError(
- "Couldn't umount one or more bind-mounts; aborting for safety.")
-
def chroot_setup(self):
self.makeconf = read_makeconf(normpath(self.settings["chroot_path"] +
self.settings["make_conf"]))
@@ -1190,7 +1157,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
env=self.env)
self.resume.enable("remove")
except:
- self.unbind()
raise
def preclean(self):
@@ -1206,7 +1172,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.resume.enable("preclean")
except:
- self.unbind()
raise CatalystError("Build failed, could not execute preclean")
def capture(self):
@@ -1269,7 +1234,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings['controller_file'])
except CatalystError:
- self.unbind()
raise CatalystError("Stage build aborting due to error.",
print_traceback=False)
@@ -1349,7 +1313,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
with namespace(mount=True):
if not self.run_sequence(self.build_sequence):
- self.unbind()
return False
if not self.run_sequence(self.finish_sequence):
@@ -1375,7 +1338,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
env=self.env)
log.info('unmerge shell script')
except CatalystError:
- self.unbind()
raise
self.resume.enable("unmerge")
@@ -1450,7 +1412,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
fileutils.touch(build_packages_resume)
self.resume.enable("build_packages")
except CatalystError:
- self.unbind()
raise CatalystError(
self.settings["spec_prefix"] +
"build aborting due to error.")
@@ -1474,7 +1435,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
self._build_kernel(kname=kname)
self.resume.enable("build_kernel")
except CatalystError:
- self.unbind()
raise CatalystError(
"build aborting due to kernel build error.",
print_traceback=True)
@@ -1518,7 +1478,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
key = 'boot/kernel/' + kname + '/config'
if key in self.settings:
if not os.path.exists(self.settings[key]):
- self.unbind()
raise CatalystError("Can't find kernel config: %s" %
self.settings[key])
@@ -1527,7 +1486,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings['chroot_path'] + '/var/tmp/' + kname + '.config')
except IOError:
- self.unbind()
+ raise
def _copy_initramfs_overlay(self, kname):
key = 'boot/kernel/' + kname + '/initramfs_overlay'
@@ -1557,7 +1516,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
env=self.env)
self.resume.enable("bootloader")
except CatalystError:
- self.unbind()
raise CatalystError("Script aborting due to error.")
def livecd_update(self):
@@ -1573,7 +1531,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.resume.enable("livecd_update")
except CatalystError:
- self.unbind()
raise CatalystError(
"build aborting due to livecd_update error.")
diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py
index 1314ce7c..e9138437 100644
--- a/catalyst/targets/embedded.py
+++ b/catalyst/targets/embedded.py
@@ -56,7 +56,6 @@ class embedded(StageBase):
"root_overlay",
"fsscript",
"unmerge",
- "unbind",
])
self.finish_sequence.extend([
"remove",
diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py
index 81367053..5c5e9f58 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -34,7 +34,6 @@ class livecd_stage1(StageBase):
"chroot_setup",
"setup_environment",
"build_packages",
- "unbind",
])
self.finish_sequence.extend([
"clean",
diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py
index f6c14919..3606047f 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -80,7 +80,6 @@ class livecd_stage2(StageBase):
for x in self.settings["livecd/modblacklist"]:
myf.write("\nblacklist "+x)
except:
- self.unbind()
raise CatalystError("Couldn't open " +
self.settings["chroot_path"] +
"/etc/modprobe.d/blacklist.conf.",
@@ -109,7 +108,6 @@ class livecd_stage2(StageBase):
"fsscript",
"rcupdate",
"unmerge",
- "unbind",
])
self.finish_sequence.extend([
"remove",
diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index 9a0a4156..55f4dff1 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -93,7 +93,6 @@ class netboot(StageBase):
cmd([self.settings['controller_file'], 'image'] +
myfiles, env=self.env)
except CatalystError:
- self.unbind()
raise CatalystError("Failed to copy files to image!",
print_traceback=True)
@@ -121,7 +120,6 @@ class netboot(StageBase):
cmd([self.settings['controller_file'], 'final'], env=self.env)
log.notice('Netboot Build Finished!')
except CatalystError:
- self.unbind()
raise CatalystError("Failed to move kernel images!",
print_traceback=True)
@@ -178,7 +176,6 @@ class netboot(StageBase):
"move_kernels",
"remove",
"empty",
- "unbind",
])
self.finish_sequence.extend([
"clean",
diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py
index 78a5c780..b7f74b01 100644
--- a/catalyst/targets/stage4.py
+++ b/catalyst/targets/stage4.py
@@ -57,7 +57,6 @@ class stage4(StageBase):
"preclean",
"rcupdate",
"unmerge",
- "unbind",
])
self.finish_sequence.extend([
"remove",
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2020-10-29 16:14 Matt Turner
0 siblings, 0 replies; 17+ messages in thread
From: Matt Turner @ 2020-10-29 16:14 UTC (permalink / raw
To: gentoo-commits
commit: 246841482234c7aa700779389bfc87795af5f16a
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 29 00:28:24 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 16:13:47 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=24684148
catalyst: Move action_sequence out of self.settings[]
This self.settings[] dictionary is very similar to the god object
anti-pattern. Moving action_sequence out it starts us down the road of
fixing this.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 17 +++++++++--------
catalyst/targets/embedded.py | 2 +-
catalyst/targets/livecd_stage1.py | 2 +-
catalyst/targets/livecd_stage2.py | 6 +++---
catalyst/targets/netboot.py | 2 +-
catalyst/targets/stage1.py | 12 ++++++------
catalyst/targets/stage4.py | 2 +-
7 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 73eacfbe..801df2fb 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -64,6 +64,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
"portage_overlay",
"portage_prefix",
])
+ self.action_sequence = []
self.set_valid_build_kernel_vars(addlargs)
TargetBase.__init__(self, myspec, addlargs)
@@ -477,13 +478,13 @@ class StageBase(TargetBase, ClearBase, GenBase):
Or it calls the normal set_action_sequence() for the target stage.
"""
if "purgeonly" in self.settings["options"]:
- self.settings["action_sequence"] = ["remove_chroot"]
+ self.action_sequence = ["remove_chroot"]
return
self.set_action_sequence()
def set_action_sequence(self):
"""Set basic stage1, 2, 3 action sequences"""
- self.settings['action_sequence'] = [
+ self.action_sequence = [
"unpack",
"setup_confdir",
"portage_overlay",
@@ -499,14 +500,14 @@ class StageBase(TargetBase, ClearBase, GenBase):
def set_completion_action_sequences(self):
if "fetch" not in self.settings["options"]:
- self.settings["action_sequence"].append("capture")
+ self.action_sequence.append("capture")
if "keepwork" in self.settings["options"]:
- self.settings["action_sequence"].append("clear_autoresume")
+ self.action_sequence.append("clear_autoresume")
elif "seedcache" in self.settings["options"]:
- self.settings["action_sequence"].append("remove_autoresume")
+ self.action_sequence.append("remove_autoresume")
else:
- self.settings["action_sequence"].append("remove_autoresume")
- self.settings["action_sequence"].append("remove_chroot")
+ self.action_sequence.append("remove_autoresume")
+ self.action_sequence.append("remove_chroot")
def set_use(self):
use = self.settings["spec_prefix"] + "/use"
@@ -1380,7 +1381,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.purge()
failure = False
- for x in self.settings["action_sequence"]:
+ for x in self.action_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 99739512..3899cf1b 100644
--- a/catalyst/targets/embedded.py
+++ b/catalyst/targets/embedded.py
@@ -41,7 +41,7 @@ class embedded(StageBase):
StageBase.__init__(self, spec, addlargs)
def set_action_sequence(self):
- self.settings['action_sequence'] = [
+ self.action_sequence = [
"unpack",
"config_profile_link",
"setup_confdir",
diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py
index f0b6be8b..b8c26cb1 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -23,7 +23,7 @@ class livecd_stage1(StageBase):
StageBase.__init__(self, spec, addlargs)
def set_action_sequence(self):
- self.settings['action_sequence'] = [
+ self.action_sequence = [
"unpack",
"config_profile_link",
"setup_confdir",
diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py
index 88c0d95c..cac16b6e 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -87,7 +87,7 @@ class livecd_stage2(StageBase):
print_traceback=True)
def set_action_sequence(self):
- self.settings['action_sequence'] = [
+ self.action_sequence = [
"unpack",
"config_profile_link",
"setup_confdir",
@@ -99,7 +99,7 @@ class livecd_stage2(StageBase):
"build_kernel"
]
if "fetch" not in self.settings["options"]:
- self.settings['action_sequence'] += [
+ self.action_sequence += [
"bootloader",
"preclean",
"livecd_update",
@@ -115,4 +115,4 @@ class livecd_stage2(StageBase):
"setup_overlay",
"create_iso",
]
- self.settings["action_sequence"].append("clear_autoresume")
+ self.action_sequence.append("clear_autoresume")
diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index 5620e0d3..61583f0d 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -160,7 +160,7 @@ class netboot(StageBase):
self.resume.enable("empty")
def set_action_sequence(self):
- self.settings['action_sequence'] = [
+ self.action_sequence = [
"unpack",
"config_profile_link",
"setup_confdir",
diff --git a/catalyst/targets/stage1.py b/catalyst/targets/stage1.py
index 2c09a41f..89b30fe1 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.settings["action_sequence"].append("capture")
+ self.action_sequence.append("capture")
if "keepwork" in self.settings["options"]:
- self.settings["action_sequence"].append("clear_autoresume")
+ self.action_sequence.append("clear_autoresume")
elif "seedcache" in self.settings["options"]:
- self.settings["action_sequence"].append("remove_autoresume")
- self.settings["action_sequence"].append("clean_stage1")
+ self.action_sequence.append("remove_autoresume")
+ self.action_sequence.append("clean_stage1")
else:
- self.settings["action_sequence"].append("remove_autoresume")
- self.settings["action_sequence"].append("remove_chroot")
+ self.action_sequence.append("remove_autoresume")
+ self.action_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 346c0845..eef24a73 100644
--- a/catalyst/targets/stage4.py
+++ b/catalyst/targets/stage4.py
@@ -39,7 +39,7 @@ class stage4(StageBase):
self.settings["cleanables"].remove('/etc/resolv.conf')
def set_action_sequence(self):
- self.settings['action_sequence'] = [
+ self.action_sequence = [
"unpack",
"config_profile_link",
"setup_confdir",
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2020-10-29 16:14 Matt Turner
0 siblings, 0 replies; 17+ messages in thread
From: Matt Turner @ 2020-10-29 16:14 UTC (permalink / raw
To: gentoo-commits
commit: 56b60e41c674e4ad4abc56fba86d5dceaf962231
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: Thu Oct 29 16:13:47 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=56b60e41
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] 17+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2020-10-29 16:14 Matt Turner
0 siblings, 0 replies; 17+ messages in thread
From: Matt Turner @ 2020-10-29 16:14 UTC (permalink / raw
To: gentoo-commits
commit: 093195d9023ab6abba795aa8314288f5c2d42b99
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 22 20:37:54 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 16:13:47 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=093195d9
catalyst: Drop unbind()
mount_namespaces(7) says
A mount ceases to be a member of a peer group when either the
mount is explicitly unmounted, or when the mount is implicitly
unmounted because a mount namespace is removed (because it has
no more member processes).
As a result, we can rely on exiting the mount namespace to unmount the
bind mounts.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 45 +--------------------------------------
catalyst/targets/embedded.py | 1 -
catalyst/targets/livecd_stage1.py | 1 -
catalyst/targets/livecd_stage2.py | 2 --
catalyst/targets/netboot.py | 3 ---
catalyst/targets/stage4.py | 1 -
6 files changed, 1 insertion(+), 52 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index d5454b77..a75dbdf9 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -498,7 +498,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
"setup_environment",
"run_local",
"preclean",
- "unbind",
])
self.finish_sequence.extend([
"clean",
@@ -853,40 +852,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
fstype=fstype, options=options)
cxt.mount()
except OSError as e:
- self.unbind()
raise CatalystError(f"Couldn't mount: {source}, {e.strerror}")
- def unbind(self):
- chroot_path = self.settings["chroot_path"]
- umount_failed = False
-
- # Unmount in reverse order
- for target in [Path(chroot_path + self.mount[x]['target'])
- for x in reversed(self.mount)
- if self.mount[x]['enable']]:
- if not target.exists():
- log.debug('%s does not exist. Skipping', target)
- continue
-
- if not ismount(target):
- log.debug('%s is not a mount point. Skipping', target)
- continue
-
- try:
- cxt = libmount.Context(target=str(target))
- cxt.umount()
- except OSError as e:
- log.warning("Couldn't umount: %s, %s", target,
- e.strerror)
- umount_failed = True
-
- if umount_failed:
- # if any bind mounts really failed, then we need to raise
- # this to potentially prevent an upcoming bash stage cleanup script
- # from wiping our bind mounts.
- raise CatalystError(
- "Couldn't umount one or more bind-mounts; aborting for safety.")
-
def chroot_setup(self):
self.makeconf = read_makeconf(normpath(self.settings["chroot_path"] +
self.settings["make_conf"]))
@@ -1190,7 +1157,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
env=self.env)
self.resume.enable("remove")
except:
- self.unbind()
raise
def preclean(self):
@@ -1206,7 +1172,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.resume.enable("preclean")
except:
- self.unbind()
raise CatalystError("Build failed, could not execute preclean")
def capture(self):
@@ -1269,7 +1234,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings['controller_file'])
except CatalystError:
- self.unbind()
raise CatalystError("Stage build aborting due to error.",
print_traceback=False)
@@ -1349,7 +1313,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
with namespace(mount=True):
if not self.run_sequence(self.build_sequence):
- self.unbind()
return False
if not self.run_sequence(self.finish_sequence):
@@ -1375,7 +1338,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
env=self.env)
log.info('unmerge shell script')
except CatalystError:
- self.unbind()
raise
self.resume.enable("unmerge")
@@ -1450,7 +1412,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
fileutils.touch(build_packages_resume)
self.resume.enable("build_packages")
except CatalystError:
- self.unbind()
raise CatalystError(
self.settings["spec_prefix"] +
"build aborting due to error.")
@@ -1474,7 +1435,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
self._build_kernel(kname=kname)
self.resume.enable("build_kernel")
except CatalystError:
- self.unbind()
raise CatalystError(
"build aborting due to kernel build error.",
print_traceback=True)
@@ -1518,7 +1478,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
key = 'boot/kernel/' + kname + '/config'
if key in self.settings:
if not os.path.exists(self.settings[key]):
- self.unbind()
raise CatalystError("Can't find kernel config: %s" %
self.settings[key])
@@ -1527,7 +1486,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings['chroot_path'] + '/var/tmp/' + kname + '.config')
except IOError:
- self.unbind()
+ raise
def _copy_initramfs_overlay(self, kname):
key = 'boot/kernel/' + kname + '/initramfs_overlay'
@@ -1557,7 +1516,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
env=self.env)
self.resume.enable("bootloader")
except CatalystError:
- self.unbind()
raise CatalystError("Script aborting due to error.")
def livecd_update(self):
@@ -1573,7 +1531,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.resume.enable("livecd_update")
except CatalystError:
- self.unbind()
raise CatalystError(
"build aborting due to livecd_update error.")
diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py
index 1314ce7c..e9138437 100644
--- a/catalyst/targets/embedded.py
+++ b/catalyst/targets/embedded.py
@@ -56,7 +56,6 @@ class embedded(StageBase):
"root_overlay",
"fsscript",
"unmerge",
- "unbind",
])
self.finish_sequence.extend([
"remove",
diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py
index 81367053..5c5e9f58 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -34,7 +34,6 @@ class livecd_stage1(StageBase):
"chroot_setup",
"setup_environment",
"build_packages",
- "unbind",
])
self.finish_sequence.extend([
"clean",
diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py
index f6c14919..3606047f 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -80,7 +80,6 @@ class livecd_stage2(StageBase):
for x in self.settings["livecd/modblacklist"]:
myf.write("\nblacklist "+x)
except:
- self.unbind()
raise CatalystError("Couldn't open " +
self.settings["chroot_path"] +
"/etc/modprobe.d/blacklist.conf.",
@@ -109,7 +108,6 @@ class livecd_stage2(StageBase):
"fsscript",
"rcupdate",
"unmerge",
- "unbind",
])
self.finish_sequence.extend([
"remove",
diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index 9a0a4156..55f4dff1 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -93,7 +93,6 @@ class netboot(StageBase):
cmd([self.settings['controller_file'], 'image'] +
myfiles, env=self.env)
except CatalystError:
- self.unbind()
raise CatalystError("Failed to copy files to image!",
print_traceback=True)
@@ -121,7 +120,6 @@ class netboot(StageBase):
cmd([self.settings['controller_file'], 'final'], env=self.env)
log.notice('Netboot Build Finished!')
except CatalystError:
- self.unbind()
raise CatalystError("Failed to move kernel images!",
print_traceback=True)
@@ -178,7 +176,6 @@ class netboot(StageBase):
"move_kernels",
"remove",
"empty",
- "unbind",
])
self.finish_sequence.extend([
"clean",
diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py
index 78a5c780..b7f74b01 100644
--- a/catalyst/targets/stage4.py
+++ b/catalyst/targets/stage4.py
@@ -57,7 +57,6 @@ class stage4(StageBase):
"preclean",
"rcupdate",
"unmerge",
- "unbind",
])
self.finish_sequence.extend([
"remove",
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2020-10-29 16:34 Matt Turner
0 siblings, 0 replies; 17+ messages in thread
From: Matt Turner @ 2020-10-29 16:34 UTC (permalink / raw
To: gentoo-commits
commit: 897b7a15df970bff62a4db98010c71d8e2f2714c
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 22 20:37:54 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 16:34:40 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=897b7a15
catalyst: Drop unbind()
mount_namespaces(7) says
A mount ceases to be a member of a peer group when either the
mount is explicitly unmounted, or when the mount is implicitly
unmounted because a mount namespace is removed (because it has
no more member processes).
As a result, we can rely on exiting the mount namespace to unmount the
bind mounts.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 44 +--------------------------------------
catalyst/targets/embedded.py | 1 -
catalyst/targets/livecd_stage1.py | 1 -
catalyst/targets/livecd_stage2.py | 2 --
catalyst/targets/netboot.py | 3 ---
catalyst/targets/stage4.py | 1 -
6 files changed, 1 insertion(+), 51 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index b9c220d0..a75dbdf9 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -498,7 +498,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
"setup_environment",
"run_local",
"preclean",
- "unbind",
])
self.finish_sequence.extend([
"clean",
@@ -853,40 +852,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
fstype=fstype, options=options)
cxt.mount()
except OSError as e:
- self.unbind()
raise CatalystError(f"Couldn't mount: {source}, {e.strerror}")
- def unbind(self):
- chroot_path = self.settings["chroot_path"]
- umount_failed = False
-
- # Unmount in reverse order
- for target in [Path(chroot_path + self.mount[x]['target'])
- for x in reversed(self.mount)
- if self.mount[x]['enable']]:
- if not target.exists():
- log.debug('%s does not exist. Skipping', target)
- continue
-
- if not ismount(target):
- log.debug('%s is not a mount point. Skipping', target)
- continue
-
- try:
- cxt = libmount.Context(target=str(target))
- cxt.umount()
- except OSError as e:
- log.warning("Couldn't umount: %s, %s", target,
- e.strerror)
- umount_failed = True
-
- if umount_failed:
- # if any bind mounts really failed, then we need to raise
- # this to potentially prevent an upcoming bash stage cleanup script
- # from wiping our bind mounts.
- raise CatalystError(
- "Couldn't umount one or more bind-mounts; aborting for safety.")
-
def chroot_setup(self):
self.makeconf = read_makeconf(normpath(self.settings["chroot_path"] +
self.settings["make_conf"]))
@@ -1190,7 +1157,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
env=self.env)
self.resume.enable("remove")
except:
- self.unbind()
raise
def preclean(self):
@@ -1206,7 +1172,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.resume.enable("preclean")
except:
- self.unbind()
raise CatalystError("Build failed, could not execute preclean")
def capture(self):
@@ -1269,7 +1234,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings['controller_file'])
except CatalystError:
- self.unbind()
raise CatalystError("Stage build aborting due to error.",
print_traceback=False)
@@ -1374,7 +1338,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
env=self.env)
log.info('unmerge shell script')
except CatalystError:
- self.unbind()
raise
self.resume.enable("unmerge")
@@ -1449,7 +1412,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
fileutils.touch(build_packages_resume)
self.resume.enable("build_packages")
except CatalystError:
- self.unbind()
raise CatalystError(
self.settings["spec_prefix"] +
"build aborting due to error.")
@@ -1473,7 +1435,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
self._build_kernel(kname=kname)
self.resume.enable("build_kernel")
except CatalystError:
- self.unbind()
raise CatalystError(
"build aborting due to kernel build error.",
print_traceback=True)
@@ -1517,7 +1478,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
key = 'boot/kernel/' + kname + '/config'
if key in self.settings:
if not os.path.exists(self.settings[key]):
- self.unbind()
raise CatalystError("Can't find kernel config: %s" %
self.settings[key])
@@ -1526,7 +1486,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings['chroot_path'] + '/var/tmp/' + kname + '.config')
except IOError:
- self.unbind()
+ raise
def _copy_initramfs_overlay(self, kname):
key = 'boot/kernel/' + kname + '/initramfs_overlay'
@@ -1556,7 +1516,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
env=self.env)
self.resume.enable("bootloader")
except CatalystError:
- self.unbind()
raise CatalystError("Script aborting due to error.")
def livecd_update(self):
@@ -1572,7 +1531,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.resume.enable("livecd_update")
except CatalystError:
- self.unbind()
raise CatalystError(
"build aborting due to livecd_update error.")
diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py
index 1314ce7c..e9138437 100644
--- a/catalyst/targets/embedded.py
+++ b/catalyst/targets/embedded.py
@@ -56,7 +56,6 @@ class embedded(StageBase):
"root_overlay",
"fsscript",
"unmerge",
- "unbind",
])
self.finish_sequence.extend([
"remove",
diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py
index 81367053..5c5e9f58 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -34,7 +34,6 @@ class livecd_stage1(StageBase):
"chroot_setup",
"setup_environment",
"build_packages",
- "unbind",
])
self.finish_sequence.extend([
"clean",
diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py
index f6c14919..3606047f 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -80,7 +80,6 @@ class livecd_stage2(StageBase):
for x in self.settings["livecd/modblacklist"]:
myf.write("\nblacklist "+x)
except:
- self.unbind()
raise CatalystError("Couldn't open " +
self.settings["chroot_path"] +
"/etc/modprobe.d/blacklist.conf.",
@@ -109,7 +108,6 @@ class livecd_stage2(StageBase):
"fsscript",
"rcupdate",
"unmerge",
- "unbind",
])
self.finish_sequence.extend([
"remove",
diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index 9a0a4156..55f4dff1 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -93,7 +93,6 @@ class netboot(StageBase):
cmd([self.settings['controller_file'], 'image'] +
myfiles, env=self.env)
except CatalystError:
- self.unbind()
raise CatalystError("Failed to copy files to image!",
print_traceback=True)
@@ -121,7 +120,6 @@ class netboot(StageBase):
cmd([self.settings['controller_file'], 'final'], env=self.env)
log.notice('Netboot Build Finished!')
except CatalystError:
- self.unbind()
raise CatalystError("Failed to move kernel images!",
print_traceback=True)
@@ -178,7 +176,6 @@ class netboot(StageBase):
"move_kernels",
"remove",
"empty",
- "unbind",
])
self.finish_sequence.extend([
"clean",
diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py
index 78a5c780..b7f74b01 100644
--- a/catalyst/targets/stage4.py
+++ b/catalyst/targets/stage4.py
@@ -57,7 +57,6 @@ class stage4(StageBase):
"preclean",
"rcupdate",
"unmerge",
- "unbind",
])
self.finish_sequence.extend([
"remove",
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2020-10-29 19:05 Matt Turner
0 siblings, 0 replies; 17+ messages in thread
From: Matt Turner @ 2020-10-29 19:05 UTC (permalink / raw
To: gentoo-commits
commit: a294ca570192c2399efc6977ccf7c1d09b720b35
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 29 00:28:24 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 19:05:44 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=a294ca57
catalyst: Move action_sequence out of self.settings[]
This self.settings[] dictionary is very similar to the god object
anti-pattern. Moving action_sequence out it starts us down the road of
fixing this.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 17 +++++++++--------
catalyst/targets/embedded.py | 2 +-
catalyst/targets/livecd_stage1.py | 2 +-
catalyst/targets/livecd_stage2.py | 6 +++---
catalyst/targets/netboot.py | 2 +-
catalyst/targets/stage1.py | 12 ++++++------
catalyst/targets/stage4.py | 2 +-
7 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 73eacfbe..801df2fb 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -64,6 +64,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
"portage_overlay",
"portage_prefix",
])
+ self.action_sequence = []
self.set_valid_build_kernel_vars(addlargs)
TargetBase.__init__(self, myspec, addlargs)
@@ -477,13 +478,13 @@ class StageBase(TargetBase, ClearBase, GenBase):
Or it calls the normal set_action_sequence() for the target stage.
"""
if "purgeonly" in self.settings["options"]:
- self.settings["action_sequence"] = ["remove_chroot"]
+ self.action_sequence = ["remove_chroot"]
return
self.set_action_sequence()
def set_action_sequence(self):
"""Set basic stage1, 2, 3 action sequences"""
- self.settings['action_sequence'] = [
+ self.action_sequence = [
"unpack",
"setup_confdir",
"portage_overlay",
@@ -499,14 +500,14 @@ class StageBase(TargetBase, ClearBase, GenBase):
def set_completion_action_sequences(self):
if "fetch" not in self.settings["options"]:
- self.settings["action_sequence"].append("capture")
+ self.action_sequence.append("capture")
if "keepwork" in self.settings["options"]:
- self.settings["action_sequence"].append("clear_autoresume")
+ self.action_sequence.append("clear_autoresume")
elif "seedcache" in self.settings["options"]:
- self.settings["action_sequence"].append("remove_autoresume")
+ self.action_sequence.append("remove_autoresume")
else:
- self.settings["action_sequence"].append("remove_autoresume")
- self.settings["action_sequence"].append("remove_chroot")
+ self.action_sequence.append("remove_autoresume")
+ self.action_sequence.append("remove_chroot")
def set_use(self):
use = self.settings["spec_prefix"] + "/use"
@@ -1380,7 +1381,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.purge()
failure = False
- for x in self.settings["action_sequence"]:
+ for x in self.action_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 99739512..3899cf1b 100644
--- a/catalyst/targets/embedded.py
+++ b/catalyst/targets/embedded.py
@@ -41,7 +41,7 @@ class embedded(StageBase):
StageBase.__init__(self, spec, addlargs)
def set_action_sequence(self):
- self.settings['action_sequence'] = [
+ self.action_sequence = [
"unpack",
"config_profile_link",
"setup_confdir",
diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py
index f0b6be8b..b8c26cb1 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -23,7 +23,7 @@ class livecd_stage1(StageBase):
StageBase.__init__(self, spec, addlargs)
def set_action_sequence(self):
- self.settings['action_sequence'] = [
+ self.action_sequence = [
"unpack",
"config_profile_link",
"setup_confdir",
diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py
index 88c0d95c..cac16b6e 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -87,7 +87,7 @@ class livecd_stage2(StageBase):
print_traceback=True)
def set_action_sequence(self):
- self.settings['action_sequence'] = [
+ self.action_sequence = [
"unpack",
"config_profile_link",
"setup_confdir",
@@ -99,7 +99,7 @@ class livecd_stage2(StageBase):
"build_kernel"
]
if "fetch" not in self.settings["options"]:
- self.settings['action_sequence'] += [
+ self.action_sequence += [
"bootloader",
"preclean",
"livecd_update",
@@ -115,4 +115,4 @@ class livecd_stage2(StageBase):
"setup_overlay",
"create_iso",
]
- self.settings["action_sequence"].append("clear_autoresume")
+ self.action_sequence.append("clear_autoresume")
diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index 5620e0d3..61583f0d 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -160,7 +160,7 @@ class netboot(StageBase):
self.resume.enable("empty")
def set_action_sequence(self):
- self.settings['action_sequence'] = [
+ self.action_sequence = [
"unpack",
"config_profile_link",
"setup_confdir",
diff --git a/catalyst/targets/stage1.py b/catalyst/targets/stage1.py
index 2c09a41f..89b30fe1 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.settings["action_sequence"].append("capture")
+ self.action_sequence.append("capture")
if "keepwork" in self.settings["options"]:
- self.settings["action_sequence"].append("clear_autoresume")
+ self.action_sequence.append("clear_autoresume")
elif "seedcache" in self.settings["options"]:
- self.settings["action_sequence"].append("remove_autoresume")
- self.settings["action_sequence"].append("clean_stage1")
+ self.action_sequence.append("remove_autoresume")
+ self.action_sequence.append("clean_stage1")
else:
- self.settings["action_sequence"].append("remove_autoresume")
- self.settings["action_sequence"].append("remove_chroot")
+ self.action_sequence.append("remove_autoresume")
+ self.action_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 346c0845..eef24a73 100644
--- a/catalyst/targets/stage4.py
+++ b/catalyst/targets/stage4.py
@@ -39,7 +39,7 @@ class stage4(StageBase):
self.settings["cleanables"].remove('/etc/resolv.conf')
def set_action_sequence(self):
- self.settings['action_sequence'] = [
+ self.action_sequence = [
"unpack",
"config_profile_link",
"setup_confdir",
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2021-01-18 19:53 Matt Turner
0 siblings, 0 replies; 17+ messages in thread
From: Matt Turner @ 2021-01-18 19:53 UTC (permalink / raw
To: gentoo-commits
commit: 7cc60e347e7084828691fc24484b08dd4261966a
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:50:38 2021 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=7cc60e34
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] 17+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2021-01-18 19:53 Matt Turner
0 siblings, 0 replies; 17+ messages in thread
From: Matt Turner @ 2021-01-18 19:53 UTC (permalink / raw
To: gentoo-commits
commit: 9f4e1ee6ca2f5a67fef7695328ee19707305251f
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 19:50:38 2021 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=9f4e1ee6
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] 17+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2021-01-18 19:53 Matt Turner
0 siblings, 0 replies; 17+ messages in thread
From: Matt Turner @ 2021-01-18 19:53 UTC (permalink / raw
To: gentoo-commits
commit: 0cf1e773acadfd5defd30db2f7dc112bb7ac461c
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 19:50:38 2021 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=0cf1e773
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 3b8d3a6e..40b60af3 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -90,7 +90,11 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.setup_confdir,
self.portage_overlay,
]
- self.build_sequence = []
+ self.build_sequence = [
+ self.bind,
+ self.chroot_setup,
+ self.setup_environment,
+ ]
self.finish_sequence = []
self.set_valid_build_kernel_vars(addlargs)
@@ -497,16 +501,13 @@ class StageBase(TargetBase, ClearBase, GenBase):
Or it calls the normal set_action_sequence() for the target stage.
"""
if "purgeonly" in self.settings["options"]:
- self.build_sequence.append(self.remove_chroot)
+ self.build_sequence = [self.remove_chroot]
return
self.set_action_sequence()
def set_action_sequence(self):
"""Set basic stage1, 2, 3 action sequences"""
self.build_sequence.extend([
- self.bind,
- self.chroot_setup,
- self.setup_environment,
self.run_local,
self.preclean,
])
diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py
index 83b17ad2..b677b226 100644
--- a/catalyst/targets/embedded.py
+++ b/catalyst/targets/embedded.py
@@ -42,9 +42,6 @@ class embedded(StageBase):
def set_action_sequence(self):
self.build_sequence.extend([
- self.bind,
- self.chroot_setup,
- self.setup_environment,
self.build_kernel,
self.build_packages,
self.root_overlay,
diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py
index 9fe95a00..dbfa54ed 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -24,9 +24,6 @@ class livecd_stage1(StageBase):
def set_action_sequence(self):
self.build_sequence.extend([
- self.bind,
- self.chroot_setup,
- self.setup_environment,
self.build_packages,
])
self.finish_sequence.extend([
diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py
index ab8f4a0e..e90e9f53 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -87,9 +87,6 @@ class livecd_stage2(StageBase):
def set_action_sequence(self):
self.build_sequence.extend([
- self.bind,
- self.chroot_setup,
- self.setup_environment,
self.run_local,
self.build_kernel
])
diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index cb5e7ae4..a2a9fcb3 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -159,9 +159,6 @@ class netboot(StageBase):
def set_action_sequence(self):
self.build_sequence.extend([
- self.bind,
- self.chroot_setup,
- self.setup_environment,
self.build_packages,
self.root_overlay,
self.copy_files_to_image,
diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py
index 9e53f070..f8383f75 100644
--- a/catalyst/targets/stage4.py
+++ b/catalyst/targets/stage4.py
@@ -40,9 +40,6 @@ class stage4(StageBase):
def set_action_sequence(self):
self.build_sequence.extend([
- self.bind,
- self.chroot_setup,
- self.setup_environment,
self.build_packages,
self.build_kernel,
self.bootloader,
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, catalyst/targets/
@ 2021-01-28 1:54 Matt Turner
0 siblings, 0 replies; 17+ messages in thread
From: Matt Turner @ 2021-01-28 1:54 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] 17+ messages in thread
end of thread, other threads:[~2021-01-28 1:54 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-29 16:14 [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, catalyst/targets/ Matt Turner
-- strict thread matches above, loose matches on Subject: below --
2021-01-28 1:54 Matt Turner
2021-01-18 19:53 Matt Turner
2021-01-18 19:53 Matt Turner
2021-01-18 19:53 Matt Turner
2020-10-29 19:05 Matt Turner
2020-10-29 16:34 Matt Turner
2020-10-29 16:14 Matt Turner
2020-10-29 16:14 Matt Turner
2020-10-29 16:04 Matt Turner
2020-10-29 16:04 Matt Turner
2020-10-29 16:04 Matt Turner
2020-10-29 15:47 Matt Turner
2020-10-29 15:47 Matt Turner
2020-10-29 15:47 Matt Turner
2020-10-29 3:33 Matt Turner
2020-10-29 3:33 Matt Turner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox