From d07f8e2406f5ddcda6e392c093cc3f9017be2aba Mon Sep 17 00:00:00 2001 From: Andrew Gaffney Date: Sun, 13 Sep 2009 15:01:57 -0500 Subject: [PATCH] Create catalyst.util.mkdir() helper function and use it --- ChangeLog | 4 ++++ modules/catalyst/target/generic_stage.py | 15 ++++++--------- modules/catalyst/util.py | 8 +++++++- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index e0717661..bab7ffe7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,10 @@ # Distributed under the GPL v2 # $Id$ + 13 Sep 2009; Andrew Gaffney + modules/catalyst/target/generic_stage.py, modules/catalyst/util.py: + Create catalyst.util.mkdir() helper function and use it + 13 Sep 2009; Andrew Gaffney modules/catalyst/target/generic_stage.py, modules/catalyst/target/netboot.py, modules/catalyst/util.py: diff --git a/modules/catalyst/target/generic_stage.py b/modules/catalyst/target/generic_stage.py index 2471d61b..31fc5a75 100644 --- a/modules/catalyst/target/generic_stage.py +++ b/modules/catalyst/target/generic_stage.py @@ -713,9 +713,7 @@ class generic_stage_target(generic_target): for x in self.settings["portage_overlay"]: if os.path.exists(x): msg("Copying overlay dir " + x) - cmd("mkdir -p "+self.settings["chroot_path"]+\ - "/usr/local/portage",\ - "Could not make portage_overlay dir",env=self.env) + catalyst.util.mkdir(self.settings["chroot_path"] + "/usr/local/portage") cmd("cp -R "+x+"/* "+self.settings["chroot_path"]+\ "/usr/local/portage",\ "Could not copy portage_overlay",env=self.env) @@ -843,7 +841,7 @@ class generic_stage_target(generic_target): and not "portage_confdir" in self.settings: if not os.path.exists(self.settings["chroot_path"]+\ "/etc/portage"): - cmd("mkdir "+self.settings["chroot_path"]+"/etc/portage") + catalyst.util.mkdir(self.settings["chroot_path"] + "/etc/portage") myf=open(self.settings["chroot_path"]+\ "/etc/portage/modules","a") myf.write("portdbapi.auxdbmodule = cache.metadata_overlay.database\n") @@ -1246,11 +1244,10 @@ class generic_stage_target(generic_target): self.settings["boot/kernel/" + kname + \ "/initramfs_overlay"]) - cmd("mkdir -p "+\ - self.settings["chroot_path"]+\ - "/tmp/initramfs_overlay/"+\ - self.settings["boot/kernel/"+kname+\ - "/initramfs_overlay"],env=self.env) + catalyst.util.mkdir(self.settings["chroot_path"] + \ + "/tmp/initramfs_overlay/" + \ + self.settings["boot/kernel/" + kname + \ + "/initramfs_overlay"]) cmd("cp -R "+self.settings["boot/kernel/"+\ kname+"/initramfs_overlay"]+"/* "+\ diff --git a/modules/catalyst/util.py b/modules/catalyst/util.py index 7efd7ea1..d1b73abf 100644 --- a/modules/catalyst/util.py +++ b/modules/catalyst/util.py @@ -221,7 +221,7 @@ def empty_dir(path): try: mystat = os.stat(path) remove_path(path, False) - os.makedirs(path, 0755) + mkdir(path) os.chown(path, mystat[stat.ST_UID], mystat[stat.ST_GID]) os.chmod(path, mystat[stat.ST_MODE]) except: @@ -268,4 +268,10 @@ def unpack_tarball(src, dest, keep_perm=True): if retval != 0: raise CatalystError("Could not unpack tarball '%s'" % (src,)) +def mkdir(path, perms=0755): + try: + os.makedirs(path, perms) + except: + raise CatalystError("Could not create directory '%s'" % (path,)) + # vim: ts=4 sw=4 sta noet sts=4 ai -- 2.26.2