* [gentoo-commits] proj/catalyst:master commit in: catalyst/targets/, catalyst/
2015-01-01 5:59 [gentoo-commits] proj/catalyst:pending commit in: catalyst/, catalyst/targets/ Brian Dolbec
@ 2015-02-26 4:12 ` Brian Dolbec
0 siblings, 0 replies; 3+ messages in thread
From: Brian Dolbec @ 2015-02-26 4:12 UTC (permalink / raw
To: gentoo-commits
commit: 11423a21603ed6ab4cdf8e1662512b9d275345bc
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 20 21:50:23 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=11423a21
[2 of 3] Update module loading for the new python structure
Rename snapshot_target to snapshot
---
catalyst/main.py | 75 ++++++++--------------
catalyst/targets/embedded_target.py | 4 --
catalyst/targets/grp_target.py | 4 --
catalyst/targets/livecd_stage1_target.py | 4 --
catalyst/targets/livecd_stage2_target.py | 4 --
catalyst/targets/netboot2_target.py | 4 --
catalyst/targets/netboot_target.py | 4 --
.../targets/{snapshot_target.py => snapshot.py} | 6 +-
catalyst/targets/stage1_target.py | 4 --
catalyst/targets/stage2_target.py | 4 --
catalyst/targets/stage3_target.py | 4 --
catalyst/targets/stage4_target.py | 5 --
catalyst/targets/tinderbox_target.py | 4 --
13 files changed, 27 insertions(+), 99 deletions(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index 15664de..1446cf9 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -16,21 +16,20 @@ import os.path
__selfpath__ = os.path.abspath(os.path.dirname(__file__))
-sys.path.append(__selfpath__ + "/modules")
from . import __version__
import catalyst.config
import catalyst.util
+from catalyst.contents import ContentsMap, CONTENTS_DEFINITIONS
+from catalyst.defaults import confdefaults, option_messages
+from catalyst.hash_utils import HashMap, HASH_DEFINITIONS
from catalyst.lock import LockInUse
from catalyst.support import CatalystError, find_binary
-from catalyst.defaults import (confdefaults, option_messages,
- required_build_targets, valid_build_targets)
-from hash_utils import HashMap, HASH_DEFINITIONS
-from contents import ContentsMap, CONTENTS_DEFINITIONS
conf_values={}
+
def usage():
print """Usage catalyst [options] [-C variable=value...] [ -s identifier]
-a --clear-autoresume clear autoresume flags
@@ -135,59 +134,40 @@ def parse_config(myconfig):
print "Envscript support enabled."
-def import_modules():
- # import catalyst's own modules
- # (i.e. stage and the arch modules)
- targetmap={}
-
+def import_module(target):
+ """
+ import catalyst's own modules
+ (i.e. targets and the arch modules)
+ """
try:
- module_dir = __selfpath__ + "/targets/"
- for x in required_build_targets:
- try:
- fh=open(module_dir + x + ".py")
- module=imp.load_module(x, fh,"targets/" + x + ".py",
- (".py", "r", imp.PY_SOURCE))
- fh.close()
-
- except IOError:
- raise CatalystError, "Can't find " + x + ".py plugin in " + \
- module_dir
- for x in valid_build_targets:
- try:
- fh=open(module_dir + x + ".py")
- module=imp.load_module(x, fh, "targets/" + x + ".py",
- (".py", "r", imp.PY_SOURCE))
- module.register(targetmap)
- fh.close()
-
- except IOError:
- raise CatalystError,"Can't find " + x + ".py plugin in " + \
- module_dir
-
+ mod_name = "catalyst.targets." + target
+ module = __import__(mod_name, [],[], ["not empty"])
except ImportError as e:
- print "!!! catalyst: Python modules not found in "+\
- module_dir + "; exiting."
- print e
+ print "!!! catalyst: Python module import error: %s " % target + \
+ "in catalyst/targets/ ... exiting."
+ print "ERROR was: ", e
sys.exit(1)
+ return module
- return targetmap
-def build_target(addlargs, targetmap):
+def build_target(addlargs):
try:
- if addlargs["target"] not in targetmap:
- raise CatalystError,"Target \""+addlargs["target"]+"\" not available."
-
- mytarget=targetmap[addlargs["target"]](conf_values, addlargs)
-
- mytarget.run()
+ module = import_module(addlargs["target"])
+ target = getattr(module, addlargs["target"])(conf_values, addlargs)
+ except AttributeError:
+ raise CatalystError(
+ "Target \"%s\" not available." % addlargs["target"],
+ print_traceback=True)
+ try:
+ target.run()
except:
+ print "Target run() exception: Python traceback output follows:"
catalyst.util.print_traceback()
print "!!! catalyst: Error encountered during run of target " + addlargs["target"]
sys.exit(1)
def main():
- targetmap={}
version()
if os.getuid() != 0:
@@ -341,9 +321,6 @@ def main():
print "Catalyst aborting...."
sys.exit(2)
- # import the rest of the catalyst modules
- targetmap=import_modules()
-
addlargs={}
if myspecfile:
@@ -364,7 +341,7 @@ def main():
# everything is setup, so the build is a go
try:
- build_target(addlargs, targetmap)
+ build_target(addlargs)
except CatalystError:
print
diff --git a/catalyst/targets/embedded_target.py b/catalyst/targets/embedded_target.py
index 528d545..aee0f00 100644
--- a/catalyst/targets/embedded_target.py
+++ b/catalyst/targets/embedded_target.py
@@ -45,7 +45,3 @@ class embedded_target(StageBase):
def set_root_path(self):
self.settings["root_path"]=normpath("/tmp/mergeroot")
print "embedded root path is "+self.settings["root_path"]
-
-def register(foo):
- foo.update({"embedded":embedded_target})
- return foo
diff --git a/catalyst/targets/grp_target.py b/catalyst/targets/grp_target.py
index deba80a..e3f08a2 100644
--- a/catalyst/targets/grp_target.py
+++ b/catalyst/targets/grp_target.py
@@ -118,7 +118,3 @@ class grp_target(StageBase):
"config_profile_link","setup_confdir","portage_overlay","bind","chroot_setup",\
"setup_environment","run_local","unbind",\
"generate_digests","clear_autoresume"]
-
-def register(foo):
- foo.update({"grp":grp_target})
- return foo
diff --git a/catalyst/targets/livecd_stage1_target.py b/catalyst/targets/livecd_stage1_target.py
index a19f4ac..9c74253 100644
--- a/catalyst/targets/livecd_stage1_target.py
+++ b/catalyst/targets/livecd_stage1_target.py
@@ -76,7 +76,3 @@ class livecd_stage1_target(StageBase):
self.settings["pkgcache_path"]=normpath(string.join(self.settings["pkgcache_path"]))
else:
StageBase.set_pkgcache_path(self)
-
-def register(foo):
- foo.update({"livecd-stage1":livecd_stage1_target})
- return foo
diff --git a/catalyst/targets/livecd_stage2_target.py b/catalyst/targets/livecd_stage2_target.py
index e7ae212..a4630e6 100644
--- a/catalyst/targets/livecd_stage2_target.py
+++ b/catalyst/targets/livecd_stage2_target.py
@@ -145,7 +145,3 @@ class livecd_stage2_target(StageBase):
"unbind","remove","empty","target_setup",\
"setup_overlay","create_iso"]
self.settings["action_sequence"].append("clear_autoresume")
-
-def register(foo):
- foo.update({"livecd-stage2":livecd_stage2_target})
- return foo
diff --git a/catalyst/targets/netboot2_target.py b/catalyst/targets/netboot2_target.py
index 987afd8..130e2b6 100644
--- a/catalyst/targets/netboot2_target.py
+++ b/catalyst/targets/netboot2_target.py
@@ -167,7 +167,3 @@ class netboot2_target(StageBase):
"setup_environment","build_packages","root_overlay",\
"copy_files_to_image","setup_overlay","build_kernel","move_kernels",\
"remove","empty","unbind","clean","clear_autoresume"]
-
-def register(foo):
- foo.update({"netboot2":netboot2_target})
- return foo
diff --git a/catalyst/targets/netboot_target.py b/catalyst/targets/netboot_target.py
index c880289..9d92ef2 100644
--- a/catalyst/targets/netboot_target.py
+++ b/catalyst/targets/netboot_target.py
@@ -127,7 +127,3 @@ class netboot_target(StageBase):
"setup_environment","build_packages","build_busybox",\
"build_kernel","copy_files_to_image",\
"clean","create_netboot_files","unbind","clear_autoresume"]
-
-def register(foo):
- foo.update({"netboot":netboot_target})
- return foo
diff --git a/catalyst/targets/snapshot_target.py b/catalyst/targets/snapshot.py
similarity index 95%
rename from catalyst/targets/snapshot_target.py
rename to catalyst/targets/snapshot.py
index 337ff1d..6c2396e 100644
--- a/catalyst/targets/snapshot_target.py
+++ b/catalyst/targets/snapshot.py
@@ -11,7 +11,7 @@ from catalyst.support import normpath, cmd
from catalyst.base.targetbase import TargetBase
from catalyst.base.genbase import GenBase
-class snapshot_target(TargetBase, GenBase):
+class snapshot(TargetBase, GenBase):
"""
Builder class for snapshots.
"""
@@ -91,7 +91,3 @@ class snapshot_target(TargetBase, GenBase):
os.makedirs(myemp,0755)
os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
os.chmod(myemp,mystat[ST_MODE])
-
-def register(foo):
- foo.update({"snapshot":snapshot_target})
- return foo
diff --git a/catalyst/targets/stage1_target.py b/catalyst/targets/stage1_target.py
index 0a36432..2329b58 100644
--- a/catalyst/targets/stage1_target.py
+++ b/catalyst/targets/stage1_target.py
@@ -94,7 +94,3 @@ class stage1_target(StageBase):
self.mounts.append("stage1root/proc")
self.target_mounts["stage1root/proc"] = "/tmp/stage1root/proc"
self.mountmap["stage1root/proc"] = "/proc"
-
-def register(foo):
- foo.update({"stage1":stage1_target})
- return foo
diff --git a/catalyst/targets/stage2_target.py b/catalyst/targets/stage2_target.py
index 783d42e..ec6d78d 100644
--- a/catalyst/targets/stage2_target.py
+++ b/catalyst/targets/stage2_target.py
@@ -62,7 +62,3 @@ class stage2_target(StageBase):
print "\tUsing an portage overlay for earlier stages could cause build issues."
print "\tIf you break it, you buy it. Don't complain to us about it."
print "\tDont say we did not warn you\n"
-
-def register(foo):
- foo.update({"stage2":stage2_target})
- return foo
diff --git a/catalyst/targets/stage3_target.py b/catalyst/targets/stage3_target.py
index 28021b1..103242d 100644
--- a/catalyst/targets/stage3_target.py
+++ b/catalyst/targets/stage3_target.py
@@ -25,7 +25,3 @@ class stage3_target(StageBase):
def set_cleanables(self):
StageBase.set_cleanables(self)
-
-def register(foo):
- foo.update({"stage3":stage3_target})
- return foo
diff --git a/catalyst/targets/stage4_target.py b/catalyst/targets/stage4_target.py
index 0d725c7..4dbdb45 100644
--- a/catalyst/targets/stage4_target.py
+++ b/catalyst/targets/stage4_target.py
@@ -36,8 +36,3 @@ class stage4_target(StageBase):
if "fetch" not in self.settings['options']:
self.settings["action_sequence"].append("capture")
self.settings["action_sequence"].append("clear_autoresume")
-
-def register(foo):
- foo.update({"stage4":stage4_target})
- return foo
-
diff --git a/catalyst/targets/tinderbox_target.py b/catalyst/targets/tinderbox_target.py
index 1e245f2..0c389e6 100644
--- a/catalyst/targets/tinderbox_target.py
+++ b/catalyst/targets/tinderbox_target.py
@@ -45,7 +45,3 @@ class tinderbox_target(StageBase):
"config_profile_link","setup_confdir","bind","chroot_setup",\
"setup_environment","run_local","preclean","unbind","clean",\
"clear_autoresume"]
-
-def register(foo):
- foo.update({"tinderbox":tinderbox_target})
- return foo
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/targets/, catalyst/
@ 2017-11-29 17:20 Brian Dolbec
0 siblings, 0 replies; 3+ messages in thread
From: Brian Dolbec @ 2017-11-29 17:20 UTC (permalink / raw
To: gentoo-commits
commit: 57055cb085a23358febf61b2c7d36627fc2815dd
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 6 20:51:23 2017 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Nov 22 01:16:22 2017 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=57055cb0
stage1: Fix seedcache to clean out the original seed root, keep only the stage1root
Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>
catalyst/fileops.py | 23 +++++++++++++++++++++++
catalyst/targets/stage1.py | 39 ++++++++++++++++++++++++++++++++++++++-
2 files changed, 61 insertions(+), 1 deletion(-)
diff --git a/catalyst/fileops.py b/catalyst/fileops.py
index ef4ee8d1..5e51f1fc 100644
--- a/catalyst/fileops.py
+++ b/catalyst/fileops.py
@@ -107,3 +107,26 @@ def clear_dir(target, mode=0o755, chg_flags=False, remove=False,
def clear_path(target):
"""Nuke |target| regardless of it being a dir or file."""
clear_dir(target, remove=True)
+
+
+def move_path(src, dest):
+ '''Move a source target to a new destination
+
+ :param src: source path to move
+ :param dest: destination path to move it to
+ :returns: boolean
+ '''
+ log.debug('Start move_path(%s, %s)', src, dest)
+ if os.path.isdir(src) and not os.path.islink(src):
+ if os.path.exists(dest):
+ log.warning('Removing existing target destination: %s', dest)
+ if not clear_dir(dest, remove=True):
+ return False
+ log.debug('Moving source...')
+ try:
+ shutil.move(src, dest)
+ except Exception:
+ log.error('move_path failed', exc_info=True)
+ return False
+ return True
+ return False
diff --git a/catalyst/targets/stage1.py b/catalyst/targets/stage1.py
index 18ef520d..cc4366b6 100644
--- a/catalyst/targets/stage1.py
+++ b/catalyst/targets/stage1.py
@@ -9,7 +9,7 @@ from snakeoil import fileutils
from catalyst import log
from catalyst.support import normpath
-from catalyst.fileops import ensure_dirs
+from catalyst.fileops import ensure_dirs, move_path
from catalyst.base.stagebase import StageBase
@@ -86,3 +86,40 @@ class stage1(StageBase):
self.mounts.append("stage1root/proc")
self.target_mounts["stage1root/proc"] = "/tmp/stage1root/proc"
self.mountmap["stage1root/proc"] = "/proc"
+
+ def set_completion_action_sequences(self):
+ '''Override function for stage1
+
+ Its purpose is to move the new stage1root out of the seed stage
+ and rename it to the stage1 chroot_path after cleaning the seed stage
+ chroot for re-use in stage2 without the need to unpack it.
+ '''
+ if "fetch" not in self.settings["options"]:
+ self.settings["action_sequence"].append("capture")
+ if "keepwork" in self.settings["options"]:
+ self.settings["action_sequence"].append("clear_autoresume")
+ elif "seedcache" in self.settings["options"]:
+ self.settings["action_sequence"].append("remove_autoresume")
+ self.settings["action_sequence"].append("clean_stage1")
+ else:
+ self.settings["action_sequence"].append("remove_autoresume")
+ self.settings["action_sequence"].append("remove_chroot")
+ return
+
+
+ def clean_stage1(self):
+ '''seedcache is enabled, so salvage the /tmp/stage1root,
+ remove the seed chroot'''
+ log.notice('Salvaging the stage1root from the chroot path ...')
+ # move the self.settings["stage_path"] outside of the self.settings["chroot_path"]
+ tmp_path = normpath(self.settings["storedir"] + "/tmp/" + "stage1root")
+ if move_path(self.settings["stage_path"], tmp_path):
+ self.remove_chroot()
+ # move it to self.settings["chroot_path"]
+ if not move_path(tmp_path, self.settings["chroot_path"]):
+ log.error('clean_stage1 failed, see previous log messages for details')
+ return False
+ log.notice('Successfully moved and cleaned the stage1root for the seedcache')
+ return True
+ log.error('clean_stage1 failed to move the stage1root to a temporary loation')
+ return False
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/targets/, catalyst/
@ 2020-04-11 20:27 Matt Turner
0 siblings, 0 replies; 3+ messages in thread
From: Matt Turner @ 2020-04-11 20:27 UTC (permalink / raw
To: gentoo-commits
commit: b96f33fad30027609291efd4983396b3f4b29a58
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 11 04:31:49 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Sat Apr 11 04:31:49 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=b96f33fa
catalyst: Remove some dead code
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/builder.py | 16 ----------------
catalyst/targets/snapshot.py | 3 ---
2 files changed, 19 deletions(-)
diff --git a/catalyst/builder.py b/catalyst/builder.py
index 64e14c8d..fd8d5eb6 100644
--- a/catalyst/builder.py
+++ b/catalyst/builder.py
@@ -9,19 +9,3 @@ class generic():
Useful for building x86-on-amd64 and such.
"""
self.settings['CHROOT'] = 'setarch %s %s' % (arch, self.settings['CHROOT'])
-
- def mount_safety_check(self):
- """
- Make sure that no bind mounts exist in chrootdir (to use before
- cleaning the directory, to make sure we don't wipe the contents of
- a bind mount
- """
- pass
-
- def mount_all(self):
- """do all bind mounts"""
- pass
-
- def umount_all(self):
- """unmount all bind mounts"""
- pass
diff --git a/catalyst/targets/snapshot.py b/catalyst/targets/snapshot.py
index c80d224f..b73135bc 100644
--- a/catalyst/targets/snapshot.py
+++ b/catalyst/targets/snapshot.py
@@ -33,9 +33,6 @@ class snapshot(TargetBase, GenBase):
x=normpath(self.settings["storedir"]+"/snapshots")
ensure_dirs(x)
- def mount_safety_check(self):
- pass
-
def run(self):
if "purgeonly" in self.settings["options"]:
self.purge()
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-04-11 20:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-11 20:27 [gentoo-commits] proj/catalyst:master commit in: catalyst/targets/, catalyst/ Matt Turner
-- strict thread matches above, loose matches on Subject: below --
2017-11-29 17:20 Brian Dolbec
2015-01-01 5:59 [gentoo-commits] proj/catalyst:pending commit in: catalyst/, catalyst/targets/ Brian Dolbec
2015-02-26 4:12 ` [gentoo-commits] proj/catalyst:master commit in: catalyst/targets/, catalyst/ Brian Dolbec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox