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/rcadd",\
21 "livecd/rcdel","livecd/fsscript","livecd/xinitrc",\
22 "livecd/root_overlay","livecd/users","portage_overlay",\
23 "livecd/fstype","livecd/fsops","livecd/linuxrc","livecd/bootargs",\
24 "gamecd/conf","livecd/xdm","livecd/xsession","livecd/volid"])
26 generic_stage_target.__init__(self,spec,addlargs)
27 if not self.settings.has_key("livecd/type"):
28 self.settings["livecd/type"] = "generic-livecd"
30 file_locate(self.settings, ["cdtar","controller_file"])
32 def set_source_path(self):
33 self.settings["source_path"]=normpath(self.settings["storedir"]+"/builds/"+self.settings["source_subpath"]+".tar.bz2")
34 if os.path.isfile(self.settings["source_path"]):
35 self.settings["source_path_hash"]=generate_hash(self.settings["source_path"])
37 self.settings["source_path"]=normpath(self.settings["storedir"]+"/tmp/"+self.settings["source_subpath"]+"/")
38 if not os.path.exists(self.settings["source_path"]):
39 raise CatalystError,"Source Path: "+self.settings["source_path"]+" does not exist."
41 def set_spec_prefix(self):
42 self.settings["spec_prefix"]="livecd"
44 def set_target_path(self):
45 self.settings["target_path"]=normpath(self.settings["storedir"]+"/builds/"+self.settings["target_subpath"]+"/")
46 if self.settings.has_key("AUTORESUME") \
47 and os.path.exists(self.settings["autoresume_path"]+"setup_target_path"):
48 print "Resume point detected, skipping target path setup operation..."
50 # first clean up any existing target stuff
51 if os.path.isdir(self.settings["target_path"]):
52 cmd("rm -rf "+self.settings["target_path"],
53 "Could not remove existing directory: "+self.settings["target_path"],env=self.env)
54 touch(self.settings["autoresume_path"]+"setup_target_path")
55 if not os.path.exists(self.settings["target_path"]):
56 os.makedirs(self.settings["target_path"])
59 # what modules do we want to blacklist?
60 if self.settings.has_key("livecd/modblacklist"):
62 myf=open(self.settings["chroot_path"]+"/etc/modprobe.d/blacklist.conf","a")
65 raise CatalystError,"Couldn't open "+self.settings["chroot_path"]+"/etc/modprobe.d/blacklist.conf."
67 myf.write("\n#Added by Catalyst:")
68 for x in self.settings["livecd/modblacklist"]:
69 myf.write("\nblacklist "+x)
76 clst_unpack_hash=read_from_clst(self.settings["autoresume_path"]+"unpack")
78 if os.path.isdir(self.settings["source_path"]):
79 unpack_cmd="rsync -a --delete "+self.settings["source_path"]+" "+self.settings["chroot_path"]
80 display_msg="\nStarting rsync from "+self.settings["source_path"]+"\nto "+\
81 self.settings["chroot_path"]+" (This may take some time) ...\n"
82 error_msg="Rsync of "+self.settings["source_path"]+" to "+self.settings["chroot_path"]+" failed."
83 invalid_snapshot=False
85 if self.settings.has_key("AUTORESUME"):
86 if os.path.isdir(self.settings["source_path"]) and \
87 os.path.exists(self.settings["autoresume_path"]+"unpack"):
88 print "Resume point detected, skipping unpack operation..."
90 elif self.settings.has_key("source_path_hash"):
91 if self.settings["source_path_hash"] != clst_unpack_hash:
95 self.mount_safety_check()
97 print "No Valid Resume point detected, cleaning up ..."
98 #os.remove(self.settings["autoresume_path"]+"dir_setup")
99 self.clear_autoresume()
103 if not os.path.exists(self.settings["chroot_path"]):
104 os.makedirs(self.settings["chroot_path"])
106 if not os.path.exists(self.settings["chroot_path"]+"/tmp"):
107 os.makedirs(self.settings["chroot_path"]+"/tmp",1777)
109 if self.settings.has_key("PKGCACHE"):
110 if not os.path.exists(self.settings["pkgcache_path"]):
111 os.makedirs(self.settings["pkgcache_path"],0755)
114 raise CatalystError,"Could not find appropriate source. Please check the 'source_subpath' setting in the spec file."
117 cmd(unpack_cmd,error_msg,env=self.env)
119 if self.settings.has_key("source_path_hash"):
120 myf=open(self.settings["autoresume_path"]+"unpack","w")
121 myf.write(self.settings["source_path_hash"])
124 touch(self.settings["autoresume_path"]+"unpack")
126 def set_action_sequence(self):
127 self.settings["action_sequence"]=["unpack","unpack_snapshot",\
128 "config_profile_link","setup_confdir","portage_overlay",\
129 "bind","chroot_setup","setup_environment","run_local",\
131 if not self.settings.has_key("FETCH"):
132 self.settings["action_sequence"] += ["bootloader","preclean",\
133 "livecd_update","root_overlay","fsscript","rcupdate","unmerge",\
134 "unbind","remove","empty","target_setup",\
135 "setup_overlay","create_iso"]
136 self.settings["action_sequence"].append("clear_autoresume")
139 foo.update({"livecd-stage2":livecd_stage2_target})