From ff3eb3a143b1dfe45ed8e63e86cf2b42f66460ce Mon Sep 17 00:00:00 2001 From: Andrew Gaffney Date: Sun, 11 Jan 2009 16:08:38 -0600 Subject: [PATCH] Move touch() from catalyst.support to catalyst.util --- ChangeLog | 7 ++++ modules/catalyst/support.py | 7 ---- modules/catalyst/target/generic_stage.py | 44 ++++++++++++------------ modules/catalyst/target/grp.py | 2 +- modules/catalyst/target/livecd_stage1.py | 2 +- modules/catalyst/target/livecd_stage2.py | 4 +-- modules/catalyst/target/netboot2.py | 8 ++--- modules/catalyst/util.py | 7 ++++ 8 files changed, 44 insertions(+), 37 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0fad171f..908fc212 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,13 @@ # Copyright 2002-2009 Gentoo Foundation; 2008-2009 Various authors (see AUTHORS) # Distributed under the GPL v2 + 11 Jan 2009; Andrew Gaffney + modules/catalyst/support.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/netboot2.py, modules/catalyst/util.py: + Move touch() from catalyst.support to catalyst.util + 11 Jan 2009; Andrew Gaffney modules/catalyst/support.py, modules/catalyst/target/generic_stage.py, modules/catalyst/util.py: diff --git a/modules/catalyst/support.py b/modules/catalyst/support.py index 1656471a..2d5fec58 100644 --- a/modules/catalyst/support.py +++ b/modules/catalyst/support.py @@ -577,13 +577,6 @@ def addl_arg_parse(myspec,addlargs,requiredspec,validspec): if not x in myspec: raise CatalystError, "Required argument \""+x+"\" not specified." -def touch(myfile): - try: - myf=open(myfile,"w") - myf.close() - except IOError: - raise CatalystError, "Could not touch "+myfile+"." - def countdown(secs=5, doing="Starting"): if secs: print ">>> Waiting",secs,"seconds before starting..." diff --git a/modules/catalyst/target/generic_stage.py b/modules/catalyst/target/generic_stage.py index c8350eb8..356ca3be 100644 --- a/modules/catalyst/target/generic_stage.py +++ b/modules/catalyst/target/generic_stage.py @@ -288,7 +288,7 @@ class generic_stage_target(generic_target): # 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") + catalyst.util.touch(self.settings["autoresume_path"]+"setup_target_path") if not os.path.exists(self.settings["storedir"]+"/builds/"): os.makedirs(self.settings["storedir"]+"/builds/") @@ -714,7 +714,7 @@ class generic_stage_target(generic_target): myf.write(self.settings["source_path_hash"]) myf.close() else: - touch(self.settings["autoresume_path"]+"unpack") + catalyst.util.touch(self.settings["autoresume_path"]+"unpack") else: print "Resume point detected, skipping unpack operation..." @@ -800,7 +800,7 @@ class generic_stage_target(generic_target): self.settings["target_profile"]+" "+\ self.settings["chroot_path"]+"/etc/make.profile",\ "Error creating profile link",env=self.env) - touch(self.settings["autoresume_path"]+"config_profile_link") + catalyst.util.touch(self.settings["autoresume_path"]+"config_profile_link") def setup_confdir(self): if "AUTORESUME" in self.settings \ @@ -815,7 +815,7 @@ class generic_stage_target(generic_target): cmd("cp -R "+self.settings["portage_confdir"]+"/ "+\ self.settings["chroot_path"]+"/etc/portage",\ "Error copying /etc/portage",env=self.env) - touch(self.settings["autoresume_path"]+"setup_confdir") + catalyst.util.touch(self.settings["autoresume_path"]+"setup_confdir") def portage_overlay(self): """ We copy the contents of our overlays to /usr/local/portage """ @@ -1026,7 +1026,7 @@ class generic_stage_target(generic_target): cmd("cp "+self.settings["chroot_path"]+"/etc/make.conf "+\ self.settings["chroot_path"]+"/etc/make.conf.catalyst",\ "Could not backup /etc/make.conf",env=self.env) - touch(self.settings["autoresume_path"]+"chroot_setup") + catalyst.util.touch(self.settings["autoresume_path"]+"chroot_setup") def fsscript(self): if "AUTORESUME" in self.settings \ @@ -1037,7 +1037,7 @@ class generic_stage_target(generic_target): if os.path.exists(self.settings["controller_file"]): cmd("/bin/bash "+self.settings["controller_file"]+\ " fsscript","fsscript script failed.",env=self.env) - touch(self.settings["autoresume_path"]+"fsscript") + catalyst.util.touch(self.settings["autoresume_path"]+"fsscript") def rcupdate(self): if "AUTORESUME" in self.settings \ @@ -1047,7 +1047,7 @@ class generic_stage_target(generic_target): if os.path.exists(self.settings["controller_file"]): cmd("/bin/bash "+self.settings["controller_file"]+" rc-update",\ "rc-update script failed.",env=self.env) - touch(self.settings["autoresume_path"]+"rcupdate") + catalyst.util.touch(self.settings["autoresume_path"]+"rcupdate") def clean(self): if "AUTORESUME" in self.settings \ @@ -1082,7 +1082,7 @@ class generic_stage_target(generic_target): if os.path.exists(self.settings["controller_file"]): cmd("/bin/bash "+self.settings["controller_file"]+" clean",\ "clean script failed.",env=self.env) - touch(self.settings["autoresume_path"]+"clean") + catalyst.util.touch(self.settings["autoresume_path"]+"clean") def empty(self): if "AUTORESUME" in self.settings \ @@ -1110,7 +1110,7 @@ class generic_stage_target(generic_target): os.makedirs(myemp,0755) os.chown(myemp,mystat[ST_UID],mystat[ST_GID]) os.chmod(myemp,mystat[ST_MODE]) - touch(self.settings["autoresume_path"]+"empty") + catalyst.util.touch(self.settings["autoresume_path"]+"empty") def remove(self): if "AUTORESUME" in self.settings \ @@ -1129,7 +1129,7 @@ class generic_stage_target(generic_target): if os.path.exists(self.settings["controller_file"]): cmd("/bin/bash "+self.settings["controller_file"]+\ " clean","Clean failed.",env=self.env) - touch(self.settings["autoresume_path"]+"remove") + catalyst.util.touch(self.settings["autoresume_path"]+"remove") except: self.unbind() raise @@ -1143,7 +1143,7 @@ class generic_stage_target(generic_target): if os.path.exists(self.settings["controller_file"]): cmd("/bin/bash "+self.settings["controller_file"]+\ " preclean","preclean script failed.",env=self.env) - touch(self.settings["autoresume_path"]+"preclean") + catalyst.util.touch(self.settings["autoresume_path"]+"preclean") except: self.unbind() @@ -1172,7 +1172,7 @@ class generic_stage_target(generic_target): self.gen_contents_file(self.settings["target_path"]) self.gen_digest_file(self.settings["target_path"]) - touch(self.settings["autoresume_path"]+"capture") + catalyst.util.touch(self.settings["autoresume_path"]+"capture") def run_local(self): if "AUTORESUME" in self.settings \ @@ -1183,7 +1183,7 @@ class generic_stage_target(generic_target): if os.path.exists(self.settings["controller_file"]): cmd("/bin/bash "+self.settings["controller_file"]+" run",\ "run script failed.",env=self.env) - touch(self.settings["autoresume_path"]+"run_local") + catalyst.util.touch(self.settings["autoresume_path"]+"run_local") except CatalystError: self.unbind() @@ -1275,7 +1275,7 @@ class generic_stage_target(generic_target): except CatalystError: self.unbind() raise - touch(self.settings["autoresume_path"]+"unmerge") + catalyst.util.touch(self.settings["autoresume_path"]+"unmerge") def target_setup(self): if "AUTORESUME" in self.settings \ @@ -1286,7 +1286,7 @@ class generic_stage_target(generic_target): cmd("/bin/bash "+self.settings["controller_file"]+\ " target_image_setup "+ self.settings["target_path"],\ "target_image_setup script failed.",env=self.env) - touch(self.settings["autoresume_path"]+"target_setup") + catalyst.util.touch(self.settings["autoresume_path"]+"target_setup") def setup_overlay(self): if "AUTORESUME" in self.settings \ @@ -1300,7 +1300,7 @@ class generic_stage_target(generic_target): self.settings["target_path"],\ self.settings["spec_prefix"]+"overlay: "+x+\ " copy failed.",env=self.env) - touch(self.settings["autoresume_path"]+"setup_overlay") + catalyst.util.touch(self.settings["autoresume_path"]+"setup_overlay") def create_iso(self): if "AUTORESUME" in self.settings \ @@ -1314,7 +1314,7 @@ class generic_stage_target(generic_target): env=self.env) self.gen_contents_file(self.settings["iso"]) self.gen_digest_file(self.settings["iso"]) - touch(self.settings["autoresume_path"]+"create_iso") + catalyst.util.touch(self.settings["autoresume_path"]+"create_iso") else: print "WARNING: livecd/iso was not defined." print "An ISO Image will not be created." @@ -1338,7 +1338,7 @@ class generic_stage_target(generic_target): cmd("/bin/bash "+self.settings["controller_file"]+\ " build_packages "+mypack,\ "Error in attempt to build packages",env=self.env) - touch(self.settings["autoresume_path"]+"build_packages") + catalyst.util.touch(self.settings["autoresume_path"]+"build_packages") except CatalystError: self.unbind() raise CatalystError,self.settings["spec_prefix"]+\ @@ -1450,7 +1450,7 @@ class generic_stage_target(generic_target): cmd("rm -R "+self.settings["chroot_path"]+\ "/tmp/initramfs_overlay/",env=self.env) - touch(self.settings["autoresume_path"]+\ + catalyst.util.touch(self.settings["autoresume_path"]+\ "build_kernel_"+kname) """ @@ -1461,7 +1461,7 @@ class generic_stage_target(generic_target): " post-kmerge ", "Runscript post-kmerge failed",env=self.env) - touch(self.settings["autoresume_path"]+"build_kernel") + catalyst.util.touch(self.settings["autoresume_path"]+"build_kernel") except CatalystError: self.unbind() @@ -1477,7 +1477,7 @@ class generic_stage_target(generic_target): cmd("/bin/bash "+self.settings["controller_file"]+\ " bootloader " + self.settings["target_path"],\ "Bootloader script failed.",env=self.env) - touch(self.settings["autoresume_path"]+"bootloader") + catalyst.util.touch(self.settings["autoresume_path"]+"bootloader") except CatalystError: self.unbind() raise CatalystError,"Script aborting due to error." @@ -1491,7 +1491,7 @@ class generic_stage_target(generic_target): try: cmd("/bin/bash "+self.settings["controller_file"]+\ " livecd-update","livecd-update failed.",env=self.env) - touch(self.settings["autoresume_path"]+"livecd_update") + catalyst.util.touch(self.settings["autoresume_path"]+"livecd_update") except CatalystError: self.unbind() diff --git a/modules/catalyst/target/grp.py b/modules/catalyst/target/grp.py index 46891298..77a67607 100644 --- a/modules/catalyst/target/grp.py +++ b/modules/catalyst/target/grp.py @@ -45,7 +45,7 @@ class grp_target(generic_stage_target): if not os.path.exists(self.settings["target_path"]): os.makedirs(self.settings["target_path"]) - touch(self.settings["autoresume_path"]+"setup_target_path") + catalyst.util.touch(self.settings["autoresume_path"]+"setup_target_path") def run_local(self): for pkgset in self.settings["grp"]: diff --git a/modules/catalyst/target/livecd_stage1.py b/modules/catalyst/target/livecd_stage1.py index e54657de..f7e81b97 100644 --- a/modules/catalyst/target/livecd_stage1.py +++ b/modules/catalyst/target/livecd_stage1.py @@ -30,7 +30,7 @@ class livecd_stage1_target(generic_stage_target): 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") + catalyst.util.touch(self.settings["autoresume_path"]+"setup_target_path") if not os.path.exists(self.settings["target_path"]): os.makedirs(self.settings["target_path"]) diff --git a/modules/catalyst/target/livecd_stage2.py b/modules/catalyst/target/livecd_stage2.py index 270b858e..b86d265e 100644 --- a/modules/catalyst/target/livecd_stage2.py +++ b/modules/catalyst/target/livecd_stage2.py @@ -52,7 +52,7 @@ class livecd_stage2_target(generic_stage_target): 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") + catalyst.util.touch(self.settings["autoresume_path"]+"setup_target_path") if not os.path.exists(self.settings["target_path"]): os.makedirs(self.settings["target_path"]) @@ -122,7 +122,7 @@ class livecd_stage2_target(generic_stage_target): myf.write(self.settings["source_path_hash"]) myf.close() else: - touch(self.settings["autoresume_path"]+"unpack") + catalyst.util.touch(self.settings["autoresume_path"]+"unpack") def set_action_sequence(self): self.settings["action_sequence"]=["unpack","unpack_snapshot",\ diff --git a/modules/catalyst/target/netboot2.py b/modules/catalyst/target/netboot2.py index db5edfe1..07886619 100644 --- a/modules/catalyst/target/netboot2.py +++ b/modules/catalyst/target/netboot2.py @@ -51,7 +51,7 @@ class netboot2_target(generic_stage_target): 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") + catalyst.util.touch(self.settings["autoresume_path"]+"setup_target_path") if not os.path.exists(self.settings["storedir"]+"/builds/"): os.makedirs(self.settings["storedir"]+"/builds/") @@ -91,7 +91,7 @@ class netboot2_target(generic_stage_target): self.unbind() raise CatalystError,"Failed to copy files to image!" - touch(self.settings["autoresume_path"]+"copy_files_to_image") + catalyst.util.touch(self.settings["autoresume_path"]+"copy_files_to_image") def setup_overlay(self): if "AUTORESUME" in self.settings \ @@ -103,7 +103,7 @@ class netboot2_target(generic_stage_target): 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") + catalyst.util.touch(self.settings["autoresume_path"]+"setup_overlay") def move_kernels(self): # we're done, move the kernels to builds/* @@ -150,7 +150,7 @@ class netboot2_target(generic_stage_target): os.makedirs(myemp,0755) os.chown(myemp,mystat[ST_UID],mystat[ST_GID]) os.chmod(myemp,mystat[ST_MODE]) - touch(self.settings["autoresume_path"]+"empty") + catalyst.util.touch(self.settings["autoresume_path"]+"empty") def set_action_sequence(self): self.settings["action_sequence"]=["unpack","unpack_snapshot","config_profile_link", diff --git a/modules/catalyst/util.py b/modules/catalyst/util.py index 371c1bfa..1c21579b 100644 --- a/modules/catalyst/util.py +++ b/modules/catalyst/util.py @@ -96,3 +96,10 @@ def ismount(path): return True return False +def touch(myfile): + try: + myf = open(myfile, "w") + myf.close() + except IOError: + raise CatalystError, "Could not touch " + myfile + "." + -- 2.26.2