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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:eol-style native

  ViewVC Help
Powered by ViewVC 1.1.20