Move file_locate() from catalyst.support to catalyst.util
authorAndrew Gaffney <agaffney@gentoo.org>
Sun, 11 Jan 2009 23:17:20 +0000 (17:17 -0600)
committerAndrew Gaffney <agaffney@gentoo.org>
Sun, 11 Jan 2009 23:17:20 +0000 (17:17 -0600)
ChangeLog
modules/catalyst/support.py
modules/catalyst/target/generic_stage.py
modules/catalyst/target/livecd_stage2.py
modules/catalyst/target/netboot.py
modules/catalyst/util.py

index 702dac8617cdcf1b41559594e3a44783b2c7e732..478527d6ecd9625f3ff13ce06d79741238803ebd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,12 @@
 # Copyright 2002-2009 Gentoo Foundation; 2008-2009 Various authors (see AUTHORS)
 # Distributed under the GPL v2
 
+  11 Jan 2009; Andrew Gaffney <agaffney@gentoo.org>
+  modules/catalyst/support.py, modules/catalyst/target/generic_stage.py,
+  modules/catalyst/target/livecd_stage2.py,
+  modules/catalyst/target/netboot.py, modules/catalyst/util.py:
+  Move file_locate() from catalyst.support to catalyst.util
+
   11 Jan 2009; Andrew Gaffney <agaffney@gentoo.org>
   modules/catalyst/spawn.py, modules/catalyst/support.py,
   modules/catalyst/target/generic_stage.py, modules/catalyst/target/grp.py,
index 84bb5043932eef2ed8d24a1b16afc61950f9842e..8d2c0a9c862c576f58cf01005459e949b40bd8c9 100644 (file)
@@ -29,23 +29,6 @@ valid_config_file_values.append("SEEDCACHE")
 
 verbosity=1
 
-def file_locate(settings,filelist,expand=1):
-       #if expand=1, non-absolute paths will be accepted and
-       # expanded to os.getcwd()+"/"+localpath if file exists
-       for myfile in filelist:
-               if not myfile in settings:
-                       #filenames such as cdtar are optional, so we don't assume the variable is defined.
-                       pass
-               else:
-                   if len(settings[myfile])==0:
-                           raise CatalystError, "File variable \""+myfile+"\" has a length of zero (not specified.)"
-                   if settings[myfile][0]=="/":
-                           if not os.path.exists(settings[myfile]):
-                                   raise CatalystError, "Cannot locate specified "+myfile+": "+settings[myfile]
-                   elif expand and os.path.exists(os.getcwd()+"/"+settings[myfile]):
-                           settings[myfile]=os.getcwd()+"/"+settings[myfile]
-                   else:
-                           raise CatalystError, "Cannot locate specified "+myfile+": "+settings[myfile]+" (2nd try)"
 """
 Spec file format:
 
index 1b1f2dd5ebeb4405393de927ed0ade0ee084d17c..1d73e858e457ee371c8df1a1e524c13cf7545b68 100644 (file)
@@ -153,11 +153,11 @@ class generic_stage_target(generic_target):
                on disk.
                """
                #pdb.set_trace()
-               file_locate(self.settings,["source_path","snapshot_path","distdir"],\
+               catalyst.util.file_locate(self.settings,["source_path","snapshot_path","distdir"],\
                        expand=0)
                """ If we are using portage_confdir, check that as well. """
                if "portage_confdir" in self.settings:
-                       file_locate(self.settings,["portage_confdir"],expand=0)
+                       catalyst.util.file_locate(self.settings,["portage_confdir"],expand=0)
 
                """ Setup our mount points """
                if "SNAPCACHE" in self.settings:
index de47f31acd54f5eeffc0296f31348e63d0a938f5..8ad662e7a0e889dd670fb7ab19420bc84dd5a1f6 100644 (file)
@@ -31,7 +31,7 @@ class livecd_stage2_target(generic_stage_target):
                if not "livecd/type" in self.settings:
                        self.settings["livecd/type"] = "generic-livecd"
 
-               file_locate(self.settings, ["cdtar","controller_file"])
+               catalyst.util.file_locate(self.settings, ["cdtar","controller_file"])
 
        def set_source_path(self):
                self.settings["source_path"]=catalyst.util.normpath(self.settings["storedir"]+"/builds/"+self.settings["source_subpath"]+".tar.bz2")
index 6bbca71efe899df4606816541b880ad4116042b4..e1a87ae9c7c92844891a14dc4dbd892adf17d4b2 100644 (file)
@@ -42,7 +42,7 @@ class netboot_target(generic_stage_target):
                generic_stage_target.__init__(self,spec,addlargs)
                self.set_build_kernel_vars(addlargs)
                if "netboot/busybox_config" in addlargs:
-                       file_locate(self.settings, ["netboot/busybox_config"])
+                       catalyst.util.file_locate(self.settings, ["netboot/busybox_config"])
 
                # Custom Kernel Tarball --- use that instead ...
 
index b97d1f1b228155d69580a10153466ec949cc00d5..3bb35fbfc964c77c8859dc16d7b9498188e756c6 100644 (file)
@@ -117,3 +117,18 @@ def countdown(secs=5, doing="Starting"):
                        time.sleep(1)
                print
 
+def file_locate(settings, filelist, expand=True):
+       #if expand is True, non-absolute paths will be accepted and
+       # expanded to os.getcwd()+"/"+localpath if file exists
+       for myfile in filelist:
+               if myfile in settings:
+                       # filenames such as cdtar are optional, so we don't assume the variable is defined.
+                   if not len(settings[myfile]):
+                           raise CatalystError, "File variable \"" + myfile + "\" has a length of zero (not specified)"
+                   if settings[myfile].startswith('/'):
+                           if not os.path.exists(settings[myfile]):
+                                   raise CatalystError, "Cannot locate specified " + myfile + ": " + settings[myfile]
+                   elif expand and os.path.exists(os.getcwd() + "/" + settings[myfile]):
+                           settings[myfile] = os.getcwd() + "/" + settings[myfile]
+                   else:
+                           raise CatalystError, "Cannot locate specified " + myfile + ": " + settings[myfile] + " (2nd try)"