/[gli]/trunk/src/templates/x86ArchitectureTemplate.py
Gentoo

Contents of /trunk/src/templates/x86ArchitectureTemplate.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 648 - (show annotations) (download) (as text)
Sat Jun 11 07:51:55 2005 UTC (15 years, 5 months ago) by robbat2
File MIME type: text/x-python
File size: 24860 byte(s)
Refactor code using spawn to reduce duplication.

1 """
2 Gentoo Linux Installer
3
4 $Id: x86ArchitectureTemplate.py,v 1.44 2005/06/11 07:51:55 robbat2 Exp $
5 Copyright 2004 Gentoo Technologies Inc.
6
7
8 This fills in x86 specific functions.
9 """
10
11 import GLIUtility, string
12 from GLIArchitectureTemplate import ArchitectureTemplate
13 from GLIException import *
14 import parted
15 import GLIStorageDevice
16
17 class x86ArchitectureTemplate(ArchitectureTemplate):
18 def __init__(self,configuration=None, install_profile=None, client_controller=None):
19 ArchitectureTemplate.__init__(self, configuration, install_profile, client_controller)
20 self._architecture_name = 'x86'
21 self._kernel_bzimage = "arch/i386/boot/bzImage"
22
23 def install_bootloader(self):
24 "Installs and configures bootloader"
25 #
26 # THIS IS ARCHITECTURE DEPENDANT!!!
27 # This is the x86 way.. it uses grub
28
29 if self._install_profile.get_boot_loader_pkg():
30 exitstatus = self._emerge(self._install_profile.get_boot_loader_pkg())
31 if exitstatus != 0:
32 raise GLIException("BootLoaderEmergeError", 'fatal', 'install_bootloader', "Could not emerge bootloader!")
33 else:
34 self._logger.log("Emerged the selected bootloader.")
35
36 if self._install_profile.get_boot_loader_pkg() == "grub":
37 self._install_grub()
38 elif self._install_profile.get_boot_loader_pkg() == "lilo":
39 self._install_lilo()
40 else:
41 raise GLIException("BootLoaderError",'fatal','install_bootloader',"Invalid bootloader selected:"+self._install_profile.get_boot_loader_pkg())
42
43 def _sectors_to_megabytes(self, sectors, sector_bytes=512):
44 return float((float(sectors) * sector_bytes)/ float(1024*1024))
45
46 def _add_partition(self, disk, start, end, type, fs):
47 types = { 'primary': parted.PARTITION_PRIMARY, 'extended': parted.PARTITION_EXTENDED, 'logical': parted.PARTITION_LOGICAL }
48 fsTypes = {}
49 fs_type = parted.file_system_type_get_next ()
50 while fs_type:
51 fsTypes[fs_type.name] = fs_type
52 fs_type = parted.file_system_type_get_next (fs_type)
53 fstype = None
54 if fs: fstype = fsTypes[fs]
55 newpart = disk.partition_new(types[type], fstype, start, end)
56 constraint = disk.dev.constraint_any()
57 disk.add_partition(newpart, constraint)
58
59 def partition(self):
60 MEGABYTE = 1024 * 1024
61 parts_old = {}
62 tmp_parts_new = self._install_profile.get_partition_tables()
63 parts_new = {}
64 for device in tmp_parts_new:
65 parts_new[device] = tmp_parts_new[device].get_install_profile_structure()
66 detected_devices = GLIStorageDevice.detect_devices()
67 for device in detected_devices:
68 tmpdevice = GLIStorageDevice.Device(device)
69 tmpdevice.set_partitions_from_disk()
70 parts_old[device] = tmpdevice.get_install_profile_structure()
71
72 for device in parts_new.keys():
73 # Skip this device in parts_new if device isn't detected on current system
74 if not device in detected_devices:
75 self._logger.log("There is no physical device " + device + " detected to match the entry in the install profile...skipping")
76 continue
77
78 # Check to see if the old and new partition table structures are the same
79 table_changed = 0
80 for part in parts_new[device]:
81 if not part in parts_old[device]:
82 table_changed = 1
83 break
84 oldpart = parts_old[device][part]
85 newpart = parts_new[device][part]
86 if oldpart['type'] == newpart['type'] and oldpart['start'] == newpart['start'] and oldpart['end'] == newpart['end'] and newpart['format'] == False:
87 continue
88 else:
89 table_changed = 1
90 break
91 # Skip this device if they are they same
92 if not table_changed:
93 self._logger.log("Partition table for " + device + " is unchanged...skipping")
94 continue
95
96 # Create pyparted objects for this device
97 parted_dev = parted.PedDevice.get(device)
98 parted_disk = parted.PedDisk.new(parted_dev)
99 new_part_list = parts_new[device].keys()
100 new_part_list.sort()
101 device_sectors = parted_dev.length
102
103 # Iterate through new partitions and check for 'origminor' and 'format' == False
104 for part in parts_new[device].keys():
105 tmppart_new = parts_new[device][part]
106 if not tmppart_new['origminor'] or tmppart_new['format']: continue
107 tmppart_old = parts_old[device][tmppart_new['origminor']]
108 # This partition in parts_new corresponds with an existing partitions, so we save the start/end sector and flags
109 for flag in range(0, 10):
110 # The 10 is completely arbitrary. If flags seem to be missed, this number should be increased
111 parted_part = parted_disk.get_partition(part)
112 if not parted_part: break
113 if parted_part.is_flag_available(flag) and parted_part.get_flag(flag):
114 if not "flags" in tmppart_new: tmppart_new['flags'] = []
115 tmppart_new['flags'].append(flag)
116 if tmppart_old['mb'] == tmppart_new['mb']:
117 tmppart_new['start'] = tmppart_old['start']
118 tmppart_new['end'] = tmppart_old['end']
119 else:
120 tmppart_new['start'] = tmppart_old['start']
121 tmppart_new['end'] = 0
122
123 # if parts_new[dev][parts_new[dev].keys()[0]]['mb']:
124 # # Change MB/%/* into sectors
125 # total_sectors = parted_dev.length
126 # sector_size = parted_dev.sector_size
127 # total_mb = float(total_sectors * sector_size) / MEGABYTE
128 # start_sector = 0
129 # mb_left = total_mb
130 # for part in parts_new[dev]:
131 # tmppart = parts_new[dev][part]
132 # if tmppart['type'] == "extended": continue
133 # if tmppart['mb'][-1] == "%":
134 # tmppart['mb'] = float(tmppart['mb'][:-1]) / 100 * total_mb
135 # mb_left = mb_left - float(tmppart['mb'])
136 # partlist = parts_new.keys()
137 # partlist.sort()
138 # for part in partlist:
139 # if part > 4: continue
140 # tmppart = parts_new[dev][part]
141 # if tmppart['type'] == "extended":
142 # for part_log in partlist:
143 # if part < 5: continue
144 # tmppart_log = parts_new[dev][part_log]
145 # if not tmppart['start']:
146 # tmppart['start'] = start_sector
147 # if tmppart_log['mb'] == "*":
148 # tmppart_log['mb'] = mb_left
149 # part_bytes = long(tmppart_log['mb'] * MEGABYTE)
150 # part_sectors = round(part_bytes / sector_size)
151 # tmppart_log['start'] = start_sector
152 # tmppart_log['end'] = start_sector + part_sectors - 1
153 # tmppart['end'] = tmppart_log['end']
154 # start_sector = start_sector + part_sectors
155 # continue
156 # if tmppart['mb'] == "*":
157 # tmppart['mb'] = mb_left
158 # part_bytes = long(tmppart['mb'] * MEGABYTE)
159 # part_sectors = round(part_bytes / sector_size)
160 # tmppart['start'] = start_sector
161 # tmppart['end'] = start_sector + part_sectors - 1
162 # start_sector = start_sector + part_sectors
163 # else:
164
165 # First pass to delete old partitions that aren't resized
166 self._logger.log("partitioning: Processing " + device + "...")
167 for part in parts_old[device]:
168 oldpart = parts_old[device][part]
169 # Replace 'x86' with call function to get arch from CC
170 if (GLIStorageDevice.archinfo['x86']['extended'] and part > 4) or oldpart['type'] == "free": continue
171 delete = 0
172 if oldpart['type'] == "extended":
173 logical_to_resize = 0
174 for part_log in parts_old[device]:
175 if part_log < 5 or parts_old[device][part_log]['type'] == "free": continue
176 delete_log = 0
177 for new_part in parts_new[device]:
178 if new_part < 5: continue
179 tmppart = parts_new[device][new_part]
180 # This partition is unchanged in the new layout
181 if tmppart['origminor'] == part_log and tmppart['start'] and tmppart['end']:
182 self._logger.log(" Deleting old minor " + str(part_log) + " to be recreated later")
183 delete_log = 1
184 break
185 # This partition is resized with the data preserved in the new layout
186 if tmppart['origminor'] == part_log and tmppart['start'] and not tmppart['end']:
187 self._logger.log(" Ignoring old minor " + str(part_log) + " to resize later")
188 logical_to_resize = 1
189 break
190 if delete_log:
191 self._logger.log(" No match found...deleting partition " + str(part_log))
192 parted_disk.delete_partition(parted_disk.get_partition(part_log))
193 if not logical_to_resize:
194 self._logger.log(" Deleting extended partition with minor " + str(part))
195 parted_disk.delete_partition(parted_disk.get_partition(part))
196 continue
197 for new_part in parts_new[device]:
198 tmppart = parts_new[device][new_part]
199 if tmppart['origminor'] == part and tmppart['start'] and tmppart['end']:
200 self._logger.log(" Deleting old minor " + str(part) + " to be recreated later")
201 delete = 1
202 break
203 if tmppart['origminor'] == part and tmppart['start'] and not tmppart['end']:
204 self._logger.log(" Ignoring old minor " + str(part) + " to resize later")
205 break
206 if delete:
207 self._logger.log(" No match found...deleting partition " + str(part))
208 parted_disk.delete_partition(parted_disk.get_partition(part))
209 parted_disk.commit()
210
211 # Second pass to resize old partitions that need to be resized
212 self._logger.log("Partitioning: Second pass...")
213 for part in parts_old[device]:
214 oldpart = parts_old[device][part]
215 for new_part in parts_new[device]:
216 tmppart = parts_new[device][new_part]
217 if tmppart['origminor'] == part and tmppart['start'] and not tmppart['end']:
218 self._logger.log(" Resizing old minor " + str(part) + " from " + str(oldpart['start']) + "-" + str(oldpart['end'])+ " to " + str(tmppart['start']) + "-" + str(tmppart['end']))
219 type = tmppart['type']
220 minor = part
221 start = tmppart['start']
222 # Replace 512 with code to retrieve bytes per sector for device
223 end = start + (long(tmppart['mb']) * MEGABYTE / 512)
224 for i in new_part_list:
225 if i <= new_part: continue
226 if parts_new[device][i]['start'] and end >= parts_new[device][i]['start']:
227 end = parts_new[device][i]['start'] - 1
228 elif end >= device_sectors:
229 end = device_sectors - 1
230 break
231 if type == "ext2" or type == "ext3":
232 total_sectors = end - start + 1
233 ret = GLIUtility.spawn("resize2fs " + device + str(minor) + " " + str(total_sectors) + "s")
234 if ret: # Resize error
235 raise GLIException("PartitionResizeError", 'fatal', 'partition', "could not resize " + device + str(minor))
236 elif type == "ntfs":
237 total_sectors = end - start + 1
238 total_bytes = long(total_sectors) * 512
239 ret = GLIUtility.spawn("ntfsresize --size " + str(total_bytes) + " " + device + str(minor))
240 if ret: # Resize error
241 raise GLIException("PartitionResizeError", 'fatal', 'partition', "could not resize " + device + str(minor))
242 elif type == "linux-swap" or type == "fat32":
243 parted_fs = parted_disk.get_partition(part).geom.file_system_open()
244 resize_constraint = parted_fs.get_resize_constraint()
245 if end < (start + resize_constraint.min_size) or start != resize_constraint.start_range.start:
246 raise GLIException("PartitionError", 'fatal', 'partition', "New size specified for " + device + str(minor) + " is not within allowed boundaries")
247 new_geom = resize_constraint.start_range.duplicate()
248 new_geom.set_start(start)
249 new_geom.set_end(end)
250 try:
251 parted_fs.resize(new_geom)
252 except:
253 raise GLIException("PartitionResizeError", 'fatal', 'partition', "could not resize " + device + str(minor))
254 self._logger.log(" Deleting old minor " + str(part) + " to be recreated in 3rd pass")
255 parted_disk.delete_partition(parted_disk.get_partition(part))
256 break
257 parted_disk.delete_all()
258 parted_disk.commit()
259
260 # Third pass to create new partition table
261 self._logger.log("Partitioning: Third pass....creating partitions")
262 start = 0
263 end = 0
264 extended_start = 0
265 extended_end = 0
266 self._logger.log(" Drive has " + str(device_sectors) + " sectors")
267 # for part in parts_new[device]:
268 for part in new_part_list:
269 newpart = parts_new[device][part]
270 self._logger.log(" Partition " + str(part) + " has " + str(newpart['mb']) + "MB")
271 part_sectors = long(newpart['mb']) * MEGABYTE / 512
272 end = start + part_sectors
273 for i in new_part_list:
274 if i <= part: continue
275 if parts_new[device][i]['start'] and end >= parts_new[device][i]['start']:
276 end = parts_new[device][i]['start'] - 1
277 break
278 # cap to end of device
279 if end >= device_sectors:
280 end = device_sectors - 1
281 # now the actual creation
282 if newpart['type'] == "free":
283 # Nothing to be done for this type
284 pass
285 elif newpart['type'] == "extended":
286 self._logger.log(" Adding extended partition " + str(part) + " from " + str(start) + " to " + str(end))
287 self._add_partition(parted_disk, start, end, "extended", "")
288 extended_start = start
289 extended_end = end
290 elif part < 5 or not GLIStorageDevice.archinfo['x86']['extended']:
291 self._logger.log(" Adding primary partition " + str(part) + " from " + str(start) + " to " + str(end))
292 self._add_partition(parted_disk, start, end, "primary", newpart['type'])
293 elif GLIStorageDevice.archinfo['x86']['extended'] and part > 4:
294 if start >= extended_end:
295 start = extended_start + 1
296 end = start + part_sectors
297 if part == new_part_list[-1] and end > extended_end:
298 end = extended_end
299 self._logger.log(" Adding logical partition " + str(part) + " from " + str(start) + " to " + str(end))
300 self._add_partition(parted_disk, start, end, "logical", newpart['type'])
301 if "flags" in newpart:
302 for flag in newpart['flags']:
303 if parted_disk.get_partition(part).is_flag_available(flag):
304 parted_disk.get_partition(part).set_flag(flag)
305 # write to disk
306 parted_disk.commit()
307 # now format the partition
308 # extended partitions should never be formatted
309 if newpart['format'] and newpart['type'] != 'extended':
310 devnode = device + str(part)
311 errormsg = "could't create %s filesystem on %s" % (newpart['type'],devnode)
312 # if you need a special command and
313 # some base options, place it here. -f
314 # is here for filesystems that asks for
315 # confirmation.
316 if newpart['type'] == "linux-swap":
317 cmdname = "mkswap"
318 elif newpart['type'] == "fat32":
319 cmdname = "mkfs.vfat -F 32"
320 elif newpart['type'] == "ntfs":
321 cmdname = "mkntfs"
322 elif newpart['type'] == "reiserfs":
323 cmdname = "mkfs.reiserfs -f"
324 elif newpart['type'] == "jfs":
325 cmdname = "mkfs.jfs -f"
326 elif newpart['type'] == "xfs":
327 cmdname = "mkfs.xfs -f"
328 else: # this should catch everything else
329 cmdname = "mkfs."+newpart['type']
330 # now the actual command
331 cmd = "%s %s %s" % (cmdname,newpart['mkfsopts'],devnode)
332 self._logger.log(" Formatting partition %s as %s with: %s" % (str(part),newpart['type'],cmd))
333 # If logging is not done, then you get errors:
334 # PartitionFormatError :FATAL: partition: could't create ext2 filesystem on /dev/hda1
335 #if GLIUtility.spawn(cmd):
336 #if GLIUtility.spawn(cmd,append_log=True,logfile='/var/log/install-mkfs.log'):
337 if GLIUtility.spawn(cmd,logfile='/dev/null'):
338 raise GLIException("PartitionFormatError", 'fatal', 'partition', errormsg)
339 start = end + 1
340
341 def _install_grub(self):
342 boot_device = ""
343 boot_minor = ""
344 root_device = ""
345 root_minor = ""
346 grub_root_minor = ""
347 grub_boot_minor = ""
348 grub_boot_drive = ""
349 grub_root_drive = ""
350 minornum = 0
351 #Assign root to the root mount point to make lines more readable
352 root = self._chroot_dir
353 file_name2 = root + "/boot/grub/device.map"
354 file_name3 = root + "/boot/grub/kernel_name"
355 file_name4 = root + "/boot/grub/initrd_name"
356 foundboot = False
357 parts = self._install_profile.get_partition_tables()
358 for device in parts:
359 tmp_partitions = parts[device].get_install_profile_structure()
360 for partition in tmp_partitions:
361 mountpoint = tmp_partitions[partition]['mountpoint']
362 if (mountpoint == "/boot"):
363 foundboot = True
364 if (( (mountpoint == "/") and (not foundboot) ) or (mountpoint == "/boot")):
365 boot_minor = str(int(tmp_partitions[partition]['minor']))
366 grub_boot_minor = str(int(tmp_partitions[partition]['minor']) - 1)
367 boot_device = device
368 if mountpoint == "/":
369 root_minor = str(int(tmp_partitions[partition]['minor']))
370 grub_root_minor = str(int(tmp_partitions[partition]['minor']) - 1)
371 root_device = device
372 if GLIUtility.is_file(root+file_name2):
373 exitstatus = GLIUtility.spawn("rm "+root+file_name2)
374 exitstatus1 = GLIUtility.spawn("echo quit | "+ root+"/sbin/grub --device-map="+file_name2)
375 exitstatus2 = GLIUtility.spawn("ls "+root+"/boot/kernel-* > "+file_name3)
376 exitstatus3 = GLIUtility.spawn("ls "+root+"/boot/initrd-* > "+file_name4)
377 if (exitstatus1 != 0) or (exitstatus2 != 0) or (exitstatus3 != 0):
378 raise GLIException("BootloaderError", 'fatal', '_install_grub', "Error in one of THE THREE run commands")
379 self._logger.log("Bootloader: the three information gathering commands have been run")
380 """
381 read the device map. sample looks like this:
382 (fd0) /dev/floppy/0
383 (hd0) /dev/ide/host2/bus0/target0/lun0/disc
384 (hd1) /dev/ide/host0/bus0/target0/lun0/disc
385 (hd2) /dev/ide/host0/bus0/target1/lun0/disc
386 """
387
388 # Search for the key
389 f = open(file_name2) #open the device map
390 file = f.readlines()
391 f.close()
392 for i in range(len(file)):
393 if file[i][6:-1] == boot_device:
394 #eurika we found the drivenum
395 grub_boot_drive = file[i][1:4]
396 if file[i][6:-1] == root_device:
397 grub_root_drive = file[i][1:4]
398 if (not grub_root_drive) or (not grub_boot_drive):
399 raise GLIException("BootloaderError", 'fatal', '_install_grub',"Couldn't find the drive num in the list from the device.map")
400
401 g = open(file_name3)
402 h = open(file_name4)
403 initrd_name = h.readlines()
404 kernel_name = g.readlines()
405 g.close()
406 h.close()
407 if not kernel_name[0]:
408 raise GLIException("BootloaderError", 'fatal', '_install_grub',"Error: We have no kernel in /boot to put in the grub.conf file!")
409 kernel_name = map(string.strip, kernel_name)
410 initrd_name = map(string.strip, initrd_name)
411 for i in range(len(kernel_name)):
412 grub_kernel_name = kernel_name[i].split(root)[1]
413 for i in range(len(initrd_name)):
414 grub_initrd_name = initrd_name[i].split(root)[1]
415 #-------------------------------------------------------------
416 #OK, now that we have all the info, let's build that grub.conf
417 newgrubconf = ""
418 newgrubconf += "default 0\ntimeout 30\n"
419 if self._install_profile.get_bootloader_kernel_args(): bootloader_kernel_args = self._install_profile.get_bootloader_kernel_args()
420 else: bootloader_kernel_args = ""
421 if foundboot: #we have a /boot
422 newgrubconf += "splashimage=(" + grub_boot_drive + "," + grub_boot_minor + ")/grub/splash.xpm.gz\n"
423 else: #we have / and /boot needs to be included
424 newgrubconf += "splashimage=(" + grub_boot_drive + "," + grub_boot_minor + ")/boot/grub/splash.xpm.gz\n"
425
426 newgrubconf += "title=Gentoo Linux\n"
427 newgrubconf += "root (" + grub_boot_drive + "," + grub_boot_minor + ")\n"
428 if self._install_profile.get_kernel_config_uri() != "": #using CUSTOM kernel
429 if foundboot:
430 newgrubconf += "kernel " + grub_kernel_name[5:] + " root="+root_device+root_minor+"\n"
431 else:
432 newgrubconf += "kernel /boot"+ grub_kernel_name[5:] + " root="+root_device+root_minor+"\n"
433 else:
434 if foundboot:
435 newgrubconf += "kernel " + grub_kernel_name[5:] + " root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root="
436 newgrubconf += root_device + root_minor + " " + bootloader_kernel_args + "\n"
437 newgrubconf += "initrd " + grub_initrd_name[5:] + "\n"
438 else:
439 newgrubconf += "kernel /boot" + grub_kernel_name[5:] + " root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root="
440 newgrubconf += root_device + root_minor + " " + bootloader_kernel_args + "\n"
441 newgrubconf += "initrd /boot" + grub_initrd_name[5:] + "\n"
442
443 #-------------------------------------------------------------
444 #OK, now that the file is built. Install grub.
445 #cp /proc/mounts /etc/mtab
446 #grub-install --root-directory=/boot /dev/hda
447 #shutil.copy("/proc/mounts",root +"/etc/mtab")
448 grubinstallstring = "echo -en 'root ("+grub_boot_drive + "," + grub_boot_minor + ")\n"
449 if not self._install_profile.get_boot_loader_mbr():
450 grubinstallstring +="setup ("+grub_boot_drive + "," + grub_boot_minor + ")\n"
451 else:
452 grubinstallstring +="setup ("+grub_boot_drive+")\n"
453 grubinstallstring += "quit\n' | "+root+"/sbin/grub"
454 #print grubinstallstring
455 exitstatus = GLIUtility.spawn(grubinstallstring)
456 if exitstatus != 0:
457 raise GLIException("GrubInstallError", 'fatal', '_install_grub', "Could not install grub!")
458 self._logger.log("Bootloader: grub has been installed!")
459 #now make the grub.conf file
460 file_name = root + "/boot/grub/grub.conf"
461 try:
462 shutil.move(file_name, file_name + ".OLDdefault")
463 except:
464 pass
465 f = open(file_name, 'w')
466 f.writelines(newgrubconf)
467 f.close()
468 self._logger.log("Grub installed and configured.")
469
470 def _install_lilo(self):
471 boot_device = ""
472 boot_minor = ""
473 root_device = ""
474 root_minor = ""
475 minornum = 0
476 #Assign root to the root mount point to make lines more readable
477 root = self._chroot_dir
478 file_name3 = root + "/boot/grub/kernel_name"
479 foundboot = False
480 parts = self._install_profile.get_partition_tables()
481 for device in parts:
482 tmp_partitions = parts[device]
483 for partition in tmp_partitions:
484 mountpoint = tmp_partitions[partition]['mountpoint']
485 if (mountpoint == "/boot"):
486 foundboot = True
487 if (( (mountpoint == "/") and (not foundboot) ) or (mountpoint == "/boot")):
488 boot_minor = str(int(tmp_partitions[partition]['minor']))
489 boot_device = device
490 if mountpoint == "/":
491 root_minor = str(int(tmp_partitions[partition]['minor']))
492 root_device = device
493 exitstatus0 = GLIUtility.spawn("ls "+root+"/boot/kernel-* > "+file_name3)
494 exitstatus1 = GLIUtility.spawn("ls "+root+"/boot/initrd-* >> "+file_name3)
495 if (exitstatus0 != 0) or (exitstatus1 != 0):
496 raise GLIException("BootloaderError", 'fatal', '_install_lilo', "Error in one of THE TWO run commands")
497 g = open(file_name3)
498 kernel_name = g.readlines()
499 g.close()
500 if not kernel_name[0]:
501 raise GLIException("BootloaderError", 'fatal', '_install_lilo',"Error: We have no kernel in /boot to put in the grub.conf file!")
502 kernel_name = map(string.strip, kernel_name)
503 kernel_name[0] = kernel_name[0].split(root)[1]
504 kernel_name[1] = kernel_name[1].split(root)[1]
505 if self._install_profile.get_bootloader_kernel_args(): bootloader_kernel_args = self._install_profile.get_bootloader_kernel_args()
506 else: bootloader_kernel_args = ""
507 #-------------------------------------------------------------
508 #time to build the lilo.conf
509 newliloconf = ""
510 if self._install_profile.get_boot_loader_mbr():
511 newliloconf += "boot="+boot_device+" # Install LILO in the MBR \n"
512 else:
513 newliloconf += "boot="+boot_device+boot_minor+" # Install LILO in the MBR \n"
514 newliloconf += "prompt # Give the user the chance to select another section\n"
515 newliloconf += "timeout=50 # Wait 5 (five) seconds before booting the default section\n"
516 newliloconf += "default=gentoo # When the timeout has passed, boot the \"gentoo\" section\n"
517 newliloconf += "# Only if you use framebuffer. Otherwise remove the following line:\n"
518 if not self._install_profile.get_kernel_bootsplash():
519 newliloconf += "#"
520 newliloconf += "vga=788 # Framebuffer setting. Adjust to your own will\n"
521 newliloconf += "image=/boot"+kernel_name[0][5:]+" \n"
522 newliloconf += " label=gentoo \n read-only \n root=/dev/ram0 \n"
523 newliloconf += " append=\"init=/linuxrc ramdisk=8192 real_root="+root_device+root_minor + " " + bootloader_kernel_args + "\" \n"
524 newliloconf += " initrd=/boot"+kernel_name[1][5:] + "\n\n"
525 newliloconf = self._lilo_add_windows(newliloconf)
526 #now make the lilo.conf file
527 file_name = root + "/etc/lilo.conf"
528 try:
529 shutil.move(file_name, file_name + ".OLDdefault")
530 except:
531 pass
532 f = open(file_name, 'w')
533 f.writelines(newliloconf)
534 f.close()
535 #-------------------------------------------------------------
536 #OK, now that the file is built. Install lilo.
537 exitstatus = GLIUtility.spawn("/sbin/lilo",chroot=self._chroot_dir)
538 if exitstatus != 0:
539 raise GLIException("LiloInstallError", 'fatal', '_install_lilo', "Running lilo failed!")
540 self._logger.log("Lilo installed, configured, and run.")
541
542 def _lilo_add_windows(self, newliloconf):
543 parts = self._install_profile.get_partition_tables()
544 for device in parts:
545 tmp_partitions = parts[device]
546 for partition in tmp_partitions:
547 if (tmp_partitions[partition]['type'] == "vfat") or (tmp_partitions[partition]['type'] == "ntfs"):
548 newliloconf += "other="+device+str(int(tmp_partitions[partition]['minor']))+"\n"
549 newliloconf += "label=Windows_P"+str(int(tmp_partitions[partition]['minor']))+"\n\n"
550 return newliloconf

Properties

Name Value
svn:eol-style native

  ViewVC Help
Powered by ViewVC 1.1.20