/[gli]/branches/overhaul/src/templates/x86ArchitectureTemplate.py
Gentoo

Contents of /branches/overhaul/src/templates/x86ArchitectureTemplate.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 377 - (hide annotations) (download) (as text)
Sat Mar 19 04:39:35 2005 UTC (13 years, 8 months ago) by agaffney
Original Path: trunk/src/templates/x86ArchitectureTemplate.py
File MIME type: text/x-python
File size: 21916 byte(s)
added code to convert MB/%/* to start/end sectors

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

Properties

Name Value
svn:eol-style native

  ViewVC Help
Powered by ViewVC 1.1.20