Create catalyst.util.mkdir() helper function and use it
authorAndrew Gaffney <agaffney@gentoo.org>
Sun, 13 Sep 2009 20:01:57 +0000 (15:01 -0500)
committerAndrew Gaffney <agaffney@gentoo.org>
Sun, 13 Sep 2009 20:01:57 +0000 (15:01 -0500)
ChangeLog
modules/catalyst/target/generic_stage.py
modules/catalyst/util.py

index e0717661ade11fe012145f88a0f1caabc6245570..bab7ffe7417a5a47ce8f808dc6f61c3c4bac0ffc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,10 @@
 # Distributed under the GPL v2
 # $Id$
 
+  13 Sep 2009; Andrew Gaffney <agaffney@gentoo.org>
+  modules/catalyst/target/generic_stage.py, modules/catalyst/util.py:
+  Create catalyst.util.mkdir() helper function and use it
+
   13 Sep 2009; Andrew Gaffney <agaffney@gentoo.org>
   modules/catalyst/target/generic_stage.py,
   modules/catalyst/target/netboot.py, modules/catalyst/util.py:
index 2471d61bfdcbe56ec9a90753477adffa2b21a3f6..31fc5a75f58be1429b7dc450eb590ac2cfd73abd 100644 (file)
@@ -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"]+"/* "+\
index 7efd7ea1b8a4d9bec0d6a0699382575e294b321b..d1b73abfab970b66a712fe8084c04c4e30806740 100644 (file)
@@ -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