AUTORESUME PATCH; modified the chroot-functions.sh script so the chroot will die...
authorEric Edgar <rocket@gentoo.org>
Thu, 14 Apr 2005 14:59:48 +0000 (14:59 +0000)
committerEric Edgar <rocket@gentoo.org>
Thu, 14 Apr 2005 14:59:48 +0000 (14:59 +0000)
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/catalyst/trunk@601 d1e1f19c-881f-0410-ab34-b69fee027534

14 files changed:
ChangeLog
modules/catalyst_support.py
modules/embedded_target.py
modules/generic_stage_target.py
modules/grp_target.py
modules/livecd_stage1_target.py
modules/livecd_stage2_target.py
modules/netboot_target.py
modules/stage4_target.py
modules/tinderbox_target.py
targets/stage1/stage1-chroot.sh
targets/stage1/stage1-controller.sh
targets/stage1/stage1-preclean-chroot.sh
targets/support/chroot-functions.sh

index 694b15096101a65b26a523d281f80d24f08474ca..f92c404e25f5ab42e15beb11c4d008c276640663 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,17 @@
 # ChangeLog for gentoo/src/catalyst 
 # Copyright 2002-2005 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/ChangeLog,v 1.217 2005/04/11 20:44:47 rocket Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/ChangeLog,v 1.218 2005/04/14 14:59:48 rocket Exp $
+
+  14 Apr 2005; Eric Edgar <rocket@gentoo.org> modules/catalyst_support.py,
+  modules/embedded_target.py, modules/generic_stage_target.py,
+  modules/grp_target.py, modules/livecd_stage1_target.py,
+  modules/livecd_stage2_target.py, modules/netboot_target.py,
+  modules/stage4_target.py, modules/tinderbox_target.py,
+  targets/stage1/stage1-chroot.sh, targets/stage1/stage1-controller.sh,
+  targets/stage1/stage1-preclean-chroot.sh,
+  targets/support/chroot-functions.sh:
+  AUTORESUME PATCH; modified the chroot-functions.sh script so the chroot will
+  die properly on CTRL-C; fixed stage1 bug with gcc-setup
 
   11 Apr 2005; Eric Edgar <rocket@gentoo.org>
   modules/livecd_stage2_target.py:
index 84c39c965b47e185a1ae968e89687e51e42c7283..f9ca29c65911691c93ef6680693817f6a840fe61 100644 (file)
@@ -1,10 +1,8 @@
 # Copyright 1999-2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/modules/catalyst_support.py,v 1.37 2005/04/07 23:02:20 rocket Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/catalyst_support.py,v 1.38 2005/04/14 14:59:48 rocket Exp $
 
 import sys,string,os,types,re,traceback,md5
-
-
 # a function to turn a string of non-printable characters into a string of
 # hex characters
 def hexify(str):
@@ -136,11 +134,19 @@ def spawn(mystring,debug=0,fd_pipes=None):
                os._exit(1)
                sys.exit(1)
                return # should never get reached
-       retval=os.waitpid(mypid,0)[1]
+       try:
+               retval=os.waitpid(mypid,0)[1]
+       except:
+               os.kill(mypid,signal.SIGTERM)
+               if os.waitpid(mypid,os.WNOHANG)[1] == 0:
+               # feisty bugger, still alive.
+                       os.kill(mypid,signal.SIGKILL)
+
        if (retval & 0xff)==0:
                return (retval >> 8) # return exit code
        else:
                return ((retval & 0xff) << 8) # interrupted by signal
+       
 
 def cmd(mycmd,myexc=""):
        try:
@@ -150,6 +156,7 @@ def cmd(mycmd,myexc=""):
        except KeyboardInterrupt:
                raise CatalystError,"Caught SIGINT, aborting."
 
+
 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
index 03d20e48de8bf12d9b7d38f2384f178c14741d58..e967078cef6c8e70dc0d27f33c6641b7d6774c37 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1999-2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/modules/embedded_target.py,v 1.9 2005/04/04 17:48:32 rocket Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/embedded_target.py,v 1.10 2005/04/14 14:59:48 rocket Exp $
 
 """
 This class works like a 'stage3'.  A stage2 tarball is unpacked, but instead
@@ -60,11 +60,8 @@ class embedded_target(generic_stage_target):
        self.settings["action_sequence"]=["dir_setup","unpack","unpack_snapshot",\
                                        "config_profile_link","setup_confdir","bind","chroot_setup",\
                                        "setup_environment","build_packages","build_kernel","unmerge","unbind",\
-                                       "clear_autoresume","remove","empty","clean","pre_build_fs","build_fs","post_build_fs"]
+                                       "remove","empty","clean","pre_build_fs","build_fs","post_build_fs","clear_autoresume"]
 
-    def set_use(self):
-        self.settings["use"]=self.settings["embedded/use"]
     def set_stage_path(self):
         self.settings["stage_path"]=self.settings["chroot_path"]+"/tmp/mergeroot"
        print "embedded stage path is "+self.settings["stage_path"]
index 8805a0191f5ad93876c597e19b5f19385420bed7..7115b96f1aa6d6fcd52fc841e7503aa53b61502b 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1999-2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/modules/generic_stage_target.py,v 1.28 2005/04/11 20:05:40 rocket Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/generic_stage_target.py,v 1.29 2005/04/14 14:59:48 rocket Exp $
 
 """
 This class does all of the chroot setup, copying of files, etc. It is
@@ -109,6 +109,7 @@ class generic_stage_target(generic_target):
                self.set_target_path()
                self.set_source_path()
                self.set_chroot_path()
+               self.set_autoresume_path()
                self.set_root_path()
                self.set_dest_path()
                self.set_stage_path()
@@ -232,6 +233,13 @@ class generic_stage_target(generic_target):
        def set_chroot_path(self):
                self.settings["chroot_path"]=self.settings["storedir"]+"/tmp/"+self.settings["target_subpath"]
        
+       def set_autoresume_path(self):
+               self.settings["autoresume_path"]=self.settings["storedir"]+"/tmp/"+self.settings["rel_type"]+"/"+\
+                       ".autoresume-"+self.settings["target"]+"-"+self.settings["subarch"]+"-"+self.settings["version_stamp"]+"/"
+               print "The autoresume path is " + self.settings["autoresume_path"]
+               if not os.path.exists(self.settings["autoresume_path"]):
+                   os.makedirs(self.settings["autoresume_path"],0755)
+       
        def set_controller_file(self):
                self.settings["controller_file"]=self.settings["sharedir"]+"/targets/"+self.settings["target"]+"/"+self.settings["target"]+"-controller.sh"
        def set_iso_volume_id(self):
@@ -246,10 +254,12 @@ class generic_stage_target(generic_target):
                #Default action sequence for run method
                self.settings["action_sequence"]=["dir_setup","unpack","unpack_snapshot",\
                                "config_profile_link","setup_confdir","bind","chroot_setup",\
-                               "setup_environment","run_local","preclean","unbind","clear_autoresume","clean","capture"]
+                               "setup_environment","run_local","preclean","unbind","clean","capture","clear_autoresume"]
        
        def set_use(self):
-               pass
+               if self.settings.has_key("use"):
+                       self.settings["use"]=self.settings[self.settings["spec_prefix"]+"/use"]
+                       del self.settings[self.settings["spec_prefix"]+"/use"]
 
        def set_stage_path(self):
                        self.settings["stage_path"]=self.settings["chroot_path"]
@@ -322,7 +332,7 @@ class generic_stage_target(generic_target):
                
        def dir_setup(self):
                if self.settings.has_key("AUTORESUME") \
-                       and os.path.exists(self.settings["chroot_path"]+"/tmp/.clst_dir_setup"):
+                       and os.path.exists(self.settings["autoresume_path"]+"dir_setup"):
                        print "Resume point detected, skipping dir_setup operation..."
                else:
                    print "Setting up directories..."
@@ -342,21 +352,21 @@ class generic_stage_target(generic_target):
                            if not os.path.exists(self.settings["pkgcache_path"]):
                                    os.makedirs(self.settings["pkgcache_path"],0755)
        
-                   touch(self.settings["chroot_path"]+"/tmp/.clst_dir_setup")
+                   touch(self.settings["autoresume_path"]+"dir_setup")
                
        def unpack(self):
-                       if os.path.exists(self.settings["chroot_path"]+"/tmp/.clst_unpack"):
-                               clst_unpack_md5sum=read_from_clst(self.settings["chroot_path"]+"/tmp/.clst_unpack")
+                       if os.path.exists(self.settings["autoresume_path"]+"unpack"):
+                               clst_unpack_md5sum=read_from_clst(self.settings["autoresume_path"]+"unpack")
                        
                        if self.settings.has_key("AUTORESUME") \
-                               and os.path.exists(self.settings["chroot_path"]+"/tmp/.clst_unpack") \
+                               and os.path.exists(self.settings["autoresume_path"]+"unpack") \
                                and self.settings["source_path_md5sum"] != clst_unpack_md5sum:
                                    print "InValid Resume point detected, cleaning up  ..."
-                                   os.remove(self.settings["chroot_path"]+"/tmp/.clst_dir_setup")      
-                                   os.remove(self.settings["chroot_path"]+"/tmp/.clst_unpack") 
+                                   os.remove(self.settings["autoresume_path"]+"dir_setup")     
+                                   os.remove(self.settings["autoresume_path"]+"unpack")        
                                    self.dir_setup()    
                        if self.settings.has_key("AUTORESUME") \
-                               and os.path.exists(self.settings["chroot_path"]+"/tmp/.clst_unpack") \
+                               and os.path.exists(self.settings["autoresume_path"]+"unpack") \
                                and self.settings["source_path_md5sum"] == clst_unpack_md5sum:
                                    print "Valid Resume point detected, skipping unpack  ..."
                        else:
@@ -368,17 +378,17 @@ class generic_stage_target(generic_target):
                                        "Error unpacking ")
 
                                if self.settings.has_key("source_path_md5sum"):
-                                   myf=open(self.settings["chroot_path"]+"/tmp/.clst_unpack","w")
+                                   myf=open(self.settings["autoresume_path"]+"unpack","w")
                                    myf.write(self.settings["source_path_md5sum"])
                                    myf.close()
        
        def unpack_snapshot(self):                      
-                       if os.path.exists(self.settings["chroot_path"]+"/tmp/.clst_unpack_portage"):
-                           clst_unpack_portage_md5sum=read_from_clst(self.settings["chroot_path"]+"/tmp/.clst_unpack_portage")
+                       if os.path.exists(self.settings["autoresume_path"]+"unpack_portage"):
+                           clst_unpack_portage_md5sum=read_from_clst(self.settings["autoresume_path"]+"unpack_portage")
                        
                        if self.settings.has_key("AUTORESUME") \
                        and os.path.exists(self.settings["chroot_path"]+"/usr/portage/") \
-                       and os.path.exists(self.settings["chroot_path"]+"/tmp/.clst_unpack_portage") \
+                       and os.path.exists(self.settings["autoresume_path"]+"unpack_portage") \
                        and self.settings["snapshot_path_md5sum"] == clst_unpack_portage_md5sum:
                                print "Valid Resume point detected, skipping unpack of portage tree..."
                        else:
@@ -392,23 +402,33 @@ class generic_stage_target(generic_target):
                                    self.settings["chroot_path"]+"/usr","Error unpacking snapshot")
                                
                                print "Setting snapshot autoresume point"
-                               myf=open(self.settings["chroot_path"]+"/tmp/.clst_unpack_portage","w")
+                               myf=open(self.settings["autoresume_path"]+"unpack_portage","w")
                                myf.write(self.settings["snapshot_path_md5sum"])
                                myf.close()
 
        def config_profile_link(self):
+               if self.settings.has_key("AUTORESUME") \
+                       and os.path.exists(self.settings["autoresume_path"]+"config_profile_link"):
+                       print "Resume point detected, skipping config_profile_link operation..."
+               else:
                        print "Configuring profile link..."
                        cmd("rm -f "+self.settings["chroot_path"]+"/etc/make.profile",\
                                        "Error zapping profile link")
                        cmd("ln -sf ../usr/portage/profiles/"+self.settings["target_profile"]+\
                                " "+self.settings["chroot_path"]+"/etc/make.profile","Error creating profile link")
+                       touch(self.settings["autoresume_path"]+"config_profile_link")
                                       
        def setup_confdir(self):        
-               if self.settings.has_key("portage_confdir"):
-                       print "Configuring /etc/portage..."
-                       cmd("rm -rf "+self.settings["chroot_path"]+"/etc/portage","Error zapping /etc/portage")
-                       cmd("cp -R "+self.settings["portage_confdir"]+"/ "+self.settings["chroot_path"]+\
-                               "/etc/portage","Error copying /etc/portage")
+               if self.settings.has_key("AUTORESUME") \
+                       and os.path.exists(self.settings["autoresume_path"]+"setup_confdir"):
+                       print "Resume point detected, skipping setup_confdir operation..."
+               else:
+                       if self.settings.has_key("portage_confdir"):
+                               print "Configuring /etc/portage..."
+                               cmd("rm -rf "+self.settings["chroot_path"]+"/etc/portage","Error zapping /etc/portage")
+                               cmd("cp -R "+self.settings["portage_confdir"]+"/ "+self.settings["chroot_path"]+\
+                                       "/etc/portage","Error copying /etc/portage")
+                               touch(self.settings["autoresume_path"]+"setup_confdir")
        
        def portage_overlay(self):      
            # copy over the portage overlays
@@ -474,6 +494,10 @@ class generic_stage_target(generic_target):
                        raise CatalystError,"Couldn't umount one or more bind-mounts; aborting for safety."
 
        def chroot_setup(self):
+               if self.settings.has_key("AUTORESUME") \
+                       and os.path.exists(self.settings["autoresume_path"]+"chroot_setup"):
+                       print "Resume point detected, skipping chroot_setup operation..."
+               else:
                    print "Setting up chroot..."
                    
                    self.makeconf=read_makeconf(self.settings["chroot_path"]+"/etc/make.conf")
@@ -525,82 +549,117 @@ class generic_stage_target(generic_target):
                                        
                                myf.write('PORTDIR_OVERLAY="'+string.join(self.settings["portage_overlay"])+'"\n')
                    myf.close()
+                   touch(self.settings["autoresume_path"]+"chroot_setup")
        
        def fsscript(self):
-               if self.settings.has_key("fsscript"):
+               if self.settings.has_key("AUTORESUME") \
+                       and os.path.exists(self.settings["autoresume_path"]+"fsscript"):
+                       print "Resume point detected, skipping fsscript operation..."
+               else:
+                   if self.settings.has_key("fsscript"):
                        if os.path.exists(self.settings["controller_file"]):
-                               cmd("/bin/bash "+self.settings["controller_file"]+" fsscript","fsscript script failed.")
-       
+                           cmd("/bin/bash "+self.settings["controller_file"]+" fsscript","fsscript script failed.")
+                       touch(self.settings["autoresume_path"]+"fsscript")
+
        def rcupdate(self):
-               if self.settings.has_key("rcadd") or self.settings.has_key("rcdel"):
-                       if os.path.exists(self.settings["controller_file"]):
-                               cmd("/bin/bash "+self.settings["controller_file"]+" rc-update","rc-update script failed.")
+               if self.settings.has_key("AUTORESUME") \
+                       and os.path.exists(self.settings["autoresume_path"]+"rcupdate"):
+                       print "Resume point detected, skipping rcupdate operation..."
+               else:
+                   if self.settings.has_key("rcadd") or self.settings.has_key("rcdel"):
+                           if os.path.exists(self.settings["controller_file"]):
+                                 cmd("/bin/bash "+self.settings["controller_file"]+" rc-update","rc-update script failed.")
+                           touch(self.settings["autoresume_path"]+"rcupdate")
 
        def clean(self):
-               for x in self.settings["cleanables"]: 
-                       print "Cleaning chroot: "+x+"... "
-                       cmd("rm -rf "+self.settings["destpath"]+x,"Couldn't clean "+x)
-
-               # put /etc/hosts back into place
-               if os.path.exists("/etc/hosts.bck"):
-                       cmd("mv -f "+self.settings["chroot_path"]+"/etc/hosts.bck "+self.settings["chroot_path"]+\
-                                       "/etc/hosts", "Could not replace /etc/hosts")
+               if self.settings.has_key("AUTORESUME") \
+                       and os.path.exists(self.settings["autoresume_path"]+"clean"):
+                       print "Resume point detected, skipping clean operation..."
+               else:
+                   for x in self.settings["cleanables"]: 
+                           print "Cleaning chroot: "+x+"... "
+                           cmd("rm -rf "+self.settings["destpath"]+x,"Couldn't clean "+x)
+
+                   # put /etc/hosts back into place
+                   if os.path.exists("/etc/hosts.bck"):
+                           cmd("mv -f "+self.settings["chroot_path"]+"/etc/hosts.bck "+self.settings["chroot_path"]+\
+                                         "/etc/hosts", "Could not replace /etc/hosts")
        
-               if os.path.exists(self.settings["controller_file"]):
-                   cmd("/bin/bash "+self.settings["controller_file"]+" clean","clean script failed.")
+                   if os.path.exists(self.settings["controller_file"]):
+                       cmd("/bin/bash "+self.settings["controller_file"]+" clean","clean script failed.")
+                       touch(self.settings["autoresume_path"]+"clean")
        
        def empty(self):                
-           if self.settings.has_key(self.settings["spec_prefix"]+"/empty"):
-               if type(self.settings[self.settings["spec_prefix"]+"/empty"])==types.StringType:
-                   self.settings[self.settings["spec_prefix"]+"/empty"]=[self.settings[self.settings["spec_prefix"]+"/empty"]]
-               for x in self.settings[self.settings["spec_prefix"]+"/empty"]:
-                   myemp=self.settings["destpath"]+x
-                   if not os.path.isdir(myemp):
-                       print x,"not a directory or does not exist, skipping 'empty' operation."
-                       continue
-                   print "Emptying directory",x
-                   # stat the dir, delete the dir, recreate the dir and set
-                   # the proper perms and ownership
-                   mystat=os.stat(myemp)
-                   shutil.rmtree(myemp)
-                   os.makedirs(myemp,0755)
-                   os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
-                   os.chmod(myemp,mystat[ST_MODE])
+           if self.settings.has_key("AUTORESUME") \
+               and os.path.exists(self.settings["autoresume_path"]+"empty"):
+               print "Resume point detected, skipping empty operation..."
+           else:
+               if self.settings.has_key(self.settings["spec_prefix"]+"/empty"):
+                   if type(self.settings[self.settings["spec_prefix"]+"/empty"])==types.StringType:
+                       self.settings[self.settings["spec_prefix"]+"/empty"]=[self.settings[self.settings["spec_prefix"]+"/empty"]]
+                   for x in self.settings[self.settings["spec_prefix"]+"/empty"]:
+                       myemp=self.settings["destpath"]+x
+                       if not os.path.isdir(myemp):
+                           print x,"not a directory or does not exist, skipping 'empty' operation."
+                           continue
+                       print "Emptying directory",x
+                       # stat the dir, delete the dir, recreate the dir and set
+                       # the proper perms and ownership
+                       mystat=os.stat(myemp)
+                       shutil.rmtree(myemp)
+                       os.makedirs(myemp,0755)
+                       os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
+                       os.chmod(myemp,mystat[ST_MODE])
+                   touch(self.settings["autoresume_path"]+"empty")
        
        def remove(self):
-           if self.settings.has_key(self.settings["spec_prefix"]+"/rm"):
-               if type(self.settings[self.settings["spec_prefix"]+"/rm"])==types.StringType:
-                   self.settings[self.settings["spec_prefix"]+"/rm"]=[self.settings[self.settings["spec_prefix"]+"/rm"]]
-               for x in self.settings[self.settings["spec_prefix"]+"/rm"]:
-                   # we're going to shell out for all these cleaning operations,
-                   # so we get easy glob handling
-                   print "livecd: removing "+x
-                   os.system("rm -rf "+self.settings["chroot_path"]+x)
-           try:
-               if os.path.exists(self.settings["controller_file"]):
-                       cmd("/bin/bash "+self.settings["controller_file"]+" clean",\
-                   "Clean runscript failed.")
-           except:
-               self.unbind()
-               raise
+           if self.settings.has_key("AUTORESUME") \
+               and os.path.exists(self.settings["autoresume_path"]+"remove"):
+               print "Resume point detected, skipping remove operation..."
+           else:
+               if self.settings.has_key(self.settings["spec_prefix"]+"/rm"):
+                   if type(self.settings[self.settings["spec_prefix"]+"/rm"])==types.StringType:
+                       self.settings[self.settings["spec_prefix"]+"/rm"]=[self.settings[self.settings["spec_prefix"]+"/rm"]]
+                   for x in self.settings[self.settings["spec_prefix"]+"/rm"]:
+                       # we're going to shell out for all these cleaning operations,
+                       # so we get easy glob handling
+                       print "livecd: removing "+x
+                       os.system("rm -rf "+self.settings["chroot_path"]+x)
+               try:
+                   if os.path.exists(self.settings["controller_file"]):
+                           cmd("/bin/bash "+self.settings["controller_file"]+" clean",\
+                               "Clean runscript failed.")
+                           touch(self.settings["autoresume_path"]+"remove")
+               except:
+                   self.unbind()
+                   raise
 
        def clear_autoresume(self):
                # clean resume points since they are no longer needed
                if self.settings.has_key("AUTORESUME"):
                        print "Removing AutoResume Points: ..."
-                       cmd("rm -f "+self.settings["chroot_path"]+"/tmp/.clst*",\
+                       cmd("rm -rf "+self.settings["autoresume_path"],\
                                "Couldn't remove resume points")
        
        def preclean(self):
+           if self.settings.has_key("AUTORESUME") \
+               and os.path.exists(self.settings["autoresume_path"]+"preclean"):
+               print "Resume point detected, skipping preclean operation..."
+           else:
                try:
                        if os.path.exists(self.settings["controller_file"]):
                                cmd("/bin/bash "+self.settings["controller_file"]+" preclean","preclean script failed.")
+                               touch(self.settings["autoresume_path"]+"preclean")
                
                except:
                        self.unbind()
                        raise CatalystError, "Build failed, could not execute preclean"
 
        def capture(self):
+           if self.settings.has_key("AUTORESUME") \
+               and os.path.exists(self.settings["autoresume_path"]+"capture"):
+               print "Resume point detected, skipping capture operation..."
+           else:
                """capture target in a tarball"""
                mypath=self.settings["target_path"].split("/")
                # remove filename from path
@@ -614,11 +673,17 @@ class generic_stage_target(generic_target):
                
                cmd("tar cjf "+self.settings["target_path"]+" -C "+self.settings["stage_path"]+\
                        " .","Couldn't create stage tarball")
+               touch(self.settings["autoresume_path"]+"capture")
 
        def run_local(self):
+           if self.settings.has_key("AUTORESUME") \
+               and os.path.exists(self.settings["autoresume_path"]+"run_local"):
+               print "Resume point detected, skipping run_local operation..."
+           else:
                try:
                        if os.path.exists(self.settings["controller_file"]):
                                cmd("/bin/bash "+self.settings["controller_file"]+" run","run script failed.")
+                               touch(self.settings["autoresume_path"]+"run_local")
 
                except CatalystError:
                        self.unbind()
@@ -672,7 +737,7 @@ class generic_stage_target(generic_target):
 
         def unmerge(self):
            if self.settings.has_key("AUTORESUME") \
-               and os.path.exists(self.settings["chroot_path"]+"/tmp/.clst_unmerge"):
+               and os.path.exists(self.settings["autoresume_path"]+"unmerge"):
                    print "Resume point detected, skipping unmerge operation..."
            else:
                if self.settings.has_key(self.settings["spec_prefix"]+"/unmerge"):
@@ -696,42 +761,62 @@ class generic_stage_target(generic_target):
                    except CatalystError:
                        self.unbind()
                        raise
-               touch(self.settings["chroot_path"]+"/tmp/.clst_unmerge")
+               touch(self.settings["autoresume_path"]+"unmerge")
 
        def target_setup(self):
+           if self.settings.has_key("AUTORESUME") \
+               and os.path.exists(self.settings["autoresume_path"]+"target_setup"):
+                   print "Resume point detected, skipping target_setup operation..."
+           else:
                cmd("/bin/bash "+self.settings["controller_file"]+" cdfs","CDFS script failed.")
+               touch(self.settings["autoresume_path"]+"target_setup")
        
        def setup_overlay(self):        
+           if self.settings.has_key("AUTORESUME") \
+               and os.path.exists(self.settings["autoresume_path"]+"setup_overlay"):
+                   print "Resume point detected, skipping setup_overlay operation..."
+           else:
                if self.settings.has_key(self.settings["spec_prefix"]+"/overlay"):
                        cmd("rsync -a "+self.settings[self.settings["spec_prefix"]+"/overlay"]+"/* "+\
                        self.settings["target_path"], self.settings["spec_prefix"]+"overlay copy failed.")
-       
-               # clean up the resume points
-               if self.settings.has_key("AUTORESUME"):
-                       cmd("rm -f "+self.settings["chroot_path"]+"/tmp/.clst*",\
-                       "Couldn't remove resume points")
+               touch(self.settings["autoresume_path"]+"setup_overlay")
        
        def create_iso(self):
+           if self.settings.has_key("AUTORESUME") \
+               and os.path.exists(self.settings["autoresume_path"]+"create_iso"):
+                   print "Resume point detected, skipping create_iso operation..."
+           else:
                # create the ISO - this is the preferred method (the iso scripts do not always work)
                if self.settings.has_key(self.settings["spec_prefix"]+"/iso"):
                        cmd("/bin/bash "+self.settings["controller_file"]+" iso "+\
                                self.settings[self.settings["spec_prefix"]+"/iso"],"ISO creation script failed.")
+               touch(self.settings["autoresume_path"]+"create_iso")
+
         def build_packages(self):
+           if self.settings.has_key("AUTORESUME") \
+               and os.path.exists(self.settings["autoresume_path"]+"build_packages"):
+                   print "Resume point detected, skipping build_packages operation..."
+           else:
                if self.settings.has_key(self.settings["spec_prefix"]+"/packages"):
                        if self.settings.has_key("AUTORESUME") \
-                               and os.path.exists(self.settings["chroot_path"]+"/tmp/.clst_build_packages"):
+                               and os.path.exists(self.settings["autoresume_path"]+"build_packages"):
                                        print "Resume point detected, skipping build_packages operation..."
                        else:
                                mypack=list_bashify(self.settings[self.settings["spec_prefix"]+"/packages"])
                                try:
                                        cmd("/bin/bash "+self.settings["controller_file"]+\
                                                " build_packages "+mypack)
-                                       touch(self.settings["chroot_path"]+"/tmp/.clst_build_packages")
+                                       touch(self.settings["autoresume_path"]+"build_packages")
                                except CatalystError:
                                        self.unbind()
                                        raise CatalystError,self.settings["spec_prefix"] + "build aborting due to error."
+               touch(self.settings["autoresume_path"]+"build_packages")
        
        def build_kernel(self):
+           if self.settings.has_key("AUTORESUME") \
+               and os.path.exists(self.settings["autoresume_path"]+"build_kernel"):
+                   print "Resume point detected, skipping build_kernel operation..."
+           else:
                if self.settings.has_key("boot/kernel"):
                        try:
                                mynames=self.settings["boot/kernel"]
@@ -777,6 +862,22 @@ class generic_stage_target(generic_target):
                                        cmd("/bin/bash "+self.settings["controller_file"]+" kernel "+kname,\
                                        "Runscript kernel build failed")
 
+                               touch(self.settings["autoresume_path"]+"build_kernel")
+                       
                        except CatalystError:
                                self.unbind()
                                raise CatalystError,"build aborting due to kernel build error."
+
+       def bootloader(self):
+           if self.settings.has_key("AUTORESUME") \
+               and os.path.exists(self.settings["autoresume_path"]+"bootloader"):
+                   print "Resume point detected, skipping bootloader operation..."
+           else:
+               try:
+                       cmd("/bin/bash "+self.settings["controller_file"]+" bootloader",\
+                               "Bootloader runscript failed.")
+                       touch(self.settings["autoresume_path"]+"bootloader")
+               except CatalystError:
+                       self.unbind()
+                       raise CatalystError,"Runscript aborting due to error."
+
index 0125503846dfefd08b87a804c17daef2e8836c0b..1089cce959ab9b27920bed06cee5755b49428342 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1999-2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/modules/grp_target.py,v 1.7 2005/04/04 17:48:32 rocket Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/grp_target.py,v 1.8 2005/04/14 14:59:48 rocket Exp $
 
 """
 The builder class for GRP (Gentoo Reference Platform) builds.
@@ -52,8 +52,9 @@ class grp_target(generic_stage_target):
 
        
        def set_use(self):
-           self.settings["use"]=self.settings["grp/use"]
-           self.settings["use"].append("bindlist")
+           generic_stage_target.set_use(self)
+           if self.settings.has_key("use"):
+               self.settings["use"].append("bindlist")
 
        def set_mounts(self):
            self.mounts.append("/tmp/grp")
index d805841bb67c544abdbb773f3b35c38d74c590db..38e865eed9dd6ddcb23773e4898dbfd369dc8661 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1999-2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/modules/livecd_stage1_target.py,v 1.8 2005/04/11 20:05:40 rocket Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/livecd_stage1_target.py,v 1.9 2005/04/14 14:59:48 rocket Exp $
 
 """
 Builder class for LiveCD stage1.
@@ -19,12 +19,8 @@ class livecd_stage1_target(generic_stage_target):
                self.settings["action_sequence"]=["dir_setup","unpack","unpack_snapshot",\
                                        "config_profile_link","setup_confdir","portage_overlay",\
                                        "bind","chroot_setup","setup_environment","build_packages",\
-                                       "preclean","fsscript","clear_autoresume","unmerge","unbind",\
-                                       "remove","empty","clean"]
-
-
-       def set_use(self):
-                   self.settings["use"]=self.settings["livecd/use"]
+                                       "preclean","fsscript","unmerge","unbind",\
+                                       "remove","empty","clean","clear_autoresume"]
 
         def set_spec_prefix(self):
                        self.settings["spec_prefix"]="livecd"
index 04da3821aa5e5e31fe6ef20e0dd47cd48957b79f..34c0e8682ba62d56c1d15412a521217b4e601617 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1999-2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/modules/livecd_stage2_target.py,v 1.33 2005/04/11 20:44:47 rocket Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/livecd_stage2_target.py,v 1.34 2005/04/14 14:59:48 rocket Exp $
 
 """
 Builder class for a LiveCD stage2 build.
@@ -49,7 +49,7 @@ class livecd_stage2_target(generic_stage_target):
                        generic_stage_target.unpack(self)
                else:
                    if self.settings.has_key("AUTORESUME") \
-                           and os.path.exists(self.settings["chroot_path"]+"/tmp/.clst_unpack"):
+                           and os.path.exists(self.settings["autoresume_path"]+"unpack"):
                            print "Resume point detected, skipping unpack operation..."
                    else:
                            if not os.path.exists(self.settings["chroot_path"]):
@@ -58,11 +58,8 @@ class livecd_stage2_target(generic_stage_target):
                            print "Copying livecd-stage1 result to new livecd-stage2 work directory..."
                            cmd("rsync -a --delete "+self.settings["source_path"]+"/* "+self.settings["chroot_path"],\
                                    "Error copying initial livecd-stage2")
-                           touch(self.settings["chroot_path"]+"/tmp/.clst_unpack")
+                           touch(self.settings["autoresume_path"]+"unpack")
 
-                           # Create the dir_setup autoresume point as the rsync --delete probably deleted it
-                           touch(self.settings["chroot_path"]+"/tmp/.clst_dir_setup")
-        
        def run_local(self):
                # first clean up any existing target stuff
                if os.path.exists(self.settings["target_path"]):
@@ -85,23 +82,14 @@ class livecd_stage2_target(generic_stage_target):
                                myf.write("\n"+x)
                        myf.close()
 
-       def bootloader(self):
-               try:
-                       cmd("/bin/bash "+self.settings["controller_file"]+" bootloader",\
-                               "Bootloader runscript failed.")
-               
-               except CatalystError:
-                       self.unbind()
-                       raise CatalystError,"Runscript aborting due to error."
-
        def set_action_sequence(self):
            self.settings["action_sequence"]=["dir_setup","unpack","unpack_snapshot",\
                            "config_profile_link","setup_confdir","portage_overlay",\
                            "bind","chroot_setup","setup_environment","run_local",\
                            "root_overlay","build_kernel","bootloader","preclean",\
-                           "fsscript","rcupdate","clear_autoresume",\
-                           "unmerge","unbind","remove","empty","target_setup",\
-                           "setup_overlay","create_iso"]
+                           "fsscript","rcupdate","unmerge","unbind","remove",\
+                           "empty","target_setup",\
+                           "setup_overlay","create_iso","clear_autoresume"]
 
 def register(foo):
        foo.update({"livecd-stage2":livecd_stage2_target})
index a48f2f5146554c55d8fd738b095d54ff39e9eb7a..a3f2743cfc0242319e7a039123507c6dd0af34d1 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1999-2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/modules/netboot_target.py,v 1.1 2005/04/04 17:48:33 rocket Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/netboot_target.py,v 1.2 2005/04/14 14:59:48 rocket Exp $
 
 """
 Builder class for a netboot build.
@@ -132,8 +132,8 @@ class netboot_target(generic_stage_target):
            self.settings["action_sequence"]=["dir_setup","unpack","unpack_snapshot",
                                        "config_profile_link","setup_confdir","bind","chroot_setup",\
                                                "setup_environment","build_packages","build_busybox",\
-                                               "build_kernel","copy_files_to_image","clear_autoresume",\
-                                               "clean","create_netboot_files","unbind"]
+                                               "build_kernel","copy_files_to_image",\
+                                               "clean","create_netboot_files","unbind","clear_autoresume"]
 
 def register(foo):
        foo.update({"netboot":netboot_target})
index 2c472081440ffb7c5efbdd200b4932d139a92203..d319e7464604056f51952d35dcc33e460ac489bd 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1999-2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/modules/stage4_target.py,v 1.2 2005/04/11 20:05:40 rocket Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/stage4_target.py,v 1.3 2005/04/14 14:59:48 rocket Exp $
 
 """
 Builder class for LiveCD stage1.
@@ -18,11 +18,6 @@ class stage4_target(generic_stage_target):
                                             "stage4/rcadd","stage4/rcdel"])
                generic_stage_target.__init__(self,spec,addlargs)
        
-       def set_use(self):
-               if self.settings.has_key("use"):
-                       self.settings["use"]=self.settings["stage4/use"]
-               else:
-                       pass
        def set_cleanables(self):
                self.settings["cleanables"]=["/var/tmp/*","/tmp/*"]
 
@@ -31,8 +26,8 @@ class stage4_target(generic_stage_target):
                                        "config_profile_link","setup_confdir","portage_overlay",\
                                        "bind","chroot_setup","setup_environment","build_packages",\
                                        "build_kernel","root_overlay","preclean","rcupdate","fsscript",\
-                                       "clear_autoresume","unmerge","unbind","remove","empty",\
-                                       "clean","capture"]
+                                       "unmerge","unbind","remove","empty",\
+                                       "clean","capture","clear_autoresume"]
 
 def register(foo):
        foo.update({"stage4":stage4_target})
index 2fb87f8912db85f89f96190be7f010b706b6850b..ba88faf0f94f8c1d2535d714b77a8fae6c8bc934 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1999-2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/modules/tinderbox_target.py,v 1.7 2005/04/04 17:48:33 rocket Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/tinderbox_target.py,v 1.8 2005/04/14 14:59:48 rocket Exp $
 
 """
 builder class for the tinderbox target
@@ -29,8 +29,7 @@ class tinderbox_target(generic_stage_target):
        
        def set_target_path(self):
            self.settings["target_path"]=self.settings["storedir"]+"/builds/"+self.settings["target_subpath"]
-       def set_use(self):
-                   self.settings["use"]=self.settings["tinderbox/use"]
+
 def register(foo):
        foo.update({"tinderbox":tinderbox_target})
        return foo
index 20b8565309908d9beed02871327584063223b765..5ee4a0eaa71de25beab3b75ca44df6f9f79239a1 100755 (executable)
@@ -1,13 +1,14 @@
 #!/bin/bash
 # Copyright 1999-2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/targets/stage1/stage1-chroot.sh,v 1.30 2005/04/04 17:48:33 rocket Exp $
-               
+# $Header: /var/cvsroot/gentoo/src/catalyst/targets/stage1/stage1-chroot.sh,v 1.31 2005/04/14 14:59:48 rocket Exp $
+       
+
 . /tmp/chroot-functions.sh
+
 check_portage_version
 
 update_env_settings
-
 setup_gcc
 
 setup_myfeatures
@@ -21,3 +22,5 @@ export FEATURES="${clst_myfeatures}"
 
 ## START BUILD
 run_emerge "--noreplace ${clst_buildpkgs}"
+
+
index 65dcee1baeefb4b1659af0fa27b79755c5dc6e47..5a2de7fbaa5b45ba6285d805ef913be7bf8a6407 100755 (executable)
@@ -1,7 +1,8 @@
 #!/bin/bash
 # Copyright 1999-2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/targets/stage1/stage1-controller.sh,v 1.1 2005/04/04 17:48:33 rocket Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/targets/stage1/stage1-controller.sh,v 1.2 2005/04/14 14:59:48 rocket Exp $
+
 . ${clst_sharedir}/targets/support/functions.sh
 
 case $1 in
index b1fdc6ecc4ce4f600b62a5f0eef8e863847b0f48..f12f7d1acb96d9cc822857e19ef455e31b5b3f1a 100755 (executable)
@@ -1,18 +1,14 @@
 #!/bin/bash
 # Copyright 1999-2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/targets/stage1/stage1-preclean-chroot.sh,v 1.3 2005/04/06 23:23:57 rocket Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/targets/stage1/stage1-preclean-chroot.sh,v 1.4 2005/04/14 14:59:48 rocket Exp $
 
 . /tmp/chroot-functions.sh
 
 # now, some finishing touches to initialize gcc-config....
 unset ROOT
 
-if [ -x /usr/bin/gcc-config ]
-then
-        mythang=$( cd /etc/env.d/gcc; ls ${clst_CHOST}-* | head -n 1 )
-        gcc-config ${mythang}; update_env_settings
-fi
+setup_gcc
                
 # stage1 is not going to have anything in zoneinfo, so save our Factory timezone
 if [ -d /usr/share/zoneinfo ] ; then
index b197688a078dffb8dd507c9bce41f505ebe40556..c41e8b8c4e416a9793bbcf2835dcc257abd7d57f 100755 (executable)
@@ -1,3 +1,20 @@
+
+# Trap these signals and kill ourselves if recieved
+# Force ourselves to die if any of these signals are recieved
+# most likely our controlling terminal is gone
+trap "echo SIGTERM signal recieved killing $0 with pid $$;kill -9 $$" SIGTERM
+trap "echo SIGHUP signal recieved killing $0 with pid $$;kill -9 $$" SIGHUP
+trap "echo SIGKILL signal recieved killing $0 with pid $$;kill -9 $$" SIGKILL
+
+#SIGINT           interrupt character (usually Ctrl-C)
+#      * example: high-level sequence of events
+#      * my process (call it "P") is running
+#      * user types ctrl-c
+#      * kernel recognizes this and generates SIGINT signal
+trap "echo SIGINT signal recieved killing $0 with pid $$;kill -9 $$" SIGINT
+       
+
 check_portage_version(){
        portage_version=`/usr/lib/portage/bin/portageq best_version / sys-apps/portage \
                | cut -d/ -f2 | cut -d- -f2,3`
@@ -82,9 +99,8 @@ setup_portage(){
 setup_gcc(){
        if [ -x /usr/bin/gcc-config ]
        then
-              gcc_current=`gcc-config -c`
-              gcc-config 3 && source /etc/profile
-              gcc-config ${gcc_current} && source /etc/profile
+               mythang=$( cd /etc/env.d/gcc; ls ${clst_CHOST}-* | head -n 1 )
+               gcc-config ${mythang}; update_env_settings
        fi
 }