aboutsummaryrefslogtreecommitdiff
blob: e763c1a8670afd22f34300e0a514b361e470846d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# Copyright 1999-2005 Gentoo Foundation
# This source code is distributed under the terms of version 2 of the GNU
# General Public License as published by the Free Software Foundation, a copy
# of which can be found in the main directory of this project.

import gtk
from GLIScreen import *
from ProgressDialog import *

class Panel(GLIScreen):

	title = "Bootloader"
	active_selection = None
	radio_bootloaders = {}
	_helptext = """
<b><u>Bootloader</u></b>

The bootloaders available depend on the architecture to be installed. For x86,
the two bootloaders available are grub and lilo.  In amd64, only grub is
available. Gentoo recommends grub.

For those who still like lilo, it is available.  Lilo will also detect windows
partitions (this support for grub coming soon).

You almost always will want to check the Install in MBR option, unless you do
not want your system to be bootable using your bootloader.

Set the boot drive to whatever hard drive is set to boot first on your computer.

If you have any extra kernel parameters you want to add, such as "doscsi", enter
them in the textbox.  Possible parameters can be found in the Handbook.  Usually
you will just leave this blank.
"""
	bootloaders = {
	  'none':  [ "none" ],
	  'x86':   [ "grub", "lilo" ],
	  'amd64': [ "grub" ],
	  'ppc':   [ "yaboot" ],
	  'hppa':  [ "palo" ],
	  'mips':  [ "arcload", "arcboot", "colo" ],
	  'sparc': [ "silo" ]
	}
	tmpbootloaders = None

	def __init__(self, controller):
		GLIScreen.__init__(self, controller)
		vert = gtk.VBox(False, 0)
		vert.set_border_width(10)

		self.tmpbootloaders = self.bootloaders[self.controller.cc.get_arch()] + self.bootloaders['none']
		if self.controller.install_type == "networkless":
			hbox = gtk.HBox(False)
			label = gtk.Label()
			label.set_markup('<b>Your bootloader will be %s</b>' % self.tmpbootloaders[0])
			hbox.pack_start(label, expand=False, fill=False, padding=0)
			vert.pack_start(hbox, expand=False, fill=False, padding=20)
		else:
			hbox = gtk.HBox(False)
			label = gtk.Label()
			label.set_markup('<b>Choose your bootloader</b>')
			hbox.pack_start(label, expand=False, fill=False, padding=0)
			vert.pack_start(hbox, expand=False, fill=False, padding=20)

			for bootloader in self.tmpbootloaders:
				hbox = gtk.HBox(False, 0)
				if bootloader == self.tmpbootloaders[0]:
					self.radio_bootloaders[bootloader] = gtk.RadioButton(None, bootloader)
				else:
					self.radio_bootloaders[bootloader] = gtk.RadioButton(self.radio_bootloaders[self.tmpbootloaders[0]], bootloader)
				self.radio_bootloaders[bootloader].set_name(bootloader)
				self.radio_bootloaders[bootloader].connect("toggled", self.bootloader_selected, bootloader)
				hbox.pack_start(self.radio_bootloaders[bootloader], expand=False, fill=False, padding=20)
				vert.pack_start(hbox, expand=False, fill=False, padding=20)

#		self.check_install_in_mbr = gtk.CheckButton("Install in MBR")
#		self.check_install_in_mbr.connect("toggled", self.mbr_selected)
#		self.check_install_in_mbr.set_size_request(125, -1)
#		hbox = gtk.HBox(False, 0)
#		hbox.pack_start(self.check_install_in_mbr, expand=False, fill=False, padding=5)
#		tmplabel = gtk.Label("This controls whether the bootloader is installed in the MBR or not")
#		tmplabel.set_line_wrap(True)
#		hbox.pack_start(tmplabel, expand=False, fill=False, padding=20)
#		vert.pack_start(hbox, expand=False, fill=False, padding=15)

#		hbox = gtk.HBox(False, 0)
#		tmplabel = gtk.Label("Boot Drive:")
#		tmplabel.set_alignment(0.0, 0.5)
#		tmplabel.set_size_request(160, -1)
#		hbox.pack_start(tmplabel, expand=False, fill=False, padding=0)
#		self.boot_device_combo = gtk.combo_box_new_text()
#		hbox.pack_start(self.boot_device_combo, expand=False, fill=False, padding=15)
#		vert.pack_start(hbox, expand=False, fill=False, padding=15)

#		hbox = gtk.HBox(False, 0)
#		tmplabel = gtk.Label("Extra kernel parameters:")
#		tmplabel.set_alignment(0.0, 0.5)
#		tmplabel.set_size_request(160, -1)
#		hbox.pack_start(tmplabel, expand=False, fill=False, padding=0)
#		self.kernel_params_entry = gtk.Entry()
#		self.kernel_params_entry.set_width_chars(40)
#		hbox.pack_start(self.kernel_params_entry, expand=False, fill=False, padding=15)
#		vert.pack_start(hbox, expand=False, fill=False, padding=15)

		self.add_content(vert)
		self.boot_devices = None

	def bootloader_selected(self, widget, data=None):
		self.active_selection = data
#		if data == "none":
#			self.check_install_in_mbr.set_sensitive(False)
#		else:
#			self.check_install_in_mbr.set_sensitive(True)

#	def mbr_selected(self, widget, data=None):
#		if self.check_install_in_mbr.get_active():
#			self.boot_device_combo.set_sensitive(True)
#		else:
#			self.boot_device_combo.set_sensitive(False)

	def activate(self):
		self.controller.SHOW_BUTTON_BACK    = True
		self.controller.SHOW_BUTTON_FORWARD = True
		if self.controller.install_type != "networkless":
			self.active_selection = self.controller.install_profile.get_boot_loader_pkg() or self.tmpbootloaders[0]
			self.radio_bootloaders[self.active_selection].set_active(True)
#		self.check_install_in_mbr.set_active(self.controller.install_profile.get_boot_loader_mbr())
#		self.boot_devices = self.controller.install_profile.get_partition_tables().keys()
#		self.boot_devices.sort()
#		self.boot_device_combo.get_model().clear()
#		boot_device = self.controller.install_profile.get_boot_device()
#		for i, device in enumerate(self.boot_devices):
#			self.boot_device_combo.get_model().append([device])
#			if boot_device == device:
#				self.boot_device_combo.set_active(i)
#		if self.boot_device_combo.get_active() == -1:
#			self.boot_device_combo.set_active(0)
#		kernel_params = self.controller.install_profile.get_bootloader_kernel_args()
#		if not "doscsi" in kernel_params.split():
#			parts_tmp = self.controller.install_profile.get_partition_tables()
#			for device in parts_tmp:
#				if not device.startswith("/dev/sda"): continue
#				for part in parts_tmp[device]:
#					if parts_tmp[device][part]['mountpoint'] == "/":
#						kernel_params += " doscsi"
#		self.kernel_params_entry.set_text(kernel_params)

	def next(self):
		if self.controller.install_type == "networkless":
			self.controller.install_profile.set_boot_loader_pkg(None, self.tmpbootloaders[0], None)
		else:
			self.controller.install_profile.set_boot_loader_pkg(None, self.active_selection, None)
		self.controller.install_profile.set_boot_loader_mbr(None, True, None)
#		if self.check_install_in_mbr.get_active():
#			self.controller.install_profile.set_boot_device(None, self.boot_devices[self.boot_device_combo.get_active()], None)
#		self.controller.install_profile.set_bootloader_kernel_args(None, self.kernel_params_entry.get_text(), None)
		progress = ProgressDialog(self.controller, ('install_bootloader', 'setup_and_run_bootloader' ), self.progress_callback)
		progress.run()

	def progress_callback(self, result, data=None):
		if result == PROGRESS_DONE:
			self.controller.load_screen("Users")
		else:
			GLIScreen.progress_callback(self, result, data)