/[gli]/branches/overhaul/src/fe/gtk/KernelConfig.py
Gentoo

Contents of /branches/overhaul/src/fe/gtk/KernelConfig.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1744 - (show annotations) (download) (as text)
Sat Mar 3 16:42:45 2007 UTC (7 years, 4 months ago) by agaffney
File MIME type: text/x-python
File size: 6684 byte(s)
allow use of genkernel with any sources
1 # Copyright 1999-2005 Gentoo Foundation
2 # This source code is distributed under the terms of version 2 of the GNU
3 # General Public License as published by the Free Software Foundation, a copy
4 # of which can be found in the main directory of this project.
5
6 import gtk
7 from GLIScreen import *
8 import GLIUtility
9 import URIBrowser
10 from ProgressDialog import *
11
12 class Panel(GLIScreen):
13
14 title = "Kernel Config"
15 active_selection = None
16 radio_configs = {}
17 _helptext = """
18 <b><u>Kernel Configuration</u></b>
19
20 There are a few different ways you can configure your new kernel. The easiest \
21 method is to just use the default configuration for your kernel. The other \
22 options are to configure the kernel yourself using the kernel's menuconfig process \
23 or to specify a URI pointing to a pre-made kernel .config file.
24
25 These options are only available in Advanced mode.
26 """
27
28 def __init__(self, controller):
29 GLIScreen.__init__(self, controller)
30 vert = gtk.VBox(False, 0)
31 vert.set_border_width(10)
32
33 if self.controller.install_type == "standard":
34 hbox = gtk.HBox(False, 0)
35 label = gtk.Label()
36 label_markup = '<b>Your kernel will be built with the default configuration.</b>'
37 label.set_markup(label_markup)
38 label.set_line_wrap(True)
39 hbox.pack_start(label, expand=False, fill=False, padding=5)
40 vert.pack_start(hbox, expand=False, fill=False, padding=10)
41 else:
42 hbox = gtk.HBox(False)
43 label = gtk.Label()
44 label.set_markup('<b>Choose your kernel configuration method</b>')
45 hbox.pack_start(label, expand=False, fill=False, padding=0)
46 vert.pack_start(hbox, expand=False, fill=False, padding=20)
47
48 hbox = gtk.HBox(False, 0)
49 self.radio_configs['auto'] = gtk.RadioButton(None, "Use default configuration")
50 self.radio_configs['auto'].set_name("auto")
51 self.radio_configs['auto'].connect("toggled", self.config_selected, "auto")
52 hbox.pack_start(self.radio_configs['auto'], expand=False, fill=False, padding=20)
53 vert.pack_start(hbox, expand=False, fill=False, padding=20)
54
55 hbox = gtk.HBox(False, 0)
56 self.radio_configs['menuconfig'] = gtk.RadioButton(self.radio_configs['auto'], "Use the kernel's menuconfig process")
57 self.radio_configs['menuconfig'].set_name("menuconfig")
58 self.radio_configs['menuconfig'].connect("toggled", self.config_selected, "menuconfig")
59 hbox.pack_start(self.radio_configs['menuconfig'], expand=False, fill=False, padding=20)
60 vert.pack_start(hbox, expand=False, fill=True, padding=20)
61
62 hbox = gtk.HBox(False, 0)
63 self.radio_configs['configuri'] = gtk.RadioButton(self.radio_configs['auto'], "Specify a pre-made kernel .config")
64 self.radio_configs['configuri'].set_name("configuri")
65 self.radio_configs['configuri'].connect("toggled", self.config_selected, "configuri")
66 hbox.pack_start(self.radio_configs['configuri'], expand=False, fill=False, padding=20)
67 vert.pack_start(hbox, expand=False, fill=True, padding=20)
68
69 hbox = gtk.HBox(False, 0)
70 hbox.pack_start(gtk.Label(" "), expand=False, fill=False, padding=15)
71 hbox.pack_start(gtk.Label("URI:"), expand=False, fill=False, padding=5)
72 self.entry_kernel_config_uri = gtk.Entry()
73 self.entry_kernel_config_uri.set_width_chars(50)
74 self.entry_kernel_config_uri.set_sensitive(False)
75 hbox.pack_start(self.entry_kernel_config_uri, expand=False, fill=False, padding=0)
76 self.browse_uri = gtk.Button("Browse")
77 self.browse_uri.connect("clicked", self.browse_uri_clicked)
78 self.browse_uri.set_sensitive(False)
79 hbox.pack_start(self.browse_uri, expand=False, fill=False, padding=5)
80 vert.pack_start(hbox, expand=False, fill=False, padding=0)
81
82 self.add_content(vert)
83
84 def browse_uri_clicked(self, widget):
85 uribrowser = URIBrowser.URIBrowser(self, self.entry_kernel_config_uri)
86 uribrowser.run(self.entry_kernel_config_uri.get_text())
87
88 def config_selected(self, widget, data=None):
89 self.active_selection = data
90 if data == "configuri":
91 self.entry_kernel_config_uri.set_sensitive(True)
92 self.browse_uri.set_sensitive(True)
93 else:
94 self.entry_kernel_config_uri.set_sensitive(False)
95 self.browse_uri.set_sensitive(False)
96
97 def activate(self):
98 self.controller.SHOW_BUTTON_BACK = True
99 self.controller.SHOW_BUTTON_FORWARD = True
100 if self.controller.install_type != "standard":
101 kernel_config_uri = self.controller.install_profile.get_kernel_config_uri()
102 if kernel_config_uri:
103 if kernel_config_uri == "file://%s/usr/src/linux/.config" % self.controller.install_profile.get_root_mount_point():
104 self.radio_configs['menuconfig'].set_active(True)
105 else:
106 self.entry_kernel_config_uri.set_text(kernel_config_uri)
107 # if self.controller.install_profile.get_kernel_source_pkg() != "gentoo-sources":
108 # self.radio_configs['auto'].set_sensitive(False)
109 # self.radio_configs['menuconfig'].set_active(True)
110
111 def next(self):
112 self.controller.install_profile.set_kernel_build_method(None, "genkernel", None)
113 if self.controller.install_type != "standard":
114 if self.active_selection == "configuri":
115 if not self.entry_kernel_config_uri.get_text():
116 msgdlg = gtk.MessageDialog(parent=self.controller.window, type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_OK, message_format="You did not enter a kernel configuration URI. You cannot continue until you enter a kernel configuration URI or choose a different configuration method.")
117 msgdlg.run()
118 msgdlg.destroy()
119 return
120 elif not GLIUtility.validate_uri(self.entry_kernel_config_uri.get_text()):
121 msgdlg = gtk.MessageDialog(parent=self.controller.window, type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_OK, message_format="The kernel configuration URI you entered does not exist or is not a valid URI. You cannot continue unless you enter a valid URI or choose another configuration method.")
122 msgdlg.run()
123 msgdlg.destroy()
124 return
125 elif self.active_selection == "menuconfig":
126 while True:
127 GLIUtility.spawn("xterm -e 'cd /usr/src/linux && make menuconfig'", chroot=self.controller.install_profile.get_root_mount_point())
128 msgdlg = gtk.MessageDialog(parent=self.controller.window, type=gtk.MESSAGE_QUESTION, buttons=gtk.BUTTONS_YES_NO, message_format="Are you finished configuring your kernel?")
129 resp = msgdlg.run()
130 msgdlg.destroy()
131 if resp == gtk.RESPONSE_YES:
132 self.controller.install_profile.set_kernel_config_uri(None, "file://%s/usr/src/linux/.config", None)
133 break
134 progress = ProgressDialog(self.controller, ("build_kernel", ), self.progress_callback)
135 progress.run()
136
137 def progress_callback(self, result, data=None):
138 if result == PROGRESS_DONE:
139 self.controller.load_screen("Networking")
140 else:
141 GLIScreen.progress_callback(self, result, data)

Properties

Name Value
svn:keywords Id

  ViewVC Help
Powered by ViewVC 1.1.20