3 Builder class for a LiveCD stage2 build.
6 import os,string,types,stat,shutil
7 from catalyst_support import *
8 from generic_stage_target import *
10 class livecd_stage2_target(generic_stage_target):
11 def __init__(self,spec,addlargs):
12 self.required_values=["boot/kernel"]
16 self.valid_values.extend(self.required_values)
17 self.valid_values.extend(["livecd/cdtar","livecd/empty","livecd/rm",\
18 "livecd/unmerge","livecd/iso","livecd/gk_mainargs","livecd/type",\
19 "livecd/readme","livecd/motd","livecd/overlay",\
20 "livecd/modblacklist","livecd/splash_theme","livecd/splash_type",\
21 "livecd/rcadd","livecd/rcdel","livecd/fsscript","livecd/xinitrc",\
22 "livecd/root_overlay","livecd/devmanager","livecd/users",\
23 "portage_overlay","livecd/cdfstype","livecd/fstype","livecd/fsops",\
24 "livecd/linuxrc","livecd/bootargs","gamecd/conf","livecd/xdm",\
25 "livecd/xsession","livecd/volid"])
27 generic_stage_target.__init__(self,spec,addlargs)
28 if not self.settings.has_key("livecd/type"):
29 self.settings["livecd/type"] = "generic-livecd"
31 if self.settings.has_key("livecd/splash_type"):
32 print "Using livecd/splash_type is deprecated as we no longer support bootsplash."
34 file_locate(self.settings, ["cdtar","controller_file"])
36 def set_source_path(self):
37 self.settings["source_path"]=normpath(self.settings["storedir"]+"/builds/"+self.settings["source_subpath"]+".tar.bz2")
38 if os.path.isfile(self.settings["source_path"]):
39 self.settings["source_path_hash"]=generate_hash(self.settings["source_path"])
41 self.settings["source_path"]=normpath(self.settings["storedir"]+"/tmp/"+self.settings["source_subpath"]+"/")
42 if not os.path.exists(self.settings["source_path"]):
43 raise CatalystError,"Source Path: "+self.settings["source_path"]+" does not exist."
45 def set_spec_prefix(self):
46 self.settings["spec_prefix"]="livecd"
48 def set_target_path(self):
49 self.settings["target_path"]=normpath(self.settings["storedir"]+"/builds/"+self.settings["target_subpath"]+"/")
50 if self.settings.has_key("AUTORESUME") \
51 and os.path.exists(self.settings["autoresume_path"]+"setup_target_path"):
52 print "Resume point detected, skipping target path setup operation..."
54 # first clean up any existing target stuff
55 if os.path.isdir(self.settings["target_path"]):
56 cmd("rm -rf "+self.settings["target_path"],
57 "Could not remove existing directory: "+self.settings["target_path"],env=self.env)
58 touch(self.settings["autoresume_path"]+"setup_target_path")
59 if not os.path.exists(self.settings["target_path"]):
60 os.makedirs(self.settings["target_path"])
63 # what modules do we want to blacklist?
64 if self.settings.has_key("livecd/modblacklist"):
66 myf=open(self.settings["chroot_path"]+"/etc/hotplug/blacklist","a")
69 raise CatalystError,"Couldn't open "+self.settings["chroot_path"]+"/etc/hotplug/blacklist."
71 myf.write("\n#Added by Catalyst:")
72 for x in self.settings["livecd/modblacklist"]:
80 clst_unpack_hash=read_from_clst(self.settings["autoresume_path"]+"unpack")
82 if os.path.isdir(self.settings["source_path"]):
83 unpack_cmd="rsync -a --delete "+self.settings["source_path"]+" "+self.settings["chroot_path"]
84 display_msg="\nStarting rsync from "+self.settings["source_path"]+"\nto "+\
85 self.settings["chroot_path"]+" (This may take some time) ...\n"
86 error_msg="Rsync of "+self.settings["source_path"]+" to "+self.settings["chroot_path"]+" failed."
87 invalid_snapshot=False
89 if self.settings.has_key("AUTORESUME"):
90 if os.path.isdir(self.settings["source_path"]) and \
91 os.path.exists(self.settings["autoresume_path"]+"unpack"):
92 print "Resume point detected, skipping unpack operation..."
94 elif self.settings.has_key("source_path_hash"):
95 if self.settings["source_path_hash"] != clst_unpack_hash:
99 self.mount_safety_check()
101 print "No Valid Resume point detected, cleaning up ..."
102 #os.remove(self.settings["autoresume_path"]+"dir_setup")
103 self.clear_autoresume()
107 if not os.path.exists(self.settings["chroot_path"]):
108 os.makedirs(self.settings["chroot_path"])
110 if not os.path.exists(self.settings["chroot_path"]+"/tmp"):
111 os.makedirs(self.settings["chroot_path"]+"/tmp",1777)
113 if self.settings.has_key("PKGCACHE"):
114 if not os.path.exists(self.settings["pkgcache_path"]):
115 os.makedirs(self.settings["pkgcache_path"],0755)
118 raise CatalystError,"Could not find appropriate source. Please check the 'source_subpath' setting in the spec file."
121 cmd(unpack_cmd,error_msg,env=self.env)
123 if self.settings.has_key("source_path_hash"):
124 myf=open(self.settings["autoresume_path"]+"unpack","w")
125 myf.write(self.settings["source_path_hash"])
128 touch(self.settings["autoresume_path"]+"unpack")
130 def set_action_sequence(self):
131 self.settings["action_sequence"]=["unpack","unpack_snapshot",\
132 "config_profile_link","setup_confdir","portage_overlay",\
133 "bind","chroot_setup","setup_environment","run_local",\
135 if not self.settings.has_key("FETCH"):
136 self.settings["action_sequence"] += ["bootloader","preclean",\
137 "livecd_update","root_overlay","fsscript","rcupdate","unmerge",\
138 "unbind","remove","empty","target_setup",\
139 "setup_overlay","create_iso"]
140 self.settings["action_sequence"].append("clear_autoresume")
143 foo.update({"livecd-stage2":livecd_stage2_target})