new tinderbox target
authorDaniel Robbins <drobbins@gentoo.org>
Sun, 30 Nov 2003 01:51:44 +0000 (01:51 +0000)
committerDaniel Robbins <drobbins@gentoo.org>
Sun, 30 Nov 2003 01:51:44 +0000 (01:51 +0000)
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/catalyst/trunk@93 d1e1f19c-881f-0410-ab34-b69fee027534

ChangeLog
modules/targets.py
targets/tinderbox/tinderbox.sh [new file with mode: 0755]

index 9c2182274c9e8801c4568187bbf82bd0749131c4..cd405d3b856c5e7d069cdb8cb7d28fc25bf5183c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,10 @@
 # ChangeLog for gentoo/src/catalyst 
 # Copyright 2002-2003 Gentoo Technologies, Inc.; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/ChangeLog,v 1.12 2003/11/09 01:52:16 drobbins Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/ChangeLog,v 1.13 2003/11/30 01:51:44 drobbins Exp $
  
+  29 Nov 2003; Daniel Robbins <drobbins@gentoo.org>: Tinderbox target added. See
+  tinderbox examples in examples/ dir.
+  
   08 Nov 2003; Daniel Robbins <drobbins@gentoo.org>: spec file support integrated
   into catalyst. Use "-f/--file specfile" as argument; see examples dir for examples.
   "grp" target now functional. See examples/x86-grp-20031102.spec for an example of
index 3c6ff57d16812828329ce8f571f2705c9c5f2603..d2fb51a569941a6603368deec6f33c6b1c7a3ddc 100644 (file)
@@ -70,7 +70,7 @@ class generic_stage_target(generic_target):
                self.settings["target_subpath"]=self.settings["target_profile"]+"/"+self.settings["target"]+"-"+self.settings["subarch"]+"-"+self.settings["version_stamp"]
                st=self.settings["storedir"]
                self.settings["snapshot_path"]=st+"/snapshots/portage-"+self.settings["snapshot"]+".tar.bz2"
-               if self.settings["target"]=="grp":
+               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"]
                        #since we have a directory here, we need to create it
@@ -82,8 +82,8 @@ class generic_stage_target(generic_target):
                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","/usr/portage/distfiles" ]
-               self.mountmap={"/proc":"/proc", "/dev":"/dev", "/usr/portage/distfiles":self.settings["distdir"]}
+               self.mounts=[ "/proc","/dev","/dev/pts","/usr/portage/distfiles" ]
+               self.mountmap={"/proc":"/proc", "/dev":"/dev", "/dev/pts":"/dev/pts","/usr/portage/distfiles":self.settings["distdir"]}
                if self.settings.has_key("PKGCACHE"):
                        self.settings["pkgcache_path"]=st+"/packages/"+self.settings["target_subpath"]
                        self.mounts.append("/usr/portage/packages")
@@ -147,7 +147,10 @@ class generic_stage_target(generic_target):
        def unbind(self):
                ouch=0
                mypath=self.settings["chroot_path"]
-               for x in self.mounts:
+               myrevmounts=self.mounts[:]
+               myrevmounts.reverse()
+               #unmount in reverse order for nested bind-mounts
+               for x in myrevmounts:
                        if not os.path.exists(mypath+x):
                                continue
                        if not ismount(mypath+x):
@@ -177,6 +180,8 @@ class generic_stage_target(generic_target):
                if self.settings["target"]=="grp":
                        myusevars.append("bindist")
                        myusevars.extend(self.settings["grp/use"])
+               elif self.settings["target"]=="tinderbox":
+                       myusevars.extend(self.settings["tinderbox/use"])
                myf.write('USE="'+string.join(myusevars)+'"\n')
                if self.settings.has_key("CXXFLAGS"):
                        myf.write('CXXFLAGS="'+self.settings["CXXFLAGS"]+'"\n')
@@ -234,18 +239,27 @@ class generic_stage_target(generic_target):
                        elif type(self.settings[x])==types.ListType:
                                os.environ["clst_"+x]=string.join(self.settings[x])
                try:
-                       if self.settings["target"]!="grp":
+                       if self.settings["target"] not in ["grp","tinderbox"]:
                                cmd(self.settings["sharedir"]+"/targets/"+self.settings["target"]+"/"+self.settings["target"]+".sh run","build script failed")
-                       else:
+                       elif self.settings["target"]=="grp":
                                for pkgset in self.settings["grp"]:
                                        #example call: "grp.sh run pkgset cd1 xmms vim sys-apps/gleep"
                                        cmd(self.settings["sharedir"]+"/targets/grp/grp.sh run "+self.settings["grp/"+pkgset+"/type"]+" "+pkgset+" "+string.join(self.settings["grp/"+pkgset+"/packages"]))
+                       else:
+                               #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."
+               
                finally:
                        #pre-clean is for stuff that needs to run with bind-mounts still active
-                       if self.settings["target"]!="grp":
+                       if self.settings["target"] not in ["grp","tinderbox"]:
                                self.preclean()
                        self.unbind()
-               if self.settings["target"]!="grp":
+               if self.settings["target"] not in ["grp","tinderbox"]:
                        #clean is for removing things after bind-mounts are unmounted (general file removal and cleanup)
                        self.clean()
                        self.capture()
@@ -310,12 +324,21 @@ class grp_target(generic_stage_target):
                generic_stage_target.__init__(self,spec,addlargs)
                self.valid_values=self.required_values
 
+class tinderbox_target(generic_stage_target):
+       def __init__(self,spec,addlargs):
+               self.required_values=["tinderbox/packages","tinderbox/use","version_stamp","target","subarch","rel_type","rel_version","snapshot","source_subpath"]
+               for myarg in ["tinderbox/packages","tinderbox/use"]:
+                       if not addlargs.has_key(myarg):
+                               raise CatalystError,"Required value \""+myarg+"\" not specified in spec."
+               generic_stage_target.__init__(self,spec,addlargs)
+               self.valid_values=self.required_values
+
 class livecd_target(generic_stage_target):
        def __init__(self,spec,addlargs):
                generic_target.__init__(self,spec,addlargs)
 
 def register(foo):
        foo.update({"stage1":stage1_target,"stage2":stage2_target,"stage3":stage3_target,
-       "grp":grp_target,"livecd":livecd_target,"snapshot":snapshot_target})
+       "grp":grp_target,"livecd":livecd_target,"snapshot":snapshot_target,"tinderbox":tinderbox_target})
        return foo
        
diff --git a/targets/tinderbox/tinderbox.sh b/targets/tinderbox/tinderbox.sh
new file mode 100755 (executable)
index 0000000..65a7e2b
--- /dev/null
@@ -0,0 +1,43 @@
+# Copyright 1999-2003 Gentoo Technologies, Inc.
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo/src/catalyst/targets/tinderbox/Attic/tinderbox.sh,v 1.1 2003/11/30 01:51:44 drobbins Exp $
+
+case $1 in
+run)
+       shift
+       export clst_tinderbox_packages="$*"
+       $clst_CHROOT $clst_chroot_path /bin/bash << EOF
+       env-update
+       source /etc/profile
+       if [ -n "${clst_CCACHE}" ]
+       then
+               export FEATURES="ccache"
+               emerge --oneshot --nodeps ccache || exit 1
+       fi
+       export CONFIG_PROTECT="-*"
+       
+       USE="build" emerge portage
+       #turn off auto-use:
+       export USE_ORDER="env:conf:defaults"    
+       #back up pristine system
+       rsync -avx --exclude "/root/" --exclude "/tmp/" --exclude "/usr/portage/" / /tmp/rsync-bak/ 
+       for x in $clst_tinderbox_packages
+       do
+               emerge --usepkg --buildpkg \$x
+               if [ "\$?" != "0" ]
+               then
+                       echo "! \$x" >> /tmp/tinderbox.log      
+               else
+                       echo "$x" >> /tmp/tinderbox.log
+               fi
+               echo "Syncing from original pristine tinderbox snapshot..."
+               rsync -avx --delete --exclude "/root/*" --exclude "/tmp/" --exclude "/usr/portage/*" /tmp/rsync-bak/ /
+       done
+EOF
+       [ $? -ne 0 ] && exit 1
+       ;;
+*)
+       exit 1
+       ;;
+esac
+exit 0