From 4ba1f6057395de3ed80c45c813bc8510c3c5cb4a Mon Sep 17 00:00:00 2001 From: Andrew Gaffney Date: Sat, 19 Sep 2009 14:07:03 -0500 Subject: [PATCH] Add dependency information for each target Add function to automatically calculate source_subpath --- ChangeLog | 12 ++++++++++++ modules/catalyst/target/embedded.py | 4 +++- modules/catalyst/target/generic.py | 8 ++++++++ modules/catalyst/target/generic_stage.py | 3 +++ modules/catalyst/target/grp.py | 5 ++++- modules/catalyst/target/livecd_stage1.py | 5 ++++- modules/catalyst/target/livecd_stage2.py | 5 ++++- modules/catalyst/target/netboot.py | 5 ++++- modules/catalyst/target/snapshot.py | 4 +++- modules/catalyst/target/stage1.py | 5 ++++- modules/catalyst/target/stage2.py | 4 +++- modules/catalyst/target/stage3.py | 4 +++- modules/catalyst/target/stage4.py | 4 +++- modules/catalyst/target/system.py | 5 ++++- modules/catalyst/target/tinderbox.py | 4 +++- 15 files changed, 65 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5e5b50fb..57cacfae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,18 @@ # Distributed under the GPL v2 # $Id$ + 19 Sep 2009; Andrew Gaffney + modules/catalyst/target/embedded.py, modules/catalyst/target/generic.py, + modules/catalyst/target/generic_stage.py, modules/catalyst/target/grp.py, + modules/catalyst/target/livecd_stage1.py, + modules/catalyst/target/livecd_stage2.py, + modules/catalyst/target/netboot.py, modules/catalyst/target/snapshot.py, + modules/catalyst/target/stage1.py, modules/catalyst/target/stage2.py, + modules/catalyst/target/stage3.py, modules/catalyst/target/stage4.py, + modules/catalyst/target/system.py, modules/catalyst/target/tinderbox.py: + Add dependency information for each target + Add function to automatically calculate source_subpath + 18 Sep 2009; Andrew Gaffney modules/catalyst/target/generic_stage.py: Fix typo for Gentoo bug #285484 diff --git a/modules/catalyst/target/embedded.py b/modules/catalyst/target/embedded.py index fd49ee45..02604dd6 100644 --- a/modules/catalyst/target/embedded.py +++ b/modules/catalyst/target/embedded.py @@ -15,6 +15,8 @@ from catalyst.output import * class embedded_target(generic_stage_target): + depends = ('system', 'stage3') + def __init__(self): self.valid_values = ["empty","rm","unmerge","fs-prepare","fs-finish","mergeroot","packages","fs-type"] self.valid_values += ["runscript","boot/kernel","linuxrc", "use", "fs-ops"] @@ -37,6 +39,6 @@ class embedded_target(generic_stage_target): self.settings["root_path"]=catalyst.util.normpath("/tmp/mergeroot") msg("embedded root path is " + self.settings["root_path"]) -__target_map = {"embedded":embedded_target} +__target_map = { "embedded": embedded_target } # vim: ts=4 sw=4 sta noet sts=4 ai diff --git a/modules/catalyst/target/generic.py b/modules/catalyst/target/generic.py index ce9e0985..25bb7089 100644 --- a/modules/catalyst/target/generic.py +++ b/modules/catalyst/target/generic.py @@ -83,4 +83,12 @@ class generic_target: cmd("/bin/bash " + self.settings["controller_file"] + " " + command, \ action + " script failed.", env=self.env) + def calculate_source_subpath(self): + depends = self.depends + subpaths = [] + for x in depends: + foo = self.settings['rel_type'] + '/' + x + '-' + self.settings['subarch'] + '-' + self.settings['version_stamp'] + subpaths.append(foo) + return subpaths + # vim: ts=4 sw=4 sta noet sts=4 ai diff --git a/modules/catalyst/target/generic_stage.py b/modules/catalyst/target/generic_stage.py index 44be4416..b2ec42ba 100644 --- a/modules/catalyst/target/generic_stage.py +++ b/modules/catalyst/target/generic_stage.py @@ -234,6 +234,9 @@ class generic_stage_target(generic_target): self.settings["version_stamp"] def set_source_subpath(self): + if not 'source_subpath' in self.settings: + subpaths = self.calculate_source_subpath() + msg("Possible source_subpath settings are: " + ', '.join(subpaths)) if not isinstance(self.settings["source_subpath"], str): raise CatalystError,\ "source_subpath should have been a string. Perhaps you have something wrong in your spec file?" diff --git a/modules/catalyst/target/grp.py b/modules/catalyst/target/grp.py index ccd22980..907080c4 100644 --- a/modules/catalyst/target/grp.py +++ b/modules/catalyst/target/grp.py @@ -11,6 +11,9 @@ from catalyst.spawn import cmd from catalyst.output import * class grp_target(generic_stage_target): + + depends = ('system', 'stage3') + def __init__(self): generic_stage_target.__init__(self) @@ -110,6 +113,6 @@ class grp_target(generic_stage_target): "setup_environment","run_local","unbind",\ "generate_digests","clear_autoresume"] -__target_map = {"grp":grp_target} +__target_map = { "grp": grp_target } # vim: ts=4 sw=4 sta noet sts=4 ai diff --git a/modules/catalyst/target/livecd_stage1.py b/modules/catalyst/target/livecd_stage1.py index eec477a9..e78a25e5 100644 --- a/modules/catalyst/target/livecd_stage1.py +++ b/modules/catalyst/target/livecd_stage1.py @@ -9,6 +9,9 @@ from catalyst.spawn import cmd from catalyst.output import * class livecd_stage1_target(generic_stage_target): + + depends = ('system', 'stage3') + def __init__(self): self.required_values=["livecd/packages"] self.valid_values=self.required_values[:] @@ -63,6 +66,6 @@ class livecd_stage1_target(generic_stage_target): else: generic_stage_target.set_pkgcache_path(self) -__target_map = {"livecd-stage1":livecd_stage1_target} +__target_map = { "livecd-stage1": livecd_stage1_target } # vim: ts=4 sw=4 sta noet sts=4 ai diff --git a/modules/catalyst/target/livecd_stage2.py b/modules/catalyst/target/livecd_stage2.py index 00bf9393..bc7c8eb0 100644 --- a/modules/catalyst/target/livecd_stage2.py +++ b/modules/catalyst/target/livecd_stage2.py @@ -11,6 +11,9 @@ from catalyst.spawn import cmd from catalyst.output import * class livecd_stage2_target(generic_stage_target): + + depends = ('livecd-stage1', ) + def __init__(self): self.required_values=["boot/kernel"] @@ -132,6 +135,6 @@ class livecd_stage2_target(generic_stage_target): "setup_overlay","create_iso"] self.settings["action_sequence"].append("clear_autoresume") -__target_map = {"livecd-stage2":livecd_stage2_target} +__target_map = { "livecd-stage2": livecd_stage2_target } # vim: ts=4 sw=4 sta noet sts=4 ai diff --git a/modules/catalyst/target/netboot.py b/modules/catalyst/target/netboot.py index 9f4f6f92..211d8253 100644 --- a/modules/catalyst/target/netboot.py +++ b/modules/catalyst/target/netboot.py @@ -11,6 +11,9 @@ from catalyst.spawn import cmd from catalyst.output import * class netboot_target(generic_stage_target): + + depends = ('system', 'stage3') + def __init__(self): generic_stage_target.__init__(self) @@ -145,6 +148,6 @@ class netboot_target(generic_stage_target): "copy_files_to_image","setup_overlay","build_kernel","move_kernels",\ "remove","empty","unbind","clean","clear_autoresume"] -__target_map = {"netboot":netboot_target} +__target_map = { "netboot": netboot_target } # vim: ts=4 sw=4 sta noet sts=4 ai diff --git a/modules/catalyst/target/snapshot.py b/modules/catalyst/target/snapshot.py index 0eb7a3fb..47695a87 100644 --- a/modules/catalyst/target/snapshot.py +++ b/modules/catalyst/target/snapshot.py @@ -11,6 +11,8 @@ from catalyst.output import * class snapshot_target(catalyst.target.generic.generic_target): + depends = () + def __init__(self): generic_target.__init__(self) @@ -66,6 +68,6 @@ class snapshot_target(catalyst.target.generic.generic_target): msg("Emptying directory " + myemp) catalyst.util.empty_dir(myemp) -__target_map = {"snapshot":snapshot_target} +__target_map = { "snapshot": snapshot_target } # vim: ts=4 sw=4 sta noet sts=4 ai diff --git a/modules/catalyst/target/stage1.py b/modules/catalyst/target/stage1.py index dde9b32a..ccc42767 100644 --- a/modules/catalyst/target/stage1.py +++ b/modules/catalyst/target/stage1.py @@ -9,6 +9,9 @@ from catalyst.output import * class stage1_target(generic_stage_target): + # We're leaving this empty since we can't do automatic source_subpath calculation for stage1 + depends = () + def __init__(self): generic_stage_target.__init__(self) @@ -94,6 +97,6 @@ class stage1_target(generic_stage_target): self.mountmap["/tmp/stage1root/proc"]="/proc" -__target_map = {"stage1":stage1_target} +__target_map = { "stage1": stage1_target } # vim: ts=4 sw=4 sta noet sts=4 ai diff --git a/modules/catalyst/target/stage2.py b/modules/catalyst/target/stage2.py index a8c46ed7..14b59fce 100644 --- a/modules/catalyst/target/stage2.py +++ b/modules/catalyst/target/stage2.py @@ -9,6 +9,8 @@ from catalyst.output import * class stage2_target(generic_stage_target): + depends = ('stage1', ) + def __init__(self): generic_stage_target.__init__(self) @@ -63,6 +65,6 @@ class stage2_target(generic_stage_target): msg("\tDont say we did not warn you") msg() -__target_map = {"stage2":stage2_target} +__target_map = { "stage2": stage2_target } # vim: ts=4 sw=4 sta noet sts=4 ai diff --git a/modules/catalyst/target/stage3.py b/modules/catalyst/target/stage3.py index 4d630dbb..1f0039fa 100644 --- a/modules/catalyst/target/stage3.py +++ b/modules/catalyst/target/stage3.py @@ -7,6 +7,8 @@ from generic_stage import * class stage3_target(generic_stage_target): + depends = ('stage2', ) + def __init__(self): generic_stage_target.__init__(self) @@ -27,6 +29,6 @@ class stage3_target(generic_stage_target): generic_stage_target.set_cleanables(self) self.settings["cleanables"].extend(["/etc/portage"]) -__target_map = {"stage3":stage3_target} +__target_map = { "stage3": stage3_target } # vim: ts=4 sw=4 sta noet sts=4 ai diff --git a/modules/catalyst/target/stage4.py b/modules/catalyst/target/stage4.py index a42b79c1..31880588 100644 --- a/modules/catalyst/target/stage4.py +++ b/modules/catalyst/target/stage4.py @@ -7,6 +7,8 @@ from generic_stage import * class stage4_target(generic_stage_target): + depends = ('system', 'stage3') + def __init__(self): generic_stage_target.__init__(self) @@ -35,6 +37,6 @@ class stage4_target(generic_stage_target): self.settings["action_sequence"].append("capture") self.settings["action_sequence"].append("clear_autoresume") -__target_map = {"stage4":stage4_target} +__target_map = { "stage4": stage4_target } # vim: ts=4 sw=4 sta noet sts=4 ai diff --git a/modules/catalyst/target/system.py b/modules/catalyst/target/system.py index 9d2b6589..1a4d315d 100644 --- a/modules/catalyst/target/system.py +++ b/modules/catalyst/target/system.py @@ -9,6 +9,9 @@ from catalyst.output import * class system_target(generic_stage_target): + # We're leaving this empty since we can't do automatic source_subpath calculation for system + depends = () + def __init__(self): generic_stage_target.__init__(self) @@ -90,6 +93,6 @@ class system_target(generic_stage_target): self.mountmap[self.settings["root_path"] + "/proc"]="/proc" -__target_map = {"system": system_target} +__target_map = { "system": system_target } # vim: ts=4 sw=4 sta noet sts=4 ai diff --git a/modules/catalyst/target/tinderbox.py b/modules/catalyst/target/tinderbox.py index d78fcea0..ccaf4950 100644 --- a/modules/catalyst/target/tinderbox.py +++ b/modules/catalyst/target/tinderbox.py @@ -10,6 +10,8 @@ from catalyst.spawn import cmd class tinderbox_target(generic_stage_target): + depends = ('system', 'stage3') + def __init__(self): generic_stage_target.__init__(self) @@ -37,6 +39,6 @@ class tinderbox_target(generic_stage_target): "setup_environment","run_local","preclean","unbind","clean",\ "clear_autoresume"] -__target_map = {"tinderbox":tinderbox_target} +__target_map = { "tinderbox": tinderbox_target } # vim: ts=4 sw=4 sta noet sts=4 ai -- 2.26.2