livecd-stage3 stuff
authorDaniel Robbins <drobbins@gentoo.org>
Wed, 7 Jan 2004 18:46:57 +0000 (18:46 +0000)
committerDaniel Robbins <drobbins@gentoo.org>
Wed, 7 Jan 2004 18:46:57 +0000 (18:46 +0000)
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/catalyst/trunk@118 d1e1f19c-881f-0410-ab34-b69fee027534

examples/x86-livecd-stage3-20031215.spec [new file with mode: 0644]
examples/x86-livecd-stage3-runscript.sh [new file with mode: 0644]
modules/targets.py

diff --git a/examples/x86-livecd-stage3-20031215.spec b/examples/x86-livecd-stage3-20031215.spec
new file mode 100644 (file)
index 0000000..c2f1651
--- /dev/null
@@ -0,0 +1,16 @@
+subarch: x86
+version_stamp: 20031215
+target: livecd-stage2
+rel_type: default
+rel_version: 1.4
+snapshot: 20031215
+source_subpath: default-x86-1.4/livecd-stage2-x86-20031215
+boot/kernel: gentoo
+livecd-stage3/cdtar: /path/to/cd.tar
+livecd-stage3/runscript: /path/to/myrunscript.sh
+livecd-stage3/clean:
+       /usr/src/linux
+       /usr/share/doc
+       /usr/share/man
+       /var/db/pkg
+       /var/tmp
diff --git a/examples/x86-livecd-stage3-runscript.sh b/examples/x86-livecd-stage3-runscript.sh
new file mode 100644 (file)
index 0000000..5989016
--- /dev/null
@@ -0,0 +1,42 @@
+# Copyright 1999-2004 Gentoo Technologies, Inc.
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo/src/catalyst/examples/Attic/x86-livecd-stage3-runscript.sh,v 1.1 2004/01/07 18:46:57 drobbins Exp $
+
+case $1 in
+run)
+       #probably don't need to run anything in the chroot, but we support it just in case.
+       ;;
+preclean)
+       #preclean runs with bind mounts active -- for running any commands inside chroot
+       ;;
+clean)
+       #clean runs after the bind mounts have been deactivated, and "livecd-stage3/clean" directories have been wiped.
+       ;;
+cdroot_setup)
+       #use this to set up the cdroot ($clst_cdroot_path)
+       cdtar=$clst_livecd_stage3_cdtar
+       if [ "$cdtar" != "" ]
+       then
+               tar xpvf $cdtar -C $clst_cdroot_path || die
+       fi
+       install -d $clst_cdroot_path/isolinux
+       if [ "$clst_boot_kernel" = "" ]
+       then
+               echo "No boot/kernel setting defined, exiting."
+               exit 1
+       fi
+       for x in $clst_boot_kernel
+       do
+               if [ ! -e "$clst_source_path/$x.tar.bz2" ] 
+               then
+                       echo "Can't find kernel tarball at $clst_source_path/$x.tar.bz2"
+                       exit 1
+               fi
+               tar xjvf $clst_source_path/$x.tar.bz2 -C $clst_cdroot_path/isolinux
+               #change kernel name from "kernel" to "gentoo", for example
+               mv $clst_cdroot_path/isolinux/kernel $clst_cdroot_path/isolinux/$x
+               #change initrd name from "initrd" to "gentoo.igz", for example
+               mv $clst_cdroot_path/isolinux/initrd $clst_cdroot_path/isolinux/$x.igz
+       done
+       ;;
+esac
index cd85ad88ece1085d15cc5415ebab6f2c5e4f1bfc..c9fc2106b39dcc07aee57c303b9c689c05d07465 100644 (file)
@@ -78,13 +78,22 @@ class generic_stage_target(generic_target):
                if self.settings["target"] in ["grp","tinderbox"]:
                        #grp creates a directory of packages and sources rather than a compressed tarball
                        self.settings["target_path"]=st+"/builds/"+self.settings["target_subpath"]
+                       self.settings["source_path"]=st+"/builds/"+self.settings["source_subpath"]+".tar.bz2"
                elif self.settings["target"] == "livecd-stage2":
                        #we have a main directory and a tarball in this case
                        os.makedirs(st+"/builds/"+self.settings["target_subpath"])
                        self.settings["target_path"]=st+"/builds/"+self.settings["target_subpath"]+"/"+self.settings["target_subpath"]+".tar.bz2"
+                       self.settings["source_path"]=st+"/builds/"+self.settings["source_subpath"]+".tar.bz2"
+               elif self.settings["target"]=="livecd-stage3":
+                       # the loop-prep/ dir is for unpacking the chroot image, and will be used to prep it.
+                       self.settings["target_path"]=st+"/builds/"+self.settings["target_subpath"]+"/loop-prep"
+                       self.settings["cdroot_path"]=st+"/builds/"+self.settings["target_subpath"]+"/cdroot"
+                       os.makedirs(self.settings["target_path"])
+                       os.makedirs(self.settings["cdroot_path"])
+                       self.settings["source_path"]=st+"/builds/"+self.settings["source_subpath"]+"/"+self.settings["source_subpath"]+".tar.bz2"
                else:
                        self.settings["target_path"]=st+"/builds/"+self.settings["target_subpath"]+".tar.bz2"
-               self.settings["source_path"]=st+"/builds/"+self.settings["source_subpath"]+".tar.bz2"
+                       self.settings["source_path"]=st+"/builds/"+self.settings["source_subpath"]+".tar.bz2"
                self.settings["chroot_path"]=st+"/tmp/"+self.settings["target_subpath"]
                
                self.mounts=[ "/proc","/dev","/dev/pts","/usr/portage/distfiles" ]
@@ -208,6 +217,13 @@ class generic_stage_target(generic_target):
                        destpath+="/tmp/stage1root"
                        #this next stuff can eventually be integrated into the python and glibc ebuilds themselves (USE="build"):
                        cleanables.extend(["/usr/share/gettext","/usr/lib/python2.2/test","/usr/lib/python2.2/encodings","/usr/lib/python2.2/email","/usr/lib/python2.2/lib-tk","/usr/share/zoneinfo"])
+               if self.settings["target"]=="livecd-stage3":
+                       if self.settings.has_key("livecd-stage3/clean"):
+                               if type(self.settings["livecd-stage3/clean"])==types.StringType:
+                                       cleanables.append(self.settings["livecd-stage3/clean"])
+                               else:
+                                       #a list of directories to clean
+                                       cleanables.extend(self.settings["livecd-stage3/clean"])
                for x in cleanables: 
                        print "Cleaning chroot: "+x+"..."
                        cmd("rm -rf "+destpath+x,"Couldn't clean "+x)
@@ -234,6 +250,14 @@ class generic_stage_target(generic_target):
                else:
                        cmd("tar cjf "+self.settings["target_path"]+" -C "+self.settings["chroot_path"]+" .","Couldn't create stage tarball")
 
+       def run_local(self):
+               try:
+                       cmd(self.settings["sharedir"]+"/targets/"+self.settings["target"]+"/"+self.settings["target"]+".sh run","build script failed")
+               except CatalystError:
+                       self.unbind()
+                       raise CatalystError,"Stage build aborting due to error."
+pass
+
        def run(self):
                self.dir_setup()
                self.unpack_and_bind()
@@ -245,60 +269,17 @@ class generic_stage_target(generic_target):
                #modify the current environment. This is an ugly hack that should be fixed. We need this
                #to use the os.system() call since we can't specify our own environ:
                for x in self.settings.keys():
+                       varname="clst_"+x
+                       #"/" is replaced with "_", "-" is also replaced with "_"
+                       string.replace(varname,"/-","__")
                        if type(self.settings[x])==types.StringType:
                                #prefix to prevent namespace clashes:
-                               os.environ["clst_"+x]=self.settings[x]
+                               os.environ[varname]=self.settings[x]
                        elif type(self.settings[x])==types.ListType:
-                               os.environ["clst_"+x]=string.join(self.settings[x])
+                               os.environ[varname]=string.join(self.settings[x])
                        
-               if self.settings["target"] in ["stage1","stage2","stage3"]:
-                       try:
-                               cmd(self.settings["sharedir"]+"/targets/"+self.settings["target"]+"/"+self.settings["target"]+".sh run","build script failed")
-                       except CatalystError:
-                               self.unbind()
-                               raise CatalystError,"Stage build aborting due to error."
-               elif self.settings["target"]=="grp":
-                       for pkgset in self.settings["grp"]:
-                               #example call: "grp.sh run pkgset cd1 xmms vim sys-apps/gleep"
-                               try:
-                                       cmd(self.settings["sharedir"]+"/targets/grp/grp.sh run "+self.settings["grp/"+pkgset+"/type"]+" "+pkgset+" "+string.join(self.settings["grp/"+pkgset+"/packages"]))
-                               except CatalystError:
-                                       self.unbind()
-                                       raise CatalystError,"GRP build aborting due to error."
-               elif self.settings["target"]=="livecd-stage1":
-                       try:
-                               cmd(self.settings["sharedir"]+"/targets/livecd-stage1/livecd-stage1.sh run "+string.join(self.settings["livecd-stage1/packages"]))
-                       except CatalystError:
-                               self.unbind()
-                               raise CatalystError,"GRP build aborting due to error."
-               elif self.settings["target"]=="livecd-stage2":
-                       mynames=self.settings["boot/kernel"]
-                       if type(mynames)==types.StringType:
-                               mynames=[mynames]
-                       args=`len(mynames)`
-                       for x in mynames:
-                               args=args+" "+x+" "+self.settings["boot/kernel/"+x+"/sources"]
-                               if not os.path.exists(self.settings["boot/kernel/"+x+"/config"]):
-                                       raise CatalystError, "Can't find kernel config: "+self.settings["boot/kernel/"+x+"/config"]
-                               retval=os.system("cp "+self.settings["boot/kernel/"+x+"/config"]+" "+self.settings["chroot_path"]+"/var/tmp/"+x+".config")
-                               if retval!=0:
-                                       raise CatalystError, "Couldn't copy kernel config: "+self.settings["boot/kernel/"+x+"/config"]
-                       try:
-                               cmd(self.settings["sharedir"]+"/targets/livecd-stage2/livecd-stage2.sh run "+args)
-                       except CatalystError:
-                               self.unbind()
-                               raise CatalystError,"GRP build aborting due to error."
-               elif self.settings["target"]=="tinderbox":
-                       #tinderbox
-                       #example call: "grp.sh run xmms vim sys-apps/gleep"
-                       try:
-                               cmd(self.settings["sharedir"]+"/targets/tinderbox/tinderbox.sh run "+string.join(self.settings["tinderbox/packages"]))
-                       except CatalystError:
-                               self.unbind()
-                               raise CatalystError,"Tinderbox aborting due to error."
-               else:
-                       raise CatalystError,"You shouldn't get to this point. Target not recognized."
-               if self.settings["target"] in ["stage1","stage2","stage3"]:
+               self.run_local()
+               if self.settings["target"] in ["stage1","stage2","stage3","livecd-stage3"]:
                        self.preclean()
                self.unbind()
                if self.settings["target"] in ["stage1","stage2","stage3"]:
@@ -370,18 +351,43 @@ class grp_target(generic_stage_target):
                        self.required_values.append("grp/"+x+"/type")
                generic_stage_target.__init__(self,spec,addlargs)
 
+       def run_local(self):
+               for pkgset in self.settings["grp"]:
+                       #example call: "grp.sh run pkgset cd1 xmms vim sys-apps/gleep"
+                       try:
+                               cmd(self.settings["sharedir"]+"/targets/grp/grp.sh run "+self.settings["grp/"+pkgset+"/type"]+" "+pkgset+" "+string.join(self.settings["grp/"+pkgset+"/packages"]))
+                       except CatalystError:
+                               self.unbind()
+                               raise CatalystError,"GRP build aborting due to error."
+
 class tinderbox_target(generic_stage_target):
        def __init__(self,spec,addlargs):
                self.required_values=["tinderbox/packages","tinderbox/use"]
                self.valid_values=self.required_values[:]
                generic_stage_target.__init__(self,spec,addlargs)
 
+       def run_local(self):
+               #tinderbox
+               #example call: "grp.sh run xmms vim sys-apps/gleep"
+               try:
+                       cmd(self.settings["sharedir"]+"/targets/tinderbox/tinderbox.sh run "+string.join(self.settings["tinderbox/packages"]))
+               except CatalystError:
+                       self.unbind()
+                       raise CatalystError,"Tinderbox aborting due to error."
+
 class livecd_stage1_target(generic_stage_target):
        def __init__(self,spec,addlargs):
                self.required_values=["livecd-stage1/packages","livecd-stage1/use"]
                self.valid_values=self.required_values[:]
                generic_stage_target.__init__(self,spec,addlargs)
 
+       def run_local(self):
+               try:
+                       cmd(self.settings["sharedir"]+"/targets/livecd-stage1/livecd-stage1.sh run "+string.join(self.settings["livecd-stage1/packages"]))
+               except CatalystError:
+                       self.unbind()
+                       raise CatalystError,"GRP build aborting due to error."
+
 class livecd_stage2_target(generic_stage_target):
        def __init__(self,spec,addlargs):
                self.required_values=["boot/kernel"]
@@ -396,9 +402,36 @@ class livecd_stage2_target(generic_stage_target):
                        self.required_values.append("boot/kernel/"+x+"/config")
                self.valid_values=self.required_values[:]
                generic_stage_target.__init__(self,spec,addlargs)
+       
+       def run_local(self):
+               mynames=self.settings["boot/kernel"]
+               if type(mynames)==types.StringType:
+                       mynames=[mynames]
+               args=`len(mynames)`
+               for x in mynames:
+                       args=args+" "+x+" "+self.settings["boot/kernel/"+x+"/sources"]
+                       if not os.path.exists(self.settings["boot/kernel/"+x+"/config"]):
+                               raise CatalystError, "Can't find kernel config: "+self.settings["boot/kernel/"+x+"/config"]
+                       retval=os.system("cp "+self.settings["boot/kernel/"+x+"/config"]+" "+self.settings["chroot_path"]+"/var/tmp/"+x+".config")
+                       if retval!=0:
+                               raise CatalystError, "Couldn't copy kernel config: "+self.settings["boot/kernel/"+x+"/config"]
+               try:
+                       cmd(self.settings["sharedir"]+"/targets/livecd-stage2/livecd-stage2.sh run "+args)
+               except CatalystError:
+                       self.unbind()
+                       raise CatalystError,"GRP build aborting due to error."
+
+class livecd_stage3_target(generic_stage_target):
+       def __init__(self,spec,addlargs):
+               self.required_values=["boot/kernel","livecd-stage3/runscript"]
+               self.valid_values=self.required_values[:]
+               self.valid_values.append("livecd-stage3/cdtar","livecd-stage3/clean")
+               generic_stage_target.__init__(self,spec,addlargs)
 
 def register(foo):
        foo.update({"stage1":stage1_target,"stage2":stage2_target,"stage3":stage3_target,
-       "grp":grp_target,"livecd-stage1":livecd_stage1_target,"livecd-stage2":livecd_stage2_target,"snapshot":snapshot_target,"tinderbox":tinderbox_target})
+       "grp":grp_target,"livecd-stage1":livecd_stage1_target,
+       "livecd-stage2":livecd_stage2_target,"livecd-stage3":livecd_stage3_target,
+       "snapshot":snapshot_target,"tinderbox":tinderbox_target})
        return foo