* [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/
@ 2015-02-26 4:12 Brian Dolbec
0 siblings, 0 replies; 14+ messages in thread
From: Brian Dolbec @ 2015-02-26 4:12 UTC (permalink / raw
To: gentoo-commits
commit: 5fa2b2a910c45401f132e7ed7e9da9a993762252
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 12 03:51:52 2013 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jan 1 05:58:05 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=5fa2b2a9
[1 of 3] Move base stage and target files to thier own sub-pkg
Fix an indent error in grp_target.py
---
catalyst/base/__init__.py | 1 +
catalyst/{targets => base}/clearbase.py | 0
catalyst/{targets => base}/genbase.py | 0
.../generic_stage_target.py => base/stagebase.py} | 8 ++---
catalyst/{targets => base}/targetbase.py | 0
catalyst/targets/embedded_target.py | 12 ++++----
catalyst/targets/grp_target.py | 34 +++++++++++++---------
catalyst/targets/livecd_stage1_target.py | 21 ++++++++-----
catalyst/targets/livecd_stage2_target.py | 13 +++++----
catalyst/targets/netboot2_target.py | 17 +++++++----
catalyst/targets/netboot_target.py | 15 ++++++----
catalyst/targets/snapshot_target.py | 4 +--
catalyst/targets/stage1_target.py | 17 ++++++-----
catalyst/targets/stage2_target.py | 15 ++++++----
catalyst/targets/stage3_target.py | 12 ++++----
catalyst/targets/stage4_target.py | 8 ++---
catalyst/targets/tinderbox_target.py | 11 ++++---
17 files changed, 113 insertions(+), 75 deletions(-)
diff --git a/catalyst/base/__init__.py b/catalyst/base/__init__.py
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/catalyst/base/__init__.py
@@ -0,0 +1 @@
+
diff --git a/catalyst/targets/clearbase.py b/catalyst/base/clearbase.py
similarity index 100%
rename from catalyst/targets/clearbase.py
rename to catalyst/base/clearbase.py
diff --git a/catalyst/targets/genbase.py b/catalyst/base/genbase.py
similarity index 100%
rename from catalyst/targets/genbase.py
rename to catalyst/base/genbase.py
diff --git a/catalyst/targets/generic_stage_target.py b/catalyst/base/stagebase.py
similarity index 99%
rename from catalyst/targets/generic_stage_target.py
rename to catalyst/base/stagebase.py
index 296eee3..bebb5dc 100644
--- a/catalyst/targets/generic_stage_target.py
+++ b/catalyst/base/stagebase.py
@@ -14,13 +14,13 @@ from catalyst.defaults import (SOURCE_MOUNT_DEFAULTS, TARGET_MOUNT_DEFAULTS,
PORT_LOGDIR_CLEAN)
from catalyst.support import (CatalystError, msg, file_locate, normpath,
touch, cmd, warn, list_bashify, read_makeconf, read_from_clst, ismount)
-from catalyst.targets.targetbase import TargetBase
-from catalyst.targets.clearbase import ClearBase
-from catalyst.targets.genbase import GenBase
+from catalyst.base.targetbase import TargetBase
+from catalyst.base.clearbase import ClearBase
+from catalyst.base.genbase import GenBase
from catalyst.lock import LockDir
-class generic_stage_target(TargetBase, ClearBase, GenBase):
+class StageBase(TargetBase, ClearBase, GenBase):
"""
This class does all of the chroot setup, copying of files, etc. It is
the driver class for pretty much everything that Catalyst does.
diff --git a/catalyst/targets/targetbase.py b/catalyst/base/targetbase.py
similarity index 100%
rename from catalyst/targets/targetbase.py
rename to catalyst/base/targetbase.py
diff --git a/catalyst/targets/embedded_target.py b/catalyst/targets/embedded_target.py
index 7cee7a6..528d545 100644
--- a/catalyst/targets/embedded_target.py
+++ b/catalyst/targets/embedded_target.py
@@ -10,12 +10,12 @@ ROOT=/tmp/submerge emerge --something foo bar .
"""
# NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
-import os,string,imp,types,shutil
-from catalyst.support import *
-from generic_stage_target import *
-from stat import *
-class embedded_target(generic_stage_target):
+from catalyst.support import normpath
+
+from catalyst.base.stagebase import StageBase
+
+class embedded_target(StageBase):
"""
Builder class for embedded target
"""
@@ -27,7 +27,7 @@ class embedded_target(generic_stage_target):
if "embedded/fs-type" in addlargs:
self.valid_values.append("embedded/fs-ops")
- generic_stage_target.__init__(self,spec,addlargs)
+ StageBase.__init__(self,spec,addlargs)
self.set_build_kernel_vars(addlargs)
def set_action_sequence(self):
diff --git a/catalyst/targets/grp_target.py b/catalyst/targets/grp_target.py
index 033db75..deba80a 100644
--- a/catalyst/targets/grp_target.py
+++ b/catalyst/targets/grp_target.py
@@ -3,11 +3,18 @@ Gentoo Reference Platform (GRP) target
"""
# NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
-import os,types,glob
-from catalyst.support import *
-from generic_stage_target import *
+import os
+import types
+import glob
-class grp_target(generic_stage_target):
+
+from catalyst.support import (CatalystError, normpath,
+ touch, cmd, list_bashify)
+
+from catalyst.base.stagebase import StageBase
+
+
+class grp_target(StageBase):
"""
The builder class for GRP (Gentoo Reference Platform) builds.
"""
@@ -32,7 +39,7 @@ class grp_target(generic_stage_target):
self.required_values.append("grp/"+x+"/packages")
self.required_values.append("grp/"+x+"/type")
- generic_stage_target.__init__(self,spec,addlargs)
+ StageBase.__init__(self,spec,addlargs)
def set_target_path(self):
self.settings["target_path"]=normpath(self.settings["storedir"]+"/builds/"+self.settings["target_subpath"]+"/")
@@ -62,16 +69,15 @@ class grp_target(generic_stage_target):
raise CatalystError,"GRP build aborting due to error."
def set_use(self):
- generic_stage_target.set_use(self)
- if "BINDIST" in self.settings:
- if "use" in self.settings:
- self.settings["use"].append("bindist")
- else:
- self.settings["use"]=["bindist"]
+ StageBase.set_use(self)
+ if "use" in self.settings:
+ self.settings["use"].append("bindist")
+ else:
+ self.settings["use"]=["bindist"]
def set_mounts(self):
- self.mounts.append("/tmp/grp")
- self.mountmap["/tmp/grp"]=self.settings["target_path"]
+ self.mounts.append("/tmp/grp")
+ self.mountmap["/tmp/grp"]=self.settings["target_path"]
def generate_digests(self):
for pkgset in self.settings["grp"]:
@@ -108,7 +114,7 @@ class grp_target(generic_stage_target):
self.gen_digest_file(normpath(destdir+"/"+i))
def set_action_sequence(self):
- self.settings["action_sequence"]=["unpack","unpack_snapshot",\
+ self.settings["action_sequence"]=["unpack","unpack_snapshot",\
"config_profile_link","setup_confdir","portage_overlay","bind","chroot_setup",\
"setup_environment","run_local","unbind",\
"generate_digests","clear_autoresume"]
diff --git a/catalyst/targets/livecd_stage1_target.py b/catalyst/targets/livecd_stage1_target.py
index 6273c9e..a19f4ac 100644
--- a/catalyst/targets/livecd_stage1_target.py
+++ b/catalyst/targets/livecd_stage1_target.py
@@ -3,10 +3,17 @@ LiveCD stage1 target
"""
# NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
-from catalyst.support import *
-from generic_stage_target import *
+import os
+import types
+import string
-class livecd_stage1_target(generic_stage_target):
+from catalyst.support import (normpath,
+ touch, cmd)
+
+from catalyst.base.stagebase import StageBase
+
+
+class livecd_stage1_target(StageBase):
"""
Builder class for LiveCD stage1.
"""
@@ -15,7 +22,7 @@ class livecd_stage1_target(generic_stage_target):
self.valid_values=self.required_values[:]
self.valid_values.extend(["livecd/use"])
- generic_stage_target.__init__(self,spec,addlargs)
+ StageBase.__init__(self,spec,addlargs)
def set_action_sequence(self):
self.settings["action_sequence"]=["unpack","unpack_snapshot",\
@@ -45,7 +52,7 @@ class livecd_stage1_target(generic_stage_target):
self.settings["spec_prefix"]="livecd"
def set_use(self):
- generic_stage_target.set_use(self)
+ StageBase.set_use(self)
if "use" in self.settings:
self.settings["use"].append("livecd")
if "BINDIST" in self.settings:
@@ -56,7 +63,7 @@ class livecd_stage1_target(generic_stage_target):
self.settings["use"].append("bindist")
def set_packages(self):
- generic_stage_target.set_packages(self)
+ StageBase.set_packages(self)
if self.settings["spec_prefix"]+"/packages" in self.settings:
if type(self.settings[self.settings["spec_prefix"]+"/packages"]) == types.StringType:
self.settings[self.settings["spec_prefix"]+"/packages"] = \
@@ -68,7 +75,7 @@ class livecd_stage1_target(generic_stage_target):
if type(self.settings["pkgcache_path"]) != types.StringType:
self.settings["pkgcache_path"]=normpath(string.join(self.settings["pkgcache_path"]))
else:
- generic_stage_target.set_pkgcache_path(self)
+ StageBase.set_pkgcache_path(self)
def register(foo):
foo.update({"livecd-stage1":livecd_stage1_target})
diff --git a/catalyst/targets/livecd_stage2_target.py b/catalyst/targets/livecd_stage2_target.py
index 11b1219..e7ae212 100644
--- a/catalyst/targets/livecd_stage2_target.py
+++ b/catalyst/targets/livecd_stage2_target.py
@@ -3,11 +3,14 @@ LiveCD stage2 target, builds upon previous LiveCD stage1 tarball
"""
# NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
-import os,string,types,stat,shutil
-from catalyst.support import *
-from generic_stage_target import *
+import os
-class livecd_stage2_target(generic_stage_target):
+from catalyst.support import (normpath, file_locate, CatalystError, cmd,
+ read_from_clst, touch)
+from catalyst.base.stagebase import StageBase
+
+
+class livecd_stage2_target(StageBase):
"""
Builder class for a LiveCD stage2 build.
"""
@@ -26,7 +29,7 @@ class livecd_stage2_target(generic_stage_target):
"livecd/fstype","livecd/fsops","livecd/linuxrc","livecd/bootargs",\
"gamecd/conf","livecd/xdm","livecd/xsession","livecd/volid"])
- generic_stage_target.__init__(self,spec,addlargs)
+ StageBase.__init__(self,spec,addlargs)
if "livecd/type" not in self.settings:
self.settings["livecd/type"] = "generic-livecd"
diff --git a/catalyst/targets/netboot2_target.py b/catalyst/targets/netboot2_target.py
index ea07d76..987afd8 100644
--- a/catalyst/targets/netboot2_target.py
+++ b/catalyst/targets/netboot2_target.py
@@ -3,11 +3,18 @@ netboot target, version 2
"""
# NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
-import os,string,types
-from catalyst.support import *
-from generic_stage_target import *
+import os
+import types
+import shutil
+from stat import ST_UID, ST_GID, ST_MODE
-class netboot2_target(generic_stage_target):
+from catalyst.support import (CatalystError, normpath,
+ touch, cmd, list_bashify)
+
+from catalyst.base.stagebase import StageBase
+
+
+class netboot2_target(StageBase):
"""
Builder class for a netboot build, version 2
"""
@@ -38,7 +45,7 @@ class netboot2_target(generic_stage_target):
except:
raise CatalystError,"configuration error in netboot2/packages."
- generic_stage_target.__init__(self,spec,addlargs)
+ StageBase.__init__(self,spec,addlargs)
self.set_build_kernel_vars()
self.settings["merge_path"]=normpath("/tmp/image/")
diff --git a/catalyst/targets/netboot_target.py b/catalyst/targets/netboot_target.py
index ae1eb04..c880289 100644
--- a/catalyst/targets/netboot_target.py
+++ b/catalyst/targets/netboot_target.py
@@ -3,11 +3,16 @@ netboot target, version 1
"""
# NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
-import os,string,types
-from catalyst.support import *
-from generic_stage_target import *
+import os
+import types
-class netboot_target(generic_stage_target):
+from catalyst.support import (CatalystError, normpath,
+ cmd, list_bashify, file_locate)
+
+from catalyst.base.stagebase import StageBase
+
+
+class netboot_target(StageBase):
"""
Builder class for a netboot build.
"""
@@ -36,7 +41,7 @@ class netboot_target(generic_stage_target):
except:
raise CatalystError,"configuration error in netboot/packages."
- generic_stage_target.__init__(self,spec,addlargs)
+ StageBase.__init__(self,spec,addlargs)
self.set_build_kernel_vars(addlargs)
if "netboot/busybox_config" in addlargs:
file_locate(self.settings, ["netboot/busybox_config"])
diff --git a/catalyst/targets/snapshot_target.py b/catalyst/targets/snapshot_target.py
index 3289bbd..337ff1d 100644
--- a/catalyst/targets/snapshot_target.py
+++ b/catalyst/targets/snapshot_target.py
@@ -8,8 +8,8 @@ from stat import ST_UID, ST_GID, ST_MODE
from catalyst.support import normpath, cmd
-from catalyst.targets.targetbase import TargetBase
-from catalyst.targets.genbase import GenBase
+from catalyst.base.targetbase import TargetBase
+from catalyst.base.genbase import GenBase
class snapshot_target(TargetBase, GenBase):
"""
diff --git a/catalyst/targets/stage1_target.py b/catalyst/targets/stage1_target.py
index 8d5a674..0a36432 100644
--- a/catalyst/targets/stage1_target.py
+++ b/catalyst/targets/stage1_target.py
@@ -3,10 +3,13 @@ stage1 target
"""
# NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
-from catalyst.support import *
-from generic_stage_target import *
+import os
-class stage1_target(generic_stage_target):
+from catalyst.support import normpath, list_to_string
+from catalyst.base.stagebase import StageBase
+
+
+class stage1_target(StageBase):
"""
Builder class for a stage1 installation tarball build.
"""
@@ -14,7 +17,7 @@ class stage1_target(generic_stage_target):
self.required_values=[]
self.valid_values=["chost"]
self.valid_values.extend(["update_seed","update_seed_command"])
- generic_stage_target.__init__(self,spec,addlargs)
+ StageBase.__init__(self,spec,addlargs)
def set_stage_path(self):
self.settings["stage_path"]=normpath(self.settings["chroot_path"]+self.settings["root_path"])
@@ -26,11 +29,11 @@ class stage1_target(generic_stage_target):
print "stage1 root path is "+self.settings["root_path"]
def set_cleanables(self):
- generic_stage_target.set_cleanables(self)
+ StageBase.set_cleanables(self)
self.settings["cleanables"].extend([\
"/usr/share/zoneinfo", "/etc/portage/package*"])
- # XXX: How do these override_foo() functions differ from the ones in generic_stage_target and why aren't they in stage3_target?
+ # XXX: How do these override_foo() functions differ from the ones in StageBase and why aren't they in stage3_target?
def override_chost(self):
if "chost" in self.settings:
@@ -49,7 +52,7 @@ class stage1_target(generic_stage_target):
self.settings["LDFLAGS"]=list_to_string(self.settings["ldflags"])
def set_portage_overlay(self):
- generic_stage_target.set_portage_overlay(self)
+ StageBase.set_portage_overlay(self)
if "portage_overlay" in self.settings:
print "\nWARNING !!!!!"
print "\tUsing an portage overlay for earlier stages could cause build issues."
diff --git a/catalyst/targets/stage2_target.py b/catalyst/targets/stage2_target.py
index 94d4a1e..783d42e 100644
--- a/catalyst/targets/stage2_target.py
+++ b/catalyst/targets/stage2_target.py
@@ -3,17 +3,20 @@ stage2 target, builds upon previous stage1 tarball
"""
# NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
-from catalyst.support import *
-from generic_stage_target import *
+import os
-class stage2_target(generic_stage_target):
+from catalyst.support import normpath, list_to_string
+from catalyst.base.stagebase import StageBase
+
+
+class stage2_target(StageBase):
"""
Builder class for a stage2 installation tarball build.
"""
def __init__(self,spec,addlargs):
self.required_values=[]
self.valid_values=["chost"]
- generic_stage_target.__init__(self,spec,addlargs)
+ StageBase.__init__(self,spec,addlargs)
def set_source_path(self):
if "seedcache" in self.settings["options"] and os.path.isdir(normpath(self.settings["storedir"]+"/tmp/"+self.settings["source_subpath"]+"/tmp/stage1root/")):
@@ -34,7 +37,7 @@ class stage2_target(generic_stage_target):
print "\tthe source path will then be "+normpath(self.settings["storedir"]+"/builds/"+self.settings["source_subpath"]+".tar.bz2\n")
# XXX: How do these override_foo() functions differ from the ones in
- # generic_stage_target and why aren't they in stage3_target?
+ # StageBase and why aren't they in stage3_target?
def override_chost(self):
if "chost" in self.settings:
@@ -53,7 +56,7 @@ class stage2_target(generic_stage_target):
self.settings["LDFLAGS"]=list_to_string(self.settings["ldflags"])
def set_portage_overlay(self):
- generic_stage_target.set_portage_overlay(self)
+ StageBase.set_portage_overlay(self)
if "portage_overlay" in self.settings:
print "\nWARNING !!!!!"
print "\tUsing an portage overlay for earlier stages could cause build issues."
diff --git a/catalyst/targets/stage3_target.py b/catalyst/targets/stage3_target.py
index 89edd66..28021b1 100644
--- a/catalyst/targets/stage3_target.py
+++ b/catalyst/targets/stage3_target.py
@@ -3,20 +3,20 @@ stage3 target, builds upon previous stage2/stage3 tarball
"""
# NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
-from catalyst.support import *
-from generic_stage_target import *
+from catalyst.base.stagebase import StageBase
-class stage3_target(generic_stage_target):
+
+class stage3_target(StageBase):
"""
Builder class for a stage3 installation tarball build.
"""
def __init__(self,spec,addlargs):
self.required_values=[]
self.valid_values=[]
- generic_stage_target.__init__(self,spec,addlargs)
+ StageBase.__init__(self,spec,addlargs)
def set_portage_overlay(self):
- generic_stage_target.set_portage_overlay(self)
+ StageBase.set_portage_overlay(self)
if "portage_overlay" in self.settings:
print "\nWARNING !!!!!"
print "\tUsing an overlay for earlier stages could cause build issues."
@@ -24,7 +24,7 @@ class stage3_target(generic_stage_target):
print "\tDont say we did not warn you\n"
def set_cleanables(self):
- generic_stage_target.set_cleanables(self)
+ StageBase.set_cleanables(self)
def register(foo):
foo.update({"stage3":stage3_target})
diff --git a/catalyst/targets/stage4_target.py b/catalyst/targets/stage4_target.py
index e2b8a79..0d725c7 100644
--- a/catalyst/targets/stage4_target.py
+++ b/catalyst/targets/stage4_target.py
@@ -3,10 +3,10 @@ stage4 target, builds upon previous stage3/stage4 tarball
"""
# NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
-from catalyst.support import *
-from generic_stage_target import *
+from catalyst.base.stagebase import StageBase
-class stage4_target(generic_stage_target):
+
+class stage4_target(StageBase):
"""
Builder class for stage4.
"""
@@ -18,7 +18,7 @@ class stage4_target(generic_stage_target):
"stage4/gk_mainargs","splash_theme",\
"portage_overlay","stage4/rcadd","stage4/rcdel",\
"stage4/linuxrc","stage4/unmerge","stage4/rm","stage4/empty"])
- generic_stage_target.__init__(self,spec,addlargs)
+ StageBase.__init__(self,spec,addlargs)
def set_cleanables(self):
self.settings["cleanables"]=["/var/tmp/*","/tmp/*"]
diff --git a/catalyst/targets/tinderbox_target.py b/catalyst/targets/tinderbox_target.py
index ea11d3f..1e245f2 100644
--- a/catalyst/targets/tinderbox_target.py
+++ b/catalyst/targets/tinderbox_target.py
@@ -3,10 +3,13 @@ Tinderbox target
"""
# NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
-from catalyst.support import *
-from generic_stage_target import *
+import os
-class tinderbox_target(generic_stage_target):
+from catalyst.support import cmd, list_bashify, CatalystError
+from catalyst.base.stagebase import StageBase
+
+
+class tinderbox_target(StageBase):
"""
Builder class for the tinderbox target
"""
@@ -14,7 +17,7 @@ class tinderbox_target(generic_stage_target):
self.required_values=["tinderbox/packages"]
self.valid_values=self.required_values[:]
self.valid_values.extend(["tinderbox/use"])
- generic_stage_target.__init__(self,spec,addlargs)
+ StageBase.__init__(self,spec,addlargs)
def run_local(self):
# tinderbox
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/
2015-02-26 19:25 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
@ 2015-02-26 20:12 ` Brian Dolbec
0 siblings, 0 replies; 14+ messages in thread
From: Brian Dolbec @ 2015-02-26 20:12 UTC (permalink / raw
To: gentoo-commits
commit: d4408f858c4c3eb71ef0efdef5f23ebf6526dd87
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 1 06:28:19 2013 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Feb 26 08:32:57 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=d4408f85
Fix some paths/normpath usage
Use pjoin to join paths.
Use os.path.dirname() instead of splitting and rejoining without the filename.
Don't remove the trailing slash from the seedcache path in set_source_path(),
fix supplied by GMsoft. Rebase it into this original commit that broke it.
---
catalyst/base/stagebase.py | 21 ++++++++++-----------
catalyst/targets/livecd_stage2.py | 2 +-
2 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index f3cb3e3..edb6032 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -306,7 +306,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
if "pkgcache_path" in self.settings:
if type(self.settings["pkgcache_path"])!=types.StringType:
self.settings["pkgcache_path"]=\
- normpath(string.join(self.settings["pkgcache_path"]))
+ normpath(self.settings["pkgcache_path"])
else:
self.settings["pkgcache_path"]=\
normpath(self.settings["storedir"]+"/packages/"+\
@@ -316,7 +316,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
if "kerncache_path" in self.settings:
if type(self.settings["kerncache_path"])!=types.StringType:
self.settings["kerncache_path"]=\
- normpath(string.join(self.settings["kerncache_path"]))
+ normpath(self.settings["kerncache_path"])
else:
self.settings["kerncache_path"]=normpath(self.settings["storedir"]+\
"/kerncache/"+self.settings["target_subpath"]+"/")
@@ -339,7 +339,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
# +self.settings["target_path"],env=self.env)
self.resume.enable("setup_target_path")
- ensure_dirs(self.settings["storedir"] + "/builds/")
+ ensure_dirs(self.settings["storedir"] + "/builds")
def set_fsscript(self):
if self.settings["spec_prefix"]+"/fsscript" in self.settings:
@@ -403,8 +403,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
if "seedcache" in self.settings["options"]\
and os.path.isdir(normpath(self.settings["storedir"]+"/tmp/"+\
self.settings["source_subpath"]+"/")):
- self.settings["source_path"]=normpath(self.settings["storedir"]+\
- "/tmp/"+self.settings["source_subpath"]+"/")
+ self.settings["source_path"] = normpath(self.settings["storedir"] +
+ "/tmp/" + self.settings["source_subpath"] + "/")
else:
self.settings["source_path"]=normpath(self.settings["storedir"]+\
"/builds/"+self.settings["source_subpath"]+".tar.bz2")
@@ -461,8 +461,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
def set_snapcache_path(self):
if "snapcache" in self.settings["options"]:
self.settings["snapshot_cache_path"] = \
- normpath(self.settings["snapshot_cache"] + "/" +
- self.settings["snapshot"])
+ normpath(pjoin(self.settings["snapshot_cache"],
+ self.settings["snapshot"]))
self.snapcache_lock=\
LockDir(self.settings["snapshot_cache_path"])
print "Caching snapshot to "+self.settings["snapshot_cache_path"]
@@ -824,7 +824,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
unpack_errmsg="Error unpacking snapshot"
if "autoresume" in self.settings["options"] \
- and os.path.exists(self.settings["chroot_path"]+\
+ and os.path.exists(self.settings["chroot_path"] +
self.settings["portdir"]) \
and self.resume.is_enabled("unpack_portage") \
and self.settings["snapshot_path_hash"] == snapshot_hash:
@@ -1235,10 +1235,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
and self.resume.is_enabled("capture"):
print "Resume point detected, skipping capture operation..."
else:
- """ Capture target in a tarball """
- mypath=self.settings["target_path"].split("/")
+ print """ Capture target in a tarball """
""" Remove filename from path """
- mypath=string.join(mypath[:-1],"/")
+ mypath = os.path.dirname(self.settings["target_path"])
""" Now make sure path exists """
ensure_dirs(mypath)
diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py
index 973a734..78bed82 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -43,7 +43,7 @@ class livecd_stage2(StageBase):
self.settings["hash_map"].generate_hash(
self.settings["source_path"])
else:
- self.settings["source_path"]=normpath(self.settings["storedir"]+"/tmp/"+self.settings["source_subpath"]+"/")
+ self.settings["source_path"]=normpath(self.settings["storedir"]+"/tmp/"+self.settings["source_subpath"])
if not os.path.exists(self.settings["source_path"]):
raise CatalystError("Source Path: " +
self.settings["source_path"] + " does not exist.",
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/
2015-01-01 5:59 [gentoo-commits] proj/catalyst:pending commit in: catalyst/targets/, catalyst/base/ Brian Dolbec
@ 2015-02-26 20:12 ` Brian Dolbec
0 siblings, 0 replies; 14+ messages in thread
From: Brian Dolbec @ 2015-02-26 20:12 UTC (permalink / raw
To: gentoo-commits
commit: a1c2785438593104d7c3d2ec20dd4fb25cb19884
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 1 06:23:46 2013 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jan 1 05:58:07 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=a1c27854
Create AutoResume class to handle all file creation, deletion...
Create catalyst/base/resume.py.
Migrate all auto_resume operations to using the new class.
---
catalyst/base/clearbase.py | 21 +----
catalyst/base/resume.py | 166 ++++++++++++++++++++++++++++++++++++++
catalyst/base/stagebase.py | 156 +++++++++++++++--------------------
catalyst/targets/grp.py | 4 +-
catalyst/targets/livecd_stage1.py | 4 +-
catalyst/targets/livecd_stage2.py | 14 ++--
catalyst/targets/netboot2.py | 19 +++--
7 files changed, 250 insertions(+), 134 deletions(-)
diff --git a/catalyst/base/clearbase.py b/catalyst/base/clearbase.py
index 8462a3c..0ebe299 100644
--- a/catalyst/base/clearbase.py
+++ b/catalyst/base/clearbase.py
@@ -13,31 +13,14 @@ class ClearBase(object):
"""
def __init__(self, myspec):
self.settings = myspec
-
+ self.resume = None
def clear_autoresume(self):
""" Clean resume points since they are no longer needed """
if "autoresume" in self.settings["options"]:
print "Removing AutoResume Points: ..."
- myemp=self.settings["autoresume_path"]
- if os.path.isdir(myemp):
- if "autoresume" in self.settings["options"]:
- print "Emptying directory",myemp
- """
- stat the dir, delete the dir, recreate the dir and set
- the proper perms and ownership
- """
- mystat=os.stat(myemp)
- if os.uname()[0] == "FreeBSD":
- cmd("chflags -R noschg "+myemp,\
- "Could not remove immutable flag for file "\
- +myemp)
- #cmd("rm -rf "+myemp, "Could not remove existing file: "+myemp,env-self.env)
- shutil.rmtree(myemp)
- ensure_dirs(myemp, 0755)
- os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
- os.chmod(myemp,mystat[ST_MODE])
+ self.resume.clear_all()
def clear_chroot(self):
diff --git a/catalyst/base/resume.py b/catalyst/base/resume.py
new file mode 100644
index 0000000..e42c7dc
--- /dev/null
+++ b/catalyst/base/resume.py
@@ -0,0 +1,166 @@
+#!/usr/bin/python
+
+# Maintained in full by:
+# Catalyst Team <catalyst@gentoo.org>
+# Release Engineering Team <releng@gentoo.org>
+# Copyright 2013 Brian Dolbec <dolsen@gentoo.org>
+
+'''resume.py
+
+Performs autoresume tracking file operations such as
+set, unset, is_set, is_unset, enabled, clear_all
+'''
+
+import os
+import shutil
+from stat import ST_UID, ST_GID, ST_MODE
+import traceback
+
+from catalyst.fileops import ensure_dirs, pjoin, listdir_files
+from catalyst.support import touch
+
+
+class AutoResumeError(Exception):
+ def __init__(self, message, print_traceback=False):
+ if message:
+ if print_traceback:
+ (type,value)=sys.exc_info()[:2]
+ if value!=None:
+ print
+ print "Traceback values found. listing..."
+ print traceback.print_exc(file=sys.stdout)
+ print "!!! catalyst: AutoResumeError " + message
+ print
+
+
+class AutoResume(object):
+ '''Class for tracking and handling all aspects of
+ the autoresume option and related files.
+ '''
+
+
+ def __init__(self, basedir, mode=0755):
+ self.basedir = basedir
+ ensure_dirs(basedir, mode=mode, fatal=True)
+ self._points = {}
+ self._init_points_()
+
+
+ def _init_points_(self):
+ '''Internal function which reads the autoresume directory and
+ for existing autoresume points and adds them to our _points variable
+ '''
+ existing = listdir_files(self.basedir, False)
+ for point in existing:
+ self._points[point] = pjoin(self.basedir, point)
+
+
+ def enable(self, point, data=None):
+ '''Sets the resume point 'ON'
+
+ @param point: string. name of the resume point to enable
+ @param data: string of information to store, or None
+ @return boolean
+ '''
+ if point in self._points and not data:
+ return True
+ fname = pjoin(self.basedir, point)
+ if data:
+ with open(fname,"w") as myf:
+ myf.write(data)
+ else:
+ try:
+ touch(fname)
+ self._points[point] = fname
+ except Exception as e:
+ print AutoResumeError(str(e))
+ return False
+ return True
+
+
+ def get(self, point, no_lf=True):
+ '''Gets any data stored inside a resume point
+
+ @param point: string. name of the resume point to enable
+ @return data: string of information stored, or None
+ '''
+ if point in self._points:
+ try:
+ with open(self._points[point], 'r') as myf:
+ data = myf.read()
+ if data and no_lf:
+ data = data.replace('\n', '')
+ except OSError as e:
+ print AutoResumeError(str(e))
+ return None
+ return data
+ return None
+
+
+ def disable(self, point):
+ '''Sets the resume point 'OFF'
+
+ @param point: string. name of the resume point to disable
+ @return boolean
+ '''
+ if point not in self._points:
+ return True
+ try:
+ os.unlink(self._points[point])
+ self._points.pop(point)
+ except Exception as e:
+ print AutoResumeError(str(e))
+ return False
+ return True
+
+
+ def is_enabled(self, point):
+ '''Returns True if the resume point 'ON'
+
+ @param point: string. name of the resume point enabled
+ @return boolean
+ '''
+ return point in self._points
+
+
+ def is_disabled(self, point):
+ '''Returns True if the resume point 'OFF'
+
+ @param point: string. name of the resume point not enabled
+ @return boolean
+ '''
+ return point not in self._points
+
+
+ @property
+ def enabled(self):
+ '''Returns a list of enabled points
+ '''
+ return list(self._points)
+
+
+ def clear_all(self):
+ '''Clear all active resume points
+
+ @return boolean
+ '''
+ try:
+ print "Emptying directory---", self.basedir
+ """
+ stat the dir, delete the dir, recreate the dir and set
+ the proper perms and ownership
+ """
+ mystat=os.stat(self.basedir)
+ if os.uname()[0] == "FreeBSD":
+ cmd("chflags -R noschg " + self.basedir,\
+ "Could not remove immutable flag for file "\
+ + self.basedir)
+ shutil.rmtree(self.basedir)
+ ensure_dirs(self.basedir, 0755)
+ os.chown(self.basedir,mystat[ST_UID],mystat[ST_GID])
+ os.chmod(self.basedir,mystat[ST_MODE])
+ self._points = {}
+ except Exception as e:
+ print AutoResumeError(str(e))
+ return False
+ return True
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 40c7362..f3cb3e3 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -19,6 +19,7 @@ from catalyst.base.clearbase import ClearBase
from catalyst.base.genbase import GenBase
from catalyst.lock import LockDir
from catalyst.fileops import ensure_dirs, pjoin
+from catalyst.base.resume import AutoResume
class StageBase(TargetBase, ClearBase, GenBase):
@@ -323,10 +324,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
def set_target_path(self):
self.settings["target_path"]=normpath(self.settings["storedir"]+\
"/builds/"+self.settings["target_subpath"]+".tar.bz2")
- setup_target_path_resume = pjoin(self.settings["autoresume_path"],
- "setup_target_path")
- if "autoresume" in self.settings["options"] and \
- os.path.exists(setup_target_path_resume):
+ if "autoresume" in self.settings["options"]\
+ and self.resume.is_enabled("setup_target_path"):
print \
"Resume point detected, skipping target path setup operation..."
else:
@@ -338,7 +337,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
# cmd("rm -f "+self.settings["target_path"],\
# "Could not remove existing file: "\
# +self.settings["target_path"],env=self.env)
- touch(setup_target_path_resume)
+ self.resume.enable("setup_target_path")
ensure_dirs(self.settings["storedir"] + "/builds/")
@@ -486,7 +485,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
))
if "autoresume" in self.settings["options"]:
print "The autoresume path is " + self.settings["autoresume_path"]
- ensure_dirs(self.settings["autoresume_path"], mode=0755)
+ self.resume = AutoResume(self.settings["autoresume_path"], mode=0755)
def set_controller_file(self):
self.settings["controller_file"]=normpath(self.settings["sharedir"]+\
@@ -667,8 +666,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
def unpack(self):
unpack=True
- unpack_resume = pjoin(self.settings["autoresume_path"], "unpack")
- clst_unpack_hash=read_from_clst(unpack_resume)
+ clst_unpack_hash = self.resume.get("unpack")
if "seedcache" in self.settings["options"]:
if os.path.isdir(self.settings["source_path"]):
@@ -714,7 +712,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
if "autoresume" in self.settings["options"]:
if os.path.isdir(self.settings["source_path"]) \
- and os.path.exists(unpack_resume):
+ and self.resume.is_enabled("unpack"):
""" Autoresume is valid, SEEDCACHE is valid """
unpack=False
invalid_snapshot=False
@@ -726,7 +724,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
invalid_snapshot=True
elif os.path.isdir(self.settings["source_path"]) \
- and not os.path.exists(unpack_resume):
+ and self.resume.is_disabled("unpack"):
""" Autoresume is invalid, SEEDCACHE """
unpack=True
invalid_snapshot=False
@@ -782,19 +780,16 @@ class StageBase(TargetBase, ClearBase, GenBase):
cmd(unpack_cmd,error_msg,env=self.env)
if "source_path_hash" in self.settings:
- myf=open(unpack_resume,"w")
- myf.write(self.settings["source_path_hash"])
- myf.close()
+ self.resume.enable("unpack",
+ data=self.settings["source_path_hash"])
else:
- touch(unpack_resume)
+ self.resume.enable("unpack")
else:
print "Resume point detected, skipping unpack operation..."
def unpack_snapshot(self):
unpack=True
- unpack_portage_resume = pjoin(self.settings["autoresume_path"],
- "unpack_portage")
- snapshot_hash=read_from_clst(unpack_portage_resume)
+ snapshot_hash = self.resume.get("unpack_portage")
if "snapcache" in self.settings["options"]:
snapshot_cache_hash=\
@@ -831,7 +826,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
if "autoresume" in self.settings["options"] \
and os.path.exists(self.settings["chroot_path"]+\
self.settings["portdir"]) \
- and os.path.exists(unpack_portage_resume) \
+ and self.resume.is_enabled("unpack_portage") \
and self.settings["snapshot_path_hash"] == snapshot_hash:
print \
"Valid Resume point detected, skipping unpack of portage tree..."
@@ -856,18 +851,15 @@ class StageBase(TargetBase, ClearBase, GenBase):
myf.close()
else:
print "Setting snapshot autoresume point"
- myf=open(unpack_portage_resume,"w")
- myf.write(self.settings["snapshot_path_hash"])
- myf.close()
+ self.resume.enable("unpack_portage",
+ data=self.settings["snapshot_path_hash"])
if "snapcache" in self.settings["options"]:
self.snapshot_lock_object.unlock()
def config_profile_link(self):
- config_protect_link_resume = pjoin(self.settings["autoresume_path"],
- "config_profile_link")
if "autoresume" in self.settings["options"] \
- and os.path.exists(config_protect_link_resume):
+ and self.resume.is_enabled("config_profile_link"):
print \
"Resume point detected, skipping config_profile_link operation..."
else:
@@ -881,21 +873,20 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings["target_profile"]+" "+\
self.settings["chroot_path"]+"/etc/portage/make.profile",\
"Error creating profile link",env=self.env)
- touch(config_protect_link_resume)
+ self.resume.enable("config_profile_link")
def setup_confdir(self):
- setup_confdir_resume = pjoin(self.settings["autoresume_path"],
- "setup_confdir")
if "autoresume" in self.settings["options"] \
- and os.path.exists(setup_confdir_resume):
+ and self.resume.is_enabled("setup_confdir"):
print "Resume point detected, skipping setup_confdir operation..."
else:
if "portage_confdir" in self.settings:
- print "Configuring /etc/portage..."
- cmd("rsync -a "+self.settings["portage_confdir"]+"/ "+\
- self.settings["chroot_path"]+"/etc/portage/",\
- "Error copying /etc/portage",env=self.env)
- touch(setup_confdir_resume)
+ print "Configuring %s..." % self.settings["port_conf"]
+ cmd("rsync -a " + self.settings["portage_confdir"] + "/ " +
+ self.settings["chroot_path"] + self.settings["port_conf"],
+ "Error copying %s" % self.settings["port_conf"],
+ env=self.env)
+ self.resume.enable("setup_confdir")
def portage_overlay(self):
""" We copy the contents of our overlays to /usr/local/portage """
@@ -1018,10 +1009,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.override_cflags()
self.override_cxxflags()
self.override_ldflags()
- chroot_setup_resume = pjoin(self.settings["autoresume_path"],
- "chroot_setup")
if "autoresume" in self.settings["options"] \
- and os.path.exists(chroot_setup_resume):
+ and self.resume.is_enabled("chroot_setup"):
print "Resume point detected, skipping chroot_setup operation..."
else:
print "Setting up chroot..."
@@ -1118,35 +1107,32 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings["make_conf"])
cmd("cp " + makepath + " " + makepath + ".catalyst",\
"Could not backup " + self.settings["make_conf"],env=self.env)
- touch(self.settings["autoresume_path"]+"chroot_setup")
+ self.resume.enable("chroot_setup")
def fsscript(self):
- fsscript_resume = pjoin(self.settings["autoresume_path"], "fsscript")
if "autoresume" in self.settings["options"] \
- and os.path.exists(fsscript_resume):
+ and self.resume.is_enabled("fsscript"):
print "Resume point detected, skipping fsscript operation..."
else:
if "fsscript" in self.settings:
if os.path.exists(self.settings["controller_file"]):
cmd(self.settings["controller_file"]+\
" fsscript","fsscript script failed.",env=self.env)
- touch(fsscript_resume)
+ self.resume.enable("fsscript")
def rcupdate(self):
- rcupdate_resume = pjoin(self.settings["autoresume_path"], "rcupdate")
if "autoresume" in self.settings["options"] \
- and os.path.exists(rcupdate_resume):
+ and self.resume.is_enabled("rcupdate"):
print "Resume point detected, skipping rcupdate operation..."
else:
if os.path.exists(self.settings["controller_file"]):
cmd(self.settings["controller_file"]+" rc-update",\
"rc-update script failed.",env=self.env)
- touch(rcupdate_resume)
+ self.resume.enable("rcupdate")
def clean(self):
- clean_resume = pjoin(self.settings["autoresume_path"], "clean")
if "autoresume" in self.settings["options"] \
- and os.path.exists(clean_resume):
+ and self.resume.is_enabled("clean"):
print "Resume point detected, skipping clean operation..."
else:
for x in self.settings["cleanables"]:
@@ -1177,12 +1163,11 @@ class StageBase(TargetBase, ClearBase, GenBase):
if os.path.exists(self.settings["controller_file"]):
cmd(self.settings["controller_file"]+" clean",\
"clean script failed.",env=self.env)
- touch(clean_resume)
+ self.resume.enable("clean")
def empty(self):
- empty_resume = pjoin(self.settings["autoresume_path"], "empty")
if "autoresume" in self.settings["options"] \
- and os.path.exists(empty_resume):
+ and self.resume.is_enabled("empty"):
print "Resume point detected, skipping empty operation..."
else:
if self.settings["spec_prefix"]+"/empty" in self.settings:
@@ -1206,12 +1191,11 @@ class StageBase(TargetBase, ClearBase, GenBase):
ensure_dirs(myemp, mode=0755)
os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
os.chmod(myemp,mystat[ST_MODE])
- touch(empty_resume)
+ self.resume.enable("empty")
def remove(self):
- remove_resume = pjoin(self.settings["autoresume_path"], "remove")
if "autoresume" in self.settings["options"] \
- and os.path.exists(remove_resume):
+ and self.resume.is_enabled("remove"):
print "Resume point detected, skipping remove operation..."
else:
if self.settings["spec_prefix"]+"/rm" in self.settings:
@@ -1226,31 +1210,29 @@ class StageBase(TargetBase, ClearBase, GenBase):
if os.path.exists(self.settings["controller_file"]):
cmd(self.settings["controller_file"]+\
" clean","Clean failed.",env=self.env)
- touch(remove_resume)
+ self.resume.enable("remove")
except:
self.unbind()
raise
def preclean(self):
- preclean_resume = pjoin(self.settings["autoresume_path"], "preclean")
if "autoresume" in self.settings["options"] \
- and os.path.exists(preclean_resume):
+ and self.resume.is_enabled("preclean"):
print "Resume point detected, skipping preclean operation..."
else:
try:
if os.path.exists(self.settings["controller_file"]):
cmd(self.settings["controller_file"]+\
" preclean","preclean script failed.",env=self.env)
- touch(preclean_resume)
+ self.resume.enable("preclean")
except:
self.unbind()
raise CatalystError("Build failed, could not execute preclean")
def capture(self):
- capture_resume = pjoin(self.settings["autoresume_path"], "capture")
if "autoresume" in self.settings["options"] \
- and os.path.exists(capture_resume):
+ and self.resume.is_enabled("capture"):
print "Resume point detected, skipping capture operation..."
else:
""" Capture target in a tarball """
@@ -1270,12 +1252,11 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.gen_contents_file(self.settings["target_path"])
self.gen_digest_file(self.settings["target_path"])
- touch(capture_resume)
+ self.resume.enable("capture")
def run_local(self):
- run_local_resume = pjoin(self.settings["autoresume_path"], "run_local")
if "autoresume" in self.settings["options"] \
- and os.path.exists(run_local_resume):
+ and self.resume.is_enabled("run_local"):
print "Resume point detected, skipping run_local operation..."
else:
try:
@@ -1283,7 +1264,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
print "run_local() starting controller script..."
cmd(self.settings["controller_file"]+" run",\
"run script failed.",env=self.env)
- touch(run_local_resume)
+ self.resume.enable("run_local")
+ else:
+ print "run_local() no controller_file found...", self.settings["controller_file"]
except CatalystError:
self.unbind()
@@ -1359,9 +1342,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.chroot_lock.unlock()
def unmerge(self):
- unmerge_resume = pjoin(self.settings["autoresume_path"], "unmerge")
if "autoresume" in self.settings["options"] \
- and os.path.exists(unmerge_resume):
+ and self.resume.is_enabled("unmerge"):
print "Resume point detected, skipping unmerge operation..."
else:
if self.settings["spec_prefix"]+"/unmerge" in self.settings:
@@ -1389,26 +1371,22 @@ class StageBase(TargetBase, ClearBase, GenBase):
except CatalystError:
self.unbind()
raise
- touch(unmerge_resume)
+ self.resume.enable("unmerge")
def target_setup(self):
- target_setup_resume = pjoin(self.settings["autoresume_path"],
- "target_setup")
if "autoresume" in self.settings["options"] \
- and os.path.exists(target_setup_resume):
+ and self.resume.is_enabled("target_setup"):
print "Resume point detected, skipping target_setup operation..."
else:
print "Setting up filesystems per filesystem type"
cmd(self.settings["controller_file"]+\
" target_image_setup "+ self.settings["target_path"],\
"target_image_setup script failed.",env=self.env)
- touch(target_setup_resume)
+ self.resume.enable("target_setup")
def setup_overlay(self):
- setup_overlay_resume = pjoin(self.settings["autoresume_path"],
- "setup_overlay")
if "autoresume" in self.settings["options"] \
- and os.path.exists(setup_overlay_resume):
+ and self.resume.is_enabled("setup_overlay"):
print "Resume point detected, skipping setup_overlay operation..."
else:
if self.settings["spec_prefix"]+"/overlay" in self.settings:
@@ -1418,12 +1396,11 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings["target_path"],\
self.settings["spec_prefix"]+"overlay: "+x+\
" copy failed.",env=self.env)
- touch(setup_overlay_resume)
+ self.resume.enable("setup_overlay")
def create_iso(self):
- create_iso_resume = pjoin(self.settings["autoresume_path"], "create_iso")
if "autoresume" in self.settings["options"] \
- and os.path.exists(create_iso_resume):
+ and self.resume.is_enabled("create_iso"):
print "Resume point detected, skipping create_iso operation..."
else:
""" Create the ISO """
@@ -1433,7 +1410,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
env=self.env)
self.gen_contents_file(self.settings["iso"])
self.gen_digest_file(self.settings["iso"])
- touch(create_iso_resume)
+ self.resume.enable("create_iso")
else:
print "WARNING: livecd/iso was not defined."
print "An ISO Image will not be created."
@@ -1442,13 +1419,12 @@ class StageBase(TargetBase, ClearBase, GenBase):
build_packages_resume = pjoin(self.settings["autoresume_path"],
"build_packages")
if "autoresume" in self.settings["options"] \
- and os.path.exists(build_packages_resume):
+ and self.resume.is_enabled("build_packages"):
print "Resume point detected, skipping build_packages operation..."
else:
if self.settings["spec_prefix"]+"/packages" in self.settings:
if "autoresume" in self.settings["options"] \
- and os.path.exists(self.settings["autoresume_path"]+\
- "build_packages"):
+ and self.resume.is_enabled("build_packages"):
print "Resume point detected, skipping build_packages operation..."
else:
mypack=\
@@ -1459,6 +1435,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
" build_packages "+mypack,\
"Error in attempt to build packages",env=self.env)
touch(build_packages_resume)
+ self.resume.enable("build_packages")
except CatalystError:
self.unbind()
raise CatalystError(self.settings["spec_prefix"]+\
@@ -1466,10 +1443,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
def build_kernel(self):
'''Build all configured kernels'''
- build_kernel_resume = pjoin(self.settings["autoresume_path"],
- "build_kernel")
if "autoresume" in self.settings["options"] \
- and os.path.exists(build_kernel_resume):
+ and self.resume.is_enabled("build_kernel"):
print "Resume point detected, skipping build_kernel operation..."
else:
if "boot/kernel" in self.settings:
@@ -1485,7 +1460,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
env=self.env)
for kname in mynames:
self._build_kernel(kname=kname)
- touch(build_kernel_resume)
+ self.resume.enable("build_kernel")
except CatalystError:
self.unbind()
raise CatalystError(
@@ -1494,10 +1469,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
def _build_kernel(self, kname):
"Build a single configured kernel by name"
- kname_resume = pjoin(self.settings["autoresume_path"],
- "build_kernel_" + kname)
if "autoresume" in self.settings["options"] \
- and os.path.exists(kname_resume):
+ and self.resume.is_enabled("build_kernel_"+kname):
print "Resume point detected, skipping build_kernel for "+kname+" operation..."
return
self._copy_kernel_config(kname=kname)
@@ -1539,7 +1512,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
cmd("rm -R "+self.settings["chroot_path"]+\
"/tmp/initramfs_overlay/",env=self.env)
- touch(kname_resume)
+ self.resume.is_enabled("build_kernel_"+kname)
"""
Execute the script that cleans up the kernel build
@@ -1592,31 +1565,28 @@ class StageBase(TargetBase, ClearBase, GenBase):
"/initramfs_overlay"],env=self.env)
def bootloader(self):
- bootloader_resume = pjoin(self.settings["autoresume_path"], "bootloader")
if "autoresume" in self.settings["options"] \
- and os.path.exists(bootloader_resume):
+ and self.resume.is_enabled("bootloader"):
print "Resume point detected, skipping bootloader operation..."
else:
try:
cmd(self.settings["controller_file"]+\
" bootloader " + self.settings["target_path"],\
"Bootloader script failed.",env=self.env)
- touch(bootloader_resume)
+ self.resume.enable("bootloader")
except CatalystError:
self.unbind()
raise CatalystError("Script aborting due to error.")
def livecd_update(self):
- livecd_update_resume = pjoin(self.settings["autoresume_path"],
- "livecd_update")
if "autoresume" in self.settings["options"] \
- and os.path.exists(livecd_update_resume):
+ and self.resume.is_enabled("livecd_update"):
print "Resume point detected, skipping build_packages operation..."
else:
try:
cmd(self.settings["controller_file"]+\
" livecd-update","livecd-update failed.",env=self.env)
- touch(livecd_update_resume)
+ self.resume.enable("livecd_update")
except CatalystError:
self.unbind()
diff --git a/catalyst/targets/grp.py b/catalyst/targets/grp.py
index a17f9bd..14cffe0 100644
--- a/catalyst/targets/grp.py
+++ b/catalyst/targets/grp.py
@@ -44,7 +44,7 @@ class grp(StageBase):
def set_target_path(self):
self.settings["target_path"]=normpath(self.settings["storedir"]+"/builds/"+self.settings["target_subpath"]+"/")
if "autoresume" in self.settings["options"] \
- and os.path.exists(self.settings["autoresume_path"]+"setup_target_path"):
+ and self.resume.is_enabled("setup_target_path"):
print "Resume point detected, skipping target path setup operation..."
else:
# first clean up any existing target stuff
@@ -53,7 +53,7 @@ class grp(StageBase):
#"Could not remove existing directory: "+self.settings["target_path"],env=self.env)
ensure_dirs(self.settings["target_path"])
- touch(self.settings["autoresume_path"]+"setup_target_path")
+ self.resume.enable("setup_target_path")
def run_local(self):
for pkgset in self.settings["grp"]:
diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py
index 668960b..55859bc 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -35,14 +35,14 @@ class livecd_stage1(StageBase):
def set_target_path(self):
self.settings["target_path"]=normpath(self.settings["storedir"]+"/builds/"+self.settings["target_subpath"])
if "autoresume" in self.settings["options"] \
- and os.path.exists(self.settings["autoresume_path"]+"setup_target_path"):
+ and self.resume.is_enabled("setup_target_path"):
print "Resume point detected, skipping target path setup operation..."
else:
# first clean up any existing target stuff
if os.path.exists(self.settings["target_path"]):
cmd("rm -rf "+self.settings["target_path"],\
"Could not remove existing directory: "+self.settings["target_path"],env=self.env)
- touch(self.settings["autoresume_path"]+"setup_target_path")
+ self.resume.enable("setup_target_path")
ensure_dirs(self.settings["target_path"])
diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py
index 94da670..973a734 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -55,14 +55,14 @@ class livecd_stage2(StageBase):
def set_target_path(self):
self.settings["target_path"]=normpath(self.settings["storedir"]+"/builds/"+self.settings["target_subpath"]+"/")
if "autoresume" in self.settings["options"] \
- and os.path.exists(self.settings["autoresume_path"]+"setup_target_path"):
+ and self.resume.is_enabled("setup_target_path"):
print "Resume point detected, skipping target path setup operation..."
else:
# first clean up any existing target stuff
if os.path.isdir(self.settings["target_path"]):
cmd("rm -rf "+self.settings["target_path"],
"Could not remove existing directory: "+self.settings["target_path"],env=self.env)
- touch(self.settings["autoresume_path"]+"setup_target_path")
+ self.resume.enable("setup_target_path")
ensure_dirs(self.settings["target_path"])
def run_local(self):
@@ -89,7 +89,7 @@ class livecd_stage2(StageBase):
unpack=True
display_msg=None
- clst_unpack_hash=read_from_clst(self.settings["autoresume_path"]+"unpack")
+ clst_unpack_hash = self.resume.get("unpack")
if os.path.isdir(self.settings["source_path"]):
unpack_cmd="rsync -a --delete "+self.settings["source_path"]+" "+self.settings["chroot_path"]
@@ -100,7 +100,7 @@ class livecd_stage2(StageBase):
if "autoresume" in self.settings["options"]:
if os.path.isdir(self.settings["source_path"]) and \
- os.path.exists(self.settings["autoresume_path"]+"unpack"):
+ self.resume.is_enabled("unpack"):
print "Resume point detected, skipping unpack operation..."
unpack=False
elif "source_path_hash" in self.settings:
@@ -131,11 +131,9 @@ class livecd_stage2(StageBase):
cmd(unpack_cmd,error_msg,env=self.env)
if "source_path_hash" in self.settings:
- myf=open(self.settings["autoresume_path"]+"unpack","w")
- myf.write(self.settings["source_path_hash"])
- myf.close()
+ self.resume.enable("unpack", data=self.settings["source_path_hash"])
else:
- touch(self.settings["autoresume_path"]+"unpack")
+ self.resume.enable("unpack")
def set_action_sequence(self):
self.settings["action_sequence"]=["unpack","unpack_snapshot",\
diff --git a/catalyst/targets/netboot2.py b/catalyst/targets/netboot2.py
index 7edfc1f..acffb05 100644
--- a/catalyst/targets/netboot2.py
+++ b/catalyst/targets/netboot2.py
@@ -54,15 +54,14 @@ class netboot2(StageBase):
self.settings["target_path"]=normpath(self.settings["storedir"]+"/builds/"+\
self.settings["target_subpath"]+"/")
if "autoresume" in self.settings["options"] \
- and os.path.exists(self.settings["autoresume_path"]+"setup_target_path"):
+ and self.resume.is_enabled("setup_target_path"):
print "Resume point detected, skipping target path setup operation..."
else:
# first clean up any existing target stuff
if os.path.isfile(self.settings["target_path"]):
cmd("rm -f "+self.settings["target_path"], \
"Could not remove existing file: "+self.settings["target_path"],env=self.env)
- touch(self.settings["autoresume_path"]+"setup_target_path")
-
+ self.resume.enable("setup_target_path")
ensure_dirs(self.settings["storedir"]+"/builds/")
def copy_files_to_image(self):
@@ -71,7 +70,7 @@ class netboot2(StageBase):
# check for autoresume point
if "autoresume" in self.settings["options"] \
- and os.path.exists(self.settings["autoresume_path"]+"copy_files_to_image"):
+ and self.resume.is_enabled("copy_files_to_image"):
print "Resume point detected, skipping target path setup operation..."
else:
if "netboot2/packages" in self.settings:
@@ -101,11 +100,11 @@ class netboot2(StageBase):
raise CatalystError("Failed to copy files to image!",
print_traceback=True)
- touch(self.settings["autoresume_path"]+"copy_files_to_image")
+ self.resume.enable("copy_files_to_image")
def setup_overlay(self):
if "autoresume" in self.settings["options"] \
- and os.path.exists(self.settings["autoresume_path"]+"setup_overlay"):
+ and self.resume.is_enabled("setup_overlay"):
print "Resume point detected, skipping setup_overlay operation..."
else:
if "netboot2/overlay" in self.settings:
@@ -113,7 +112,7 @@ class netboot2(StageBase):
if os.path.exists(x):
cmd("rsync -a "+x+"/ "+\
self.settings["chroot_path"] + self.settings["merge_path"], "netboot2/overlay: "+x+" copy failed.",env=self.env)
- touch(self.settings["autoresume_path"]+"setup_overlay")
+ self.resume.enable("setup_overlay")
def move_kernels(self):
# we're done, move the kernels to builds/*
@@ -130,7 +129,7 @@ class netboot2(StageBase):
def remove(self):
if "autoresume" in self.settings["options"] \
- and os.path.exists(self.settings["autoresume_path"]+"remove"):
+ and self.resume.is_enabled("remove"):
print "Resume point detected, skipping remove operation..."
else:
if self.settings["spec_prefix"]+"/rm" in self.settings:
@@ -142,7 +141,7 @@ class netboot2(StageBase):
def empty(self):
if "autoresume" in self.settings["options"] \
- and os.path.exists(self.settings["autoresume_path"]+"empty"):
+ and self.resume.is_enabled("empty"):
print "Resume point detected, skipping empty operation..."
else:
if "netboot2/empty" in self.settings:
@@ -161,7 +160,7 @@ class netboot2(StageBase):
ensure_dirs(myemp, mode=0755)
os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
os.chmod(myemp,mystat[ST_MODE])
- touch(self.settings["autoresume_path"]+"empty")
+ self.resume.enable("empty")
def set_action_sequence(self):
self.settings["action_sequence"]=["unpack","unpack_snapshot","config_profile_link",
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/
2015-09-06 21:18 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
@ 2015-09-06 21:21 ` Brian Dolbec
0 siblings, 0 replies; 14+ messages in thread
From: Brian Dolbec @ 2015-09-06 21:21 UTC (permalink / raw
To: gentoo-commits
commit: a708728d812020ee630fe4182e07b1f3ddbbb1e2
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 15 23:10:50 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun Sep 6 21:18:00 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=a708728d
Fix a couple print() uses back to print statements for consistency
catalyst/base/stagebase.py | 4 ++--
catalyst/targets/snapshot.py | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 7212409..8f12ac6 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -1308,8 +1308,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
target_filename = ".".join([self.settings["target_path"].rstrip('/'),
self.compressor.extension(pack_info['mode'])])
- print("Creating stage tarball... mode:",
- self.settings["compression_mode"])
+ print "Creating stage tarball... mode:", \
+ self.settings["compression_mode"]
if self.compressor.compress(pack_info):
self.gen_contents_file(target_filename)
diff --git a/catalyst/targets/snapshot.py b/catalyst/targets/snapshot.py
index ad96d37..1edcd02 100644
--- a/catalyst/targets/snapshot.py
+++ b/catalyst/targets/snapshot.py
@@ -72,11 +72,11 @@ class snapshot(TargetBase, GenBase):
auto_extension=True
)
if not compressor.compress(infodict):
- print("Snapshot compression failure")
+ print "Snapshot compression failure"
else:
filename = '.'.join([self.settings["snapshot_path"],
compressor.extension(self.settings["compression_mode"])])
- print("COMPRESSOR success!!!! filename", filename)
+ print "COMPRESSOR success!!!! filename", filename
self.gen_contents_file(filename)
self.gen_digest_file(filename)
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/
@ 2015-11-20 21:26 Brian Dolbec
0 siblings, 0 replies; 14+ messages in thread
From: Brian Dolbec @ 2015-11-20 21:26 UTC (permalink / raw
To: gentoo-commits
commit: 3228dec78968e5f0b831cd477039decee6c79838
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 20 21:20:35 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Fri Nov 20 21:24:31 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=3228dec7
Debug autoextension detection not working for stage2
Remove the set_source_path() re-definition from stage2. This only modified the
seedcache location from the normal one to the previous build directory.
This is wrong. The previous build location is normally cleaned and removed.
Also, if this is actually needed, then it should be done globally and configurable.
Add extra log messages to stagebase.
Clean out a no longer relevant log.info message
catalyst/base/stagebase.py | 17 ++++++++---------
catalyst/targets/stage2.py | 21 ---------------------
2 files changed, 8 insertions(+), 30 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index df19c0b..69b7b0d 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -420,10 +420,15 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings["source_path"] = normpath(self.settings["storedir"] +
"/tmp/" + self.settings["source_subpath"] + "/")
else:
+ log.debug('Checking source path existence and '
+ 'get the final filepath. subpath: %s',
+ self.settings["source_subpath"])
self.settings["source_path"] = file_check(
normpath(self.settings["storedir"] + "/builds/" +
self.settings["source_subpath"])
)
+ log.debug('Source path returned from file_check is: %s',
+ self.settings["source_path"])
if os.path.isfile(self.settings["source_path"]):
# XXX: Is this even necessary if the previous check passes?
if os.path.exists(self.settings["source_path"]):
@@ -431,14 +436,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings["hash_map"].generate_hash(
self.settings["source_path"],
hash_=self.settings["hash_function"])
- log.info('Source path set to %s', self.settings['source_path'])
- if os.path.isdir(self.settings["source_path"]):
- log.warning(
- 'If this is not desired, remove this directory or turn off\n'
- 'seedcache in the options of catalyst.conf the source path\n'
- 'will then be %s',
- normpath(self.settings['storedir'] + '/builds/' +
- self.settings['source_subpath']))
+ log.notice('Source path set to %s', self.settings['source_path'])
def set_dest_path(self):
if "root_path" in self.settings:
@@ -749,7 +747,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
elif os.path.isdir(self.settings["source_path"]):
# We should never reach this, so something is very wrong
raise CatalystError(
- "source path is a dir but seedcache is not enabled")
+ "source path is a dir but seedcache is not enabled: %s"
+ % self.settings["source_path"])
if _unpack:
self.mount_safety_check()
diff --git a/catalyst/targets/stage2.py b/catalyst/targets/stage2.py
index ff060d2..9658a49 100644
--- a/catalyst/targets/stage2.py
+++ b/catalyst/targets/stage2.py
@@ -3,10 +3,8 @@ stage2 target, builds upon previous stage1 tarball
"""
# NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
-import os
from catalyst import log
-from catalyst.support import normpath
from catalyst.base.stagebase import StageBase
@@ -19,25 +17,6 @@ class stage2(StageBase):
self.valid_values=["chost"]
StageBase.__init__(self,spec,addlargs)
- def set_source_path(self):
- if "seedcache" in self.settings["options"] and os.path.isdir(normpath(self.settings["storedir"]+"/tmp/"+self.settings["source_subpath"]+"/tmp/stage1root")):
- self.settings["source_path"]=normpath(self.settings["storedir"]+"/tmp/"+self.settings["source_subpath"]+"/tmp/stage1root")
- else:
- self.settings["source_path"]=normpath(self.settings["storedir"]+"/builds/"+self.settings["source_subpath"])
- if os.path.isfile(self.settings["source_path"]):
- if os.path.exists(self.settings["source_path"]):
- # XXX: Is this even necessary if the previous check passes?
- self.settings["source_path_hash"] = \
- self.settings["hash_map"].generate_hash(
- self.settings["source_path"],\
- hash_=self.settings["hash_function"])
- log.notice('Source path set to %s', self.settings['source_path'])
- if os.path.isdir(self.settings["source_path"]):
- log.warning(
- 'If this is not desired, remove this directory or turn off seedcache in the\n'
- 'options of catalyst.conf. The source path will then be:\n%s',
- normpath(self.settings['storedir'] + '/builds/' + self.settings['source_subpath']))
-
# XXX: How do these override_foo() functions differ from the ones in
# StageBase and why aren't they in stage3_target?
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/
@ 2016-05-22 3:34 Mike Frysinger
0 siblings, 0 replies; 14+ messages in thread
From: Mike Frysinger @ 2016-05-22 3:34 UTC (permalink / raw
To: gentoo-commits
commit: 415c65624ff62f5ab139666cd5447bc35e1e9e8b
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri May 20 05:42:43 2016 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri May 20 05:42:43 2016 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=415c6562
replace ad-hoc implementations of clear_dir
A few places copy & paste the logic we have in the clear_dir func.
Punt them with a simple call to clear_dir.
catalyst/base/stagebase.py | 9 +--------
catalyst/targets/netboot2.py | 10 ++--------
catalyst/targets/snapshot.py | 20 ++------------------
3 files changed, 5 insertions(+), 34 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 78e5b94..f0f3ba9 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -3,7 +3,6 @@ import os
import imp
import shutil
import sys
-from stat import ST_UID, ST_GID, ST_MODE
from snakeoil import fileutils
@@ -1202,13 +1201,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
log.warning('not a directory or does not exist, skipping "empty" operation: %s', x)
continue
log.info('Emptying directory %s', x)
- # stat the dir, delete the dir, recreate the dir and set
- # the proper perms and ownership
- mystat=os.stat(myemp)
- shutil.rmtree(myemp)
- ensure_dirs(myemp, mode=0o755)
- os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
- os.chmod(myemp,mystat[ST_MODE])
+ clear_dir(myemp)
self.resume.enable("empty")
def remove(self):
diff --git a/catalyst/targets/netboot2.py b/catalyst/targets/netboot2.py
index da856ba..87dada3 100644
--- a/catalyst/targets/netboot2.py
+++ b/catalyst/targets/netboot2.py
@@ -4,12 +4,10 @@ netboot target, version 2
# NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
import os
-import shutil
-from stat import ST_UID, ST_GID, ST_MODE
from catalyst import log
from catalyst.support import (CatalystError, normpath, cmd)
-from catalyst.fileops import ensure_dirs, clear_path
+from catalyst.fileops import (ensure_dirs, clear_dir, clear_path)
from catalyst.base.stagebase import StageBase
@@ -152,11 +150,7 @@ class netboot2(StageBase):
log.info('Emptying directory %s', x)
# stat the dir, delete the dir, recreate the dir and set
# the proper perms and ownership
- mystat=os.stat(myemp)
- shutil.rmtree(myemp)
- ensure_dirs(myemp, mode=0o755)
- os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
- os.chmod(myemp,mystat[ST_MODE])
+ clear_dir(myemp)
self.resume.enable("empty")
def set_action_sequence(self):
diff --git a/catalyst/targets/snapshot.py b/catalyst/targets/snapshot.py
index 7ba94b2..8a9acdd 100644
--- a/catalyst/targets/snapshot.py
+++ b/catalyst/targets/snapshot.py
@@ -2,17 +2,13 @@
Snapshot target
"""
-import os
-import shutil
-from stat import ST_UID, ST_GID, ST_MODE
-
from DeComp.compress import CompressMap
from catalyst import log
from catalyst.support import normpath, cmd
from catalyst.base.targetbase import TargetBase
from catalyst.base.genbase import GenBase
-from catalyst.fileops import ensure_dirs
+from catalyst.fileops import (clear_dir, ensure_dirs)
class snapshot(TargetBase, GenBase):
@@ -102,16 +98,4 @@ class snapshot(TargetBase, GenBase):
log.info('Cleaning up ...')
def purge(self):
- myemp=self.settings["tmp_path"]
- if os.path.isdir(myemp):
- log.notice('Emptying directory %s', myemp)
- # stat the dir, delete the dir, recreate the dir and set
- # the proper perms and ownership
- mystat=os.stat(myemp)
- # There's no easy way to change flags recursively in python
- if os.uname()[0] == "FreeBSD":
- os.system("chflags -R noschg "+myemp)
- shutil.rmtree(myemp)
- ensure_dirs(myemp, mode=0o755)
- os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
- os.chmod(myemp,mystat[ST_MODE])
+ clear_dir(self.settings['tmp_path'])
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/
@ 2020-04-13 20:43 Matt Turner
0 siblings, 0 replies; 14+ messages in thread
From: Matt Turner @ 2020-04-13 20:43 UTC (permalink / raw
To: gentoo-commits
commit: dd9e1cda4772f33fa0c3d07578c5ca6808c6dd22
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 11 22:23:54 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Mon Apr 13 20:43:10 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=dd9e1cda
catalyst: Clean assignments of {valid/required}_values
Making them class variables will allow us to verify that all subclasses
of TargetBase have defined them (in the next commit).
While we're moving them, change them to frozensets, since testing
membership is the thing they're useed for.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 68 ++++++++++++++++++++++++++-------------
catalyst/targets/embedded.py | 24 ++++++++++----
catalyst/targets/livecd_stage1.py | 11 ++++---
catalyst/targets/livecd_stage2.py | 48 +++++++++++++++++++--------
catalyst/targets/netboot.py | 29 ++++++++---------
catalyst/targets/snapshot.py | 11 +++++--
catalyst/targets/stage1.py | 10 ++++--
catalyst/targets/stage2.py | 7 ++--
catalyst/targets/stage3.py | 5 +--
catalyst/targets/stage4.py | 26 +++++++++++----
10 files changed, 159 insertions(+), 80 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index b4275355..27516af6 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -27,16 +27,36 @@ class StageBase(TargetBase, ClearBase, GenBase):
the driver class for pretty much everything that Catalyst does.
"""
def __init__(self,myspec,addlargs):
- self.required_values.extend(["version_stamp", "target", "subarch",
- "rel_type", "profile", "snapshot", "source_subpath"])
-
- self.valid_values.extend(["version_stamp", "target", "subarch",
- "rel_type", "profile", "snapshot", "source_subpath",
- "portage_confdir", "portage_prefix", "portage_overlay",
- "cflags", "cxxflags", "fcflags", "fflags", "ldflags", "asflags",
- "common_flags", "cbuild", "hostuse", "catalyst_use",
- "distcc_hosts", "makeopts", "pkgcache_path", "kerncache_path",
- "compression_mode", "decompression_mode"])
+ self.required_values |= frozenset([
+ "profile",
+ "rel_type",
+ "snapshot",
+ "source_subpath",
+ "subarch",
+ "target",
+ "version_stamp",
+ ])
+ self.valid_values |= self.required_values | frozenset([
+ "asflags",
+ "catalyst_use",
+ "cbuild",
+ "cflags",
+ "common_flags",
+ "compression_mode",
+ "cxxflags",
+ "decompression_mode",
+ "distcc_hosts",
+ "fcflags",
+ "fflags",
+ "hostuse",
+ "kerncache_path",
+ "ldflags",
+ "makeopts",
+ "pkgcache_path",
+ "portage_confdir",
+ "portage_overlay",
+ "portage_prefix",
+ ])
self.set_valid_build_kernel_vars(addlargs)
TargetBase.__init__(self, myspec, addlargs)
@@ -422,7 +442,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
def set_fsops(self):
if "fstype" in self.settings:
- self.valid_values.append("fsops")
+ self.valid_values |= {"fsops"}
if self.settings["spec_prefix"] + "/fsops" in self.settings:
self.settings["fsops"] = \
self.settings[self.settings["spec_prefix"] + "/fsops"]
@@ -647,18 +667,20 @@ class StageBase(TargetBase, ClearBase, GenBase):
loopy = addlargs["boot/kernel"]
for x in loopy:
- self.valid_values.append("boot/kernel/" + x + "/aliases")
- self.valid_values.append("boot/kernel/" + x + "/config")
- self.valid_values.append("boot/kernel/" + x + "/console")
- self.valid_values.append("boot/kernel/" + x + "/extraversion")
- self.valid_values.append("boot/kernel/" + x + "/gk_action")
- self.valid_values.append("boot/kernel/" + x + "/gk_kernargs")
- self.valid_values.append("boot/kernel/" + x + "/initramfs_overlay")
- self.valid_values.append("boot/kernel/" + x + "/sources")
- self.valid_values.append("boot/kernel/" + x + "/softlevel")
- self.valid_values.append("boot/kernel/" + x + "/use")
- self.valid_values.append("boot/kernel/" + x + "/packages")
- self.valid_values.append("boot/kernel/" + x + "/kernelopts")
+ self.valid_values |= frozenset([
+ "boot/kernel/" + x + "/aliases",
+ "boot/kernel/" + x + "/config",
+ "boot/kernel/" + x + "/console",
+ "boot/kernel/" + x + "/extraversion",
+ "boot/kernel/" + x + "/gk_action",
+ "boot/kernel/" + x + "/gk_kernargs",
+ "boot/kernel/" + x + "/initramfs_overlay",
+ "boot/kernel/" + x + "/kernelopts",
+ "boot/kernel/" + x + "/packages",
+ "boot/kernel/" + x + "/softlevel",
+ "boot/kernel/" + x + "/sources",
+ "boot/kernel/" + x + "/use",
+ ])
if "boot/kernel/" + x + "/packages" in addlargs:
if isinstance(addlargs['boot/kernel/' + x + '/packages'], str):
addlargs["boot/kernel/" + x + "/packages"] = \
diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py
index e441757b..97604503 100644
--- a/catalyst/targets/embedded.py
+++ b/catalyst/targets/embedded.py
@@ -18,14 +18,24 @@ class embedded(StageBase):
"""
Builder class for embedded target
"""
- def __init__(self,spec,addlargs):
- self.required_values=[]
- self.valid_values=[]
- self.valid_values.extend(["embedded/empty","embedded/rm","embedded/unmerge","embedded/fs-prepare","embedded/fs-finish","embedded/mergeroot","embedded/packages","embedded/fs-type","embedded/runscript","boot/kernel","embedded/linuxrc"])
- self.valid_values.extend(["embedded/use"])
- if "embedded/fs-type" in addlargs:
- self.valid_values.append("embedded/fs-ops")
+ required_values = frozenset()
+ valid_values = required_values | frozenset([
+ "boot/kernel",
+ "embedded/empty",
+ "embedded/fs-finish",
+ "embedded/fs-ops",
+ "embedded/fs-prepare",
+ "embedded/fs-type",
+ "embedded/linuxrc",
+ "embedded/mergeroot",
+ "embedded/packages",
+ "embedded/rm",
+ "embedded/runscript",
+ "embedded/unmerge",
+ "embedded/use",
+ ])
+ def __init__(self,spec,addlargs):
StageBase.__init__(self,spec,addlargs)
def set_action_sequence(self):
diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py
index 25f54c13..fece8f79 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -12,11 +12,14 @@ class livecd_stage1(StageBase):
"""
Builder class for LiveCD stage1.
"""
- def __init__(self,spec,addlargs):
- self.required_values=["livecd/packages"]
- self.valid_values=self.required_values[:]
+ required_values = frozenset([
+ "livecd/packages",
+ ])
+ valid_values = required_values | frozenset([
+ "livecd/use",
+ ])
- self.valid_values.extend(["livecd/use"])
+ def __init__(self,spec,addlargs):
StageBase.__init__(self,spec,addlargs)
def set_action_sequence(self):
diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py
index 454dbab3..c917f9fd 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -12,21 +12,41 @@ class livecd_stage2(StageBase):
"""
Builder class for a LiveCD stage2 build.
"""
- def __init__(self,spec,addlargs):
- self.required_values=["boot/kernel"]
-
- self.valid_values=[]
-
- self.valid_values.extend(self.required_values)
- self.valid_values.extend(["livecd/cdtar","livecd/empty","livecd/rm","livecd/depclean",\
- "livecd/unmerge","livecd/iso","livecd/gk_mainargs","livecd/type",\
- "livecd/readme","livecd/motd","livecd/overlay",\
- "livecd/modblacklist","livecd/splash_theme","livecd/rcadd",\
- "livecd/rcdel","livecd/fsscript","livecd/xinitrc",\
- "livecd/root_overlay","livecd/users","portage_overlay",\
- "livecd/fstype","livecd/fsops","livecd/linuxrc","livecd/bootargs",\
- "livecd/xdm","livecd/xsession","livecd/volid","livecd/verify"])
+ required_values = frozenset([
+ "boot/kernel",
+ ])
+ valid_values = required_values | frozenset([
+ "livecd/bootargs",
+ "livecd/cdtar",
+ "livecd/depclean",
+ "livecd/empty",
+ "livecd/fsops",
+ "livecd/fsscript",
+ "livecd/fstype",
+ "livecd/gk_mainargs",
+ "livecd/iso",
+ "livecd/linuxrc",
+ "livecd/modblacklist",
+ "livecd/motd",
+ "livecd/overlay",
+ "livecd/rcadd",
+ "livecd/rcdel",
+ "livecd/readme",
+ "livecd/rm",
+ "livecd/root_overlay",
+ "livecd/splash_theme",
+ "livecd/type",
+ "livecd/unmerge",
+ "livecd/users",
+ "livecd/verify",
+ "livecd/volid",
+ "livecd/xdm",
+ "livecd/xinitrc",
+ "livecd/xsession",
+ "portage_overlay",
+ ])
+ def __init__(self,spec,addlargs):
StageBase.__init__(self,spec,addlargs)
if "livecd/type" not in self.settings:
self.settings["livecd/type"] = "generic-livecd"
diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index 675a6f79..95fe3368 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -16,21 +16,20 @@ class netboot(StageBase):
"""
Builder class for a netboot build, version 2
"""
- def __init__(self,spec,addlargs):
- self.required_values=[
- "boot/kernel"
- ]
- self.valid_values=self.required_values[:]
- self.valid_values.extend([
- "netboot/packages",
- "netboot/use",
- "netboot/extra_files",
- "netboot/overlay",
- "netboot/busybox_config",
- "netboot/root_overlay",
- "netboot/linuxrc"
- ])
+ required_values = frozenset([
+ "boot/kernel",
+ ])
+ valid_values = required_values | frozenset([
+ "netboot/busybox_config",
+ "netboot/extra_files",
+ "netboot/linuxrc",
+ "netboot/overlay",
+ "netboot/packages",
+ "netboot/root_overlay",
+ "netboot/use",
+ ])
+ def __init__(self,spec,addlargs):
try:
if "netboot/packages" in addlargs:
if isinstance(addlargs['netboot/packages'], str):
@@ -39,7 +38,7 @@ class netboot(StageBase):
loopy=addlargs["netboot/packages"]
for x in loopy:
- self.valid_values.append("netboot/packages/"+x+"/files")
+ self.valid_values |= {"netboot/packages/"+x+"/files"}
except:
raise CatalystError("configuration error in netboot/packages.")
diff --git a/catalyst/targets/snapshot.py b/catalyst/targets/snapshot.py
index b73135bc..d876acbe 100644
--- a/catalyst/targets/snapshot.py
+++ b/catalyst/targets/snapshot.py
@@ -15,10 +15,15 @@ class snapshot(TargetBase, GenBase):
"""
Builder class for snapshots.
"""
- def __init__(self,myspec,addlargs):
- self.required_values=["version_stamp","target"]
- self.valid_values=["version_stamp","target", "compression_mode"]
+ required_values = frozenset([
+ "target",
+ "version_stamp",
+ ])
+ valid_values = required_values | frozenset([
+ "compression_mode",
+ ])
+ def __init__(self,myspec,addlargs):
TargetBase.__init__(self, myspec, addlargs)
GenBase.__init__(self,myspec)
diff --git a/catalyst/targets/stage1.py b/catalyst/targets/stage1.py
index d40d4ffe..4ce0d0b4 100644
--- a/catalyst/targets/stage1.py
+++ b/catalyst/targets/stage1.py
@@ -13,10 +13,14 @@ class stage1(StageBase):
"""
Builder class for a stage1 installation tarball build.
"""
+ required_values = frozenset()
+ valid_values = required_values | frozenset([
+ "chost",
+ "update_seed",
+ "update_seed_command",
+ ])
+
def __init__(self,spec,addlargs):
- self.required_values=[]
- self.valid_values=["chost"]
- self.valid_values.extend(["update_seed","update_seed_command"])
StageBase.__init__(self,spec,addlargs)
def set_stage_path(self):
diff --git a/catalyst/targets/stage2.py b/catalyst/targets/stage2.py
index 9658a493..e975b14c 100644
--- a/catalyst/targets/stage2.py
+++ b/catalyst/targets/stage2.py
@@ -12,9 +12,12 @@ class stage2(StageBase):
"""
Builder class for a stage2 installation tarball build.
"""
+ required_values = frozenset()
+ valid_values = required_values | frozenset([
+ "chost",
+ ])
+
def __init__(self,spec,addlargs):
- self.required_values=[]
- self.valid_values=["chost"]
StageBase.__init__(self,spec,addlargs)
# XXX: How do these override_foo() functions differ from the ones in
diff --git a/catalyst/targets/stage3.py b/catalyst/targets/stage3.py
index f0831932..c8532aba 100644
--- a/catalyst/targets/stage3.py
+++ b/catalyst/targets/stage3.py
@@ -11,9 +11,10 @@ class stage3(StageBase):
"""
Builder class for a stage3 installation tarball build.
"""
+ required_values = frozenset()
+ valid_values = frozenset()
+
def __init__(self,spec,addlargs):
- self.required_values=[]
- self.valid_values=[]
StageBase.__init__(self,spec,addlargs)
def set_portage_overlay(self):
diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py
index 71c1f302..1e16ff8c 100644
--- a/catalyst/targets/stage4.py
+++ b/catalyst/targets/stage4.py
@@ -10,14 +10,26 @@ class stage4(StageBase):
"""
Builder class for stage4.
"""
+ required_values = frozenset([
+ "stage4/packages",
+ ])
+ valid_values = required_values | frozenset([
+ "boot/kernel",
+ "portage_overlay",
+ "splash_theme",
+ "stage4/empty",
+ "stage4/fsscript",
+ "stage4/gk_mainargs",
+ "stage4/linuxrc",
+ "stage4/rcadd",
+ "stage4/rcdel",
+ "stage4/rm",
+ "stage4/root_overlay",
+ "stage4/unmerge",
+ "stage4/use",
+ ])
+
def __init__(self,spec,addlargs):
- self.required_values=["stage4/packages"]
- self.valid_values=self.required_values[:]
- self.valid_values.extend(["stage4/use", "boot/kernel",
- "stage4/root_overlay", "stage4/fsscript",
- "stage4/gk_mainargs", "splash_theme",
- "portage_overlay", "stage4/rcadd", "stage4/rcdel",
- "stage4/linuxrc", "stage4/unmerge", "stage4/rm", "stage4/empty"])
StageBase.__init__(self,spec,addlargs)
def set_cleanables(self):
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/
@ 2020-04-15 18:29 Matt Turner
0 siblings, 0 replies; 14+ messages in thread
From: Matt Turner @ 2020-04-15 18:29 UTC (permalink / raw
To: gentoo-commits
commit: 92af7453a386fb5bd1b03ba5afae6d0165fe4364
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Wed Apr 15 18:00:15 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Wed Apr 15 18:04:03 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=92af7453
catalyst: Remove dead base_dirs() function
Prior to commit 8ef6e85a57ec (catalyst: Drop BSD remnants) this was used
for some FreeBSD-specific logic.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 5 +----
catalyst/targets/stage1.py | 3 ---
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index b01e4825..d993641f 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -528,7 +528,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
"""Set basic stage1, 2, 3 action sequences"""
self.settings["action_sequence"] = ["unpack", "unpack_snapshot",
"setup_confdir", "portage_overlay",
- "base_dirs", "bind", "chroot_setup", "setup_environment",
+ "bind", "chroot_setup", "setup_environment",
"run_local", "preclean", "unbind", "clean"]
self.set_completion_action_sequences()
@@ -940,9 +940,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
cmd(['rsync', '-a', x + '/', self.settings['chroot_path']],
env=self.env)
- def base_dirs(self):
- pass
-
def bind(self):
for x in self.mounts:
log.debug('bind(); x = %s', x)
diff --git a/catalyst/targets/stage1.py b/catalyst/targets/stage1.py
index 4ce0d0b4..a1a29cff 100644
--- a/catalyst/targets/stage1.py
+++ b/catalyst/targets/stage1.py
@@ -77,9 +77,6 @@ class stage1(StageBase):
"If you break it, you buy it. Don't complain to us about it.\n"
"Don't say we did not warn you.")
- def base_dirs(self):
- pass
-
def set_mounts(self):
# stage_path/proc probably doesn't exist yet, so create it
ensure_dirs(self.settings["stage_path"]+"/proc")
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/
@ 2020-04-18 20:30 Matt Turner
0 siblings, 0 replies; 14+ messages in thread
From: Matt Turner @ 2020-04-18 20:30 UTC (permalink / raw
To: gentoo-commits
commit: d3a8f202bf8eb82cc1d61e2b2b9da4eadc550c90
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 18 00:36:46 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Sat Apr 18 20:29:57 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=d3a8f202
catalyst: Reformat some array definitions
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 17 +++++++++++++----
catalyst/targets/embedded.py | 29 +++++++++++++++++++++++------
catalyst/targets/livecd_stage1.py | 17 +++++++++++++----
catalyst/targets/livecd_stage2.py | 6 +++---
catalyst/targets/netboot.py | 26 +++++++++++++++++++++-----
catalyst/targets/stage4.py | 28 ++++++++++++++++++++++------
6 files changed, 95 insertions(+), 28 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 71bf1ef9..60cb891a 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -531,10 +531,19 @@ class StageBase(TargetBase, ClearBase, GenBase):
def set_action_sequence(self):
"""Set basic stage1, 2, 3 action sequences"""
- self.settings["action_sequence"] = ["unpack", "unpack_snapshot",
- "setup_confdir", "portage_overlay",
- "bind", "chroot_setup", "setup_environment",
- "run_local", "preclean", "unbind", "clean"]
+ self.settings['action_sequence'] = [
+ "unpack",
+ "unpack_snapshot",
+ "setup_confdir",
+ "portage_overlay",
+ "bind",
+ "chroot_setup",
+ "setup_environment",
+ "run_local",
+ "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 e288228e..189eb722 100644
--- a/catalyst/targets/embedded.py
+++ b/catalyst/targets/embedded.py
@@ -40,12 +40,29 @@ class embedded(StageBase):
StageBase.__init__(self, spec, addlargs)
def set_action_sequence(self):
- self.settings["action_sequence"] = ["dir_setup", "unpack", "unpack_snapshot",
- "config_profile_link", "setup_confdir",
- "portage_overlay", "bind", "chroot_setup",
- "setup_environment", "build_kernel", "build_packages",
- "bootloader", "root_overlay", "fsscript", "unmerge",
- "unbind", "remove", "empty", "clean", "capture", "clear_autoresume"]
+ self.settings['action_sequence'] = [
+ "dir_setup",
+ "unpack",
+ "unpack_snapshot",
+ "config_profile_link",
+ "setup_confdir",
+ "portage_overlay",
+ "bind",
+ "chroot_setup",
+ "setup_environment",
+ "build_kernel",
+ "build_packages",
+ "bootloader",
+ "root_overlay",
+ "fsscript",
+ "unmerge",
+ "unbind",
+ "remove",
+ "empty",
+ "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 f4f6b512..727d95f2 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -23,10 +23,19 @@ class livecd_stage1(StageBase):
StageBase.__init__(self, spec, addlargs)
def set_action_sequence(self):
- self.settings["action_sequence"] = ["unpack", "unpack_snapshot",
- "config_profile_link", "setup_confdir", "portage_overlay",
- "bind", "chroot_setup", "setup_environment", "build_packages",
- "unbind", "clean"]
+ self.settings['action_sequence'] = [
+ "unpack",
+ "unpack_snapshot",
+ "config_profile_link",
+ "setup_confdir",
+ "portage_overlay",
+ "bind",
+ "chroot_setup",
+ "setup_environment",
+ "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 d41321e6..09de22fb 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -88,7 +88,7 @@ class livecd_stage2(StageBase):
print_traceback=True)
def set_action_sequence(self):
- self.settings["action_sequence"] = [
+ self.settings['action_sequence'] = [
"unpack",
"unpack_snapshot",
"config_profile_link",
@@ -101,7 +101,7 @@ class livecd_stage2(StageBase):
"build_kernel"
]
if "fetch" not in self.settings["options"]:
- self.settings["action_sequence"] += [
+ self.settings['action_sequence'] += [
"bootloader",
"preclean",
"livecd_update",
@@ -115,6 +115,6 @@ class livecd_stage2(StageBase):
"clean",
"target_setup",
"setup_overlay",
- "create_iso"
+ "create_iso",
]
self.settings["action_sequence"].append("clear_autoresume")
diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index 12dcf989..7c37bad5 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -160,8 +160,24 @@ class netboot(StageBase):
self.resume.enable("empty")
def set_action_sequence(self):
- self.settings["action_sequence"] = ["unpack", "unpack_snapshot", "config_profile_link",
- "setup_confdir", "portage_overlay", "bind", "chroot_setup",
- "setup_environment", "build_packages", "root_overlay",
- "copy_files_to_image", "setup_overlay", "build_kernel", "move_kernels",
- "remove", "empty", "unbind", "clean", "clear_autoresume"]
+ self.settings['action_sequence'] = [
+ "unpack",
+ "unpack_snapshot",
+ "config_profile_link",
+ "setup_confdir",
+ "portage_overlay",
+ "bind",
+ "chroot_setup",
+ "setup_environment",
+ "build_packages",
+ "root_overlay",
+ "copy_files_to_image",
+ "setup_overlay",
+ "build_kernel",
+ "move_kernels",
+ "remove",
+ "empty",
+ "unbind",
+ "clean",
+ "clear_autoresume",
+ ]
diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py
index 99b67934..a3de2cae 100644
--- a/catalyst/targets/stage4.py
+++ b/catalyst/targets/stage4.py
@@ -36,10 +36,26 @@ class stage4(StageBase):
self.settings["cleanables"] = ["/var/tmp/*", "/tmp/*"]
def set_action_sequence(self):
- self.settings["action_sequence"] = ["unpack", "unpack_snapshot",
- "config_profile_link", "setup_confdir", "portage_overlay",
- "bind", "chroot_setup", "setup_environment", "build_packages",
- "build_kernel", "bootloader", "root_overlay", "fsscript",
- "preclean", "rcupdate", "unmerge", "unbind", "remove", "empty",
- "clean"]
+ self.settings['action_sequence'] = [
+ "unpack",
+ "unpack_snapshot",
+ "config_profile_link",
+ "setup_confdir",
+ "portage_overlay",
+ "bind",
+ "chroot_setup",
+ "setup_environment",
+ "build_packages",
+ "build_kernel",
+ "bootloader",
+ "root_overlay",
+ "fsscript",
+ "preclean",
+ "rcupdate",
+ "unmerge",
+ "unbind",
+ "remove",
+ "empty",
+ "clean",
+ ]
self.set_completion_action_sequences()
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/
@ 2020-10-30 22:41 Matt Turner
0 siblings, 0 replies; 14+ messages in thread
From: Matt Turner @ 2020-10-30 22:41 UTC (permalink / raw
To: gentoo-commits
commit: 2c28062446246e246c992ea7084a3950b1337827
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: Fri Oct 30 22:40:52 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=2c280624
catalyst: Use .extend() and .append() for action_sequence
Ensures that we don't overwrite and lose some settings.
Signed-off-by: Matt Turner <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 801df2fb..46b7c59c 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -478,13 +478,13 @@ class StageBase(TargetBase, ClearBase, GenBase):
Or it calls the normal set_action_sequence() for the target stage.
"""
if "purgeonly" in self.settings["options"]:
- self.action_sequence = ["remove_chroot"]
+ self.action_sequence.append("remove_chroot")
return
self.set_action_sequence()
def set_action_sequence(self):
"""Set basic stage1, 2, 3 action sequences"""
- self.action_sequence = [
+ self.action_sequence.extend([
"unpack",
"setup_confdir",
"portage_overlay",
@@ -495,7 +495,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
"preclean",
"unbind",
"clean",
- ]
+ ])
self.set_completion_action_sequences()
def set_completion_action_sequences(self):
diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py
index 3899cf1b..75eb68e4 100644
--- a/catalyst/targets/embedded.py
+++ b/catalyst/targets/embedded.py
@@ -41,7 +41,7 @@ class embedded(StageBase):
StageBase.__init__(self, spec, addlargs)
def set_action_sequence(self):
- self.action_sequence = [
+ self.action_sequence.extend([
"unpack",
"config_profile_link",
"setup_confdir",
@@ -60,7 +60,7 @@ class embedded(StageBase):
"clean",
"capture",
"clear_autoresume",
- ]
+ ])
def set_stage_path(self):
self.settings["stage_path"] = normpath(
diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py
index b8c26cb1..9dbfa506 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -23,7 +23,7 @@ class livecd_stage1(StageBase):
StageBase.__init__(self, spec, addlargs)
def set_action_sequence(self):
- self.action_sequence = [
+ self.action_sequence.extend([
"unpack",
"config_profile_link",
"setup_confdir",
@@ -34,7 +34,7 @@ class livecd_stage1(StageBase):
"build_packages",
"unbind",
"clean",
- ]
+ ])
self.set_completion_action_sequences()
def set_spec_prefix(self):
diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py
index cac16b6e..c9b5ce08 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -87,7 +87,7 @@ class livecd_stage2(StageBase):
print_traceback=True)
def set_action_sequence(self):
- self.action_sequence = [
+ self.action_sequence.extend([
"unpack",
"config_profile_link",
"setup_confdir",
@@ -97,9 +97,9 @@ class livecd_stage2(StageBase):
"setup_environment",
"run_local",
"build_kernel"
- ]
+ ])
if "fetch" not in self.settings["options"]:
- self.action_sequence += [
+ self.action_sequence.extend([
"bootloader",
"preclean",
"livecd_update",
@@ -114,5 +114,5 @@ class livecd_stage2(StageBase):
"target_setup",
"setup_overlay",
"create_iso",
- ]
+ ])
self.action_sequence.append("clear_autoresume")
diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index 61583f0d..e5c6d43c 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -160,7 +160,7 @@ class netboot(StageBase):
self.resume.enable("empty")
def set_action_sequence(self):
- self.action_sequence = [
+ self.action_sequence.extend([
"unpack",
"config_profile_link",
"setup_confdir",
@@ -179,4 +179,4 @@ class netboot(StageBase):
"unbind",
"clean",
"clear_autoresume",
- ]
+ ])
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] 14+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/
2020-12-19 19:56 [gentoo-commits] proj/catalyst:wip/mattst88 " Matt Turner
@ 2020-10-30 22:41 ` Matt Turner
0 siblings, 0 replies; 14+ messages in thread
From: Matt Turner @ 2020-10-30 22:41 UTC (permalink / raw
To: gentoo-commits
commit: 3d85d537b1a00d05234cea064f863602b83ffaab
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 29 03:08:04 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Fri Oct 30 22:40:52 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=3d85d537
catalyst: Split action_sequence into prepare/build/finish
We want to run the "build" sequence in a different mount namespace from
the "prepare" and "finish" sequences, so this splits action_sequence
into those groupings.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 24 +++++++++++++++---------
catalyst/targets/embedded.py | 6 +++++-
catalyst/targets/livecd_stage1.py | 6 +++++-
catalyst/targets/livecd_stage2.py | 10 +++++++---
catalyst/targets/netboot.py | 6 +++++-
catalyst/targets/stage1.py | 12 ++++++------
catalyst/targets/stage4.py | 6 +++++-
7 files changed, 48 insertions(+), 22 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 46b7c59c..75c84baa 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -64,7 +64,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
"portage_overlay",
"portage_prefix",
])
- self.action_sequence = []
+ self.prepare_sequence = []
+ self.build_sequence = []
+ self.finish_sequence = []
self.set_valid_build_kernel_vars(addlargs)
TargetBase.__init__(self, myspec, addlargs)
@@ -478,36 +480,40 @@ class StageBase(TargetBase, ClearBase, GenBase):
Or it calls the normal set_action_sequence() for the target stage.
"""
if "purgeonly" in self.settings["options"]:
- self.action_sequence.append("remove_chroot")
+ self.build_sequence.append("remove_chroot")
return
self.set_action_sequence()
def set_action_sequence(self):
"""Set basic stage1, 2, 3 action sequences"""
- self.action_sequence.extend([
+ self.prepare_sequence.extend([
"unpack",
"setup_confdir",
"portage_overlay",
+ ])
+ self.build_sequence.extend([
"bind",
"chroot_setup",
"setup_environment",
"run_local",
"preclean",
"unbind",
+ ])
+ self.finish_sequence.extend([
"clean",
])
self.set_completion_action_sequences()
def set_completion_action_sequences(self):
if "fetch" not in self.settings["options"]:
- self.action_sequence.append("capture")
+ self.finish_sequence.append("capture")
if "keepwork" in self.settings["options"]:
- self.action_sequence.append("clear_autoresume")
+ self.finish_sequence.append("clear_autoresume")
elif "seedcache" in self.settings["options"]:
- self.action_sequence.append("remove_autoresume")
+ self.finish_sequence.append("remove_autoresume")
else:
- self.action_sequence.append("remove_autoresume")
- self.action_sequence.append("remove_chroot")
+ self.finish_sequence.append("remove_autoresume")
+ self.finish_sequence.append("remove_chroot")
def set_use(self):
use = self.settings["spec_prefix"] + "/use"
@@ -1381,7 +1387,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.purge()
failure = False
- for x in self.action_sequence:
+ for x in self.prepare_sequence + self.build_sequence + self.finish_sequence:
log.notice('--- Running action sequence: %s', x)
sys.stdout.flush()
try:
diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py
index 75eb68e4..1314ce7c 100644
--- a/catalyst/targets/embedded.py
+++ b/catalyst/targets/embedded.py
@@ -41,11 +41,13 @@ class embedded(StageBase):
StageBase.__init__(self, spec, addlargs)
def set_action_sequence(self):
- self.action_sequence.extend([
+ self.prepare_sequence.extend([
"unpack",
"config_profile_link",
"setup_confdir",
"portage_overlay",
+ ])
+ self.build_sequence.extend([
"bind",
"chroot_setup",
"setup_environment",
@@ -55,6 +57,8 @@ class embedded(StageBase):
"fsscript",
"unmerge",
"unbind",
+ ])
+ self.finish_sequence.extend([
"remove",
"empty",
"clean",
diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py
index 9dbfa506..81367053 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -23,16 +23,20 @@ class livecd_stage1(StageBase):
StageBase.__init__(self, spec, addlargs)
def set_action_sequence(self):
- self.action_sequence.extend([
+ self.prepare_sequence.extend([
"unpack",
"config_profile_link",
"setup_confdir",
"portage_overlay",
+ ])
+ self.build_sequence.extend([
"bind",
"chroot_setup",
"setup_environment",
"build_packages",
"unbind",
+ ])
+ self.finish_sequence.extend([
"clean",
])
self.set_completion_action_sequences()
diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py
index c9b5ce08..f6c14919 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -87,11 +87,13 @@ class livecd_stage2(StageBase):
print_traceback=True)
def set_action_sequence(self):
- self.action_sequence.extend([
+ self.prepare_sequence.extend([
"unpack",
"config_profile_link",
"setup_confdir",
"portage_overlay",
+ ])
+ self.build_sequence.extend([
"bind",
"chroot_setup",
"setup_environment",
@@ -99,7 +101,7 @@ class livecd_stage2(StageBase):
"build_kernel"
])
if "fetch" not in self.settings["options"]:
- self.action_sequence.extend([
+ self.build_sequence.extend([
"bootloader",
"preclean",
"livecd_update",
@@ -108,6 +110,8 @@ class livecd_stage2(StageBase):
"rcupdate",
"unmerge",
"unbind",
+ ])
+ self.finish_sequence.extend([
"remove",
"empty",
"clean",
@@ -115,4 +119,4 @@ class livecd_stage2(StageBase):
"setup_overlay",
"create_iso",
])
- self.action_sequence.append("clear_autoresume")
+ self.finish_sequence.append("clear_autoresume")
diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index e5c6d43c..9a0a4156 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -160,11 +160,13 @@ class netboot(StageBase):
self.resume.enable("empty")
def set_action_sequence(self):
- self.action_sequence.extend([
+ self.prepare_sequence.extend([
"unpack",
"config_profile_link",
"setup_confdir",
"portage_overlay",
+ ])
+ self.build_sequence.extend([
"bind",
"chroot_setup",
"setup_environment",
@@ -177,6 +179,8 @@ class netboot(StageBase):
"remove",
"empty",
"unbind",
+ ])
+ self.finish_sequence.extend([
"clean",
"clear_autoresume",
])
diff --git a/catalyst/targets/stage1.py b/catalyst/targets/stage1.py
index 89b30fe1..be3eae93 100644
--- a/catalyst/targets/stage1.py
+++ b/catalyst/targets/stage1.py
@@ -87,15 +87,15 @@ class stage1(StageBase):
chroot for re-use in stage2 without the need to unpack it.
'''
if "fetch" not in self.settings["options"]:
- self.action_sequence.append("capture")
+ self.finish_sequence.append("capture")
if "keepwork" in self.settings["options"]:
- self.action_sequence.append("clear_autoresume")
+ self.finish_sequence.append("clear_autoresume")
elif "seedcache" in self.settings["options"]:
- self.action_sequence.append("remove_autoresume")
- self.action_sequence.append("clean_stage1")
+ self.finish_sequence.append("remove_autoresume")
+ self.finish_sequence.append("clean_stage1")
else:
- self.action_sequence.append("remove_autoresume")
- self.action_sequence.append("remove_chroot")
+ self.finish_sequence.append("remove_autoresume")
+ self.finish_sequence.append("remove_chroot")
def clean_stage1(self):
'''seedcache is enabled, so salvage the /tmp/stage1root,
diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py
index bb20be79..78a5c780 100644
--- a/catalyst/targets/stage4.py
+++ b/catalyst/targets/stage4.py
@@ -39,11 +39,13 @@ class stage4(StageBase):
self.settings["cleanables"].remove('/etc/resolv.conf')
def set_action_sequence(self):
- self.action_sequence.extend([
+ self.prepare_sequence.extend([
"unpack",
"config_profile_link",
"setup_confdir",
"portage_overlay",
+ ])
+ self.build_sequence.extend([
"bind",
"chroot_setup",
"setup_environment",
@@ -56,6 +58,8 @@ class stage4(StageBase):
"rcupdate",
"unmerge",
"unbind",
+ ])
+ self.finish_sequence.extend([
"remove",
"empty",
"clean",
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/
2021-01-28 1:54 [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/targets/, catalyst/base/ Matt Turner
@ 2021-01-23 16:22 ` Matt Turner
0 siblings, 0 replies; 14+ messages in thread
From: Matt Turner @ 2021-01-23 16:22 UTC (permalink / raw
To: gentoo-commits
commit: 4f0fa29d5a2499b7178dc4d19f7693e52eb8def9
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 18 03:15:02 2021 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Sat Jan 23 16:19:07 2021 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=4f0fa29d
catalyst: Deduplicate prepare_sequence assignments
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 13 ++++++-------
catalyst/targets/embedded.py | 6 ------
catalyst/targets/livecd_stage1.py | 6 ------
catalyst/targets/livecd_stage2.py | 6 ------
catalyst/targets/netboot.py | 6 ------
catalyst/targets/stage4.py | 6 ------
6 files changed, 6 insertions(+), 37 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 53b0a224..3b8d3a6e 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -84,7 +84,12 @@ class StageBase(TargetBase, ClearBase, GenBase):
"portage_overlay",
"portage_prefix",
])
- self.prepare_sequence = []
+ self.prepare_sequence = [
+ self.unpack,
+ self.config_profile_link,
+ self.setup_confdir,
+ self.portage_overlay,
+ ]
self.build_sequence = []
self.finish_sequence = []
@@ -498,12 +503,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
def set_action_sequence(self):
"""Set basic stage1, 2, 3 action sequences"""
- self.prepare_sequence.extend([
- self.unpack,
- self.config_profile_link,
- self.setup_confdir,
- self.portage_overlay,
- ])
self.build_sequence.extend([
self.bind,
self.chroot_setup,
diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py
index 7d328808..83b17ad2 100644
--- a/catalyst/targets/embedded.py
+++ b/catalyst/targets/embedded.py
@@ -41,12 +41,6 @@ class embedded(StageBase):
StageBase.__init__(self, spec, addlargs)
def set_action_sequence(self):
- self.prepare_sequence.extend([
- self.unpack,
- self.config_profile_link,
- self.setup_confdir,
- self.portage_overlay,
- ])
self.build_sequence.extend([
self.bind,
self.chroot_setup,
diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py
index eb6bb0f0..9fe95a00 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -23,12 +23,6 @@ class livecd_stage1(StageBase):
StageBase.__init__(self, spec, addlargs)
def set_action_sequence(self):
- self.prepare_sequence.extend([
- self.unpack,
- self.config_profile_link,
- self.setup_confdir,
- self.portage_overlay,
- ])
self.build_sequence.extend([
self.bind,
self.chroot_setup,
diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py
index 5fecff85..ab8f4a0e 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -86,12 +86,6 @@ class livecd_stage2(StageBase):
print_traceback=True)
def set_action_sequence(self):
- self.prepare_sequence.extend([
- self.unpack,
- self.config_profile_link,
- self.setup_confdir,
- self.portage_overlay,
- ])
self.build_sequence.extend([
self.bind,
self.chroot_setup,
diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index 9a7e59e5..cb5e7ae4 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -158,12 +158,6 @@ class netboot(StageBase):
self.resume.enable("empty")
def set_action_sequence(self):
- self.prepare_sequence.extend([
- self.unpack,
- self.config_profile_link,
- self.setup_confdir,
- self.portage_overlay,
- ])
self.build_sequence.extend([
self.bind,
self.chroot_setup,
diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py
index 997139a5..9e53f070 100644
--- a/catalyst/targets/stage4.py
+++ b/catalyst/targets/stage4.py
@@ -39,12 +39,6 @@ class stage4(StageBase):
self.settings["cleanables"].remove('/etc/resolv.conf')
def set_action_sequence(self):
- self.prepare_sequence.extend([
- self.unpack,
- self.config_profile_link,
- self.setup_confdir,
- self.portage_overlay,
- ])
self.build_sequence.extend([
self.bind,
self.chroot_setup,
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/
2021-01-28 1:54 [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/targets/, catalyst/base/ Matt Turner
@ 2021-01-23 16:22 ` Matt Turner
0 siblings, 0 replies; 14+ messages in thread
From: Matt Turner @ 2021-01-23 16:22 UTC (permalink / raw
To: gentoo-commits
commit: 27d7c7898bb0cccf6962b84058b0e2789bc314c1
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: Sat Jan 23 16:19:07 2021 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=27d7c789
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] 14+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/
@ 2024-08-03 10:53 Andreas K. Hüttel
0 siblings, 0 replies; 14+ messages in thread
From: Andreas K. Hüttel @ 2024-08-03 10:53 UTC (permalink / raw
To: gentoo-commits
commit: d4903c231ad2b338e1cb2e2ef9d8585b68e737df
Author: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 3 10:52:38 2024 +0000
Commit: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
CommitDate: Sat Aug 3 10:52:38 2024 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=d4903c23
stagebase: Move ROOT repo bind mount logic to stagebase instead of stage1
Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org>
catalyst/base/stagebase.py | 21 ++++++++++++++++++++-
catalyst/targets/stage1.py | 21 ---------------------
2 files changed, 20 insertions(+), 22 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 2975236e..a23b1d90 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -223,13 +223,32 @@ class StageBase(TargetBase, ClearBase, GenBase):
for path, name, _ in self.repos:
name = get_repo_name(path)
mount_id = f'repo_{name}'
+ root_mount_id = f'root_repo_{name}'
+ repo_loc = self.get_repo_location(name)
self.mount[mount_id] = {
'enable': True,
'source': path,
- 'target': self.get_repo_location(name)
+ 'target': repo_loc
}
+ # In e.g. the stage1 build we need to make sure that the ebuild repositories are
+ # accessible within $ROOT too... otherwise relative symlinks may point nowhere
+ # and, e.g., portageq may malfunction due to missing profile.
+ # In the meantime we specifically fixed make.profile to point outside ROOT, so
+ # this may not be necessary at the moment anymore. Having it can prevent future
+ # surprises though.
+ # Create a second, bind mount entry for each repository. We need to
+ # take as source not the original source but the original target, since
+ # otherwise we may end up trying to mount the same squashfs twice instead
+ # of a bind mount
+ if self.settings['root_path'] != "/":
+ self.mount[root_mount_id] = {
+ 'enable': True,
+ 'source': self.settings['chroot_path'] / repo_loc.relative_to('/'),
+ 'target': self.settings['root_path'] / repo_loc.relative_to('/')
+ }
+
self.mount['distdir']['source'] = self.settings['distdir']
self.mount["distdir"]['target'] = self.settings['target_distdir']
diff --git a/catalyst/targets/stage1.py b/catalyst/targets/stage1.py
index ae27cd0a..66f21a9c 100644
--- a/catalyst/targets/stage1.py
+++ b/catalyst/targets/stage1.py
@@ -23,27 +23,6 @@ class stage1(StageBase):
def __init__(self, spec, addlargs):
StageBase.__init__(self, spec, addlargs)
- # In the stage1 build we need to make sure that the ebuild repositories are
- # accessible within $ROOT too... otherwise relative symlinks may point nowhere
- # and, e.g., portageq may malfunction due to missing profile.
- # Create a second, bind mount entry for each repository. We need to
- # * take as source not the original source but the original target, since
- # otherwise we may end up trying to mount the same squashfs twice instead
- # of a bind mount
- # * take the directory inside the chroot as source, not the host directory
- # In the meantime we fixed make.profile to point outside ROOT, so this may not
- # be necessary at the moment anymore. Having it can prevent future surprises
- # though.
- self.set_chroot_path()
- for path, name, _ in self.repos:
- name = get_repo_name(path)
- mount_id = f'root_repo_{name}'
- repo_loc = self.get_repo_location(name)
- self.mount[mount_id] = {
- 'enable': True,
- 'source': self.settings['chroot_path'] / repo_loc.relative_to('/'),
- 'target': normpath("/tmp/stage1root") / repo_loc.relative_to('/')
- }
def set_root_path(self):
# sets the root path, relative to 'chroot_path', of the stage1 root
^ permalink raw reply related [flat|nested] 14+ messages in thread
end of thread, other threads:[~2024-08-03 10:53 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-13 20:43 [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/ Matt Turner
-- strict thread matches above, loose matches on Subject: below --
2024-08-03 10:53 Andreas K. Hüttel
2021-01-28 1:54 [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/targets/, catalyst/base/ Matt Turner
2021-01-23 16:22 ` [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/ Matt Turner
2021-01-28 1:54 [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/targets/, catalyst/base/ Matt Turner
2021-01-23 16:22 ` [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/ Matt Turner
2020-12-19 19:56 [gentoo-commits] proj/catalyst:wip/mattst88 " Matt Turner
2020-10-30 22:41 ` [gentoo-commits] proj/catalyst:master " Matt Turner
2020-10-30 22:41 Matt Turner
2020-04-18 20:30 Matt Turner
2020-04-15 18:29 Matt Turner
2016-05-22 3:34 Mike Frysinger
2015-11-20 21:26 Brian Dolbec
2015-09-06 21:18 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-09-06 21:21 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-02-26 19:25 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-02-26 20:12 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-02-26 4:12 Brian Dolbec
2015-01-01 5:59 [gentoo-commits] proj/catalyst:pending commit in: catalyst/targets/, catalyst/base/ Brian Dolbec
2015-02-26 20:12 ` [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/ Brian Dolbec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox