def __init__(self,myspec,addlargs): self.required_values=["version_stamp","target"] self.valid_values=["version_stamp","target", "compression_mode"] TargetBase.__init__(self, myspec, addlargs) GenBase.__init__(self,myspec) #self.settings=myspec self.settings["target_subpath"]="repos" st=self.settings["storedir"] self.settings["snapshot_path"] = normpath(st + "/snapshots/" + self.settings["snapshot_name"] + self.settings["version_stamp"]) self.settings["tmp_path"]=normpath(st+"/tmp/"+self.settings["target_subpath"])
def set_pkgcache_path(self): if "pkgcache_path" in self.settings: if type(self.settings["pkgcache_path"]) != types.StringType: self.settings["pkgcache_path"] = normpath( string.join(self.settings["pkgcache_path"])) else: StageBase.set_pkgcache_path(self)
def set_pkgcache_path(self): if "pkgcache_path" in self.settings: if not isinstance(self.settings['pkgcache_path'], str): self.settings["pkgcache_path"] = normpath( ' '.join(self.settings["pkgcache_path"])) else: StageBase.set_pkgcache_path(self)
def __init__(self,spec,addlargs): self.required_values=[ "boot/kernel" ] self.valid_values=self.required_values[:] self.valid_values.extend([ "netboot2/packages", "netboot2/use", "netboot2/extra_files", "netboot2/overlay", "netboot2/busybox_config", "netboot2/root_overlay", "netboot2/linuxrc" ]) try: if "netboot2/packages" in addlargs: if isinstance(addlargs['netboot2/packages'], str): loopy=[addlargs["netboot2/packages"]] else: loopy=addlargs["netboot2/packages"] for x in loopy: self.valid_values.append("netboot2/packages/"+x+"/files") except: raise CatalystError("configuration error in netboot2/packages.") StageBase.__init__(self,spec,addlargs) self.settings["merge_path"]=normpath("/tmp/image/")
def set_source_path(self): if "seedcache" in self.settings["options"] and os.path.isdir(normpath(self.settings["storedir"]+"/tmp/"+self.settings["source_subpath"]+"/tmp/stage1root/")): self.settings["source_path"]=normpath(self.settings["storedir"]+"/tmp/"+self.settings["source_subpath"]+"/tmp/stage1root/") else: self.settings["source_path"]=normpath(self.settings["storedir"]+"/builds/"+self.settings["source_subpath"].rstrip('/')+".tar.bz2") if os.path.isfile(self.settings["source_path"]): if os.path.exists(self.settings["source_path"]): # XXX: Is this even necessary if the previous check passes? self.settings["source_path_hash"] = \ self.settings["hash_map"].generate_hash( self.settings["source_path"],\ hash_=self.settings["hash_function"], verbose=False) print "Source path set to "+self.settings["source_path"] if os.path.isdir(self.settings["source_path"]): print "\tIf this is not desired, remove this directory or turn of seedcache in the options of catalyst.conf" print "\tthe source path will then be "+normpath(self.settings["storedir"]+"/builds/"+self.settings["source_subpath"].rstrip('/')+".tar.bz2\n")
def set_source_path(self): self.settings["source_path"] = normpath( self.settings["storedir"] + "/builds/" + self.settings["source_subpath"].rstrip('/') + ".tar.bz2") if os.path.isfile(self.settings["source_path"]): self.settings["source_path_hash"] = \ self.settings["hash_map"].generate_hash( self.settings["source_path"]) else: self.settings["source_path"] = normpath( self.settings["storedir"] + "/tmp/" + self.settings["source_subpath"] + '/') if not os.path.exists(self.settings["source_path"]): raise CatalystError("Source Path: " + self.settings["source_path"] + " does not exist.", print_traceback=True)
def generate_digests(self): for pkgset in self.settings["grp"]: if self.settings["grp/"+pkgset+"/type"] == "pkgset": destdir=normpath(self.settings["target_path"]+"/"+pkgset+"/All") log.notice('Digesting files in the pkgset...') digests=glob.glob(destdir+'/*.DIGESTS') for i in digests: if os.path.exists(i): os.remove(i) files=os.listdir(destdir) #ignore files starting with '.' using list comprehension files=[filename for filename in files if filename[0] != '.'] for i in files: if os.path.isfile(normpath(destdir+"/"+i)): self.gen_contents_file(normpath(destdir+"/"+i)) self.gen_digest_file(normpath(destdir+"/"+i)) else: destdir=normpath(self.settings["target_path"]+"/"+pkgset) log.notice('Digesting files in the srcset...') digests=glob.glob(destdir+'/*.DIGESTS') for i in digests: if os.path.exists(i): os.remove(i) files=os.listdir(destdir) #ignore files starting with '.' using list comprehension files=[filename for filename in files if filename[0] != '.'] for i in files: if os.path.isfile(normpath(destdir+"/"+i)): #self.gen_contents_file(normpath(destdir+"/"+i)) self.gen_digest_file(normpath(destdir+"/"+i))
def generate_digests(self): for pkgset in self.settings["grp"]: if self.settings["grp/" + pkgset + "/type"] == "pkgset": destdir = normpath(self.settings["target_path"] + "/" + pkgset + "/All") print "Digesting files in the pkgset....." digests = glob.glob(destdir + '/*.DIGESTS') for i in digests: if os.path.exists(i): os.remove(i) files = os.listdir(destdir) #ignore files starting with '.' using list comprehension files = [filename for filename in files if filename[0] != '.'] for i in files: if os.path.isfile(normpath(destdir + "/" + i)): self.gen_contents_file(normpath(destdir + "/" + i)) self.gen_digest_file(normpath(destdir + "/" + i)) else: destdir = normpath(self.settings["target_path"] + "/" + pkgset) print "Digesting files in the srcset....." digests = glob.glob(destdir + '/*.DIGESTS') for i in digests: if os.path.exists(i): os.remove(i) files = os.listdir(destdir) #ignore files starting with '.' using list comprehension files = [filename for filename in files if filename[0] != '.'] for i in files: if os.path.isfile(normpath(destdir + "/" + i)): #self.gen_contents_file(normpath(destdir+"/"+i)) self.gen_digest_file(normpath(destdir + "/" + i))
def set_target_path(self): self.settings["target_path"]=normpath(self.settings["storedir"]+"/builds/"+\ self.settings["target_subpath"]) if "autoresume" in self.settings["options"] \ and self.resume.is_enabled("setup_target_path"): log.notice('Resume point detected, skipping target path setup operation...') else: # first clean up any existing target stuff clear_path(self.settings['target_path']) self.resume.enable("setup_target_path") ensure_dirs(self.settings["storedir"]+"/builds/")
def __init__(self, spec, addlargs): if "netboot/packages" in addlargs: if isinstance(addlargs['netboot/packages'], str): loopy = [addlargs["netboot/packages"]] else: loopy = addlargs["netboot/packages"] for x in loopy: self.valid_values |= {"netboot/packages/" + x + "/files"} StageBase.__init__(self, spec, addlargs) self.settings["merge_path"] = normpath("/tmp/image/")
def set_lockdir(self, lockdir): if not os.path.exists(lockdir): os.makedirs(lockdir) if os.path.isdir(lockdir): if not self.islocked(): if lockdir[-1] == "/": lockdir = lockdir[:-1] self.lockdir = normpath(lockdir) # if "DEBUG" in self.settings: # print "setting lockdir to", self.lockdir else: raise "the lock object needs a path to a dir"
def set_target_path(self): self.settings["target_path"]=normpath(self.settings["storedir"]+"/builds/"+\ self.settings["target_subpath"]) if "autoresume" in self.settings["options"] \ and self.resume.is_enabled("setup_target_path"): log.notice('Resume point detected, skipping target path setup operation...') else: # first clean up any existing target stuff 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) self.resume.enable("setup_target_path") ensure_dirs(self.settings["storedir"]+"/builds/")
def set_target_path(self): self.settings["target_path"] = normpath( self.settings["storedir"] + "/builds/" + self.settings["target_subpath"] + '/') if "autoresume" in self.settings["options"] \ and self.resume.is_enabled("setup_target_path"): print "Resume point detected, skipping target path setup operation..." else: # first clean up any existing target stuff 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) self.resume.enable("setup_target_path") ensure_dirs(self.settings["target_path"])
def __init__(self, spec, addlargs): try: if "netboot/packages" in addlargs: if isinstance(addlargs['netboot/packages'], str): loopy = [addlargs["netboot/packages"]] else: loopy = addlargs["netboot/packages"] for x in loopy: self.valid_values |= {"netboot/packages/" + x + "/files"} except: raise CatalystError("configuration error in netboot/packages.") StageBase.__init__(self, spec, addlargs) self.settings["merge_path"] = normpath("/tmp/image/")
def run_local(self): # what modules do we want to blacklist? if "livecd/modblacklist" in self.settings: path = normpath(self.settings["chroot_path"] + "/etc/modprobe.d/blacklist.conf") try: with open(path, "a") as myf: myf.write("\n#Added by Catalyst:") # workaround until config.py is using configparser if isinstance(self.settings["livecd/modblacklist"], str): self.settings["livecd/modblacklist"] = self.settings[ "livecd/modblacklist"].split() for x in self.settings["livecd/modblacklist"]: myf.write("\nblacklist " + x) except Exception as e: raise CatalystError("Couldn't open " + self.settings["chroot_path"] + "/etc/modprobe.d/blacklist.conf.", print_traceback=True) from e
def run_local(self): # what modules do we want to blacklist? if "livecd/modblacklist" in self.settings: path = normpath(self.settings["chroot_path"] + "/etc/modprobe.d/blacklist.conf") try: with open(path, "a") as myf: myf.write("\n#Added by Catalyst:") # workaround until config.py is using configparser if isinstance(self.settings["livecd/modblacklist"], str): self.settings["livecd/modblacklist"] = self.settings[ "livecd/modblacklist"].split() for x in self.settings["livecd/modblacklist"]: myf.write("\nblacklist "+x) except: self.unbind() raise CatalystError("Couldn't open " + self.settings["chroot_path"] + "/etc/modprobe.d/blacklist.conf.", print_traceback=True)
def clean_stage1(self): '''seedcache is enabled, so salvage the /tmp/stage1root, remove the seed chroot''' log.notice('Salvaging the stage1root from the chroot path ...') # move the self.settings["stage_path"] outside of the self.settings["chroot_path"] tmp_path = normpath(self.settings["storedir"] + "/tmp/" + "stage1root") if move_path(self.settings["stage_path"], tmp_path): self.remove_chroot() # move it to self.settings["chroot_path"] if not move_path(tmp_path, self.settings["chroot_path"]): log.error( 'clean_stage1 failed, see previous log messages for details' ) return False log.notice( 'Successfully moved and cleaned the stage1root for the seedcache' ) return True log.error( 'clean_stage1 failed to move the stage1root to a temporary loation' ) return False
def set_root_path(self): self.settings["root_path"] = normpath("/tmp/mergeroot") print "embedded root path is " + self.settings["root_path"]
def set_stage_path(self): self.settings["stage_path"] = normpath(self.settings["chroot_path"] + "/tmp/mergeroot") print "embedded stage path is " + self.settings["stage_path"]
def set_stage_path(self): self.settings["stage_path"]=normpath(self.settings["chroot_path"]+"/tmp/mergeroot") log.info('embedded stage path is %s', self.settings['stage_path'])
def set_lockfile(self): if not self.islocked(): self.lockfile = normpath(self.lockdir + '/' + self.lockfilename)
def set_pkgcache_path(self): if "pkgcache_path" in self.settings: if not isinstance(self.settings['pkgcache_path'], str): self.settings["pkgcache_path"] = normpath(' '.join(self.settings["pkgcache_path"])) else: StageBase.set_pkgcache_path(self)
def set_stage_path(self): self.settings["stage_path"] = normpath(self.settings["chroot_path"] + self.settings["root_path"]) print "stage1 stage path is " + self.settings["stage_path"]
def set_root_path(self): # sets the root path, relative to 'chroot_path', of the stage1 root self.settings["root_path"] = normpath("/tmp/stage1root") print "stage1 root path is " + self.settings["root_path"]
def set_root_path(self): # sets the root path, relative to 'chroot_path', of the stage1 root self.settings["root_path"] = normpath("/tmp/stage1root") log.info('stage1 root path is %s', self.settings['root_path'])
def set_stage_path(self): self.settings["stage_path"] = normpath(self.settings["chroot_path"] + self.settings["root_path"]) log.notice('stage1 stage path is %s', self.settings['stage_path'])
def set_root_path(self): # ROOT= variable for emerges self.settings["root_path"] = normpath("/tmp/image") log.info('netboot root path is %s', self.settings['root_path'])
def set_root_path(self): # sets the root path, relative to 'chroot_path', of the stage1 root self.settings["root_path"]=normpath("/tmp/stage1root") log.info('stage1 root path is %s', self.settings['root_path'])
def set_root_path(self): # ROOT= variable for emerges self.settings["root_path"] = normpath("/tmp/image") print "netboot root path is " + self.settings["root_path"]
def set_stage_path(self): self.settings["stage_path"] = normpath(self.settings["chroot_path"] + "/tmp/mergeroot") log.info('embedded stage path is %s', self.settings['stage_path'])
def set_root_path(self): self.settings["root_path"] = normpath("/tmp/mergeroot") log.info('embedded root path is %s', self.settings['root_path'])
def set_root_path(self): # ROOT= variable for emerges self.settings["root_path"]=normpath("/tmp/image") log.info('netboot root path is %s', self.settings['root_path'])
def setup(self): x = normpath(self.settings["storedir"] + "/snapshots") ensure_dirs(x)
def set_root_path(self): self.settings["root_path"]=normpath("/tmp/mergeroot") log.info('embedded root path is %s', self.settings['root_path'])
def set_stage_path(self): self.settings["stage_path"]=normpath(self.settings["chroot_path"]+self.settings["root_path"]) log.notice('stage1 stage path is %s', self.settings['stage_path'])
def setup(self): x=normpath(self.settings["storedir"]+"/snapshots") ensure_dirs(x)