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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1623 - (show annotations) (download) (as text)
Fri Jan 19 10:19:38 2007 UTC (7 years, 5 months ago) by agaffney
File MIME type: text/x-python
File size: 16085 byte(s)
remove Help button
rearrange Stage screen
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 import GLIScreen
8 import commands
9 import gobject
10 import GLIUtility
11
12 class Panel(GLIScreen.GLIScreen):
13
14 title = "make.conf"
15 make_conf_values = {}
16 use_flags = []
17 use_desc = {}
18 columns = []
19 arch_procs = { 'alpha': ("ev4", "ev5", "ev56", "pca56", "ev6", "ev67"),
20 'amd64': ("athlon64", "opteron", "athlon-fx", "k8", "nocona"),
21 'ppc': ("G3", "G4", "G5", "power", "common", "powerpc"),
22 'x86': ("i386", "i486", "i586", "pentium", "pentium-mmx", "i686", "pentiumpro", "pentium2", "pentium3", "pentium3m", "pentium-m", "pentium4", "pentium4m", "prescott", "k6", "k6-2", "k6-3", "athlon", "athlon-tbird", "athlon-4", "athlon-xp", "athlon-mp", "winchip-c6", "winchip2", "c3", "c3-2")
23 }
24 optimizations = ["-O0", "-O1", "-O2", "-Os", "-O3"]
25 _helptext = """
26 <b><u>Make.conf</u></b>
27
28 One of the unique (and best) features of Gentoo is the ability to define flags
29 (called USE flags) that determine what components are compiled into
30 applications. For example, you can enable the "alsa" flag and programs that
31 have alsa capability will compile in support for alsa. Otherwise they will
32 leave it out, resulting in smaller, faster applications. The result is a
33 finely-tuned OS with no unnecessary components to slow you down.
34
35 There are two types of USE flags, local (for only one application), and global
36 (for all apps). The local use flags will tell you which package they refer to
37 in the Description. Note that the names of the USE flags can sometimes be
38 misleading since they often refer to only one package.
39
40 CFLAGS:
41
42 The CFLAGS variable defines the optimization flags for the gcc C and C++
43 compilers. Although we define those generally here, you will only have maximum
44 performance if you optimize these flags for each program separately. The reason
45 for this is because every program is different.
46
47 A first setting is the processor, which specifies the name of the target
48 architecture. Select your Proc from the list.
49
50 A second one is the -O flag (that is a capital O, not a zero), which specifies
51 the gcc optimization class flag. Possible classes are s (for size-optimized),
52 0 (zero - for no optimizations), 1, 2 or 3 for more speed-optimization flags
53 (every class has the same flags as the one before, plus some extras). 2 is a
54 safe level of optimization.
55
56 You can add additional custom CFLAGS with the textbox.
57
58 Another popular optimization flag is -pipe (use pipes rather than temporary
59 files for communication between the various stages of compilation).
60
61 Mind you that using -fomit-frame-pointer (which doesn't keep the frame pointer
62 in a register for functions that don't need one) might have serious
63 repercussions on the debugging of applications!
64
65 Other:
66
67 Select Use unstable only if you are an expert Gentoo user or want to use
68 bleeding edge unstable applications. This is highly NOT recommended because it
69 will often result in failed installations due to compilation errors in unstable
70 applications.
71
72 Select Build binary packages if you plan on using the compiled packages
73 elsewhere (very rarely needed).
74
75 DistCC functionality has not yet been implemented with the GTK+ frontend. If
76 you need this, use gli-dialog, the command-line frontend to GLI.
77
78 Select ccache to enable ccache support via CC.
79
80 The CHOST variable declares the target build host for your system. This variable
81 should already be set to the correct value. Do not edit it as that might break
82 your system. If the CHOST variable does not look correct to you, you might be
83 using the wrong stage3 tarball.
84
85 With MAKEOPTS you define how many parallel compilations should occur when you
86 install a package. A good choice is the number of CPUs in your system plus one,
87 but this guideline isn't always perfect. The syntax for the MAKEOPTS varaible is
88 "-jN" where N is the number of parallel compilations (for example: -j2).
89 """
90
91 def __init__(self, controller):
92 GLIScreen.GLIScreen.__init__(self, controller)
93
94 self.system_use_flags = commands.getoutput("portageq envvar USE").strip()
95 self.system_cflags = commands.getoutput("portageq envvar CFLAGS").strip()
96 self.system_chost = commands.getoutput("portageq envvar CHOST").strip()
97 self.system_makeopts = commands.getoutput("portageq envvar MAKEOPTS").strip()
98 self.system_features = commands.getoutput("portageq envvar FEATURES").strip()
99 self.system_accept_keywords = commands.getoutput("portageq envvar ACCEPT_KEYWORDS").strip()
100
101 vert = gtk.VBox(False, 0)
102 vert.set_border_width(10)
103
104 content_str = """On this screen, you'll define all of your /etc/make.conf settings.
105 """
106
107 content_label = gtk.Label(content_str)
108 vert.pack_start(content_label, expand=False, fill=False, padding=0)
109
110 f = open("/usr/portage/profiles/use.desc", "r")
111 for line in f:
112 line = line.strip()
113 if not line or line.startswith("#"): continue
114 dash_pos = line.find(" - ")
115 if dash_pos == -1: continue
116 flagname = line[:dash_pos] or line[dash_pos-1]
117 desc = line[dash_pos+3:]
118 self.use_desc[flagname] = desc
119 f.close()
120
121 f = open("/usr/portage/profiles/use.local.desc", "r")
122 for line in f:
123 line = line.strip()
124 if not line or line.startswith("#"): continue
125 dash_pos = line.find(" - ")
126 if dash_pos == -1: continue
127 colon_pos = line.find(":", 0, dash_pos)
128 pkg = line[:colon_pos]
129 flagname = line[colon_pos+1:dash_pos] or line[colon_pos+1]
130 desc = "(" + pkg + ") " + line[dash_pos+3:]
131 self.use_desc[flagname] = desc
132 f.close()
133
134 hbox = gtk.HBox(False, 0)
135 label = gtk.Label()
136 label.set_markup("<b>USE flags:</b>")
137 hbox.pack_start(label, expand=False, fill=False, padding=0)
138 vert.pack_start(hbox, expand=False, fill=False, padding=5)
139
140 sorted_use = self.use_desc.keys()
141 sorted_use.sort()
142 self.treedata = gtk.ListStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, gobject.TYPE_STRING)
143 for flag in sorted_use:
144 self.treedata.append([(flag in self.use_flags and self.use_flags[flag] == 1), flag, self.use_desc[flag]])
145 self.treeview = gtk.TreeView(self.treedata)
146 self.toggle_renderer = gtk.CellRendererToggle()
147 self.toggle_renderer.set_property("activatable", True)
148 self.toggle_renderer.connect("toggled", self.flag_toggled)
149 self.columns.append(gtk.TreeViewColumn("Active", self.toggle_renderer, active=0))
150 self.columns.append(gtk.TreeViewColumn("Flag", gtk.CellRendererText(), text=1))
151 self.columns.append(gtk.TreeViewColumn("Description", gtk.CellRendererText(), text=2))
152 for column in self.columns:
153 column.set_resizable(True)
154 self.treeview.append_column(column)
155 self.treewindow = gtk.ScrolledWindow()
156 self.treewindow.set_size_request(-1, 180)
157 self.treewindow.set_shadow_type(gtk.SHADOW_IN)
158 self.treewindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
159 self.treewindow.add(self.treeview)
160 vert.pack_start(self.treewindow, expand=False, fill=False, padding=10)
161
162 hbox = gtk.HBox(False, 0)
163 label = gtk.Label()
164 label.set_markup("<b>CFLAGS:</b>")
165 hbox.pack_start(label, expand=False, fill=False, padding=0)
166 vert.pack_start(hbox, expand=False, fill=False, padding=5)
167
168 hbox = gtk.HBox(False, 0)
169 hbox.pack_start(gtk.Label("Proc:"), expand=False, fill=False, padding=0)
170 self.proc_combo = gtk.combo_box_new_text()
171 # for proc in self.arch_procs[self.controller.client_profile.get_architecture_template()]:
172 # self.proc_combo.append_text(proc)
173 # self.proc_combo.set_active(0)
174 hbox.pack_start(self.proc_combo, expand=False, fill=False, padding=10)
175 hbox.pack_start(gtk.Label("Optimizations:"), expand=False, fill=False, padding=0)
176 self.optimizations_combo = gtk.combo_box_new_text()
177 for opt in self.optimizations:
178 self.optimizations_combo.append_text(opt)
179 self.optimizations_combo.set_active(0)
180 hbox.pack_start(self.optimizations_combo, expand=False, fill=False, padding=10)
181 hbox.pack_start(gtk.Label("Custom:"), expand=False, fill=False, padding=0)
182 self.custom_cflags_entry = gtk.Entry()
183 self.custom_cflags_entry.set_width_chars(25)
184 self.custom_cflags_entry.set_text("-pipe")
185 hbox.pack_start(self.custom_cflags_entry, expand=False, fill=False, padding=10)
186 vert.pack_start(hbox, expand=False, fill=False, padding=5)
187
188 hbox = gtk.HBox(False, 0)
189 label = gtk.Label()
190 label.set_markup("<b>Other:</b>")
191 hbox.pack_start(label, expand=False, fill=False, padding=0)
192 vert.pack_start(hbox, expand=False, fill=False, padding=5)
193
194 hbox = gtk.HBox(False, 0)
195 self.unstable_packages_check = gtk.CheckButton("Use unstable (~arch)")
196 hbox.pack_start(self.unstable_packages_check, expand=False, fill=False, padding=0)
197 self.build_binary_check = gtk.CheckButton("Build binary packages")
198 hbox.pack_start(self.build_binary_check, expand=False, fill=False, padding=20)
199 self.use_distcc_check = gtk.CheckButton("DistCC")
200 hbox.pack_start(self.use_distcc_check, expand=False, fill=False, padding=0)
201 self.use_ccache_check = gtk.CheckButton("ccache")
202 hbox.pack_start(self.use_ccache_check, expand=False, fill=False, padding=20)
203 vert.pack_start(hbox, expand=False, fill=False, padding=5)
204
205 hbox = gtk.HBox(False, 0)
206 hbox.pack_start(gtk.Label("CHOST:"), expand=False, fill=False, padding=0)
207 self.chost_combo = gtk.combo_box_new_text()
208 # for chost in GLIUtility.get_chosts(self.controller.client_profile.get_architecture_template()):
209 # self.chost_combo.append_text(chost)
210 # self.chost_combo.set_active(0)
211 hbox.pack_start(self.chost_combo, expand=False, fill=False, padding=10)
212 hbox.pack_start(gtk.Label(" "), expand=False, fill=False, padding=15)
213 hbox.pack_start(gtk.Label("MAKEOPTS:"), expand=False, fill=False, padding=0)
214 self.makeopts_entry = gtk.Entry()
215 self.makeopts_entry.set_width_chars(7)
216 hbox.pack_start(self.makeopts_entry, expand=False, fill=False, padding=10)
217 vert.pack_start(hbox, expand=False, fill=False, padding=5)
218
219 self.add_content(vert)
220
221 def flag_toggled(self, cell, path):
222 model = self.treeview.get_model()
223 model[path][0] = not model[path][0]
224 flag = model[path][1]
225 if model[path][0]:
226 self.use_flags[flag] = 1
227 else:
228 if flag in self.use_flags:
229 self.use_flags[flag] = 0
230 return
231
232 def activate(self):
233 self.controller.SHOW_BUTTON_EXIT = True
234 # self.controller.SHOW_BUTTON_HELP = True
235 self.controller.SHOW_BUTTON_BACK = True
236 self.controller.SHOW_BUTTON_FORWARD = True
237 self.controller.SHOW_BUTTON_FINISH = False
238 self.etc_files = self.controller.install_profile.get_etc_files()
239 if not "make.conf" in self.etc_files:
240 self.etc_files['make.conf'] = {}
241 self.make_conf_values = self.etc_files['make.conf']
242 # Parsing USE
243 self.use_flags = {}
244 if not self.make_conf_values.has_key('USE') or not self.make_conf_values['USE']:
245 self.make_conf_values['USE'] = self.system_use_flags
246 for flag in self.make_conf_values['USE'].split(" "):
247 if flag.startswith("-"):
248 flag = flag[1:]
249 self.use_flags[flag] = 0
250 else:
251 self.use_flags[flag] = 1
252 sorted_use = self.use_desc.keys()
253 sorted_use.sort()
254 self.treedata = gtk.ListStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, gobject.TYPE_STRING)
255 for flag in sorted_use:
256 if flag in self.use_flags and self.use_flags[flag] == 1:
257 self.treedata.append([True, flag, self.use_desc[flag]])
258 else:
259 self.treedata.append([False, flag, self.use_desc[flag]])
260 self.treeview.set_model(self.treedata)
261 if self.controller.install_profile.get_grp_install():
262 self.treeview.set_sensitive(False)
263 self.unstable_packages_check.set_sensitive(False)
264 self.unstable_packages_check.set_active(False)
265 else:
266 self.treeview.set_sensitive(True)
267 self.unstable_packages_check.set_sensitive(True)
268 # Parsing CFLAGS
269 if not self.make_conf_values.has_key('CFLAGS') or not self.make_conf_values['CFLAGS']:
270 self.make_conf_values['CFLAGS'] = self.system_cflags
271 custom_cflags = ""
272 arch = ""
273 for flag in self.make_conf_values['CFLAGS'].split(" "):
274 flag = flag.strip()
275 if flag.startswith("-march="):
276 arch = flag[flag.find("=")+1:]
277 elif flag.startswith("-O"):
278 i = 0
279 for opt in self.optimizations:
280 if flag == opt:
281 self.optimizations_combo.set_active(i)
282 break
283 i += 1
284 else:
285 custom_cflags = custom_cflags + " " + flag
286 self.proc_combo.get_model().clear()
287 for i, proc in enumerate(self.arch_procs[self.controller.client_profile.get_architecture_template()]):
288 self.proc_combo.append_text(proc)
289 if proc == arch:
290 self.proc_combo.set_active(i)
291 if self.proc_combo.get_active() == -1:
292 self.proc_combo.set_active(0)
293 self.custom_cflags_entry.set_text(custom_cflags.strip())
294 # Parsing ACCEPT_KEYWORDS
295 if not self.make_conf_values.has_key('ACCEPT_KEYWORDS') or not self.make_conf_values['ACCEPT_KEYWORDS']:
296 self.make_conf_values['ACCEPT_KEYWORDS'] = self.system_accept_keywords
297 if self.make_conf_values['ACCEPT_KEYWORDS'][0] == "~":
298 self.unstable_packages_check.set_active(True)
299 else:
300 self.unstable_packages_check.set_active(False)
301 # Parsing FEATURES
302 if not self.make_conf_values.has_key('FEATURES') or not self.make_conf_values['FEATURES']:
303 self.make_conf_values['FEATURES'] = self.system_features
304 self.use_distcc_check.set_active(False)
305 self.use_ccache_check.set_active(False)
306 self.build_binary_check.set_active(False)
307 for feature in self.make_conf_values['FEATURES'].split(" "):
308 feature = feature.strip()
309 if feature == "distcc":
310 self.use_distcc_check.set_active(True)
311 elif feature == "ccache":
312 self.use_ccache_check.set_active(True)
313 elif feature == "buildpkg":
314 self.build_binary_check.set_active(True)
315 # Parsing CHOST
316 if not self.make_conf_values.has_key('CHOST') or not self.make_conf_values['CHOST']:
317 self.make_conf_values['CHOST'] = self.system_chost
318 self.chost_combo.get_model().clear()
319 for i, chost in enumerate(GLIUtility.get_chosts(self.controller.client_profile.get_architecture_template())):
320 self.chost_combo.append_text(chost)
321 if chost == self.make_conf_values['CHOST'] or i == 0:
322 self.chost_combo.set_active(i)
323 if self.controller.install_profile.get_install_stage() > 1:
324 self.chost_combo.set_sensitive(False)
325 else:
326 self.chost_combo.set_sensitive(True)
327 # Parsing MAKEOPTS
328 if not self.make_conf_values.has_key('MAKEOPTS') or not self.make_conf_values['MAKEOPTS']:
329 self.make_conf_values['MAKEOPTS'] = self.system_makeopts
330 self.makeopts_entry.set_text(self.make_conf_values['MAKEOPTS'])
331
332 def deactivate(self):
333 temp_use = ""
334 sorted_use = self.use_flags.keys()
335 sorted_use.sort()
336 for flag in sorted_use:
337 if self.use_flags[flag]:
338 temp_use += " " + flag
339 else:
340 temp_use += " -" + flag
341 self.make_conf_values['USE'] = temp_use
342 self.make_conf_values['CFLAGS'] = "-march=" + self.arch_procs[self.controller.client_profile.get_architecture_template()][self.proc_combo.get_active()] + " " + self.optimizations[self.optimizations_combo.get_active()] + " " + self.custom_cflags_entry.get_text()
343 if self.unstable_packages_check.get_active():
344 self.make_conf_values['ACCEPT_KEYWORDS'] = "~" + self.controller.client_profile.get_architecture_template()
345 else:
346 self.make_conf_values['ACCEPT_KEYWORDS'] = ""
347 temp_features = ""
348 if self.build_binary_check.get_active():
349 temp_features += "buildpkg "
350 if self.use_distcc_check.get_active():
351 temp_features += "distcc "
352 if self.use_ccache_check.get_active():
353 temp_features += "ccache "
354 self.make_conf_values['FEATURES'] = temp_features.strip()
355 if self.controller.install_profile.get_install_stage() > 1:
356 if 'CHOST' in self.make_conf_values:
357 del self.make_conf_values['CHOST']
358 else:
359 self.make_conf_values['CHOST'] = GLIUtility.get_chosts(self.controller.client_profile.get_architecture_template())[self.chost_combo.get_active()]
360 self.make_conf_values['MAKEOPTS'] = self.makeopts_entry.get_text()
361 self.etc_files['make.conf'] = self.make_conf_values
362 self.controller.install_profile.set_etc_files(self.etc_files)
363 return True

Properties

Name Value
svn:eol-style native

  ViewVC Help
Powered by ViewVC 1.1.20