# 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,
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:
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:
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")
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 ...
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)"