From c035a8d09d4e330e830159ea346e87f8c97f4fb9 Mon Sep 17 00:00:00 2001 From: Andrew Gaffney Date: Tue, 13 Jan 2009 08:01:40 -0600 Subject: [PATCH] Remove all references to self.settings[spec_prefix] and remove some now useless functions that remove the prefix from certain spec settings --- ChangeLog | 9 ++ modules/catalyst/target/embedded.py | 9 +- modules/catalyst/target/generic.py | 1 + modules/catalyst/target/generic_stage.py | 170 ++++++----------------- modules/catalyst/target/livecd_stage1.py | 13 +- modules/catalyst/target/livecd_stage2.py | 3 - modules/catalyst/target/netboot.py | 5 +- modules/catalyst/target/snapshot.py | 6 +- 8 files changed, 64 insertions(+), 152 deletions(-) diff --git a/ChangeLog b/ChangeLog index e5deb790..16704594 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,15 @@ # Copyright 2002-2009 Gentoo Foundation; 2008-2009 Various authors (see AUTHORS) # Distributed under the GPL v2 + 13 Jan 2009; Andrew Gaffney + modules/catalyst/target/embedded.py, modules/catalyst/target/generic.py, + modules/catalyst/target/generic_stage.py, + modules/catalyst/target/livecd_stage1.py, + modules/catalyst/target/livecd_stage2.py, + modules/catalyst/target/netboot.py, modules/catalyst/target/snapshot.py: + Remove all references to self.settings[spec_prefix] and remove some now + useless functions that remove the prefix from certain spec settings + 13 Jan 2009; Andrew Gaffney modules/catalyst/target/snapshot.py: Reorganize init for snapshot target diff --git a/modules/catalyst/target/embedded.py b/modules/catalyst/target/embedded.py index 68edf761..9afdc406 100644 --- a/modules/catalyst/target/embedded.py +++ b/modules/catalyst/target/embedded.py @@ -16,15 +16,10 @@ from catalyst.output import * class embedded_target(generic_stage_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") + self.valid_values = ["empty","rm","unmerge","fs-prepare","fs-finish","mergeroot","packages","fs-type"] + self.valid_values += ["runscript","boot/kernel","linuxrc", "use", "fs-ops"] generic_stage_target.__init__(self,spec,addlargs) - self.set_build_kernel_vars() def set_action_sequence(self): self.settings["action_sequence"]=["dir_setup","unpack","unpack_snapshot",\ diff --git a/modules/catalyst/target/generic.py b/modules/catalyst/target/generic.py index 3e09da48..a97f13ae 100644 --- a/modules/catalyst/target/generic.py +++ b/modules/catalyst/target/generic.py @@ -2,6 +2,7 @@ The toplevel class for generic_stage_target. This is about as generic as we get. """ +import os import catalyst from catalyst.output import * diff --git a/modules/catalyst/target/generic_stage.py b/modules/catalyst/target/generic_stage.py index 12bf1de1..dc7da534 100644 --- a/modules/catalyst/target/generic_stage.py +++ b/modules/catalyst/target/generic_stage.py @@ -103,9 +103,6 @@ class generic_stage_target(generic_target): "for alternate personality type " + self.settings["hostarch"]) # XXX This should all be moved somewhere "higher" ^^^^^^^^^^^^^^ - """ This must be set first as other set_ options depend on this """ - self.set_spec_prefix() - """ Define all of our core variables """ self.set_target_profile() self.set_target_subpath() @@ -127,19 +124,12 @@ class generic_stage_target(generic_target): self.set_use() self.set_cleanables() self.set_iso_volume_id() - self.set_build_kernel_vars() - self.set_fsscript() self.set_install_mask() - self.set_rcadd() - self.set_rcdel() - self.set_cdtar() self.set_fstype() self.set_fsops() self.set_iso() self.set_packages() self.set_rm() - self.set_linuxrc() - self.set_busybox_config() self.set_overlay() self.set_portage_overlay() self.set_root_overlay() @@ -235,9 +225,6 @@ class generic_stage_target(generic_target): self.settings["install_mask"]=\ string.join(self.settings["install_mask"]) - def set_spec_prefix(self): - self.settings["spec_prefix"]=self.settings["target"] - def set_target_profile(self): self.settings["target_profile"]=self.settings["profile"] @@ -289,63 +276,28 @@ class generic_stage_target(generic_target): if not os.path.exists(self.settings["storedir"]+"/builds/"): os.makedirs(self.settings["storedir"]+"/builds/") - def set_fsscript(self): - if self.settings["spec_prefix"]+"/fsscript" in self.settings: - self.settings["fsscript"]=\ - self.settings[self.settings["spec_prefix"]+"/fsscript"] - del self.settings[self.settings["spec_prefix"]+"/fsscript"] - - def set_rcadd(self): - if self.settings["spec_prefix"]+"/rcadd" in self.settings: - self.settings["rcadd"]=\ - self.settings[self.settings["spec_prefix"]+"/rcadd"] - del self.settings[self.settings["spec_prefix"]+"/rcadd"] - - def set_rcdel(self): - if self.settings["spec_prefix"]+"/rcdel" in self.settings: - self.settings["rcdel"]=\ - self.settings[self.settings["spec_prefix"]+"/rcdel"] - del self.settings[self.settings["spec_prefix"]+"/rcdel"] - - def set_cdtar(self): - if self.settings["spec_prefix"]+"/cdtar" in self.settings: - self.settings["cdtar"]=\ - catalyst.util.normpath(self.settings[self.settings["spec_prefix"]+"/cdtar"]) - del self.settings[self.settings["spec_prefix"]+"/cdtar"] - def set_iso(self): - if self.settings["spec_prefix"]+"/iso" in self.settings: - if self.settings[self.settings["spec_prefix"]+"/iso"].startswith('/'): + if "iso" in self.settings: + if self.settings["iso"].startswith('/'): self.settings["iso"]=\ - catalyst.util.normpath(self.settings[self.settings["spec_prefix"]+"/iso"]) + catalyst.util.normpath(self.settings["iso"]) else: # This automatically prepends the build dir to the ISO output path # if it doesn't start with a / self.settings["iso"] = catalyst.util.normpath(self.settings["storedir"] + \ "/builds/" + self.settings["rel_type"] + "/" + \ - self.settings[self.settings["spec_prefix"]+"/iso"]) - del self.settings[self.settings["spec_prefix"]+"/iso"] + self.settings["iso"]) def set_fstype(self): - if self.settings["spec_prefix"]+"/fstype" in self.settings: - self.settings["fstype"]=\ - self.settings[self.settings["spec_prefix"]+"/fstype"] - del self.settings[self.settings["spec_prefix"]+"/fstype"] - if not "fstype" in self.settings: self.settings["fstype"]="normal" for x in self.valid_values: - if x == self.settings["spec_prefix"]+"/fstype": - msg(self.settings["spec_prefix"] + \ - "/fstype is being set to the default of 'normal'") + if x == "fstype": + msg("fstype is being set to the default of 'normal'") def set_fsops(self): if "fstype" in self.settings: self.valid_values.append("fsops") - if self.settings["spec_prefix"]+"/fsops" in self.settings: - self.settings["fsops"]=\ - self.settings[self.settings["spec_prefix"]+"/fsops"] - del self.settings[self.settings["spec_prefix"]+"/fsops"] def set_source_path(self): if "SEEDCACHE" in self.settings\ @@ -415,9 +367,9 @@ class generic_stage_target(generic_target): "-controller.sh") def set_iso_volume_id(self): - if self.settings["spec_prefix"]+"/volid" in self.settings: + if "volid" in self.settings: self.settings["iso_volume_id"]=\ - self.settings[self.settings["spec_prefix"]+"/volid"] + self.settings["volid"] if len(self.settings["iso_volume_id"])>32: raise CatalystError,\ "ISO volume ID must not exceed 32 characters." @@ -437,10 +389,6 @@ class generic_stage_target(generic_target): self.settings["action_sequence"].append("clear_autoresume") def set_use(self): - if self.settings["spec_prefix"]+"/use" in self.settings: - self.settings["use"]=\ - self.settings[self.settings["spec_prefix"]+"/use"] - del self.settings[self.settings["spec_prefix"]+"/use"] if "use" in self.settings: if type(self.settings["use"])==types.StringType: self.settings["use"]=self.settings["use"].split() @@ -456,27 +404,10 @@ class generic_stage_target(generic_target): pass def set_rm(self): - if self.settings["spec_prefix"]+"/rm" in self.settings: - if type(self.settings[self.settings["spec_prefix"]+\ - "/rm"])==types.StringType: - self.settings[self.settings["spec_prefix"]+"/rm"]=\ - self.settings[self.settings["spec_prefix"]+"/rm"].split() - - def set_linuxrc(self): - if self.settings["spec_prefix"]+"/linuxrc" in self.settings: - if type(self.settings[self.settings["spec_prefix"]+\ - "/linuxrc"])==types.StringType: - self.settings["linuxrc"]=\ - self.settings[self.settings["spec_prefix"]+"/linuxrc"] - del self.settings[self.settings["spec_prefix"]+"/linuxrc"] - - def set_busybox_config(self): - if self.settings["spec_prefix"]+"/busybox_config" in self.settings: - if type(self.settings[self.settings["spec_prefix"]+\ - "/busybox_config"])==types.StringType: - self.settings["busybox_config"]=\ - self.settings[self.settings["spec_prefix"]+"/busybox_config"] - del self.settings[self.settings["spec_prefix"]+"/busybox_config"] + if "rm" in self.settings: + if type(self.settings["rm"])==types.StringType: + self.settings["rm"]=\ + self.settings["rm"].split() def set_portage_overlay(self): if "portage_overlay" in self.settings: @@ -487,20 +418,16 @@ class generic_stage_target(generic_target): "".join(self.settings["portage_overlay"]) + "'") def set_overlay(self): - if self.settings["spec_prefix"]+"/overlay" in self.settings: - if type(self.settings[self.settings["spec_prefix"]+\ - "/overlay"])==types.StringType: - self.settings[self.settings["spec_prefix"]+"/overlay"]=\ - self.settings[self.settings["spec_prefix"]+\ - "/overlay"].split() + if "overlay" in self.settings: + if type(self.settings["overlay"])==types.StringType: + self.settings["overlay"]=\ + self.settings["overlay"].split() def set_root_overlay(self): - if self.settings["spec_prefix"]+"/root_overlay" in self.settings: - if type(self.settings[self.settings["spec_prefix"]+\ - "/root_overlay"])==types.StringType: - self.settings[self.settings["spec_prefix"]+"/root_overlay"]=\ - self.settings[self.settings["spec_prefix"]+\ - "/root_overlay"].split() + if "root_overlay" in self.settings: + if type(self.settings["root_overlay"])==types.StringType: + self.settings["root_overlay"]=\ + self.settings["root_overlay"].split() def set_root_path(self): """ ROOT= variable for emerges """ @@ -532,12 +459,6 @@ class generic_stage_target(generic_target): addlargs["boot/kernel/"+x+"/packages"]=\ [addlargs["boot/kernel/"+x+"/packages"]] - def set_build_kernel_vars(self): - if self.settings["spec_prefix"]+"/gk_mainargs" in self.settings: - self.settings["gk_mainargs"]=\ - self.settings[self.settings["spec_prefix"]+"/gk_mainargs"] - del self.settings[self.settings["spec_prefix"]+"/gk_mainargs"] - def kill_chroot_pids(self): msg("Checking for processes running in chroot and killing them.") @@ -807,14 +728,13 @@ class generic_stage_target(generic_target): def root_overlay(self): """ Copy over the root_overlay """ - if self.settings["spec_prefix"]+"/root_overlay" in self.settings: - for x in self.settings[self.settings["spec_prefix"]+\ - "/root_overlay"]: + if "root_overlay" in self.settings: + for x in self.settings["root_overlay"]: if os.path.exists(x): msg("Copying root_overlay: " + x) cmd("rsync -a "+x+"/ "+\ self.settings["chroot_path"],\ - self.settings["spec_prefix"]+"/root_overlay: "+x+\ + "root_overlay: "+x+\ " copy failed.",env=self.env) def base_dirs(self): @@ -988,8 +908,7 @@ class generic_stage_target(generic_target): myf.write('USE="'+string.join(myusevars)+'"\n') if '-*' in myusevars: msg("\nWarning!!! ") - msg("\tThe use of -* in " + self.settings["spec_prefix"] + \ - "/use will cause portage to ignore") + msg("\tThe use of -* in " + "use will cause portage to ignore") msg("\tpackage.use in the profile and portage_confdir. You've been warned!") """ Setup the portage overlay """ @@ -1059,13 +978,11 @@ class generic_stage_target(generic_target): if self.check_autoresume("empty"): msg("Resume point detected, skipping empty operation...") else: - if self.settings["spec_prefix"]+"/empty" in self.settings: - if type(self.settings[self.settings["spec_prefix"]+\ - "/empty"])==types.StringType: - self.settings[self.settings["spec_prefix"]+"/empty"]=\ - self.settings[self.settings["spec_prefix"]+\ - "/empty"].split() - for x in self.settings[self.settings["spec_prefix"]+"/empty"]: + if "empty" in self.settings: + if type(self.settings["empty"])==types.StringType: + self.settings["empty"]=\ + self.settings["empty"].split() + for x in self.settings["empty"]: myemp=self.settings["destpath"]+x if not os.path.isdir(myemp): msg(x + " not a directory or does not exist, skipping 'empty' operation.") @@ -1086,8 +1003,8 @@ class generic_stage_target(generic_target): if self.check_autoresume("remove"): msg("Resume point detected, skipping remove operation...") else: - if self.settings["spec_prefix"]+"/rm" in self.settings: - for x in self.settings[self.settings["spec_prefix"]+"/rm"]: + if "rm" in self.settings: + for x in self.settings["rm"]: """ We're going to shell out for all these cleaning operations, so we get easy glob handling. @@ -1215,13 +1132,12 @@ class generic_stage_target(generic_target): if self.check_autoresume("unmerge"): msg("Resume point detected, skipping unmerge operation...") else: - if self.settings["spec_prefix"]+"/unmerge" in self.settings: - if type(self.settings[self.settings["spec_prefix"]+\ - "/unmerge"])==types.StringType: - self.settings[self.settings["spec_prefix"]+"/unmerge"]=\ - [self.settings[self.settings["spec_prefix"]+"/unmerge"]] + if "unmerge" in self.settings: + if type(self.settings["unmerge"])==types.StringType: + self.settings["unmerge"]=\ + [self.settings["unmerge"]] myunmerge=\ - self.settings[self.settings["spec_prefix"]+"/unmerge"][:] + self.settings["unmerge"][:] for x in range(0,len(myunmerge)): """ @@ -1256,12 +1172,12 @@ class generic_stage_target(generic_target): if self.check_autoresume("setup_overlay"): msg("Resume point detected, skipping setup_overlay operation...") else: - if self.settings["spec_prefix"]+"/overlay" in self.settings: - for x in self.settings[self.settings["spec_prefix"]+"/overlay"]: + if "overlay" in self.settings: + for x in self.settings["overlay"]: if os.path.exists(x): cmd("rsync -a "+x+"/ "+\ self.settings["target_path"],\ - self.settings["spec_prefix"]+"overlay: "+x+\ + "overlay: "+x+\ " copy failed.",env=self.env) self.set_autoresume("setup_overlay") @@ -1282,13 +1198,12 @@ class generic_stage_target(generic_target): msg("An ISO Image will not be created.") def build_packages(self): - if self.settings["spec_prefix"]+"/packages" in self.settings: + if "packages" in self.settings: if self.check_autoresume("build_packages"): msg("Resume point detected, skipping build_packages operation...") else: mypack = \ - catalyst.util.list_bashify(self.settings[self.settings["spec_prefix"] \ - +"/packages"]) + catalyst.util.list_bashify(self.settings["packages"]) try: cmd("/bin/bash "+self.settings["controller_file"]+\ " build_packages "+mypack,\ @@ -1296,8 +1211,7 @@ class generic_stage_target(generic_target): self.set_autoresume("build_packages") except CatalystError: self.unbind() - raise CatalystError,self.settings["spec_prefix"]+\ - "build aborting due to error." + raise CatalystError("build aborting due to error") def build_kernel(self): if self.check_autoresume("build_kernel"): diff --git a/modules/catalyst/target/livecd_stage1.py b/modules/catalyst/target/livecd_stage1.py index 841fb642..a66fc208 100644 --- a/modules/catalyst/target/livecd_stage1.py +++ b/modules/catalyst/target/livecd_stage1.py @@ -40,9 +40,6 @@ class livecd_stage1_target(generic_stage_target): def set_target_path(self): pass - def set_spec_prefix(self): - self.settings["spec_prefix"]="livecd" - def set_use(self): generic_stage_target.set_use(self) if "use" in self.settings: @@ -54,11 +51,11 @@ class livecd_stage1_target(generic_stage_target): def set_packages(self): generic_stage_target.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"] = \ - self.settings[self.settings["spec_prefix"]+"/packages"].split() - self.settings[self.settings["spec_prefix"]+"/packages"].append("app-misc/livecd-tools") + if "packages" in self.settings: + if type(self.settings["packages"]) == types.StringType: + self.settings["packages"] = \ + self.settings["packages"].split() + self.settings["packages"].append("app-misc/livecd-tools") def set_pkgcache_path(self): if "pkgcache_path" in self.settings: diff --git a/modules/catalyst/target/livecd_stage2.py b/modules/catalyst/target/livecd_stage2.py index bd8931db..35675db1 100644 --- a/modules/catalyst/target/livecd_stage2.py +++ b/modules/catalyst/target/livecd_stage2.py @@ -41,9 +41,6 @@ class livecd_stage2_target(generic_stage_target): if not os.path.exists(self.settings["source_path"]): raise CatalystError,"Source Path: "+self.settings["source_path"]+" does not exist." - def set_spec_prefix(self): - self.settings["spec_prefix"]="livecd" - def set_target_path(self): self.settings["target_path"]=catalyst.util.normpath(self.settings["storedir"]+"/builds/"+self.settings["target_subpath"]+"/") if self.check_autoresume("setup_target_path"): diff --git a/modules/catalyst/target/netboot.py b/modules/catalyst/target/netboot.py index ebfccc43..55156edd 100644 --- a/modules/catalyst/target/netboot.py +++ b/modules/catalyst/target/netboot.py @@ -39,7 +39,6 @@ class netboot_target(generic_stage_target): raise CatalystError,"configuration error in netboot/packages." generic_stage_target.__init__(self,spec,addlargs) - self.set_build_kernel_vars() self.settings["merge_path"]=catalyst.util.normpath("/tmp/image/") def set_target_path(self): @@ -120,8 +119,8 @@ class netboot_target(generic_stage_target): if self.check_autoresume("remove"): msg("Resume point detected, skipping remove operation...") else: - if self.settings["spec_prefix"]+"/rm" in self.settings: - for x in self.settings[self.settings["spec_prefix"]+"/rm"]: + if "rm" in self.settings: + for x in self.settings["rm"]: # we're going to shell out for all these cleaning operations, # so we get easy glob handling msg("netboot: removing " + x) diff --git a/modules/catalyst/target/snapshot.py b/modules/catalyst/target/snapshot.py index 7d5cbc0d..b9ff0c85 100644 --- a/modules/catalyst/target/snapshot.py +++ b/modules/catalyst/target/snapshot.py @@ -3,7 +3,7 @@ Builder class for snapshots. """ -import os +import os, shutil, stat import catalyst from catalyst.spawn import cmd from catalyst.output import * @@ -79,7 +79,7 @@ class snapshot_target(catalyst.target.generic.generic_target): os.system("chflags -R noschg "+myemp) shutil.rmtree(myemp) os.makedirs(myemp,0755) - os.chown(myemp,mystat[ST_UID],mystat[ST_GID]) - os.chmod(myemp,mystat[ST_MODE]) + os.chown(myemp,mystat[stat.ST_UID],mystat[stat.ST_GID]) + os.chmod(myemp,mystat[stat.ST_MODE]) __target_map = {"snapshot":snapshot_target} -- 2.26.2