diff options
author | John P. Davis <zhen@gentoo.org> | 2004-05-17 01:21:17 +0000 |
---|---|---|
committer | John P. Davis <zhen@gentoo.org> | 2004-05-17 01:21:17 +0000 |
commit | 194fa7e3333387e8a2a3110ad03277117cf35abc (patch) | |
tree | fe580d6b4424e539fa6e6425979bfa67f455cdfa /modules/embedded_target.py | |
parent | adding in the all important livecd local rcscript (diff) | |
download | catalyst-194fa7e3333387e8a2a3110ad03277117cf35abc.tar.gz catalyst-194fa7e3333387e8a2a3110ad03277117cf35abc.tar.bz2 catalyst-194fa7e3333387e8a2a3110ad03277117cf35abc.zip |
consult changelog
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/catalyst/trunk@370 d1e1f19c-881f-0410-ab34-b69fee027534
Diffstat (limited to 'modules/embedded_target.py')
-rw-r--r-- | modules/embedded_target.py | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/modules/embedded_target.py b/modules/embedded_target.py new file mode 100644 index 00000000..dbfc47e4 --- /dev/null +++ b/modules/embedded_target.py @@ -0,0 +1,72 @@ +# Distributed under the GNU General Public License version 2 +# Copyright 2003-2004 Gentoo Technologies, Inc. +# $Header: /var/cvsroot/gentoo/src/catalyst/modules/embedded_target.py,v 1.1 2004/05/17 01:21:17 zhen Exp $ + +""" +This class works like a 'stage3'. A stage2 tarball is unpacked, but instead +of building a stage3, it emerges a 'system' into another directory +inside the 'stage2' system. This way we do not have to emerge gcc/portage +into the staged system. + +It sounds real complicated but basically it's a it runs +ROOT=/tmp/submerge emerge --blahblah foo bar +""" + +import os,string,imp,types,shutil +from catalyst_support import * +from generic_stage_target import * +from stat import * + +class embedded_target(generic_stage_target): + + def __init__(self,spec,addlargs): + self.required_values=[] + self.valid_values=[] + #self.required_values.extend(["embedded/packages"]); + self.valid_values.extend(["embedded/empty","embedded/rm","embedded/unmerge","embedded/runscript","embedded/mergeroot","embedded/packages","embedded/use"]) + + generic_stage_target.__init__(self,spec,addlargs) + self.settings["image_path"]=self.settings["storedir"]+"/builds/"+self.settings["target_subpath"]+"/image" + + # taken from livecd-stage3 code + def unmerge(self): + print "Unmerging packages" + if self.settings.has_key("embedded/unmerge"): + if type(self.settings["embedded/unmerge"])==types.StringType: + self.settings["embedded/unmerge"]=[self.settings["embedded/unmerge"]] + myunmerge=self.settings["embedded/unmerge"][:] + + for x in range(0,len(myunmerge)): + myunmerge[x]="'"+myunmerge[x]+"'" + myunmerge=string.join(myunmerge) + # before cleaning unmerge stuff + cmd("/bin/bash "+self.settings["sharedir"]+"/targets/"+self.settings["target"]+"/unmerge.sh "+myunmerge,"unmerge script failed.") + + def clean(self): + if self.settings.has_key("embedded/rm"): + if type(self.settings["embedded/rm"])==types.StringType: + self.settings["embedded/rm"]=[self.settings["embedded/rm"]] + print "Removing directories from image" + for x in self.settings["embedded/rm"]: + print "Removing "+x + os.system("rm -rf "+self.settings["chroot_path"]+"/tmp/mergeroot"+x) + def run_local(self): + mypackages=list_bashify(self.settings["embedded/packages"]) + print "Merging embedded image" + try: + cmd("/bin/bash "+self.settings["sharedir"]+"/targets/embedded/embedded.sh run") + except CatalystError: + self.unbind() + raise CatalystError, "Embedded build aborted due to error." + self.unmerge() + self.clean() + try: + if self.settings.has_key("embedded/runscript"): + cmd("/bin/bash "+self.settings["embedded/runscript"]+" run ","runscript failed") + except CatalystError: + self.unbind() + raise CatalystError, "embedded runscript aborting due to error." + +def register(foo): + foo.update({"embedded":embedded_target}) + return foo |