/[gli]/branches/overhaul/src/GLIArchitectureTemplate.py
Gentoo

Contents of /branches/overhaul/src/GLIArchitectureTemplate.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1674 - (show annotations) (download) (as text)
Tue Jan 30 03:37:35 2007 UTC (7 years, 9 months ago) by agaffney
File MIME type: text/x-python
File size: 67478 byte(s)
grp_install parameter passed to emerge() and get_deps()
1 """
2 # Copyright 1999-2005 Gentoo Foundation
3 # This source code is distributed under the terms of version 2 of the GNU
4 # General Public License as published by the Free Software Foundation, a copy
5 # of which can be found in the main directory of this project.
6 Gentoo Linux Installer
7
8 $Id: GLIArchitectureTemplate.py,v 1.297 2006/09/15 16:37:11 agaffney Exp $
9
10 The ArchitectureTemplate is largely meant to be an abstract class and an
11 interface (yes, it is both at the same time!). The purpose of this is to create
12 subclasses that populate all the methods with working methods for that architecture.
13 The only definitions that are filled in here are architecture independent.
14
15 """
16
17 import GLIUtility, GLILogger, os, string, sys, shutil, re, time
18 import GLIPortage
19 from GLIException import *
20 import Partitioning
21
22 MEGABYTE = 1024 * 1024
23 LOGFILE = '/var/log/installer.log'
24 COMPILE_LOGFILE = '/tmp/compile_output.log'
25
26 class ArchitectureTemplate:
27 ##
28 # Initialization of the ArchitectureTemplate. Called from some other arch template.
29 # @param install_profile=None An Install Profile
30 # @param client_controller=None Client Controller. not same as configuration.
31 def __init__(self,install_profile=None, client_controller=None):
32 self._install_profile = install_profile
33 self._cc = client_controller
34
35 # This will get used a lot, so it's probably
36 # better to store it in a variable than to call
37 # this method 100000 times.
38 self._chroot_dir = self._install_profile.get_root_mount_point()
39 self._logger = GLILogger.Logger(LOGFILE)
40 self._compile_logfile = COMPILE_LOGFILE
41 self._debug = self._install_profile.get_verbose()
42
43 self._portage = GLIPortage.GLIPortage(self._chroot_dir, self._logger, self._debug, self._cc, self._compile_logfile)
44
45 # This will cleanup the logfile if it's a dead link (pointing
46 # to the chroot logfile when partitions aren't mounted, else
47 # no action needs to be taken
48
49 if os.path.islink(self._compile_logfile) and not os.path.exists(self._compile_logfile):
50 os.unlink(self._compile_logfile)
51
52 # cache the list of successfully mounted devices and swap devices here
53 self._mounted_devices = []
54 self._swap_devices = []
55
56 # These must be filled in by the subclass. _steps is a list of
57 # functions, that will carry out the installation. They must be
58 # in order.
59 #
60 # For example, self._steps might be: [preinstall, stage1, stage2, stage3, postinstall],
61 # where each entry is a function (with no arguments) that carries out the desired actions.
62 # Of course, steps will be different depending on the install_profile
63
64 self._architecture_name = "generic"
65 self._install_steps = {
66 'mount_local_partitions': "Mount local partitions",
67 'mount_network_shares': "Mount network (NFS) shares",
68 'unpack_stage_tarball': "Unpack stage tarball",
69 'update_config_files': "Updating config files",
70 'configure_make_conf': "Configure /etc/make.conf",
71 'prepare_chroot': "Preparing chroot",
72 'install_portage_tree': "Syncing the Portage tree",
73 'stage1': "Performing bootstrap",
74 'stage2': "Performing 'emerge system'",
75 'set_root_password': "Set the root password",
76 'set_timezone': "Setting timezone",
77 'emerge_kernel_sources': "Emerge kernel sources",
78 'build_kernel': "Building kernel",
79 'install_distcc': "Install distcc",
80 'install_mta': "Installing MTA",
81 'install_logging_daemon': "Installing system logger",
82 'install_cron_daemon': "Installing Cron daemon",
83 'install_filesystem_tools': "Installing filesystem tools",
84 'setup_network_post': "Configuring post-install networking",
85 'install_bootloader': "Configuring and installing bootloader",
86 'setup_and_run_bootloader': "Setting up and running bootloader",
87 # 'update_config_files': "Re-Updating config files", #second run.
88 'set_users': "Add additional users.",
89 'install_packages': "Installing additional packages.",
90 # services for startup need to come after installing extra packages
91 # otherwise some of the scripts will not exist.
92 'set_services': "Setting up services for startup",
93 'run_post_install_script': "Running custom post-install script",
94 'finishing_cleanup': "Cleanup and unmounting local filesystems.",
95 'install_failed_cleanup': "Cleaning up after a failed install"
96 }
97
98 ##
99 # Returns the steps and their comments in an array
100 def get_install_steps(self):
101 return self._install_steps
102
103 ##
104 # Tells the frontend something
105 # @param type type of data
106 # @param data the data itself. usually a number.
107 def notify_frontend(self, type, data):
108 self._cc.addNotification(type, data)
109
110 # It is possible to override these methods in each Arch Template.
111 # It might be necessary to do so, if the arch needs something 'weird'.
112
113 ######################## Private Functions ########################
114 ##
115 # Private function to add a /etc/init.d/ script to the given runlevel in the chroot environement
116 # @param script_name the script to be added
117 # @param runlevel="default" the runlevel to add to
118 def _add_to_runlevel(self, script_name, runlevel="default"):
119 if not GLIUtility.is_file(self._chroot_dir + '/etc/init.d/' + script_name):
120 #raise GLIException("RunlevelAddError", 'fatal', '_add_to_runlevel', "Failure adding " + script_name + " to runlevel " + runlevel + "!")
121 #This is not a fatal error. If the init script is important it will exist.
122 self._logger.log("ERROR! Failure adding " + script_name + " to runlevel " + runlevel + " because it was not found!")
123 if self._debug: self._logger.log("DEBUG: running rc-update add " + script_name + " " + runlevel + " in chroot.")
124 status = GLIUtility.spawn("rc-update add " + script_name + " " + runlevel, display_on_tty8=True, chroot=self._chroot_dir, logfile=self._compile_logfile, append_log=True)
125 if not GLIUtility.exitsuccess(status):
126 #raise GLIException("RunlevelAddError", 'fatal', '_add_to_runlevel', "Failure adding " + script_name + " to runlevel " + runlevel + "!")
127 #Again, an error here will not prevent a new system from booting. But it is important to log the error.
128 self._logger.log("ERROR! Could not add " + script_name + " to runlevel " + runlevel + ". returned a bad status code.")
129 else:
130 self._logger.log("Added "+script_name+" to runlevel "+runlevel)
131
132 ##
133 # Private Function. Will return a list of packages to be emerged for a given command. Not yet used.
134 # @param cmd full command to run ('/usr/portage/scripts/bootstrap.sh --pretend' or 'emerge -p system')
135 def _get_packages_to_emerge(self, cmd):
136 if self._debug: self._logger.log("DEBUG: _get_packages_to_emerge() called with '%s'" % cmd)
137 return GLIUtility.spawn(cmd + r" 2>/dev/null | grep -e '\[ebuild' | sed -e 's:\[ebuild .\+ \] ::' -e 's: \[.\+\] ::' -e 's: \+$::'", chroot=self._chroot_dir, return_output=True)[1].strip().split("\n")
138
139 ##
140 # Private Function. Will emerge a given package in the chroot environment.
141 # @param package package to be emerged
142 # @param binary=False defines whether to try a binary emerge (if GRP this gets ignored either way)
143 # @param binary_only=False defines whether to only allow binary emerges.
144 def _emerge(self, package, binary=True, binary_only=False):
145 #Error checking of this function is to be handled by the parent function.
146 # self._logger.log("_emerge() called with: package='%s', binary='%s', binary_only='%s', grp_install='%s'" % (package, str(binary), str(binary_only), str(self._install_profile.get_grp_install())))
147 # now short-circuit for GRP
148 if self._install_profile.get_grp_install():
149 cmd="emerge -k " + package
150 # now normal installs
151 else:
152 if binary_only:
153 cmd="emerge -K " + package
154 elif binary:
155 cmd="emerge -k " + package
156 else:
157 cmd="emerge " + package
158
159 self._logger.log("Calling emerge: "+cmd)
160 return GLIUtility.spawn(cmd, display_on_tty8=True, chroot=self._chroot_dir, logfile=self._compile_logfile, append_log=True)
161
162 ##
163 # Private Function. Will edit a config file and insert a value or two overwriting the previous value
164 # (actually it only just comments out the old one)
165 # @param filename file to be edited
166 # @param newvalues a dictionary of VARIABLE:VALUE pairs
167 # @param delimeter='=' what is between the key and the value
168 # @param quotes_around_value=True whether there are quotes around the value or not (ex. "local" vs. localhost)
169 # @param only_value=False Ignore the keys and output only a value.
170 # @param create_file=True Create the file if it does not exist.
171 def _edit_config(self, filename, newvalues, delimeter='=', quotes_around_value=True, only_value=False,create_file=True):
172 # don't use 'file' as a normal variable as it conflicts with the __builtin__.file
173 newvalues = newvalues.copy()
174 if self._debug: self._logger.log("DEBUG: _edit_config() called with " + str(newvalues)+" and flags: "+delimeter + "quotes: "+str(quotes_around_value)+" value: "+str(only_value))
175 if GLIUtility.is_file(filename):
176 f = open(filename)
177 contents = f.readlines()
178 f.close()
179 elif create_file:
180 contents = []
181 else:
182 raise GLIException("NoSuchFileError", 'notice','_edit_config',filename + ' does not exist!')
183
184 for key in newvalues.keys():
185 newline = ""
186 if key == "SPACER":
187 newline = "\n"
188 elif key == "COMMENT":
189 newline = '# ' + newvalues[key] + "\n"
190 elif newvalues[key] == "##comment##" or newvalues[key] == "##commented##":
191 newline = '#' + key + delimeter + '""' + "\n"
192 else:
193 if quotes_around_value:
194 newvalues[key] = '"' + newvalues[key] + '"'
195 #Only the printing of values is required.
196 if only_value:
197 newline = newvalues[key] + "\n"
198 else:
199 newline = key + delimeter + newvalues[key] + "\n"
200 add_at_line = len(contents)
201 for i in range(len(contents)):
202 if newline == contents[i]:
203 break
204 if contents[i].startswith(key + delimeter):
205 contents[i] = "#" + contents[i]
206 add_at_line = i + 1
207 else:
208 contents.insert(add_at_line, newline)
209 if self._debug: self._logger.log("DEBUG: Contents of file "+filename+": "+str(contents))
210 f = open(filename,'w')
211 f.writelines(contents)
212 f.flush()
213 f.close()
214 self._logger.log("Edited Config file "+filename)
215
216 ##
217 # Configures /etc/fstab on the new envorinment
218 def _configure_fstab(self):
219 newfstab = ""
220 mounts = self._install_profile.get_mounts()
221 for mount in mounts:
222 if mount['type'] == "linux-swap":
223 newfstab += mount['devnode']+"\t none swap sw 0 0\n"
224 continue #Stop here and move on.
225 if not mount['mountopts'].strip(): mount['mountopts'] = "defaults"
226 if mount['mountpoint']:
227 if not GLIUtility.is_file(self._chroot_dir+mount['mountpoint']):
228 if self._debug: self._logger.log("DEBUG: making mountpoint: "+mount['mountpoint'])
229 exitstatus = GLIUtility.spawn("mkdir -p " + self._chroot_dir + mount['mountpoint'])
230 if not GLIUtility.exitsuccess(exitstatus):
231 raise GLIException("MkdirError", 'fatal','configure_fstab', "Making the mount point failed!")
232 newfstab += mount['devnode']+"\t "+mount['mountpoint']+"\t "+mount['type']+"\t "+mount['mountopts']+"\t\t "
233 #Now figure out the last 2 numbers depending on the mountpoint.
234 if mount['mountpoint'] == "/boot":
235 newfstab += "1 2\n"
236 elif mount['mountpoint'] == "/":
237 newfstab += "0 1\n"
238 else:
239 newfstab += "0 0\n"
240
241 newfstab += "none /proc proc defaults 0 0\n"
242 newfstab += "none /dev/shm tmpfs defaults 0 0\n"
243 if GLIUtility.is_device("/dev/cdroms/cdrom0"):
244 newfstab += "/dev/cdroms/cdrom0 /mnt/cdrom auto noauto,user 0 0\n"
245
246 for netmount in self._install_profile.get_network_mounts():
247 if netmount['type'] == "nfs":
248 newfstab += netmount['host'] + ":" + netmount['export'] + "\t" + netmount['mountpoint'] + "\tnfs\t" + netmount['mountopts'] + "\t0 0\n"
249
250 file_name = self._chroot_dir + "/etc/fstab"
251 try:
252 if self._debug: self._logger.log("DEBUG: backing up original fstab")
253 shutil.move(file_name, file_name + ".OLDdefault")
254 except:
255 self._logger.log("ERROR: could not backup original fstab.")
256 if self._debug: self._logger.log("DEBUG: Contents of new fstab: "+newfstab)
257 f = open(file_name, 'w')
258 f.writelines(newfstab)
259 f.close()
260 self._logger.log("fstab configured.")
261
262 #####################################################################
263 #####################################################################
264 ########################## Installation Functions ###################
265 ##
266 # Will grab partition info from the profile and mount all partitions with a specified mountpoint (and swap too)
267 def mount_local_partitions(self):
268 mounts = self._install_profile.get_mounts()
269 mount_progress = 1
270 self.notify_frontend("progress", (float(mount_progress) / (len(mounts)+1), "Generating mount list"))
271 parts_to_mount = {}
272 for mount in mounts:
273 Partitioning.wait_for_device_node(mount['devnode'])
274 mountpoint = mount['mountpoint']
275 mountopts = mount['mountopts']
276 partition_type = mount['type']
277 if not mountpoint:
278 continue #Skip this. Probably should be an error. but should NEVER happen.
279 if mountopts:
280 mountopts = "-o " + mountopts + " "
281 if partition_type in ("linux-swap", "swap"):
282 mount_progress += 1
283 self.notify_frontend("progress", (float(mount_progress) / (len(mounts)+1), "Activating swap on " + mount['devnode']))
284 ret = GLIUtility.spawn("swapon " + mount['devnode'])
285 if not GLIUtility.exitsuccess(ret):
286 self._logger.log("ERROR! : Could not activate swap (" + mount['devnode'] + ")!")
287 else:
288 self._swap_devices.append(mount['devnode'])
289 continue
290 elif partition_type:
291 if partition_type == "fat32" or partition_type == "fat16":
292 partition_type = "vfat"
293 partition_type = "-t " + partition_type + " "
294 else: #Unknown partition type!!!
295 self._logger.log("ERROR! : Unknown partition type for mountpoint %s which is device %s" % (mountpoint, mount['devnode']))
296 parts_to_mount[mountpoint] = (mountopts, partition_type, mount['devnode'])
297
298 sorted_list = parts_to_mount.keys()
299 sorted_list.sort()
300
301 if not GLIUtility.is_file(self._chroot_dir):
302 if self._debug: self._logger.log("DEBUG: making the chroot dir")
303 exitstatus = GLIUtility.spawn("mkdir -p " + self._chroot_dir)
304 if not GLIUtility.exitsuccess(exitstatus):
305 raise GLIException("MkdirError", 'fatal','mount_local_partitions', "Making the ROOT mount point failed!")
306 else:
307 self._logger.log("Created root mount point")
308 for i, mountpoint in enumerate(sorted_list):
309 mountopts = parts_to_mount[mountpoint][0]
310 partition_type = parts_to_mount[mountpoint][1]
311 partition = parts_to_mount[mountpoint][2]
312 mount_progress += 1
313 self.notify_frontend("progress", (float(mount_progress) / (len(mounts)+1), "Mounting %s at %s" % (partition, mountpoint)))
314 if not GLIUtility.is_file(self._chroot_dir + mountpoint):
315 if self._debug: self._logger.log("DEBUG: making mountpoint: "+mountpoint)
316 exitstatus = GLIUtility.spawn("mkdir -p " + self._chroot_dir + mountpoint)
317 if not GLIUtility.exitsuccess(exitstatus):
318 raise GLIException("MkdirError", 'fatal','mount_local_partitions', "Making the mount point failed!")
319 else:
320 self._logger.log("Created mountpoint " + mountpoint)
321 if self._debug: self._logger.log("DEBUG: running mount "+ partition_type + mountopts + partition + " " + self._chroot_dir + mountpoint)
322 ret = GLIUtility.spawn("mount " + partition_type + mountopts + partition + " " + self._chroot_dir + mountpoint, display_on_tty8=True, logfile=self._compile_logfile, append_log=True)
323 if not GLIUtility.exitsuccess(ret):
324 raise GLIException("MountError", 'fatal','mount_local_partitions','Could not mount a partition')
325 else:
326 self._mounted_devices.append(mountpoint)
327 # double check in /proc/mounts
328 # This current code doesn't work and needs to be fixed, because there is a case that it is needed for - robbat2
329 #ret, output = GLIUtility.spawn('awk \'$2 == "%s" { print "Found" }\' /proc/mounts | head -n1' % (self._chroot_dir + mountpoint), display_on_tty8=True, return_output=True)
330 #if output.strip() != "Found":
331 # raise GLIException("MountError", 'fatal','mount_local_partitions','Could not mount a partition (failed in double-check)')
332 self._logger.log("Mounted mountpoint: " + mountpoint)
333
334 ##
335 # Mounts all network shares to the local machine
336 def mount_network_shares(self):
337 """
338 <agaffney> it'll be much easier than mount_local_partitions
339 <agaffney> make sure /etc/init.d/portmap is started
340 <agaffney> then mount each one: mount -t nfs -o <mountopts> <host>:<export> <mountpoint>
341 """
342 nfsmounts = self._install_profile.get_network_mounts()
343 for netmount in nfsmounts:
344 if netmount['type'] == "NFS" or netmount['type'] == "nfs":
345 mountopts = netmount['mountopts']
346 if mountopts:
347 mountopts = "-o " + mountopts
348 host = netmount['host']
349 export = netmount['export']
350 mountpoint = netmount['mountpoint']
351 if not GLIUtility.is_file(self._chroot_dir + mountpoint):
352 exitstatus = GLIUtility.spawn("mkdir -p " + self._chroot_dir + mountpoint)
353 if not GLIUtility.exitsuccess(exitstatus):
354 raise GLIException("MkdirError", 'fatal','mount_network_shares', "Making the mount point failed!")
355 else:
356 if self._debug: self._logger.log("DEBUG: mounting nfs mount")
357 ret = GLIUtility.spawn("mount -t nfs " + mountopts + " " + host + ":" + export + " " + self._chroot_dir + mountpoint, display_on_tty8=True, logfile=self._compile_logfile, append_log=True)
358 if not GLIUtility.exitsuccess(ret):
359 raise GLIException("MountError", 'fatal','mount_network_shares','Could not mount an NFS partition')
360 else:
361 self._logger.log("Mounted netmount at mountpoint: " + mountpoint)
362 self._mounted_devices.append(mountpoint)
363 else:
364 self._logger.log("Netmount type " + netmount['type'] + " not supported...skipping " + netmount['mountpoint'])
365
366 ##
367 # Unpacks the stage tarball that has been specified in the profile (it better be there!)
368 def unpack_stage_tarball(self):
369 if not os.path.isdir(self._chroot_dir):
370 if self._debug: self._logger.log("DEBUG: making the chroot dir:"+self._chroot_dir)
371 os.makedirs(self._chroot_dir)
372 if self._install_profile.get_install_stage() == 3 and self._install_profile.get_dynamic_stage3():
373 # stage3 generation code here
374 if not GLIUtility.is_file("/usr/livecd/systempkgs.txt"):
375 raise GLIException("CreateStage3Error", "fatal", "unpack_stage_tarball", "Required file /usr/livecd/systempkgs.txt does not exist")
376 try:
377 syspkgs = open("/usr/livecd/systempkgs.txt", "r")
378 systempkgs = syspkgs.readlines()
379 syspkgs.close()
380 except:
381 raise GLIException("CreateStage3Error", "fatal", "unpack_stage_tarball", "Could not open /usr/livecd/systempkgs.txt")
382
383 # Pre-create /lib (and possibly /lib32 and /lib64)
384 for libdir in ("/lib", "/usr/lib"):
385 if os.path.islink(libdir) and os.readlink(libdir).endswith("64"):
386 if self._debug: self._logger.log("DEBUG: unpack_stage_tarball(): precreating " + libdir + "64 dir and " + libdir + " -> lib64 symlink because glibc/portage sucks")
387 if not GLIUtility.exitsuccess(GLIUtility.spawn("mkdir -p " + self._chroot_dir + libdir + "64 && ln -sf lib64 " + self._chroot_dir + libdir)):
388 raise GLIException("CreateStage3Error", "fatal", "unpack_stage_tarball", "Could not precreate " + libdir + "64 dir and " + libdir + " -> lib64 symlink")
389
390 syspkglen = len(systempkgs)
391 for i, pkg in enumerate(systempkgs):
392 pkg = pkg.strip()
393 self.notify_frontend("progress", (float(i) / (syspkglen+1), "Copying " + pkg + " (" + str(i+1) + "/" + str(syspkglen) + ")"))
394 self._portage.copy_pkg_to_chroot(pkg, True, ignore_missing=True)
395 self.notify_frontend("progress", (float(syspkglen) / (syspkglen+1), "Finishing"))
396 GLIUtility.spawn("cp /etc/make.conf " + self._chroot_dir + "/etc/make.conf")
397 GLIUtility.spawn("ln -s `readlink /etc/make.profile` " + self._chroot_dir + "/etc/make.profile")
398 GLIUtility.spawn("cp -f /etc/inittab.old " + self._chroot_dir + "/etc/inittab")
399
400 # Nasty, nasty, nasty hack because vapier is a tool
401 for tmpfile in ("/etc/passwd", "/etc/group", "/etc/shadow"):
402 GLIUtility.spawn("grep -ve '^gentoo' " + tmpfile + " > " + self._chroot_dir + tmpfile)
403
404 chrootscript = r"""
405 #!/bin/bash
406
407 source /etc/make.conf
408 export LDPATH="/usr/lib/gcc-lib/${CHOST}/$(cd /usr/lib/gcc-lib/${CHOST} && ls -1 | head -n 1)"
409
410 ldconfig $LDPATH
411 gcc-config 1
412 env-update
413 source /etc/profile
414 modules-update
415 [ -f /usr/bin/binutils-config ] && binutils-config 1
416 source /etc/profile
417 #mount -t proc none /proc
418 #cd /dev
419 #/sbin/MAKEDEV generic-i386
420 #umount /proc
421 [ -f /lib/udev-state/devices.tar.bz2 ] && tar -C /dev -xjf /lib/udev-state/devices.tar.bz2
422 """
423 script = open(self._chroot_dir + "/tmp/extrastuff.sh", "w")
424 script.write(chrootscript)
425 script.close()
426 GLIUtility.spawn("chmod 755 /tmp/extrastuff.sh && /tmp/extrastuff.sh", chroot=self._chroot_dir, display_on_tty8=True, logfile=self._compile_logfile, append_log=True)
427 GLIUtility.spawn("rm -rf /var/tmp/portage/* /usr/portage /tmp/*", chroot=self._chroot_dir)
428 self.notify_frontend("progress", (1, "Done"))
429 self._logger.log("Stage3 was generated successfully")
430 else:
431 self._logger.log("Fetching and unpacking tarball: "+self._install_profile.get_stage_tarball_uri())
432 GLIUtility.fetch_and_unpack_tarball(self._install_profile.get_stage_tarball_uri(), self._chroot_dir, temp_directory=self._chroot_dir, keep_permissions=True, cc=self._cc)
433 self._logger.log(self._install_profile.get_stage_tarball_uri()+" was fetched and unpacked.")
434
435 ##
436 # This runs etc-update and then re-overwrites the files by running the configure_*'s to keep our values.
437 def update_config_files(self):
438 "Runs etc-update (overwriting all config files), then re-configures the modified ones"
439 # Run etc-update overwriting all config files
440 if self._debug: self._logger.log("DEBUG: update_config_files(): running: "+'echo "-5" | chroot '+self._chroot_dir+' etc-update')
441 status = GLIUtility.spawn('echo "-5" | chroot '+self._chroot_dir+' etc-update', display_on_tty8=True, logfile=self._compile_logfile, append_log=True)
442 if not GLIUtility.exitsuccess(status):
443 self._logger.log("ERROR! : Could not update the config files!")
444 else:
445 self._configure_fstab()
446 etc_files = self._install_profile.get_etc_files()
447 for etc_file in etc_files:
448 # Skip entries with blank filenames
449 if not etc_file: continue
450 if self._debug: self._logger.log("DEBUG: update_config_files(): updating config file: "+etc_file)
451 if isinstance(etc_files[etc_file], dict):
452 self._edit_config(self._chroot_dir + "/etc/" + etc_file, etc_files[etc_file])
453 else:
454 for entry in etc_files[etc_file]:
455 # Skip blank entries
456 if not entry: continue
457 self._edit_config(self._chroot_dir + "/etc/" + etc_file, { "0": entry }, only_value=True)
458 self._logger.log("Config files updated using etc-update. make.conf/fstab/rc.conf restored.")
459
460 ##
461 # Configures the new /etc/make.conf
462 def configure_make_conf(self):
463 # Get make.conf options
464 make_conf = self._install_profile.get_make_conf()
465
466 # For each configuration option...
467 filename = self._chroot_dir + "/etc/make.conf"
468 # self._edit_config(filename, {"COMMENT": "GLI additions ===>"})
469 for key in make_conf.keys():
470 # Add/Edit it into make.conf
471 self._edit_config(filename, {key: make_conf[key]})
472 # self._edit_config(filename, {"COMMENT": "<=== End GLI additions"})
473
474 self._logger.log("Make.conf configured")
475 # now make any directories that emerge needs, otherwise it will fail
476 # this must take place before ANY calls to emerge.
477 # otherwise emerge will fail (for PORTAGE_TMPDIR anyway)
478 # defaults first
479 # this really should use portageq or something.
480 PKGDIR = '/usr/portage/packages'
481 PORTAGE_TMPDIR = '/var/tmp'
482 PORT_LOGDIR = None
483 PORTDIR_OVERLAY = None
484 # now other stuff
485 if 'PKGDIR' in make_conf: PKGDIR = make_conf['PKGDIR']
486 if 'PORTAGE_TMPDIR' in make_conf: PORTAGE_TMPDIR = make_conf['PORTAGE_TMPDIR']
487 if 'PORT_LOGDIR' in make_conf: PORT_LOGDIR = make_conf['PORT_LOGDIR']
488 if 'PORTDIR_OVERLAY' in make_conf: PORTDIR_OVERLAY = make_conf['PORTDIR_OVERLAY']
489 if self._debug: self._logger.log("DEBUG: making PKGDIR if necessary: "+PKGDIR)
490 GLIUtility.spawn("mkdir -p " + self._chroot_dir + PKGDIR, logfile=self._compile_logfile, append_log=True)
491 if self._debug: self._logger.log("DEBUG: making PORTAGE_TMPDIR if necessary: "+PORTAGE_TMPDIR)
492 GLIUtility.spawn("mkdir -p " + self._chroot_dir + PORTAGE_TMPDIR, logfile=self._compile_logfile, append_log=True)
493 if PORT_LOGDIR != None:
494 if self._debug: self._logger.log("DEBUG: making PORT_LOGDIR if necessary: "+PORT_LOGDIR)
495 GLIUtility.spawn("mkdir -p " + self._chroot_dir + PORT_LOGDIR, logfile=self._compile_logfile, append_log=True)
496 if PORTDIR_OVERLAY != None:
497 if self._debug: self._logger.log("DEBUG: making PORTDIR_OVERLAY if necessary "+PORTDIR_OVERLAY)
498 GLIUtility.spawn("mkdir -p " + self._chroot_dir + PORTDIR_OVERLAY, logfile=self._compile_logfile, append_log=True)
499
500 ##
501 # Prepares the Chroot environment by copying /etc/resolv.conf and mounting proc and dev
502 def prepare_chroot(self):
503 # Copy resolv.conf to new env
504 try:
505 if self._debug: self._logger.log("DEBUG: copying /etc/resolv.conf over.")
506 shutil.copy("/etc/resolv.conf", self._chroot_dir + "/etc/resolv.conf")
507 except:
508 pass
509 if self._debug: self._logger.log("DEBUG: mounting proc")
510 ret = GLIUtility.spawn("mount -t proc none "+self._chroot_dir+"/proc")
511 if not GLIUtility.exitsuccess(ret):
512 raise GLIException("MountError", 'fatal','prepare_chroot','Could not mount /proc')
513 else:
514 self._mounted_devices.append("/proc")
515 bind_mounts = [ '/dev' ]
516 uname = os.uname()
517 if uname[0] == 'Linux' and uname[2].split('.')[1] == '6':
518 bind_mounts.append('/sys')
519 if self._debug: self._logger.log("DEBUG: bind-mounting " + ", ".join(bind_mounts))
520 for mount in bind_mounts:
521 ret = GLIUtility.spawn('mount -o bind %s %s%s' % (mount,self._chroot_dir,mount))
522 if not GLIUtility.exitsuccess(ret):
523 raise GLIException("MountError", 'fatal','prepare_chroot','Could not mount '+mount)
524 else:
525 self._mounted_devices.append(mount)
526 if self._debug: self._logger.log("DEBUG: copying logfile to new system!")
527 GLIUtility.spawn("mv " + self._compile_logfile + " " + self._chroot_dir + self._compile_logfile + " && ln -s " + self._chroot_dir + self._compile_logfile + " " + self._compile_logfile)
528 self._logger.log("Chroot environment ready.")
529
530 ##
531 # This will get/update the portage tree. If you want to snapshot or mount /usr/portage use "custom".
532 def install_portage_tree(self):
533 # Check the type of portage tree fetching we'll do
534 # If it is custom, follow the path to the custom tarball and unpack it
535
536 # This is a hack to copy the LiveCD's rsync into the chroot since it has the sigmask patch
537 if self._debug: self._logger.log("DEBUG: Doing the hack where we copy the LiveCD's rsync into the chroot since it has the sigmask patch")
538 GLIUtility.spawn("cp -a /usr/bin/rsync " + self._chroot_dir + "/usr/bin/rsync")
539 GLIUtility.spawn("cp -a /usr/lib/libpopt* " + self._chroot_dir + "/usr/lib")
540
541 sync_type = self._install_profile.get_portage_tree_sync_type()
542 if sync_type == "snapshot" or sync_type == "custom": # Until this is finalized
543
544 # Get portage tree info
545 portage_tree_snapshot_uri = self._install_profile.get_portage_tree_snapshot_uri()
546 if portage_tree_snapshot_uri:
547 # Fetch and unpack the tarball
548 if self._debug: self._logger.log("DEBUG: grabbing custom snapshot uri: "+portage_tree_snapshot_uri)
549 GLIUtility.fetch_and_unpack_tarball(portage_tree_snapshot_uri, self._chroot_dir + "/usr/", self._chroot_dir + "/", cc=self._cc)
550 if GLIUtility.is_file("/usr/livecd/metadata.tar.bz2"):
551 GLIUtility.fetch_and_unpack_tarball("/usr/livecd/metadata.tar.bz2", self._chroot_dir + "/", self._chroot_dir + "/", cc=self._cc)
552 self._logger.log("Portage tree install was custom.")
553 elif sync_type == "sync":
554 if self._debug: self._logger.log("DEBUG: starting emerge sync")
555 exitstatus = GLIUtility.spawn("emerge sync", chroot=self._chroot_dir, display_on_tty8=True, logfile=self._compile_logfile, append_log=True)
556 if not GLIUtility.exitsuccess(exitstatus):
557 self._logger.log("ERROR! Could not sync the portage tree using emerge sync. Falling back to emerge-webrsync as a backup.")
558 sync_type = "webrsync"
559 else:
560 self._logger.log("Portage tree sync'd")
561 # If the type is webrsync, then run emerge-webrsync
562 elif sync_type == "webrsync":
563 if self._debug: self._logger.log("DEBUG: starting emerge webrsync")
564 exitstatus = GLIUtility.spawn("emerge-webrsync", chroot=self._chroot_dir, display_on_tty8=True, logfile=self._compile_logfile, append_log=True)
565 if not GLIUtility.exitsuccess(exitstatus):
566 raise GLIException("EmergeWebRsyncError", 'fatal','install_portage_tree', "Failed to retrieve portage tree using webrsync!")
567 self._logger.log("Portage tree sync'd using webrsync")
568 # Otherwise, spit out a message because its probably a bad thing.
569 else:
570 self._logger.log("NOTICE! No valid portage tree sync method was selected. This will most likely result in a failed installation unless the tree is mounted.")
571
572
573 ##
574 # Stage 1 install -- bootstraping the system
575 # If we are doing a stage 1 install, then bootstrap
576 def stage1(self):
577 if self._install_profile.get_install_stage() == 1:
578 self._logger.mark()
579 self._logger.log("Starting bootstrap.")
580 pkgs = self._get_packages_to_emerge("/usr/portage/scripts/bootstrap.sh --pretend")
581 if self._debug: self._logger.log("DEBUG: Packages to emerge: "+str(pkgs)+". Now running bootstrap.sh")
582 exitstatus = GLIUtility.spawn("env-update && source /etc/profile && /usr/portage/scripts/bootstrap.sh", chroot=self._chroot_dir, display_on_tty8=True, logfile=self._compile_logfile, append_log=True)
583 if not GLIUtility.exitsuccess(exitstatus):
584 raise GLIException("Stage1Error", 'fatal','stage1', "Bootstrapping failed!")
585 self._logger.log("Bootstrap complete.")
586
587 ##
588 # Stage 2 install -- emerge -e system
589 # If we are doing a stage 1 or 2 install, then emerge system
590 def stage2(self):
591 if self._install_profile.get_install_stage() in [ 1, 2 ]:
592 self._logger.mark()
593 self._logger.log("Starting emerge system.")
594 pkgs = self._get_packages_to_emerge("emerge -p system") #currently quite the useless
595 if self._debug: self._logger.log("DEBUG: Packages to emerge: "+str(pkgs)+"/ Now running emerge --emptytree system")
596 # exitstatus = self._emerge("--emptytree system")
597 exitstatus = GLIUtility.spawn("env-update && source /etc/profile && emerge -e system", chroot=self._chroot_dir, display_on_tty8=True, logfile=self._compile_logfile, append_log=True)
598 if not GLIUtility.exitsuccess(exitstatus):
599 raise GLIException("Stage2Error", 'fatal','stage2', "Building the system failed!")
600 self._logger.log("Emerge system complete.")
601
602 ##
603 # Sets the root password
604 def set_root_password(self):
605 if self._debug: self._logger.log("DEBUG: set_root_password(): running: "+ 'echo \'root:' + self._install_profile.get_root_pass_hash() + '\' | chroot '+self._chroot_dir+' chpasswd -e')
606 status = GLIUtility.spawn('echo \'root:' + self._install_profile.get_root_pass_hash() + '\' | chroot '+self._chroot_dir+' chpasswd -e')
607 if not GLIUtility.exitsuccess(status):
608 raise GLIException("SetRootPasswordError", 'fatal', 'set_root_password', "Failure to set root password!")
609 self._logger.log("Root Password set on the new system.")
610
611 ##
612 # Sets the timezone for the new environment
613 def set_timezone(self):
614
615 # Set symlink
616 if os.access(self._chroot_dir + "/etc/localtime", os.W_OK):
617 if self._debug: self._logger.log("DEBUG: /etc/localtime already exists, removing it so it can be symlinked")
618 GLIUtility.spawn("rm "+self._chroot_dir + "/etc/localtime")
619 if self._debug: self._logger.log("DEBUG: running ln -s ../usr/share/zoneinfo/" + self._install_profile.get_time_zone() + " /etc/localtime")
620 GLIUtility.spawn("ln -s ../usr/share/zoneinfo/" + self._install_profile.get_time_zone() + " /etc/localtime", chroot=self._chroot_dir)
621 if not (self._install_profile.get_time_zone() == "UTC"):
622 if self._debug: self._logger.log("DEBUG: timezone was not UTC, setting CLOCK to local. This may be overwritten later.")
623 self._edit_config(self._chroot_dir + "/etc/conf.d/clock", {"CLOCK":"local"})
624 self._logger.log("Timezone set.")
625
626 ##
627 # Fetches desired kernel sources, unless you're using a livecd-kernel in which case it does freaky stuff.
628 def emerge_kernel_sources(self):
629 self._logger.log("Starting emerge_kernel")
630 kernel_pkg = self._install_profile.get_kernel_source_pkg()
631 # if kernel_pkg:
632 # Special case, no kernel installed
633 if kernel_pkg == "none":
634 return
635 # Special case, livecd kernel
636 elif kernel_pkg == "livecd-kernel":
637 if self._debug: self._logger.log("DEBUG: starting livecd-kernel setup")
638 self.notify_frontend("progress", (0, "Copying livecd-kernel to chroot"))
639 self._portage.copy_pkg_to_chroot(self._portage.get_best_version_vdb("livecd-kernel"))
640 self.notify_frontend("progress", (1, "Done copying livecd-kernel to chroot"))
641
642 exitstatus = self._portage.emerge("coldplug", self._install_profile.get_grp_install())
643 self._logger.log("Coldplug emerged. Now they should be added to the boot runlevel.")
644 self._add_to_runlevel("coldplug", runlevel="boot")
645
646 if self._install_profile.get_kernel_bootsplash():
647 self._logger.log("Bootsplash enabled for livecd-kernel...this is currently broken, so we're skipping the package install")
648 # self._logger.log("Bootsplash enabled...emerging necessary packages")
649 # self._portage.emerge(["splashutils", "splash-themes-livecd"])
650
651 # Extra modules from kernelpkgs.txt...disabled until I can figure out why it sucks
652 # try:
653 # kernpkgs = open("/usr/livecd/kernelpkgs.txt", "r")
654 # pkgs = ""
655 # for line in kernpkgs.readlines():
656 # pkgs += line.strip() + " "
657 # kernpkgs.close()
658 # except:
659 # raise GLIException("EmergeColdplugError", 'fatal','build_kernel', "Could not read kernelpkgs.txt")
660 # exitstatus = self._emerge(pkgs)
661 # if not GLIUtility.exitsuccess(exitstatus):
662 # raise GLIException("EmergeExtraKernelModulesError", 'fatal','build_kernel', "Could not emerge extra kernel packages")
663 # self._logger.log("Extra kernel packages emerged.")
664
665 # normal case
666 else:
667 exitstatus = self._portage.emerge(kernel_pkg, self._install_profile.get_grp_install())
668 # if not GLIUtility.exitsuccess(exitstatus):
669 # raise GLIException("EmergeKernelSourcesError", 'fatal','emerge_kernel_sources',"Could not retrieve kernel sources!")
670 try:
671 os.stat(self._chroot_dir + "/usr/src/linux")
672 except:
673 kernels = os.listdir(self._chroot_dir+"/usr/src")
674 if self._debug: self._logger.log("DEBUG: no /usr/src/linux found. found kernels: "+kernels)
675 found_a_kernel = False
676 counter = 0
677 while not found_a_kernel:
678 if (len(kernels[counter]) > 6) and (kernels[counter][0:6]=="linux-"):
679 if self._debug: self._logger.log("DEBUG: found one. linking it. running: ln -s /usr/src/"+kernels[counter]+ " /usr/src/linux in the chroot.")
680 exitstatus = GLIUtility.spawn("ln -s /usr/src/"+kernels[counter]+ " /usr/src/linux",chroot=self._chroot_dir)
681 if not GLIUtility.exitsuccess(exitstatus):
682 raise GLIException("EmergeKernelSourcesError", 'fatal','emerge_kernel_sources',"Could not make a /usr/src/linux symlink")
683 found_a_kernel = True
684 else:
685 counter = counter + 1
686 self._logger.log("Kernel sources:"+kernel_pkg+" emerged and /usr/src/linux symlinked.")
687
688 ##
689 # Builds the kernel using genkernel or regularly if given a custom .config file in the profile
690 def build_kernel(self):
691 self._logger.mark()
692 self._logger.log("Starting build_kernel")
693
694 build_mode = self._install_profile.get_kernel_build_method()
695
696 # No building necessary if using the LiveCD's kernel/initrd
697 # or using the 'none' kernel bypass
698 if self._install_profile.get_kernel_source_pkg() in ["livecd-kernel","none"]:
699 if self._debug: self._logger.log("DEBUG: using "+self._install_profile.get_kernel_source_pkg()+ " so skipping this function.")
700 return
701 # Get the uri to the kernel config
702 kernel_config_uri = self._install_profile.get_kernel_config_uri()
703
704 # is there an easier way to do this?
705 if self._debug: self._logger.log("DEBUG: running command: awk '/^PATCHLEVEL/{print $3}' /usr/src/linux/Makefile in chroot.")
706 ret, kernel_major = GLIUtility.spawn("awk '/^PATCHLEVEL/{print $3}' /usr/src/linux/Makefile",chroot=self._chroot_dir,return_output=True)
707 # 6 == 2.6 kernel, 4 == 2.4 kernel
708 kernel_major = int(kernel_major)
709 if self._debug: self._logger.log("DEBUG: kernel major version is: "+str(kernel_major))
710 #Copy the kernel .config to the proper location in /usr/src/linux
711 if kernel_config_uri != '':
712 try:
713 if self._debug: self._logger.log("DEBUG: grabbing kernel config from "+kernel_config_uri+" and putting it in "+self._chroot_dir + "/var/tmp/kernel_config")
714 GLIUtility.get_uri(kernel_config_uri, self._chroot_dir + "/var/tmp/kernel_config")
715 except:
716 raise GLIException("KernelBuildError", 'fatal', 'build_kernel', "Could not copy kernel config!")
717
718 # the && stuff is important so that we can catch any errors.
719 kernel_compile_script = "#!/bin/bash\n"
720 kernel_compile_script += "cp /var/tmp/kernel_config /usr/src/linux/.config && "
721 kernel_compile_script += "cd /usr/src/linux && "
722 # required for 2.[01234] etc kernels
723 if kernel_major in [0,1,2,3,4]:
724 kernel_compile_script += " yes 'n' | make oldconfig && make symlinks && make dep"
725 # not strictly needed, but recommended by upstream
726 else: #elif kernel_major in [5,6]:
727 kernel_compile_script += "make prepare"
728
729 # bypass to install a kernel, but not compile it
730 if build_mode == "none":
731 return
732 # this mode is used to install kernel sources, and have then configured
733 # but not actually build the kernel. This is needed for netboot
734 # situations when you have packages that require kernel sources
735 # to build.
736 elif build_mode == "prepare-only":
737 if self._debug: self._logger.log("DEBUG: writing kernel script with contents: "+kernel_compile_script)
738 f = open(self._chroot_dir+"/var/tmp/kernel_script", 'w')
739 f.writelines(kernel_compile_script)
740 f.close()
741 #Build the kernel
742 if self._debug: self._logger.log("DEBUG: running: chmod u+x "+self._chroot_dir+"/var/tmp/kernel_script")
743 exitstatus1 = GLIUtility.spawn("chmod u+x "+self._chroot_dir+"/var/tmp/kernel_script")
744 if self._debug: self._logger.log("DEBUG: running: /var/tmp/kernel_script in chroot.")
745 exitstatus2 = GLIUtility.spawn("/var/tmp/kernel_script", chroot=self._chroot_dir, display_on_tty8=True, logfile=self._compile_logfile, append_log=True)
746 if not GLIUtility.exitsuccess(exitstatus1):
747 raise GLIException("KernelBuildError", 'fatal', 'build_kernel', "Could not handle prepare-only build! died on chmod.")
748 if not GLIUtility.exitsuccess(exitstatus2):
749 raise GLIException("KernelBuildError", 'fatal', 'build_kernel', "Could not handle prepare-only build! died on running of kernel script.")
750 #i'm sure i'm forgetting something here.
751 #cleanup
752 exitstatus = GLIUtility.spawn("rm -f "+self._chroot_dir+"/var/tmp/kernel_script "+self._chroot_dir+"/var/tmp/kernel_config")
753 #it's not important if this fails.
754 self._logger.log("prepare-only build complete")
755 # Genkernel mode, including custom kernel_config. Initrd always on.
756 elif build_mode == "genkernel":
757 if self._debug: self._logger.log("DEBUG: build_kernel(): starting emerge genkernel")
758 exitstatus = self._portage.emerge("genkernel", self._install_profile.get_grp_install())
759 # if not GLIUtility.exitsuccess(exitstatus):
760 # raise GLIException("EmergeGenKernelError", 'fatal','build_kernel', "Could not emerge genkernel!")
761 self._logger.log("Genkernel emerged. Beginning kernel compile.")
762 # Null the genkernel_options
763 genkernel_options = ""
764
765 # If the uri for the kernel config is not null, then
766 if kernel_config_uri != "":
767 if self._debug: self._logger.log("DEBUG: build_kernel(): getting kernel config "+kernel_config_uri)
768 GLIUtility.get_uri(kernel_config_uri, self._chroot_dir + "/var/tmp/kernel_config")
769 genkernel_options = genkernel_options + " --kernel-config=/var/tmp/kernel_config"
770
771 # Decide whether to use bootsplash or not
772 if self._install_profile.get_kernel_bootsplash():
773 genkernel_options = genkernel_options + " --gensplash"
774 else:
775 genkernel_options = genkernel_options + " --no-gensplash"
776 # Run genkernel in chroot
777 #print "genkernel all " + genkernel_options
778 if self._debug: self._logger.log("DEBUG: build_kernel(): running: genkernel all " + genkernel_options + " in chroot.")
779 exitstatus = GLIUtility.spawn("genkernel all " + genkernel_options, chroot=self._chroot_dir, display_on_tty8=True, logfile=self._compile_logfile, append_log=True)
780 if not GLIUtility.exitsuccess(exitstatus):
781 raise GLIException("KernelBuildError", 'fatal', 'build_kernel', "Could not build kernel!")
782
783 # exitstatus = self._emerge("hotplug")
784 # if not GLIUtility.exitsuccess(exitstatus):
785 # raise GLIException("EmergeHotplugError", 'fatal','build_kernel', "Could not emerge hotplug!")
786 # self._logger.log("Hotplug emerged.")
787 exitstatus = self._portage.emerge("coldplug", self._install_profile.get_grp_install())
788 # if not GLIUtility.exitsuccess(exitstatus):
789 # raise GLIException("EmergeColdplugError", 'fatal','build_kernel', "Could not emerge coldplug!")
790 self._logger.log("Coldplug emerged. Now they should be added to the default runlevel.")
791
792 # self._add_to_runlevel("hotplug")
793 self._add_to_runlevel("coldplug", runlevel="boot")
794
795 if self._install_profile.get_kernel_bootsplash():
796 self._logger.log("Bootsplash enabled...emerging necessary packages")
797 self._portage.emerge(["splashutils", "splash-themes-livecd"], self._install_profile.get_grp_install())
798
799 self._logger.log("Genkernel complete.")
800 elif build_mode == "custom": #CUSTOM CONFIG
801
802 kernel_compile_script += " && make && make modules && make modules_install"
803
804 #Ok now that it's built, copy it to /boot/kernel-* for bootloader code to find it
805 if self._architecture_name == "x86":
806 kernel_compile_script += " && cp /usr/src/linux/arch/i386/boot/bzImage /boot/kernel-custom\n"
807 elif self._architecture_name == "amd64":
808 kernel_compile_script += " && cp /usr/src/linux/arch/x86_64/boot/bzImage /boot/kernel-custom\n"
809 elif self._architecture_name == "ppc":
810 kernel_compile_script += " && cp /usr/src/linux/vmlinux /boot/kernel-custom\n"
811 if self._debug: self._logger.log("DEBUG: build_kernel(): writing custom kernel script: "+kernel_compile_script)
812 f = open(self._chroot_dir+"/var/tmp/kernel_script", 'w')
813 f.writelines(kernel_compile_script)
814 f.close()
815 #Build the kernel
816 if self._debug: self._logger.log("DEBUG: build_kernel(): running: chmod u+x "+self._chroot_dir+"/var/tmp/kernel_script")
817 exitstatus1 = GLIUtility.spawn("chmod u+x "+self._chroot_dir+"/var/tmp/kernel_script")
818 if self._debug: self._logger.log("DEBUG: build_kernel(): running: /var/tmp/kernel_script in chroot")
819 exitstatus2 = GLIUtility.spawn("/var/tmp/kernel_script", chroot=self._chroot_dir, display_on_tty8=True, logfile=self._compile_logfile, append_log=True)
820 if not GLIUtility.exitsuccess(exitstatus1):
821 raise GLIException("KernelBuildError", 'fatal', 'build_kernel', "Could not build custom kernel! died on chmod.")
822 if not GLIUtility.exitsuccess(exitstatus2):
823 raise GLIException("KernelBuildError", 'fatal', 'build_kernel', "Could not build custom kernel! died on running of kernel script.")
824
825 #i'm sure i'm forgetting something here.
826 #cleanup
827 exitstatus = GLIUtility.spawn("rm -f "+self._chroot_dir+"/var/tmp/kernel_script "+self._chroot_dir+"/var/tmp/kernel_config")
828 #it's not important if this fails.
829
830 if self._install_profile.get_kernel_bootsplash():
831 self._logger.log("Bootsplash enabled...emerging necessary packages")
832 self._portage.emerge(["splashutils", "splash-themes-livecd"], self._install_profile.get_grp_install())
833
834 self._logger.log("Custom kernel complete")
835
836 ##
837 # Installs and starts up distccd if the user has it set, so that it will get used for the rest of the install
838 def install_distcc(self):
839 if self._install_profile.get_install_distcc():
840 if self._debug: self._logger.log("DEBUG: install_distcc(): we ARE installing distcc")
841 if self._debug: self._logger.log("DEBUG: install_distcc(): running: USE='-*' emerge --nodeps sys-devel/distcc in chroot.")
842 exitstatus = GLIUtility.spawn("USE='-*' emerge --nodeps sys-devel/distcc", chroot=self._chroot_dir, display_on_tty8=True, logfile=self._compile_logfile, append_log=True)
843 if not GLIUtility.exitsuccess(exitstatus):
844 self._logger.log("ERROR! : Could not emerge distcc!")
845 else:
846 self._logger.log("distcc emerged.")
847
848 ##
849 # Installs mail MTA. Does not put into runlevel, as this is not simple with MTAs.
850 def install_mta(self):
851 # Get MTA info
852 mta_pkg = self._install_profile.get_mta_pkg()
853 if mta_pkg:
854 # Emerge MTA
855 if self._debug: self._logger.log("DEBUG: install_mta(): installing mta: "+mta_pkg)
856 exitstatus = self._portage.emerge(mta_pkg, self._install_profile.get_grp_install())
857 # if not GLIUtility.exitsuccess(exitstatus):
858 # raise GLIException("MTAError", 'fatal','install_mta', "Could not emerge " + mta_pkg + "!")
859 self._logger.log("MTA installed: "+mta_pkg)
860 else:
861 installpackages = self._install_profile.get_install_packages()
862 if installpackages:
863 for pkg in installpackages:
864 if pkg in ['esmtp', 'exim', 'msmtp', 'nbsmtp', 'nullmailer', 'sendmail', 'ssmtp', 'xmail']:
865 self._logger.log("Found an mta in the package list: "+pkg+". Installing early.")
866 exitstatus = self._portage.emerge(pkg, self._install_profile.get_grp_install())
867 self._logger.log("MTA installed.")
868 break # We only want to install one
869
870 ##
871 # Installs and sets up logging daemon on the new system. adds to runlevel too.
872 def install_logging_daemon(self):
873 # Get loggin daemon info
874 logging_daemon_pkg = self._install_profile.get_logging_daemon_pkg()
875 if logging_daemon_pkg:
876 # Emerge Logging Daemon
877 if self._debug: self._logger.log("DEBUG: install_logging_daemon: emerging "+logging_daemon_pkg)
878 exitstatus = self._portage.emerge(logging_daemon_pkg, self._install_profile.get_grp_install())
879 # if not GLIUtility.exitsuccess(exitstatus):
880 # raise GLIException("LoggingDaemonError", 'fatal','install_logging_daemon', "Could not emerge " + logging_daemon_pkg + "!")
881
882 # Add Logging Daemon to default runlevel
883 # After we find the name of it's initscript
884 # This current code is a hack, and should be better.
885 initscript = logging_daemon_pkg[(logging_daemon_pkg.find('/')+1):]
886 if self._debug: self._logger.log("DEBUG: install_logging_daemon: adding "+initscript+" to runlevel")
887 self._add_to_runlevel(initscript)
888 self._logger.log("Logging daemon installed: "+logging_daemon_pkg)
889 ##
890 # Installs and sets up cron package.
891 def install_cron_daemon(self):
892 # Get cron daemon info
893 cron_daemon_pkg = self._install_profile.get_cron_daemon_pkg()
894 if cron_daemon_pkg:
895 if cron_daemon_pkg == "none":
896 self._logger.log("Skipping installation of cron daemon")
897 else:
898 # Emerge Cron Daemon
899 if self._debug: self._logger.log("DEBUG: install_cron_daemon: emerging "+cron_daemon_pkg)
900 exitstatus = self._portage.emerge(cron_daemon_pkg, self._install_profile.get_grp_install())
901 # if not GLIUtility.exitsuccess(exitstatus):
902 # raise GLIException("CronDaemonError", 'fatal', 'install_cron_daemon', "Could not emerge " + cron_daemon_pkg + "!")
903
904 # Add Cron Daemon to default runlevel
905 # After we find the name of it's initscript
906 # This current code is a hack, and should be better.
907 initscript = cron_daemon_pkg[(cron_daemon_pkg.find('/')+1):]
908 if self._debug: self._logger.log("DEBUG: install_cron_daemon: adding "+initscript+" to runlevel")
909 self._add_to_runlevel(initscript)
910
911 # If the Cron Daemon is not vixie-cron, run crontab
912 if "vixie-cron" not in cron_daemon_pkg:
913 if self._debug: self._logger.log("DEBUG: install_cron_daemon: running: crontab /etc/crontab in chroot.")
914 exitstatus = GLIUtility.spawn("crontab /etc/crontab", chroot=self._chroot_dir, display_on_tty8=True)
915 if not GLIUtility.exitsuccess(exitstatus):
916 raise GLIException("CronDaemonError", 'fatal', 'install_cron_daemon', "Failure making crontab!")
917 self._logger.log("Cron daemon installed and configured: "+cron_daemon_pkg)
918
919 ##
920 # This will parse the partitions looking for types that require fstools and emerge them if found.
921 def install_filesystem_tools(self):
922 "Installs and sets up fstools"
923 # Get the list of file system tools to be installed
924 mounts = self._install_profile.get_mounts()
925 # don't use an array, use a set instead
926 filesystem_types = []
927 for mount in mounts:
928 partition_type = mount['type'].lower()
929 if mount['mountpoint'] and partition_type not in filesystem_types:
930 filesystem_types.append(partition_type)
931
932 package_list = []
933 for filesystem in filesystem_types:
934 if filesystem == 'xfs':
935 package_list.append('sys-fs/xfsprogs')
936 elif filesystem == 'reiserfs':
937 package_list.append('sys-fs/reiserfsprogs')
938 elif filesystem == 'jfs':
939 package_list.append('sys-fs/jfsutils')
940 elif filesystem == 'ntfs':
941 package_list.append('sys-fs/ntfsprogs')
942 elif filesystem in ['fat','vfat', 'msdos', 'umsdos']:
943 package_list.append('sys-fs/dosfstools')
944 elif filesystem == 'hfs':
945 # should check with the PPC guys on this
946 package_list.append('sys-fs/hfsutils')
947 package_list.append('sys-fs/hfsplusutils')
948 #else:
949 # should be code here for every FS type!
950 failed_list = []
951 for package in package_list:
952 if self._debug: self._logger.log("DEBUG: install_filesystem_tools(): emerging "+package)
953 exitstatus = self._portage.emerge(package, self._install_profile.get_grp_install())
954 # if not GLIUtility.exitsuccess(exitstatus):
955 # self._logger.log("ERROR! : Could not emerge "+package+"!")
956 # failed_list.append(package)
957 # else:
958 self._logger.log("FileSystemTool "+package+" was emerged successfully.")
959 # error checking is important!
960 if len(failed_list) > 0:
961 raise GLIException("InstallFileSystemToolsError", 'warning', 'install_filesystem_tools', "Could not emerge " + failed_list + "!")
962
963
964 ##
965 # Installs and sets up pcmcia-cs if selected in the profile IS THIS USED AT ALL????
966 def install_pcmcia_cs(self):
967 if self._debug: self._logger.log("DEBUG: install_pcmcia_cs(): emerging pcmcia-cs")
968 exitstatus = self._portage.emerge("pcmcia-cs", self._install_profile.get_grp_install())
969 # if not GLIUtility.exitsuccess(exitstatus):
970 # self._logger.log("ERROR! : Could not emerge pcmcia-cs!")
971
972 # Add pcmcia-cs to the default runlevel
973 # else:
974 self._add_to_runlevel('pcmcia')
975 self._logger.log("PCMCIA_CS emerged and configured.")
976
977
978 ##
979 # Sets up the network for the first boot
980 def setup_network_post(self):
981 if self._debug: self._logger.log("DEBUG: setup_network_post(): starting network configuration")
982 # Get hostname, domainname and nisdomainname
983 hostname = self._install_profile.get_hostname()
984 domainname = self._install_profile.get_domainname()
985 nisdomainname = self._install_profile.get_nisdomainname()
986
987 # Write the hostname to the hostname file
988 #open(self._chroot_dir + "/etc/hostname", "w").write(hostname + "\n")
989 self._edit_config(self._chroot_dir + "/etc/conf.d/hostname", {"HOSTNAME": hostname})
990
991 # Write the domainname to the nisdomainname file
992 if domainname:
993 #open(self._chroot_dir + "/etc/dnsdomainname", "w").write(domainname + "\n")
994 self._edit_config(self._chroot_dir + "/etc/conf.d/domainname", {"DNSDOMAIN": domainname})
995 self._add_to_runlevel("domainname")
996
997 # Write the nisdomainname to the nisdomainname file
998 if nisdomainname:
999 #open(self._chroot_dir + "/etc/nisdomainname", "w").write(nisdomainname + "\n")
1000 self._edit_config(self._chroot_dir + "/etc/conf.d/domainname", {"NISDOMAIN": nisdomainname})
1001 self._add_to_runlevel("domainname")
1002
1003 #
1004 # EDIT THE /ETC/HOSTS FILE
1005 #
1006
1007 # The address we are editing is 127.0.0.1
1008 hosts_ip = "127.0.0.1"
1009
1010 # If the hostname is localhost
1011 if hostname == "localhost":
1012 # If a domainname is set
1013 if domainname:
1014 hosts_line = hostname + "." + domainname + "\t" + hostname
1015 else:
1016 hosts_line = hostname
1017 # If the hostname is not localhost
1018 else:
1019 # If a domainname is set
1020 if domainname:
1021 hosts_line = hostname + "." + domainname + "\t" + hostname + "\tlocalhost"
1022 else:
1023 hosts_line = "localhost\t" + hostname
1024
1025 # Write to file
1026 self._edit_config(self._chroot_dir + "/etc/hosts", {hosts_ip: hosts_line}, delimeter='\t', quotes_around_value=False)
1027
1028 #
1029 # SET DEFAULT GATEWAY
1030 #
1031
1032 # Get default gateway
1033 default_gateway = self._install_profile.get_default_gateway()
1034
1035 # If the default gateway exists, add it
1036 if default_gateway:
1037 default_gateway_string = '( "default via ' + default_gateway[1] + '" )'
1038 if self._debug: self._logger.log("DEBUG: setup_network_post(): found gateway. adding to confing. "+default_gateway_string)
1039 self._edit_config(self._chroot_dir + "/etc/conf.d/net", {"routes_"+default_gateway[0]: default_gateway_string}, quotes_around_value=False)
1040
1041 #
1042 # SET RESOLV INFO
1043 #
1044
1045 # Get dns servers
1046 dns_servers = self._install_profile.get_dns_servers()
1047
1048 # Clear the list
1049 resolv_output = []
1050
1051 # If dns servers are set
1052 if dns_servers:
1053
1054
1055 # Parse each dns server
1056 for dns_server in dns_servers:
1057 # Add the server to the output
1058 resolv_output.append("nameserver " + dns_server +"\n")
1059
1060 # If the domainname is set, then also output it
1061 if domainname:
1062 resolv_output.append("search " + domainname + "\n")
1063
1064 # Output to file
1065 if self._debug: self._logger.log("DEBUG: setup_network_post(): writing resolv.conf with contents: " + str(resolv_output))
1066 resolve_conf = open(self._chroot_dir + "/etc/resolv.conf", "w")
1067 resolve_conf.writelines(resolv_output)
1068 resolve_conf.close()
1069
1070 #
1071 # PARSE INTERFACES
1072 #
1073
1074 # Fetch interfaces
1075 interfaces = self._install_profile.get_network_interfaces()
1076 emerge_dhcp = False
1077 # Parse each interface
1078 for interface in interfaces.keys():
1079 if self._debug: self._logger.log("DEBUG: setup_network_post(): configuring interface: "+ interface)
1080 # Set what kind of interface it is
1081 interface_type = interface[:3]
1082
1083 # Check to see if there is a startup script for this interface, if there isn't link to the proper script
1084 try:
1085 os.stat(self._chroot_dir + "/etc/init.d/net." + interface)
1086 except:
1087 if self._debug: self._logger.log("DEBUG: setup_network_post(): /etc/init.d/net." + interface + " didn't exist, symlinking it.")
1088 os.symlink("net." + interface_type + "0", self._chroot_dir + "/etc/init.d/net." + interface)
1089
1090 # If we are going to load the network at boot...
1091 #if interfaces[interface][2]: #THIS FEATURE NO LONGER EXISTS
1092
1093 # Add it to the default runlevel
1094 if self._debug: self._logger.log("DEBUG: setup_network_post(): adding net."+interface+" to runlevel.")
1095 self._add_to_runlevel("net."+interface) # moved a bit <-- for indentation
1096
1097 #
1098 # ETHERNET
1099 #
1100 if interface_type == "eth":
1101
1102 #
1103 # STATIC IP
1104 #
1105 # If the post-install device info is not None, then it is a static ip addy
1106 if interfaces[interface][0] != "dhcp":
1107 ip = interfaces[interface][0]
1108 broadcast = interfaces[interface][1]
1109 netmask = interfaces[interface][2]
1110 # aliases = interfaces[interface][1][3]
1111 # alias_ips = []
1112 # alias_broadcasts = []
1113 # alias_netmasks = []
1114
1115 # Write the static ip config to /etc/conf.d/net
1116 self._edit_config(self._chroot_dir + "/etc/conf.d/net", {"iface_" + interface: ip + " broadcast " + broadcast + " netmask " + netmask})
1117
1118 # If aliases are set
1119 # if aliases:
1120
1121 # Parse aliases to format alias info
1122 # for alias in aliases:
1123 # alias_ips.append(alias[0])
1124 # alias_broadcasts.append(alias[1])
1125 # alias_netmasks.append(allias[2])
1126
1127 # Once the alias info has been gathered, then write it out
1128 # Alias ips first
1129 # self._edit_config(self._chroot_dir + "/etc/conf.d/net", "alias_" + interface, string.join(alias_ips))
1130 # Alias broadcasts next
1131 # self._edit_config(self._chroot_dir + "/etc/conf.d/net", "broadcast_" + interface, string.join(alias_broadcasts))
1132 # Alias netmasks last
1133 # self._edit_config(self._chroot_dir + "/etc/conf.d/net", "netmask_" + interface, string.join(alias_netmasks))
1134
1135 #
1136 # DHCP IP
1137 #
1138 else:
1139 dhcpcd_options = interfaces[interface][1]
1140 if not dhcpcd_options:
1141 dhcpcd_options = ""
1142 self._edit_config(self._chroot_dir + "/etc/conf.d/net", {"iface_" + interface: "dhcp", "dhcpcd_" + interface: dhcpcd_options})
1143 emerge_dhcp = True
1144 if emerge_dhcp:
1145 if self._debug: self._logger.log("DEBUG: setup_network_post(): emerging dhcpcd.")
1146 exitstatus = self._portage.emerge("dhcpcd", self._install_profile.get_grp_install())
1147 # if not GLIUtility.exitsuccess(exitstatus):
1148 # self._logger.log("ERROR! : Could not emerge dhcpcd!")
1149 # else:
1150 self._logger.log("dhcpcd emerged.")
1151
1152
1153 ##
1154 # This is a stub function to be done by the individual arch. I don't think it's even needed here.
1155 # but it's nice having it just incase.
1156 def install_bootloader(self):
1157 "THIS FUNCTION MUST BE DONE BY THE INDIVIDUAL ARCH"
1158 pass
1159
1160 ##
1161 # Sets up the new users for the system
1162 def set_users(self):
1163 # Loop for each user
1164 for user in self._install_profile.get_users():
1165
1166 # Get values from the tuple
1167 username = user[0]
1168 password_hash = user[1]
1169 groups = user[2]
1170 shell = user[3]
1171 home_dir = user[4]
1172 uid = user[5]
1173 comment = user[6]
1174
1175 options = [ "-m", "-p '" + password_hash + "'" ]
1176
1177 # If the groups are specified
1178 if groups:
1179
1180 # If just one group is listed as a string, make it a list
1181 if groups == str:
1182 groups = [ groups ]
1183
1184 # If only 1 group is listed
1185 if len(groups) == 1:
1186 options.append("-G " + groups[0])
1187
1188 # If there is more than one group
1189 elif len(groups) > 1:
1190 options.append('-G "' + string.join(groups, ",") + '"')
1191
1192 # Attempt to add the group (will return success when group exists)
1193 for group in groups:
1194 if not group: continue
1195 # Add the user
1196 if self._debug: self._logger.log("DEBUG: set_users(): adding user to groups with (in chroot): "+'groupadd -f ' + group)
1197 exitstatus = GLIUtility.spawn('groupadd -f ' + group, chroot=self._chroot_dir, logfile=self._compile_logfile, append_log=True, display_on_tty8=True)
1198 if not GLIUtility.exitsuccess(exitstatus):
1199 self._logger.log("ERROR! : Failure to add group " + group+" and it wasn't that the group already exists!")
1200
1201
1202 # If a shell is specified
1203 if shell:
1204 options.append("-s " + shell)
1205
1206 # If a home dir is specified
1207 if home_dir:
1208 options.append("-d " + home_dir)
1209
1210 # If a UID is specified
1211 if uid:
1212 options.append("-u " + str(uid))
1213
1214 # If a comment is specified
1215 if comment:
1216 options.append('-c "' + comment + '"')
1217
1218 # Add the user
1219 if self._debug: self._logger.log("DEBUG: set_users(): adding user with (in chroot): "+'useradd ' + string.join(options) + ' ' + username)
1220 exitstatus = GLIUtility.spawn('useradd ' + string.join(options) + ' ' + username, chroot=self._chroot_dir, logfile=self._compile_logfile, append_log=True, display_on_tty8=True)
1221 if not GLIUtility.exitsuccess(exitstatus):
1222 self._logger.log("ERROR! : Failure to add user " + username)
1223 # raise GLIException("AddUserError", 'warning', 'set_users', "Failure to add user " + username)
1224 else:
1225 self._logger.log("User " + username + " was added.")
1226
1227 ##
1228 # Installs a list of packages specified in the profile. Will install any extra software!
1229 # In the future this function will lead to better things. It may even wipe your ass for you.
1230 def install_packages(self):
1231 installpackages = self._install_profile.get_install_packages()
1232 if installpackages:
1233 # pkglist = self._portage.get_deps(" ".join(installpackages))
1234 # if self._debug: self._logger.log("install_packages(): pkglist is " + str(pkglist))
1235 # for i, pkg in enumerate(pkglist):
1236 # if self._debug: self._logger.log("install_packages(): processing package " + pkg)
1237 # self.notify_frontend("progress", (float(i) / len(pkglist), "Emerging " + pkg + " (" + str(i) + "/" + str(len(pkglist)) + ")"))
1238 # if not self._portage.get_best_version_vdb("=" + pkg):
1239 # status = self._emerge("=" + pkg)
1240 # if not GLIUtility.exitsuccess(status):
1241 # raise GLIException("ExtraPackagesError", "fatal", "install_packages", "Could not emerge " + pkg + "!")
1242 # else:
1243 # try:
1244 # self._portage.copy_pkg_to_chroot(pkg)
1245 # except:
1246 # raise GLIException("ExtraPackagesError", "fatal", "install_packages", "Could not emerge " + pkg + "!")
1247 self._portage.emerge(installpackages, self._install_profile.get_grp_install())
1248
1249 if GLIUtility.is_file(self._chroot_dir + "/etc/X11"):
1250 # Copy the xorg.conf from the LiveCD if they installed xorg-x11
1251 exitstatus = GLIUtility.spawn("cp /etc/X11/xorg.conf " + self._chroot_dir + "/etc/X11/xorg.conf")
1252 if not GLIUtility.exitsuccess(exitstatus):
1253 self._logger.log("Could NOT copy the xorg configuration from the livecd to the new system!")
1254 else:
1255 self._logger.log("xorg.conf copied to new system. X should be ready to roll!")
1256 if GLIUtility.is_file(self._chroot_dir + "/etc/X11/gdm/gdm.conf"):
1257 GLIUtility.spawn("cp -f /etc/X11/gdm/gdm.conf.old " + self._chroot_dir + "/etc/X11/gdm/gdm.conf")
1258 if GLIUtility.is_file(self._chroot_dir + "/etc/X11/gdm/custom.conf"):
1259 GLIUtility.spawn("cp -f /etc/X11/gdm/custom.conf.old " + self._chroot_dir + "/etc/X11/gdm/custom.conf")
1260
1261 ##
1262 # Will set the list of services to runlevel default. This is a temporary solution!
1263 def set_services(self):
1264 services = self._install_profile.get_services()
1265 for service in services:
1266 if service:
1267 self._add_to_runlevel(service)
1268
1269
1270 ##
1271 # Will execute any arbritraially defined script here for post-install customization.
1272 def run_post_install_script(self):
1273 if self._install_profile.get_post_install_script_uri():
1274 try:
1275 if self._debug: self._logger.log("DEBUG: run_post_install_script(): getting script: "+self._install_profile.get_post_install_script_uri())
1276 GLIUtility.get_uri(self._install_profile.get_post_install_script_uri(), self._chroot_dir + "/var/tmp/post-install")
1277 if self._debug: self._logger.log("DEBUG: run_post_install_script(): running: chmod a+x /var/tmp/post-install && /var/tmp/post-install in chroot")
1278 GLIUtility.spawn("chmod a+x /var/tmp/post-install && /var/tmp/post-install", chroot=self._chroot_dir, display_on_tty8=True, logfile=self._compile_logfile, append_log=True)
1279 except:
1280 raise GLIException("RunPostInstallScriptError", 'fatal', 'run_post_install_script', "Failed to retrieve and/or execute post-install script")
1281
1282
1283 ##
1284 # This function will handle the various cleanup tasks as well as unmounting the filesystems for reboot.
1285 def finishing_cleanup(self):
1286 #These are temporary until I come up with a nicer idea.
1287 #get rid of the compile_output file so the symlink doesn't get screwed up.
1288
1289 #we copy the log over to the new system.
1290 install_logfile = LOGFILE
1291 try:
1292 if self._debug: self._logger.log("DEBUG: finishing_cleanup(): copying logfile over to new system's root.")
1293 shutil.copy(install_logfile, self._chroot_dir + install_logfile)
1294 except:
1295 if self._debug: self._logger.log("DEBUG: finishing_cleanup(): ERROR! could not copy logfile over to /root.")
1296 #Now we're done logging as far as the new system is concerned.
1297 GLIUtility.spawn("cp /tmp/installprofile.xml " + self._chroot_dir + "/root/installprofile.xml")
1298 GLIUtility.spawn("cp /tmp/clientconfiguration.xml " + self._chroot_dir + "/root/clientconfiguration.xml")
1299
1300 #Unmount mounted fileystems in preparation for reboot
1301 #mounts = GLIUtility.spawn(r"mount | sed -e 's:^.\+ on \(.\+\) type .\+$:\1:' | grep -e '^" + self._chroot_dir + "' | sort -r", return_output=True)[1].split("\n")
1302 mounted_devices = self._mounted_devices
1303 mounted_devices.sort()
1304 mounted_devices.reverse()
1305 for mount in mounted_devices:
1306 if self._debug: self._logger.log("DEBUG: finishing_cleanup(): running: umount -l " + mount)
1307 ret = GLIUtility.spawn("umount -l " + self._chroot_dir + mount)
1308 if not GLIUtility.exitsuccess(ret):
1309 self._logger.log("ERROR! : Could not unmount mountpoint %s" % mount)
1310
1311 # now turn off all swap as well.
1312 # we need to find the swap devices
1313 for swap_device in self._swap_devices:
1314 if self._debug: self._logger.log("DEBUG: finishing_cleanup(): running: swapoff "+swap_device)
1315 ret = GLIUtility.spawn("swapoff "+swap_device)
1316 if not GLIUtility.exitsuccess(ret):
1317 self._logger.log("ERROR! : Could not deactivate swap ("+swap_device+")!")
1318
1319 GLIUtility.spawn("rm /tmp/compile_output.log && rm " + install_logfile)
1320
1321
1322
1323 ##
1324 # This function should only be called in the event of an install failure. It performs
1325 # general cleanup to prepare the system for another installer run.
1326 def install_failed_cleanup(self):
1327 steps = len(self._mounted_devices) + len(self._swap_devices) + 2
1328 cur_step = 0
1329 if self._debug: self._logger.log("DEBUG: install_failed_cleanup(): gathering mounts to unmount")
1330 #mounts = GLIUtility.spawn(r"mount | sed -e 's:^.\+ on \(.\+\) type .\+$:\1:' | grep -e '^" + self._chroot_dir + "' | sort -r", return_output=True)[1].split("\n")
1331 mounted_devices = self._mounted_devices
1332 mounted_devices.sort()
1333 mounted_devices.reverse()
1334 for mount in mounted_devices:
1335 cur_step += 1
1336 self.notify_frontend("progress", (float(cur_step) / (steps), "Unmounting " + mount))
1337 if self._debug: self._logger.log("DEBUG: install_failed_cleanup(): running: umount -l " + mount)
1338 ret = GLIUtility.spawn("umount -l " + self._chroot_dir + mount)
1339 if not GLIUtility.exitsuccess(ret):
1340 self._logger.log("ERROR! : Could not unmount mountpoint %s" % mount)
1341
1342 # now turn off all swap as well.
1343 # we need to find the swap devices
1344 for swap_device in self._swap_devices:
1345 cur_step += 1
1346 self.notify_frontend("progress", (float(cur_step) / (steps), "Deactivating swap on " + swap_device))
1347 if self._debug: self._logger.log("DEBUG: install_failed_cleanup(): running: swapoff "+swap_device)
1348 ret = GLIUtility.spawn("swapoff "+swap_device)
1349 if not GLIUtility.exitsuccess(ret):
1350 self._logger.log("ERROR! : Could not deactivate swap ("+swap_device+")!")
1351
1352 if self._debug: self._logger.log("DEBUG: install_failed_cleanup(): running: mv /tmp/compile_output.log /tmp/compile_output.log.failed")
1353 self.notify_frontend("progress", (float(cur_step + 1) / (steps), "Moving compile output logfile"))
1354 GLIUtility.spawn("mv " + self._compile_logfile + " " + self._compile_logfile + ".failed")
1355 # GLIUtility.spawn("rm /tmp/compile_output.log")
1356 self.notify_frontend("progress", (float(cur_step + 2) / (steps), "Moving install logfile"))
1357 GLIUtility.spawn("mv " + LOGFILE + " " + LOGFILE + ".failed")
1358 # GLIUtility.spawn("rm /var/log/installer.log")

Properties

Name Value
svn:eol-style native

  ViewVC Help
Powered by ViewVC 1.1.20