=== modified file 'ubiquity/components/summary.py' --- ubiquity/components/summary.py 2008-08-08 14:22:31 +0000 +++ ubiquity/components/summary.py 2008-10-11 06:55:55 +0000 @@ -28,6 +28,36 @@ from ubiquity.filteredcommand import FilteredCommand +def find_grub_target(): + # This needs to be somewhat duplicated from grub-installer here because we + # need to be able to show the user what device GRUB will be installed to + # well before grub-installer is run. + try: + boot = '' + root = '' + os.seteuid(0) + p = PartedServer() + for disk in p.disks(): + p.select_disk(disk) + for part in p.partitions(): + part = part[1] + if p.has_part_entry(part, 'mountpoint'): + mp = p.readline_part_entry(part, 'mountpoint') + if mp == '/boot': + boot = disk.replace('=', '/') + elif mp == '/': + root = disk.replace('=', '/') + drop_privileges() + if boot: + return boot + elif root: + return root + except Exception, e: + import syslog + syslog.syslog('Exception in find_grub_target: ' + str(e)) + return '(hd0)' + return '(hd0)' + def grub_options(): """ Generates a list of suitable targets for grub-installer @return empty list or a list of ['/dev/sda1','Ubuntu Hardy 8.04'] """ @@ -107,7 +137,7 @@ if os.access('/usr/share/grub-installer/grub-installer', os.X_OK): # TODO cjwatson 2006-09-04: a bit inelegant, and possibly # Ubuntu-specific? - self.frontend.set_summary_device('(hd0)') + self.frontend.set_summary_device(find_grub_target()) else: self.frontend.set_summary_device(None)