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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 497 - (show annotations) (download) (as text)
Mon Apr 11 19:59:20 2005 UTC (15 years, 7 months ago) by agaffney
File MIME type: text/x-python
File size: 23722 byte(s)
Finish overhaul of backend partitioning code.

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

Properties

Name Value
svn:eol-style native

  ViewVC Help
Powered by ViewVC 1.1.20