tidying of the resume code.
authorJohn P. Davis <zhen@gentoo.org>
Tue, 6 Jul 2004 13:48:00 +0000 (13:48 +0000)
committerJohn P. Davis <zhen@gentoo.org>
Tue, 6 Jul 2004 13:48:00 +0000 (13:48 +0000)
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/catalyst/trunk@403 d1e1f19c-881f-0410-ab34-b69fee027534

modules/generic_stage_target.py
modules/livecd_stage2_target.py

index 6d2584a9b582c158c8a128c51cf105c04dc4ad2e..cce1606283b6c01a7653267742ee7c8e24abe91a 100644 (file)
@@ -1,6 +1,6 @@
 # Distributed under the GNU General Public License version 2
 # Copyright 2003-2004 Gentoo Technologies, Inc.
-# $Header: /var/cvsroot/gentoo/src/catalyst/modules/generic_stage_target.py,v 1.5 2004/07/03 00:33:37 zhen Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/generic_stage_target.py,v 1.6 2004/07/06 13:48:00 zhen Exp $
 
 """
 This class does all of the chroot setup, copying of files, etc. It is
@@ -181,23 +181,28 @@ class generic_stage_target(generic_target):
                print "Setting up directories..."
                self.mount_safety_check()
                if self.settings.has_key("AUTORESUME") \
-                       and os.path.exists(self.settings["chroot_path"]+"/tmp/unpacked"):
-                       print "Directories previously setup, resuming..."
+                       and os.path.exists(self.settings["chroot_path"]+"/tmp/.clst_dir_setup"):
+                       print "Resume point detected, skipping directory setup..."
                
                else:
                        cmd("rm -rf "+self.settings["chroot_path"],\
                                "Could not remove existing directory: "+self.settings["chroot_path"])
-
+                       
+                       if not os.path.exists(self.settings["chroot_path"]+"/tmp"):
+                               os.makedirs(self.settings["chroot_path"]+"/tmp")
+                               touch(self.settings["chroot_path"]+"/tmp/.clst_dir_setup")
+                       
                if not os.path.exists(self.settings["chroot_path"]):
                        os.makedirs(self.settings["chroot_path"])
                
                if self.settings.has_key("PKGCACHE"):   
                        if not os.path.exists(self.settings["pkgcache_path"]):
                                os.makedirs(self.settings["pkgcache_path"])
-                                       
+       
+               
        def unpack_and_bind(self):
                if self.settings.has_key("AUTORESUME") \
-                       and os.path.exists(self.settings["chroot_path"]+"/tmp/unpacked"):
+                       and os.path.exists(self.settings["chroot_path"]+"/tmp/.clst_unpack_and_bind"):
                        print "Resume point detected, skipping unpack and bind operation..."
                
                else:
@@ -214,7 +219,7 @@ class generic_stage_target(generic_target):
                        cmd("tar xjpf "+self.settings["snapshot_path"]+" -C "+\
                                self.settings["chroot_path"]+"/usr","Error unpacking snapshot")
                        
-                       touch(self.settings["chroot_path"]+"/tmp/.unpack_and_bind")
+                       touch(self.settings["chroot_path"]+"/tmp/.clst_unpack_and_bind")
 
                # for safety's sake, we really don't want to resume these either                
                print "Configuring profile link..."
@@ -411,6 +416,12 @@ class generic_stage_target(generic_target):
                # now make sure path exists
                if not os.path.exists(mypath):
                        os.makedirs(mypath)
+
+               # clean resume points since they are no longer needed
+               if self.settings.has_key("AUTORESUME"):
+                       cmd("rm -f "+self.settings["chroot_path"]+"/tmp/.clst*",\
+                               "Couldn't remove resume points")
+                       
                print "Creating stage tarball..."
                
                if self.settings["target"]=="stage1":
index 5b8a8cefb35237cfe2ef50b8d5f5c908ad050b40..75f414e09dff75f15a45597c7e7b499e3b587970 100644 (file)
@@ -1,6 +1,6 @@
 # Distributed under the GNU General Public License version 2
 # Copyright 2003-2004 Gentoo Technologies, Inc.
-# $Header: /var/cvsroot/gentoo/src/catalyst/modules/livecd_stage2_target.py,v 1.11 2004/07/03 00:33:37 zhen Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/livecd_stage2_target.py,v 1.12 2004/07/06 13:48:00 zhen Exp $
 
 """
 Builder class for a LiveCD stage2 build.
@@ -46,8 +46,8 @@ class livecd_stage2_target(generic_stage_target):
        
        def unpack_and_bind(self):
                if self.settings.has_key("AUTORESUME") \
-                       and os.path.exists(self.settings["cdroot_path"]+"/tmp/.unpack_and_bind"):
-                       print "Detected resume point, skipping unpack and bind operation..."
+                       and os.path.exists(self.settings["cdroot_path"]+"/tmp/.clst_unpack_and_bind"):
+                       print "Resume point detected, skipping unpack and bind operation..."
                
                else:
                        if os.path.exists(self.settings["chroot_path"]):
@@ -58,7 +58,7 @@ class livecd_stage2_target(generic_stage_target):
                        print "Copying livecd-stage1 result to new livecd-stage2 work directory..."
                        cmd("cp -a "+self.settings["source_path"]+"/* "+self.settings["chroot_path"],
                                "Error copying initial livecd-stage2")
-                       touch(self.settings["chroot_path"]+"/tmp/.unpack_and_bind")
+                       touch(self.settings["chroot_path"]+"/tmp/.clst_unpack_and_bind")
        
                # we do not want to resume code below this line
                print "Configuring profile link..."
@@ -85,8 +85,8 @@ class livecd_stage2_target(generic_stage_target):
                        
        def unmerge(self):
                if self.settings.has_key("AUTORESUME") \
-                       and os.path.exists(self.settings["chroot_path"]+"/tmp/unmerge"):
-                       print "Detected resume point, skipping unmerge operation..."
+                       and os.path.exists(self.settings["chroot_path"]+"/tmp/.clst_unmerge"):
+                       print "Resume point detected, skipping unmerge operation..."
                
                else:
                        if self.settings.has_key("livecd/unmerge"):
@@ -108,51 +108,37 @@ class livecd_stage2_target(generic_stage_target):
                                except CatalystError:
                                        self.unbind()
                                        raise
-                               touch(self.settings["chroot_path"]+"/tmp/unmerge")
+                               touch(self.settings["chroot_path"]+"/tmp/.clst_unmerge")
 
        def clean(self):
-               if self.settings.has_key("AUTORESUME") \
-                       and os.path.exists(self.settings["chroot_path"]+"/tmp/.clean"):
-                       print "Detected resume point, skipping clean operation..."
-               
-               else:
-                       generic_stage_target.clean(self)
-                       try:
-                               cmd("/bin/bash "+self.settings["livecd/runscript"]+" clean",\
-                                       "Clean runscript failed.")
-                       except:
-                               self.unbind()
-                               raise
-                       touch(self.settings["chroot_path"]+"/tmp/.clean")
+               try:
+                       cmd("/bin/bash "+self.settings["livecd/runscript"]+" clean",\
+                               "Clean runscript failed.")
+               except:
+                       self.unbind()
+                       raise
 
        def preclean(self):
-               if self.settings.has_key("AUTORESUME") \
-                       and os.path.exists(self.settings["chroot_path"]+"/tmp/.preclean"):
-                       print "Detected resume point, skipping preclean operation..."
-               
-               else:
-                       try:
-                               cmd("/bin/bash "+self.settings["livecd/runscript"]+" preclean",
-                                       "Preclean runscript failed.")
-                       
-                       except:
-                               self.unbind()
-                               raise
-                       touch(self.settings["chroot_path"]+"/tmp/.preclean")
+               try:
+                       cmd("/bin/bash "+self.settings["livecd/runscript"]+" preclean",\
+                               "Preclean runscript failed.")
+       
+               except:
+                       self.unbind()
+                       raise
 
        def cdroot_setup(self):
-               if self.settings.has_key("AUTORESUME") \
-                       and os.path.exists(self.settings["chroot_path"]+"/tmp/.cdroot_setup"):
-                       print "Detected resume point, skipping cdroot setup..."
-               
-               else:
-                       cmd("/bin/bash "+self.settings["livecd/runscript"]+" cdfs","CDFS runscript failed.")
-                       if self.settings.has_key("livecd/overlay"):
-                               cmd("/bin/cp -a "+self.settings["livecd/overlay"]+"/* "+\
-                                       self.settings["cdroot_path"],"LiveCD overlay copy failed.")
-                                       
-                       touch(self.settings["chroot_path"]+"/tmp/.cdroot_setup")
+               cmd("/bin/bash "+self.settings["livecd/runscript"]+" cdfs","CDFS runscript failed.")
                
+               if self.settings.has_key("livecd/overlay"):
+                       cmd("/bin/cp -a "+self.settings["livecd/overlay"]+"/* "+\
+                       self.settings["cdroot_path"],"LiveCD 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")
+       
                # create the ISO - this is the preferred method (the iso scripts do not always work)
                if self.settings.has_key("livecd/iso"):
                        cmd("/bin/bash "+self.settings["livecd/runscript"]+" iso "+\
@@ -247,8 +233,8 @@ class livecd_stage2_target(generic_stage_target):
                # first clean up any existing cdroot stuff
                # unless of course we are resuming
                if self.settings.has_key("AUTORESUME") \
-                       and os.path.exists(self.settings["chroot_path"]+"/tmp/.run_local_cdroot_clean"):
-                       print "Detected resume point, not cleaning cdroot_path..."
+                       and os.path.exists(self.settings["chroot_path"]+"/tmp/.clst_run_local_cdroot_clean"):
+                       print "Resume point detected, not cleaning cdroot_path..."
                
                else:
                        if os.path.exists(self.settings["cdroot_path"]):
@@ -257,26 +243,26 @@ class livecd_stage2_target(generic_stage_target):
                                        "Could not remove existing directory: "+self.settings["cdroot_path"])
                        else:
                                os.makedirs(self.settings["cdroot_path"])
-                               touch(self.settings["chroot_path"]+"/tmp/.run_local_cdroot_clean")
+                               touch(self.settings["chroot_path"]+"/tmp/.clst_run_local_cdroot_clean")
                                
                # the runscripts do the real building, so execute them now
                # this is the part that we want to resume on since it is the most time consuming
                try:
                        if self.settings.has_key("AUTORESUME") \
-                               and os.path.exists(self.settings["chroot_path"]+"/tmp/.run_local_kernel_script"):
+                               and os.path.exists(self.settings["chroot_path"]+"/tmp/.clst_run_local_kernel_script"):
                                print "Resume point detected, skipping kernel build runscript..."
                        
                        else:
                                self.build_kernel()
-                               touch(self.settings["chroot_path"]+"/tmp/.run_local_kernel_script")
+                               touch(self.settings["chroot_path"]+"/tmp/.clst_run_local_kernel_script")
                        
                        if self.settings.has_key("AUTORESUME") \
-                               and os.path.exists(self.settings["chroot_path"]+"/tmp/.run_local_bootloader_script"):
+                               and os.path.exists(self.settings["chroot_path"]+"/tmp/.clst_run_local_bootloader_script"):
                                print "Resume point detected, skipping bootloader runscript..."
                        
                        else:
                                cmd("/bin/bash "+self.settings["livecd/runscript"]+" bootloader","Bootloader runscript failed.")
-                               touch(self.settings["chroot_path"]+"/tmp/.run_local_bootloader_script")
+                               touch(self.settings["chroot_path"]+"/tmp/.clst_run_local_bootloader_script")
                
                except CatalystError:
                        self.unbind()
@@ -284,7 +270,7 @@ class livecd_stage2_target(generic_stage_target):
 
                # what modules do we want to blacklist?
                if self.settings.has_key("AUTORESUME") \
-                               and os.path.exists(self.settings["chroot_path"]+"/tmp/.run_local_blacklist"):
+                               and os.path.exists(self.settings["chroot_path"]+"/tmp/.clst_run_local_blacklist"):
                                print "Resume point detected, skipping module blacklisting..."
                
                else:
@@ -298,7 +284,7 @@ class livecd_stage2_target(generic_stage_target):
                                for x in self.settings["livecd/modblacklist"]:
                                        myf.write("\n"+x)
                                myf.close()
-                       touch(self.settings["chroot_path"]+"/tmp/.run_local_blacklist")
+                       touch(self.settings["chroot_path"]+"/tmp/.clst_run_local_blacklist")
 
 def register(foo):
        foo.update({"livecd-stage2":livecd_stage2_target})