/[gli]/branches/overhaul/src/fe/dialog/gli-dialog.py
Gentoo

Contents of /branches/overhaul/src/fe/dialog/gli-dialog.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1750 - (show annotations) (download) (as text)
Sat Mar 3 23:54:59 2007 UTC (7 years, 1 month ago) by codeman
File MIME type: text/x-python
File size: 103157 byte(s)
moving the configure_networking function into gli-dialog
updating TODO

1 #!/usr/bin/python
2 # Copyright 1999-2005 Gentoo Foundation
3 # This source code is distributed under the terms of version 2 of the GNU
4 # General Public License as published by the Free Software Foundation, a copy
5 # of which can be found in the main directory of this project.
6
7 import sys
8 sys.path.append("../..")
9
10 import dialog
11 import GLIException, GLIInstallProfile, GLIClientController, GLIUtility, Partitioning
12
13 import string, copy, time, re, glob, os, platform
14 import gettext
15 try:
16 gettext.install('gli-dialog', './languages')
17 translator = gettext.translation('gli-dialog', './languages')
18 _ = translator.gettext
19 except:
20 _ = gettext.gettext
21
22
23 # ------------------------------------------------------------------
24 class GLIDialog(object):
25 def __init__(self):
26 self._d = dialog.Dialog()
27 self._install_profile = GLIInstallProfile.InstallProfile()
28 self._cc = GLIClientController.GLIClientController(self._install_profile,pretend=False,verbose=True) #FIXME change to False
29
30 self._DLG_OK = 0
31 self._DLG_YES = 0
32 self._DLG_CANCEL = 1
33 self._DLG_NO = 1
34 self._DLG_ESC = 2
35 self._DLG_ERROR = 3
36 self._DLG_EXTRA = 4
37 self._DLG_HELP = 5
38 self._d.setBackgroundTitle("Gentoo Linux Installer")
39 self.profile_xml_file = None
40 self.advanced_mode = True
41 self.networkless = False
42 self.just_starting = 1
43
44
45 ############ ACCESSOR FUNCTIONS #############
46 def _dmenu_list_to_choices(self, list):
47 choices = []
48 for i in range(0, len(list)):
49 choices.append((str(i + 1), list[i]))
50 return choices
51
52 def install_profile(self):
53 return self._install_profile
54
55 def fatal(self,message):
56 self._d.msgbox(message)
57 sys.exit(0)
58
59 ############ QUESTION FUNCTIONS #################
60 def show_welcome_screen(self):
61
62 welcome_string = _(u"""Welcome to the Gentoo Linux Installer! This program will help install Gentoo on your computer.
63 Before proceeding please thoroughly read the Gentoo Installation Handbook available at
64 http://www.gentoo.org/doc/en/handbook/index.xml \n
65 Press OK to continue""")
66 self._d.msgbox(welcome_string, height=25, width=78, title=_(u"Welcome"))
67
68 def ask_advanced_mode(self):
69 #Set the Yes/No labels.
70 self._d.add_persistent_args(["--yes-label", _(u"Standard")])
71 self._d.add_persistent_args(["--no-label",_(u"Advanced")])
72 advanced_string = _(u"""This installer has two modes, an advanced mode for those knowledgable with the inner details of their computer and a standard mode where many of the defaults will be chosen for the user for simplicity and to speed up the install process. The advanced mode offers full customizability and is required for generating profiles to be used other computers. \nThe advanced mode is recommended by the developers.
73 """)
74 if self._d.yesno(advanced_string, width=55, height=15) == self._DLG_NO:
75 self.advanced_mode = True
76 else:
77 self.advanced_mode = False
78
79 def ask_networkless(self):
80 networkless_string = _(u"Do you want to do a networkless installation? This will limit the customizability of your install due to the limitations of the LiveCD. For example, choosing networkless will set your installation stage, portage snapshot, and limit your extra packages selections. NOTE: It is easily possible to do a networkless installation on a machine with an active Internet connection; in fact this may result in the fastest installations for many users.")
81 #Change the Yes/No buttons
82 self._d.add_persistent_args(["--yes-label", _(u"Networkless")])
83 self._d.add_persistent_args(["--no-label", _(u"Internet enabled")])
84 if self._d.yesno(networkless_string, width=65, height=20) == self._DLG_YES:
85 self.networkless = True
86 try:
87 self._install_profile.set_grp_install(None, True, None)
88 self._install_profile.set_install_stage(None, "3", None)
89 self._install_profile.set_dynamic_stage3(None, True, None)
90 self._install_profile.set_portage_tree_sync_type(None,"snapshot", None)
91 cd_snapshot_uri = GLIUtility.get_cd_snapshot_uri()
92 self._install_profile.set_portage_tree_snapshot_uri(None, cd_snapshot_uri, None)
93 self._install_profile.set_kernel_source_pkg(None, "livecd-kernel", None)
94 self._install_profile.set_cron_daemon_pkg(None, "vixie-cron", None)
95 self._install_profile.set_logging_daemon_pkg(None,"syslog-ng", None)
96 except:
97 self._d.msgbox(_(u"ERROR: Could not set networkless information in the profile"))
98 else:
99 self.networkless = False
100
101 def ask_load_profile(self):
102 #Reset the Yes/No labels.
103 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
104 self._d.add_persistent_args(["--no-label",_(u"No")])
105 #Ask
106 while 1:
107 string = _(u"""
108 All of the installation settings are stored in an XML file, which we call the InstallProfile. If you have a previously-created profile, you can load it now
109 for use in this installation.
110 Do you have a previously generated profile for the installer?
111 """)
112 if self._d.yesno(string, width=70, height=15, defaultno=1) == self._DLG_YES:
113 code, self.profile_xml_file = self._d.inputbox(_(u"Enter the filename of the XML file"))
114 if code != self._DLG_OK:
115 break
116 if GLIUtility.is_file(self.profile_xml_file):
117 break
118 self._d.msgbox(_(u"Cannot open file %s") % self.profile_xml_file, height=7, width=50)
119 self.profile_xml_file = None
120 continue
121 else:
122 break
123 if self.profile_xml_file != None:
124 self._install_profile.parse(self.profile_xml_file)
125 self.run_phase5()
126 sys.exit(0)
127
128 ############ STAGE1 FUNCTIONS #################
129
130 def set_arch_template(self):
131 subarches = { 'i386': 'x86', 'i486': 'x86', 'i586': 'x86', 'i686': 'x86', 'x86_64': 'amd64', 'parisc': 'hppa' }
132 arch = platform.machine()
133 if arch in subarches:
134 arch = subarches[arch]
135 self._arch = arch
136
137 def set_verbose(self):
138 #Don't show unless advanced.
139 if self.advanced_mode:
140 #Change the Yes/No buttons back.
141 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
142 self._d.add_persistent_args(["--no-label", _(u"No")])
143 if self._d.yesno(_(u"Do you want debugging output enabled during the install? This is mainly meant to help the developers debug any bugs."), width=60) == self._DLG_YES:
144 self._install_profile.set_verbose(None, True, None)
145 else:
146 self._install_profile.set_verbose(None, False, None)
147
148 def set_client_networking(self):
149 if self.networkless: return
150 if GLIUtility.ping("www.gentoo.org"): #If an active connection exists, ignore this step.
151 return
152
153 device_list = GLIUtility.get_eth_devices()
154
155 choice_list = []
156 for device in device_list:
157 choice_list.append((device, GLIUtility.get_interface_realname(device)))
158 choice_list.append((_(u"Other"),_(u"Type your own.")))
159 cnet_string1 = _(u"In order to complete most installs, an active Internet connection is required. Listed are the network devices already detected. In this step you will need to setup one network connection for GLI to use to connect to the Internet. If your desired device does not show up in the list, you can select Other and input the device name manually.")
160 code, interface = self._d.menu(cnet_string1, width=75, height=20, choices=choice_list)
161
162 if interface == _(u"Other"):
163 code, interface = self._d.inputbox(_(u"Enter the interface (NIC) you would like to use for installation (e.g. eth0):"))
164 if code != self._DLG_OK:
165 return
166
167 dhcp_options = ""
168
169 #Change the Yes/No buttons to new labels for this question.
170 self._d.add_persistent_args(["--yes-label", _(u"DHCP")])
171 self._d.add_persistent_args(["--no-label", _(u"Static IP/Manual")])
172 cnet_string2 = _(u"To setup your network interface, you can either use DHCP if enabled, or manually enter your network information.\n DHCP (Dynamic Host Configuration Protocol) makes it possible to automatically receive networking information (IP address, netmask, broadcast address, gateway, nameservers etc.). This only works if you have a DHCP server in your network (or if your provider provides a DHCP service). If you do not, you must enter the information manually. Please select your networking configuration method:")
173 if self._d.yesno(cnet_string2, height=15, width=60) == self._DLG_YES: #DHCP
174 network_type = 'dhcp'
175 if self.advanced_mode:
176 code, dhcp_options = self._d.inputbox(_(u"If you have any additional DHCP options to pass, type them here in a space-separated list. If you have none, just press Enter."), height=13, width=50)
177 else:
178 network_type = 'static'
179 code, data = self._d.form(_(u'Enter your networking information: (See Chapter 3 of the Handbook for more information) Your broadcast address is probably your IP address with 255 as the last tuple. DO NOT PRESS ENTER until all fields you intend to fill out are complete!'),
180 ((_(u'Enter your IP address:'), 15),
181 (_(u'Enter your Broadcast address:'), 15),
182 (_(u'Enter your Netmask:'),15,'255.255.255.0'),
183 (_(u'Enter your default gateway:'),15),
184 (_(u'Enter a DNS server:'),15,'4.2.2.1'),
185 (_(u'Enter a HTTP Proxy IP:'), 15),
186 (_(u'Enter a FTP Proxy IP:'), 15),
187 (_(u'Enter a RSYNC Proxy:'),15)
188 ))
189 (ip_address, broadcast, netmask, gateway, dnsservers, http_proxy, ftp_proxy, rsync_proxy) = data[:-1].split('\n')
190 if code != self._DLG_OK:
191 return
192 #Set the info now that it's all gathered.
193 if network_type == "dhcp":
194 if dhcp_options:
195 status = GLIUtility.spawn("/sbin/dhcpcd -t 15 " + dhcp_options + " " + interface)
196 else:
197 status = GLIUtility.spawn("/sbin/dhcpcd -t 15 -n " + interface)
198 if not GLIUtility.exitsuccess(status):
199 self._d.msgbox("ERROR: Could not run dhcpcd command!") #FIXME LANGUAGE
200 elif network_type == "static":
201 # Configure the network from the settings they gave.
202 if not GLIUtility.set_ip(interface, ip_address, broadcast, netmask):
203 self._d.msgbox("ERROR: Could not set the IP address!") #FIXME LANGUAGE
204
205 if not GLIUtility.set_default_route(gateway):
206 self._d.msgbox("ERROR: Could not set the default route!") #FIXME LANGUAGE
207
208 if dns_servers:
209 try:
210 resolv_conf = open("/etc/resolv.conf", "w")
211 for dns_server in dns_servers:
212 resolv_conf.write("nameserver " + dns_server + "\n")
213 resolv_conf.close()
214 except:
215 self._d.msgbox("ERROR: Could not set the DNS servers!") #FIXME LANGUAGE
216
217 if ftp_proxy and ftp_proxy != "":
218 os.environ['ftp_proxy'] = ftp_proxy
219
220 if http_proxy and http_proxy != "":
221 os.environ['http_proxy'] = http_proxy
222
223 if rsync_proxy and rsync_proxy != "":
224 os.environ['RSYNC_PROXY'] = rsync_proxy
225
226 #Test the connection to make sure everything worked.
227 if ping("www.gentoo.org"):
228 return True
229 else:
230 fatal(_(u"Sorry, but the network could not be set up successfully. Please configure yourself manually and restart the installer."))
231
232 def set_enable_ssh(self):
233 #Change the Yes/No buttons back.
234 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
235 self._d.add_persistent_args(["--no-label", _(u"No")])
236 if self.advanced_mode and not self.networkless:
237 if self._d.yesno(_(u"Do you want SSH enabled during the install? This will allow you to login remotely during the installation process. If choosing Yes, be sure you select a new LiveCD root password!"), width=60) == self._DLG_YES:
238 # Enables SSH **Code originally from GLIClientController**
239 status = GLIUtility.spawn("/etc/init.d/sshd start")
240 if not GLIUtility.exitsuccess(status):
241 self._d.msgbox(_(u"ERROR! : Could not start the SSH daemon!"))
242
243 def set_livecd_password(self):
244 # The root password will be set here only if in advanced mode. Otherwise it is auto-scrambled.
245 if self.advanced_mode:
246 self._root_passwd = ""
247 match = False;
248 while not match:
249 livecd_password_string = _(u"""If you want to be able to login to your machine from another console during the installation,
250 you will want to enter a new root password for the LIVECD.
251 Note that this can be different from your new system's root password.
252 Presss Enter twice to skip this step.
253 Enter the new LIVECD root password (will not be echoed): """)
254 code, passwd1 = self._d.passwordbox(livecd_password_string, width=60, height=16)
255 if code != self._DLG_OK:
256 return
257 code, passwd2 = self._d.passwordbox(_(u"Enter the new LIVECD root password again to verify:"))
258 if code != self._DLG_OK:
259 return
260 if passwd1 != passwd2:
261 self._d.msgbox(_(u"The passwords do not match. Please try again."))
262 return
263 else:
264 match = True;
265 if passwd1 != "": #don't want to hash an empty password.
266 try:
267 self._root_passwd = GLIUtility.hash_password(passwd1)
268 except:
269 self._d.msgbox(_(u"ERROR! Could not hash the root password on the LiveCD!"))
270 ##
271 # Actually set it now. **Code originally from GLIClientController**
272 #self._logger.log("Setting root password.")
273 if self._root_passwd != "":
274 # The password specified in the configuration is encrypted.
275 status = GLIUtility.spawn("echo 'root:" + self._root_passwd + "' | chpasswd -e")
276
277 if not GLIUtility.exitsuccess(status):
278 self._d.msgbox(_(u"ERROR! Could not set the root password on the livecd environment!"))
279 # else:
280 # self._logger.log("Livecd root password set.")
281
282 def set_client_kernel_modules(self):
283 if self.advanced_mode:
284 status, output = GLIUtility.spawn("lsmod", return_output=True)
285 cmodules_string1 = _(u"Here is a list of modules currently loaded on your machine.\n Please look through and see if any modules are missing\n that you would like loaded.\n\n")
286 self._d.add_persistent_args(["--exit-label", _(u"Continue")])
287 self._d.scrollbox(cmodules_string1+output, height=20, width=70, title=_(u"Loaded Modules"))
288 cmodules_string2 = _(u"If you have additional modules you would like loaded before the installation begins (ex. a network driver), enter them in a space-separated list.")
289 code, kernel_modules_list = self._d.inputbox(cmodules_string2, init="", width=60, height=12)
290 if code != self._DLG_OK:
291 return
292
293
294 # Actually Load the kernel modules **Code originally from GLIClientController
295
296 #self._logger.log("DEBUG: load_kernel_modules(): modules are " + str(modules))
297 for module in kernel_modules_list.split():
298 try:
299 # if self._configuration.get_verbose(): self._logger.log("DEBUG: load_kernel_modules(): trying to load module " + module)
300 ret = GLIUtility.spawn('modprobe ' + module)
301 if not GLIUtility.exitsuccess(ret):
302 self._d.msgbox(_(u"ERROR! : Could not load module: %s ") % module)
303 # raise GLIException("KernelModuleError", 'warning', 'load_kernel_modules', 'Could not load module: ' + module)
304 #else:
305 # self._logger.log('kernel module: ' + module + ' loaded.')
306 except:
307 self._d.msgbox(_(u"ERROR!: An unknown error occurred during modprobing the modules. Please load them manually and then restart the installer."))
308
309 #######################################
310 #######################################
311 ### MAIN INSTALL SETUP FUNCTIONS START HERE
312
313 ############ STAGE2 FUNCTIONS #################
314
315 def set_mounts(self):
316 mounts = copy.deepcopy(self._install_profile.get_mounts())
317
318 if not mounts:
319 #No mountpoints defined. lets at least find the swap partitions and add them.
320 for drive in self._drives:
321 for part in self._devices[drive]:
322 if part['type'] == "linux-swap":
323 mounts.append({'devnode': part['devnode'], 'mountopts': '', 'mountpoint': '', 'type': "linux-swap"})
324
325 while 1:
326 menulist = []
327 for mount in mounts:
328 if mount['type'] == "linux-swap":
329 menulist.append(mount['devnode'] + " - swap")
330 else:
331 menulist.append(mount['devnode'] + " - " + mount['mountpoint'])
332 #menulist.append(_(u"Define a new mountpoint"))
333 choices = self._dmenu_list_to_choices(menulist)
334 choices.append((_(u"Add"),_(u"Define a new mountpoint")))
335 code, choice = self._d.menu(_(u"Please define the mountpoints of your partitions for the new system. At minimum, a / mountpoint must be defined. Defining /boot and /home mountpoints is recommended."),choices=choices, cancel=_(u"Save and Continue"), height=18)
336 if code == self._DLG_CANCEL:
337 try:
338 self._install_profile.set_mounts(mounts)
339 except:
340 self._d.msgbox(_(u"ERROR: Could net set mounts!"))
341 break
342 if choice == _(u"Add"):
343 parts = []
344 fstypes = {}
345
346 #Make a list of the partitions
347 for drive in self._drives:
348 for tmppart in self._devices[drive]:
349 skip = False
350 devnode = tmppart['devnode']
351 entry = ""
352 if tmppart['type'] == "free":
353 continue
354 elif tmppart['type'] == "extended":
355 continue
356 else:
357 if tmppart.is_logical():
358 entry += _(u"Logical (")
359 else:
360 entry += _(u"Primary (")
361 entry += tmppart['type'] + ", "
362 entry += str(tmppart['mb']) + "MB)"
363
364 #Go through and remove any already defined.
365 for mount in mounts:
366 if mount['devnode'] == devnode:
367 skip = True
368
369 if not skip:
370 #Add to the choices list.
371 parts.append((devnode,entry))
372 fstypes[devnode] = tmppart['type']
373
374 if not parts:
375 continue
376 code, partition = self._d.menu(_(u"Select a Partition to define a mountpoint for"), choices=parts, height=18)
377 if code != self._DLG_OK:
378 continue
379
380 fstype = fstypes[partition]
381 #Ask for mountpoint for this partition. #FIXME use Partition to get the type.
382 # choices_list = ['ext2', 'ext3', 'linux-swap', 'xfs', 'jfs', 'reiserfs','ntfs', 'fat16', 'fat32']
383 # choices = self._dmenu_list_to_choices(choices_list)
384 # code,fstypeidx = self._d.menu(_(u"Select the filesystem for partition %s") % partition, choices=choices, height=18)
385 # if fstypeidx:
386 # fstype = choices_list[int(fstypeidx)-1]
387 # else: continue
388
389 if fstype == 'linux-swap':
390 #We have all the info we need, now add the mount
391 mounts.append({'devnode': partition, 'mountopts': '', 'mountpoint': '', 'type': fstype})
392 continue
393
394 #Ask for the mountpoint
395 mountpoint_menu = ["/","/boot","/etc","/home","/lib","/mnt","/mnt/windows","/opt","/root","/usr","/usr/local","/usr/portage","/var",_(u"Other")]
396 code, mountpt = self._d.menu(_(u"Choose a mountpoint from the list or choose Other to type your own for partition %s. ") % partition, choices=self._dmenu_list_to_choices(mountpoint_menu)) #may have to make that an integer
397 if code == self._DLG_OK:
398 mountpoint = mountpoint_menu[int(mountpt)-1]
399 if mountpoint == _(u"Other"):
400 code, mountpoint = self._d.inputbox(_(u"Enter a mountpoint for partition %s") % partition)
401
402 if not mountpoint: continue
403
404 #Ask for mountopts
405 code, mountopts = self._d.inputbox(_(u"Enter mount options for mountpoint %s. Leave blank for defaults") % mountpoint, height=13, width=50)
406 if code != self._DLG_OK:
407 continue
408
409 #We have all the info we need, now add the mount
410 mounts.append({'devnode': partition, 'mountopts': mountopts, 'mountpoint': mountpoint, 'type': fstype})
411 elif choice: #EDITING A MOUNTPOINT
412 #Find the mount in question, based on devnode
413 idx = int(choice) - 1
414 devnode = mounts[idx]['devnode']
415 mountpoint = mounts[idx]['mountpoint']
416 mountopts = mounts[idx]['mountopts']
417 fstype = mounts[idx]['type']
418
419 menu = [_(u"Change Mountpoint"),
420 _(u"Change Filesystem Type"),
421 _(u"Change Mountoptions"),
422 _(u"Delete This Mountpoint")]
423 code, editchoice = self._d.menu(_(u"Select an option for device %(dev)s : Mountpoint: %(mt)s, Type: %(type)s, Options: %(opt)s" % {'dev': devnode, 'mt': mountpoint, 'type': fstype, 'opt': mountopts}), choices=self._dmenu_list_to_choices(menu))
424 if code == self._DLG_CANCEL:
425 continue
426 editchoice = menu[int(editchoice)-1]
427 if editchoice == _(u"Change Mountpoint"):
428 mountpoint_menu = ["/","/boot","/etc","/home","/lib","/mnt","/mnt/windows","/opt","/root","/usr","/usr/local","/usr/portage","/var",_(u"Other")]
429 code, mountpt = self._d.menu(_(u"Choose a mountpoint from the list or choose Other to type your own for partition %(part)s. Current mountpoint is: %(mt)s" % {'part': devnode, 'mt': mountpoint}) , choices=self._dmenu_list_to_choices(mountpoint_menu), height=18) #may have to make that an integer
430 if code == self._DLG_OK:
431 mountpoint = mountpoint_menu[int(mountpt)-1]
432 if mountpoint == _(u"Other"):
433 code, mountpoint = self._d.inputbox(_(u"Enter a mountpoint for partition %s") % devnode)
434 if not mountpoint: continue
435 mounts[idx]['mountpoint'] = mountpoint
436 elif editchoice == _(u"Change Filesystem Type"):
437 choices_list = ['ext2', 'ext3', 'linux-swap', 'xfs', 'jfs', 'reiserfs','ntfs', 'fat16', 'fat32']
438 choices = self._dmenu_list_to_choices(choices_list)
439 code,fstypeidx = self._d.menu(_(u"Select the filesystem for partition %(part)s. It is currently %(fs)s." % {'part': devnode,'fs': fstype}), choices=choices, height=18)
440 if fstypeidx:
441 fstype = choices_list[int(fstypeidx)-1]
442 else: continue
443 mounts[idx]['type'] = fstype
444 elif editchoice == _(u"Change Mountoptions"):
445 code, mountopts = self._d.inputbox(_(u"Enter mount options for mountpoint %s. Leave blank for defaults") % mountpoint, init=mountopts,height=13, width=50)
446 if code != self._DLG_OK:
447 continue
448 mounts[idx]['mountopts'] = mountopts
449 elif editchoice == _(u"Delete This Mountpoint"):
450 del mounts[idx]
451 else: continue #catchall.
452 def set_partitions(self):
453 partitions_string1 = _(u"""The first thing on the new system to setup is the partitoning.
454 You will first select a drive and then edit its partitions.
455 WARNING: CHANGES ARE MADE IMMEDIATELY TO DISK. BE CAREFUL
456 NOTE: YOU MUST AT LEAST SELECT ONE PARTITION AS YOUR ROOT PARTITION "/"
457 If your drive is pre-partitioned, just select the mountpoints and make
458 sure that the format option is set to FALSE or it will erase your data.
459 The installer does not yet support resizing of partitions (its not safe).
460 When in doubt, **Partition it yourself and then re-run the installer**
461 Please refer to the Gentoo Installation Handbook for more information
462 on partitioning and the various filesystem types available in Linux.""")
463 self._d.msgbox(partitions_string1, height=17, width=78)
464 drives = []
465 devices = {}
466 choice_list = []
467 tmp_drives = Partitioning.detect_devices()
468 tmp_drives.sort()
469 for drive in tmp_drives:
470 devices[drive] = Partitioning.Device(drive, self._arch, self._install_profile)
471 drives.append(drive)
472 choice_list.append((drive, devices[drive].get_model()))
473 self._drives = drives #Store for use in mounts.
474 self._devices = devices #Store for use in mounts.
475 while 1:
476 code, drive_to_partition = self._d.menu(_(u"Which drive would you like to partition?\n Info provided: Type, Size in MB"), choices=choice_list, cancel=_(u"Done"))
477 if code != self._DLG_OK: break
478 while 1:
479 partsmenu = []
480 # for part in partlist:
481 for tmppart in devices[drive_to_partition]:
482 # tmppart = tmpparts[part]
483 entry = ""
484 if tmppart['type'] == "free":
485 #partschoice = "New"
486 entry = _(u" - Unallocated space (")
487 if tmppart.is_logical():
488 entry += _(u"logical, ")
489 entry += str(tmppart['mb']) + "MB)"
490 elif tmppart['type'] == "extended":
491 entry = str(int(tmppart['minor']))
492 entry += _(u" - Extended Partition (") + str(tmppart['mb']) + "MB)"
493 else:
494 entry = str(int(tmppart['minor'])) + " - "
495 # Type: " + tmppart.get_type() + ", Mountpoint: " + tmppart.get_mountpoint() + ", Mountopts: " + tmppart.get_mountopts() + "("
496 if tmppart.is_logical():
497 entry += _(u"Logical (")
498 else:
499 entry += _(u"Primary (")
500 entry += tmppart['type'] + ", "
501 entry += str(tmppart['mb']) + "MB)"
502 partsmenu.append(entry)
503 #Add recommended partitioning option and clear option
504 partsmenu.append(_(u"Set Recommended Layout"))
505 partsmenu.append(_(u"Clear Partitions On This Drive."))
506 code, part_to_edit = self._d.menu(_(u"Select a partition or unallocated space to edit\nKey: Minor, Pri/Ext, Filesystem, Size."), width=70, choices=self._dmenu_list_to_choices(partsmenu), cancel=_(u"Back"))
507 if code != self._DLG_OK: break
508 partmenuchoice = partsmenu[int(part_to_edit)-1]
509 #Check for recommended and clear here before setting the tmppart
510 if partmenuchoice == _(u"Set Recommended Layout"):
511 if self._d.yesno(_(u"This will ERASE YOUR DRIVE and apply a recommended layout. Are you sure you wish to do this?")) == self._DLG_YES:
512 if self._d.yesno(_(u"This is your last chance. Are you SURE you want to CLEAR this drive and set a recommended layout? THERE IS NO TURNING BACK IF YOU SELECT YES."), defaultno=1) == self._DLG_YES:
513 devices[drive_to_partition].do_recommended()
514 continue
515 if partmenuchoice == _(u"Clear Partitions On This Drive."):
516 if self._d.yesno(_(u"This will remove all partitions on your drive. Are you sure you wish to do this?")) == self._DLG_YES:
517 if self._d.yesno(_(u"This is your last chance. Are you SURE you want to CLEAR this drive? THIS WILL DELETE ANY DATA ON THE DRIVE!"), defaultno=1) == self._DLG_YES:
518 devices[drive_to_partition].clear_partitions()
519 # self._d.msgbox(_(u"Partition table cleared successfully"))
520 # except:
521 # self._d.msgbox(_(u"ERROR: could not clear the partition table!"))
522 continue
523 #all other cases (partitions)
524 part_to_edit = int(part_to_edit) - 1
525 tmppart = devices[drive_to_partition][part_to_edit]
526 if tmppart['type'] == "free":
527 # partition size first
528 free_mb = long(tmppart['mb'])
529 code, new_mb = self._d.inputbox(_(u"Enter the size of the new partition in MB (max %s MB). If creating an extended partition input its entire size (not just the first logical size):") % str(free_mb), init=str(free_mb))
530 if code != self._DLG_OK: continue
531 if int(new_mb) > free_mb:
532 self._d.msgbox(_(u"The size you entered (%(entered)s MB) is larger than the maximum of %(max)s MB" % {'entered': new_mb, 'max': str(free_mb)}))
533 continue
534 # partition type
535 part_types = [("ext2", _(u"Old, stable, but no journaling")),
536 ("ext3", _(u"ext2 with journaling and b-tree indexing (RECOMMENDED)")),
537 ("linux-swap", _(u"Swap partition for memory overhead")),
538 ("fat32", _(u"Windows filesystem format used in Win9X and XP")),
539 # ("ntfs", _(u"Windows filesystem format used in Win2K and NT")),
540 # ("jfs", _(u"IBM's journaling filesystem. stability unknown.")),
541 # ("xfs", _(u"Don't use this unless you know you need it.")),
542 ("reiserfs", _(u"B*-tree based filesystem. great performance. Only V3 supported.")),
543 ("extended", _(u"Create an extended partition containing other logical partitions")),
544 (_(u"Other"), _(u"Something else we probably don't support."))]
545 code, type = self._d.menu(_(u"Choose the filesystem type for this new partition."), height=20, width=77, choices=part_types)
546 if code != self._DLG_OK: continue
547
548 # 'other' partition type
549 if type == _(u"Other"):
550 code, type = self._d.inputbox(_(u"Please enter the new partition's type:"))
551 if code != self._DLG_OK: continue
552
553 # now add it to the data structure
554 devices[drive_to_partition].add_partition(part_to_edit, int(new_mb), type)
555 else:
556 while 1:
557 tmppart = devices[drive_to_partition][part_to_edit]
558 tmptitle = drive_to_partition + str(tmppart['minor']) + " - "
559 if tmppart.is_logical():
560 tmptitle += _(u"Logical (")
561 else:
562 tmptitle += _(u"Primary (")
563 tmptitle += tmppart['type'] + ", "
564 tmptitle += str(tmppart['mb']) + "MB)"
565 menulist = [_(u"Delete"), _(u"Extra mkfs.* Parameters")]
566 code, part_action = self._d.menu(tmptitle, choices=self._dmenu_list_to_choices(menulist), cancel=_(u"Back"))
567 if code != self._DLG_OK: break
568 part_action = menulist[int(part_action)-1]
569 if part_action == _(u"Delete"):
570 answer = (self._d.yesno(_(u"Are you sure you want to delete the partition ") + drive_to_partition + str(tmppart['minor']) + "?") == self._DLG_YES)
571 if answer == True:
572 devices[drive_to_partition].remove_partition(part_to_edit)
573 break
574
575 elif part_action == _(u"Extra mkfs.* Parameters"):
576 self._d.msgbox(_(u"This feature is coming soon. Please go to console and do it yourself for now."))
577
578 def set_network_mounts(self):
579 # This is where any NFS mounts will be specified
580 network_mounts = copy.deepcopy(self._install_profile.get_network_mounts())
581 while 1:
582 menulist = []
583 for mount in network_mounts:
584 menulist.append(mount['host'] + ":" + mount['export'])
585 menulist.append(_(u"Add a new network mount"))
586 choices = self._dmenu_list_to_choices(menulist)
587 code, menuitemidx = self._d.menu(_(u"If you have any network shares you would like to mount during the install and for your new system, define them here. Select a network mount to edit or add a new mount. Currently GLI only supports NFS mounts."), choices=choices, cancel=_(u"Save and Continue"), height=18)
588 if code == self._DLG_CANCEL:
589 try:
590 self._install_profile.set_network_mounts(network_mounts)
591 except:
592 self._d.msgbox(_(u"ERROR: Could net set network mounts!"))
593 break
594 menuitem = menulist[int(menuitemidx)-1]
595 if menuitem == _(u"Add a new network mount"):
596 #Change the Yes/No buttons back.
597 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
598 self._d.add_persistent_args(["--no-label", _(u"No")])
599 if self._d.yesno(_(u"Do you want to start portmap to be able to search for NFS mounts?"), width=60) == self._DLG_YES:
600 status = GLIUtility.start_portmap()
601 if not status:
602 self._d.msgbox(_(u"ERROR: Could not start portmap!"))
603
604 code, nfsmount = self._d.inputbox(_(u"Enter NFS mount or just enter the IP/hostname to search for available mounts"), height=13, width=50)
605 if code != self._DLG_OK:
606 continue
607 if not GLIUtility.is_nfs(nfsmount):
608 if GLIUtility.is_ip(nfsmount) or GLIUtility.is_hostname(nfsmount):
609 status, remotemounts = GLIUtility.spawn("/usr/sbin/showmount -e " + nfsmount + " 2>&1 | egrep '^/' | cut -d ' ' -f 1 && echo", return_output=True)
610 remotemounts = remotemounts.strip().split("\n")
611 if (not GLIUtility.exitsuccess(status)) or (not len(remotemounts)) or not remotemounts[0]:
612 self._d.msgbox(_(u"No NFS exports were detected on ") + nfsmount)
613 continue
614 code, nfsmount2 = self._d.menu(_(u"Select a NFS export"), choices=self._dmenu_list_to_choices(remotemounts), cancel=_(u"Back"))
615 if code != self._DLG_OK:
616 continue
617 nfsmount2 = remotemounts[int(nfsmount2)-1]
618 else:
619 self._d.msgbox(_(u"The address you entered, %s, is not a valid IP or hostname. Please try again.") % nfsmount)
620 continue
621 else:
622 colon_location = nfsmount.find(':')
623 menuitem = nfsmount
624 nfsmount = menuitem[:colon_location]
625 nfsmount2 = menuitem[colon_location+1:]
626 for mount in network_mounts:
627 if nfsmount == mount['host'] and nfsmount2 == mount['export']:
628 self._d.msgbox(_(u"There is already an entry for ") + nfsmount + ":" + nfsmount2 + ".")
629 nfsmount = None
630 break
631 if nfsmount == None:
632 continue
633 network_mounts.append({'export': nfsmount2, 'host': nfsmount, 'mountopts': '', 'mountpoint': '', 'type': 'nfs'})
634 menuitem = nfsmount + ":" + nfsmount2
635 menuitemidx = len(network_mounts)
636
637 if menuitem.find(':') != -1:
638 colon_location = menuitem.find(':')
639 tmpmount = network_mounts[int(menuitemidx)-1]
640 code, mountpoint = self._d.inputbox(_(u"Enter a mountpoint"), init=tmpmount['mountpoint'])
641 if code == self._DLG_OK:
642 tmpmount['mountpoint'] = mountpoint
643 code, mountopts = self._d.inputbox(_(u"Enter mount options"), init=tmpmount['mountopts'])
644 if code == self._DLG_OK:
645 tmpmount['mountopts'] = mountopts
646 network_mounts[int(menuitemidx)-1] = tmpmount
647
648 ############ STAGE3 FUNCTIONS #################
649
650 def set_install_stage(self):
651 if self.networkless: return
652 # The install stage and stage tarball will be selected here
653 install_stages = (("3",_(u"Stage3 is a basic system that has been built for you (no compiling).")),
654 ("3+GRP", _(u"A Stage3 install but using binaries from the LiveCD when able.")))
655 code, install_stage = self._d.menu(_(u"Which stage do you want to start at?"), choices=install_stages, cancel=_(u"Back"), width=78)
656 stage3warning = ""
657 if code == self._DLG_OK:
658 if install_stage == "3+GRP":
659 stage3warning = _(u"WARNING: Since you are doing a GRP install it is HIGHLY recommended you choose Create from CD to avoid a potentially broken installation.")
660 try:
661 self._install_profile.set_grp_install(None, True, None)
662 except:
663 self._d.msgbox(_(u"ERROR! Could not set install stage!"))
664 install_stage = "3"
665 try:
666 self._install_profile.set_install_stage(None, install_stage, None)
667 except:
668 self._d.msgbox(_(u"ERROR! Could not set install stage!"))
669 has_systempkgs = GLIUtility.is_file("/usr/livecd/systempkgs.txt")
670 if install_stage == "3" and has_systempkgs:
671 #Change the Yes/No buttons to new labels for this question.
672 self._d.add_persistent_args(["--yes-label", _(u"Create from CD")])
673 self._d.add_persistent_args(["--no-label", _(u"Specify URI")])
674 if self._d.yesno(_(u"Do you want to generate a stage3 on the fly using the files on the LiveCD (fastest) or do you want to grab your stage tarball from the Internet?\n")+stage3warning, width=55) == self._DLG_YES:
675 #Generate on the FLY
676 try:
677 self._install_profile.set_dynamic_stage3(None, True, None)
678 except:
679 self._d.msgbox(_(u"ERROR: Could not set the stage tarball URI!"))
680 return
681 #Specify URI
682 #subarches = { 'x86': ("x86", "i686", "pentium3", "pentium4", "athlon-xp"), 'hppa': ("hppa1.1", "hppa2.0"), 'ppc': ("g3", "g4", "g5", "ppc"), 'sparc': ("sparc32", "sparc64")}
683
684 stage_tarball = ""
685 while (not stage_tarball) and (not GLIUtility.is_uri(stage_tarball)): #LOOP till valid.
686 type_it_in = False
687 if GLIUtility.ping("www.gentoo.org"): #Test for network connectivity
688 mirrors = GLIUtility.list_mirrors()
689 mirrornames = []
690 mirrorurls = []
691 for item in mirrors:
692 mirrornames.append(item[1])
693 mirrorurls.append(item[0])
694 code, mirror = self._d.menu(_(u"Select a mirror to grab the tarball from or select Cancel to enter an URI manually."), choices=self._dmenu_list_to_choices(mirrornames), width=77, height=20)
695 if code != self._DLG_OK:
696 type_it_in = True
697 else:
698 mirror = mirrorurls[int(mirror)-1]
699 tarballs = GLIUtility.list_stage_tarballs_from_mirror(mirror, self._arch)
700 code, stage_tarball = self._d.menu(_(u"Select your desired stage tarball:"), choices=self._dmenu_list_to_choices(tarballs), width=77, height=20)
701 if (code != self._DLG_OK):
702 type_it_in = True
703 else:
704 stage_tarball = mirror + "/releases/" + self._arch + "/current/stages/" + tarballs[int(stage_tarball)-1]
705 #get portageq envvar value of cflags and look for x86, i686,etc.
706 #URL SYNTAX
707 #http://gentoo.osuosl.org/releases/ARCHITECTURE/current/stages/
708 else:
709 type_it_in = True
710 if type_it_in:
711 code, stage_tarball = self._d.inputbox(_(u"Specify the stage tarball URI or local file:"), init=self._install_profile.get_stage_tarball_uri())
712 if code != self._DLG_OK:
713 return
714 #If Doing a local install, check for valid file:/// uri
715 if stage_tarball:
716 if not GLIUtility.is_uri(stage_tarball):
717 self._d.msgbox(_(u"The specified URI is invalid. It was not saved. Please go back and try again."));
718 else: self._install_profile.set_stage_tarball_uri(None, stage_tarball, None)
719 else: self._d.msgbox(_(u"No URI was specified!"))
720
721 def set_portage_tree(self):
722 # This section will ask whether to sync the tree, whether to use a snapshot, etc.
723 if self._install_profile.get_dynamic_stage3(): #special case
724 try:
725 self._install_profile.set_portage_tree_sync_type(None,"snapshot", None)
726 cd_snapshot_uri = GLIUtility.get_cd_snapshot_uri()
727 self._install_profile.set_portage_tree_snapshot_uri(None, cd_snapshot_uri, None)
728 except:
729 self._d.msgbox(_(u"ERROR! Could not set the portage cd snapshot URI!"))
730 return
731
732 #Normal case
733 menulist = [("Sync", _(u"Normal. Use emerge sync RECOMMENDED!")),
734 ("Webrsync", _(u"HTTP daily snapshot. Use when rsync is firewalled.")),
735 ("Snapshot", _(u"Use a portage snapshot, either a local file or a URL")),
736 ("None", _(u"Extra cases such as if /usr/portage is an NFS mount"))]
737 code, portage_tree_sync = self._d.menu(_(u"Which method do you want to use to sync the portage tree for the installation? If choosing a snapshot you will need to provide the URI for the snapshot if it is not on the livecd."),width=75, height=17, choices=menulist)
738 if code != self._DLG_OK:
739 return
740 self._install_profile.set_portage_tree_sync_type(None, portage_tree_sync.lower(), None)
741 if portage_tree_sync == "Snapshot":
742 if self._install_profile.get_portage_tree_snapshot_uri():
743 initval = self._install_profile.get_portage_tree_snapshot_uri()
744 else:
745 initval = GLIUtility.get_cd_snapshot_uri()
746 code, snapshot = self._d.inputbox(_(u"Enter portage tree snapshot URI"), init=initval)
747 if code == self._DLG_OK:
748 if snapshot:
749 if not GLIUtility.is_uri(snapshot):
750 self._d.msgbox(_(u"The specified URI is invalid. It was not saved. Please go back and try again."))
751 else:
752 self._install_profile.set_portage_tree_snapshot_uri(None, snapshot, None)
753
754 else:
755 self._d.msgbox(_(u"No URI was specified! Returning to default emerge sync."))
756 #if d.yesno("The specified URI is invalid. Use it anyway?") == DLG_YES: install_profile.set_stage_tarball_uri(None, stage_tarball, None)
757
758 ############ STAGE4 FUNCTIONS #################
759
760 def set_make_conf(self):
761 # This section will be for setting things like CFLAGS, ACCEPT_KEYWORDS, and USE
762 #special case for dynamic stage3
763 if self._install_profile.get_dynamic_stage3() or not self.advanced_mode:
764 return
765
766 etc_files = self._install_profile.get_etc_files()
767 if etc_files.has_key("make.conf"):
768 make_conf = etc_files['make.conf']
769 else:
770 make_conf = {}
771
772 self._d.msgbox(_(u"""The installer will now gather information regarding the contents of /etc/make.conf
773 One of the unique (and best) features of Gentoo is the ability to
774 define flags (called USE flags) that define what components are
775 compiled into applications. For example, you can enable the alsa
776 flag and programs that have alsa capability will use it.
777 The result is a finely tuned OS with no unnecessary components to
778 slow you down.
779 The installer divides USE flag selection into two screens, one for
780 global USE flags and one for local flags specific to each program.
781 Please be patient while the screens load. It may take awhile."""), width=73, height=16)
782
783 #First grab the system USE flags. These will be used often.
784 system_use_flags = GLIUtility.spawn("portageq envvar USE", return_output=True)[1].strip().split()
785
786 #Now get any stored USE flags.
787 remove_from_system = {}
788 add_flags = []
789 if make_conf.has_key("USE"):
790 stored_use_flags = make_conf["USE"].split()
791 for flag in stored_use_flags:
792 if "-" in flag: #A subtraction of a flag in the system USE
793 remove_flag = flag[1:]
794 remove_from_system[remove_flag] = 1
795 else:
796 add_flags.append(flag) #Add to checked list
797
798
799 #Load data.
800 use_flags = []
801 use_local_flags = []
802 use_desc = GLIUtility.get_global_use_flags()
803 use_local_desc = GLIUtility.get_local_use_flags()
804
805 #populate the choices list
806 sorted_use = use_desc.keys()
807 sorted_use.sort()
808 for flagname in sorted_use:
809 use_flags.append((flagname, use_desc[flagname], int((flagname in system_use_flags or flagname in add_flags) and not remove_from_system.has_key(flagname) )))
810 #present the menu
811 code, chosen_use_flags = self._d.checklist(_(u"Choose which *global* USE flags you want on the new system"), height=25, width=80,list_height=17, choices=use_flags)
812
813 #populate the chocies list
814 sorted_use = use_local_desc.keys()
815 sorted_use.sort()
816 for flagname in sorted_use:
817 use_local_flags.append((flagname, use_local_desc[flagname], int((flagname in system_use_flags or flagname in add_flags) and not remove_from_system.has_key(flagname) )))
818 #present the menu
819 code, chosen_use_local_flags = self._d.checklist(_(u"Choose which *local* USE flags you want on the new system"), height=25, width=80,list_height=17, choices=use_local_flags)
820
821
822 #Hash the chosen list for speed.
823 chosen_hash = {}
824 for flag in chosen_use_flags:
825 chosen_hash[flag] = 1
826 for flag in chosen_use_local_flags:
827 chosen_hash[flag] = 1
828
829 #Create the new string. Loop through ALL flags, look for match in hash then in USE
830 temp_use = ""
831 for flag in use_desc:
832 if chosen_hash.has_key(flag) and (flag in system_use_flags):
833 continue #Already in USE, don't need to add.
834 elif chosen_hash.has_key(flag):
835 temp_use += flag + " " #Checked. Add.
836 elif not chosen_hash.has_key(flag) and (flag in system_use_flags):
837 temp_use += "-"+flag+" " #Was unchecked. add a -flag to USE
838
839 for flag in use_local_desc:
840 if chosen_hash.has_key(flag) and (flag in system_use_flags):
841 continue #Already in USE, don't need to add.
842 elif chosen_hash.has_key(flag):
843 temp_use += flag + " " #Checked. Add.
844 elif not chosen_hash.has_key(flag) and (flag in system_use_flags):
845 temp_use += "-"+flag+" " #Was unchecked. add a -flag to USE
846 #Store it!
847 make_conf["USE"] = temp_use
848
849 if not self._install_profile.get_dynamic_stage3() and self.advanced_mode:
850 #Second, set the ACCEPT_KEYWORDS
851 #Change the Yes/No buttons to new labels for this question.
852 self._d.add_persistent_args(["--yes-label", _(u"Stable")])
853 self._d.add_persistent_args(["--no-label", _(u"Unstable")])
854 if self._d.yesno(_(u"Do you want to run the normal stable portage tree, or the bleeding edge unstable (i.e. ACCEPT_KEYWORDS=%s)? If unsure select stable. Stable is required for GRP installs." % self._arch), height=12, width=55) == self._DLG_YES:
855 #Stable
856 make_conf["ACCEPT_KEYWORDS"] = ""
857 else: #Unstable
858 make_conf["ACCEPT_KEYWORDS"] = "~" + self._arch
859 #Third, misc. stuff.
860 while self.advanced_mode:
861 menulist = [("CFLAGS",_(u"Edit your C Flags and Optimization level")),
862 ("CHOST", _(u"Change the Host Setting")),
863 ("MAKEOPTS", _(u"Specify number of parallel makes (-j) to perform.")),
864 ("FEATURES", _(u"Change portage functionality settings. (distcc/ccache)")),
865 ("GENTOO_MIRRORS", _(u"Specify mirrors to use for source retrieval.")),
866 ("SYNC", _(u"Specify server used by rsync to sync the portage tree.")),
867 (_(u"Other"), _(u"Specify your own variable and value."))]
868 if self._install_profile.get_dynamic_stage3(): #SPECIAL LIST WITHOUT CHOST
869 menulist = [("CFLAGS",_(u"Edit your C Flags and Optimization level")),
870 ("MAKEOPTS", _(u"Specify number of parallel makes (-j) to perform.")),
871 ("FEATURES", _(u"Change portage functionality settings. (distcc/ccache)")),
872 ("GENTOO_MIRRORS", _(u"Specify mirrors to use for source retrieval.")),
873 ("SYNC", _(u"Specify server used by rsync to sync the portage tree.")),
874 (_(u"Other"), _(u"Specify your own variable and value."))]
875 code, menuitem = self._d.menu(_(u"For experienced users, the following /etc/make.conf variables can also be defined. Choose a variable to edit or Done to continue."), choices=menulist, cancel=_(u"Done"), width=77)
876 if code != self._DLG_OK:
877 break
878 if menuitem == _(u"Other"):
879 code,menuitem = self._d.inputbox(_(u"Enter the variable name: "))
880 if code != self._DLG_OK:
881 continue
882 oldval = ""
883 if make_conf.has_key(menuitem):
884 oldval = make_conf[menuitem]
885 if oldval:
886 code, newval = self._d.inputbox(_(u"Enter new value for ") + menuitem, init=oldval)
887 if code == self._DLG_OK:
888 make_conf[menuitem] = newval
889 continue
890 #SPECIAL CASES here with their own menus.
891 if menuitem == "CFLAGS":
892 if not make_conf.has_key("CFLAGS"):
893 try:
894 cflags = GLIUtility.get_value_from_config("/etc/make.conf","CFLAGS")
895 except:
896 cflags = ""
897 else:
898 cflags = make_conf['CFLAGS']
899 while 1:
900 choices_list = [
901 (_(u"CLEAR"),_(u"Erase the current value and start over.")),
902 ("-mcpu",_(u"Add a CPU optimization (deprecated in GCC 3.4)")),
903 ("-mtune",_(u"Add a CPU optimization (GCC 3.4+)")),
904 ("-march",_(u"Add an Architecture optimization")),
905 ("-O",_(u"Add optimization level (please do NOT go over 2)")),
906 ("-fomit-frame-pointer",_(u"For advanced users only.")),
907 ("-pipe",_(u"Common additional flag")),
908 (_(u"Manual"),_(u"Specify your CFLAGS manually"))
909 ]
910 code, choice = self._d.menu(_(u"Choose a flag to add to the CFLAGS variable or Done to go back. The current value is: ")+ cflags, choices=choices_list, cancel=_(u"Done"), width=70)
911 if code != self._DLG_OK:
912 break
913 if choice == _(u"CLEAR"):
914 cflags = ""
915 elif choice == _(u"Manual"):
916 code, cflags = self._d.inputbox(_(u"Enter new value for ") + menuitem)
917 break
918 elif choice in ["-fomit-frame-pointer","-pipe"]:
919 cflags += " "+choice
920 else:
921 code, newval = self._d.inputbox(_(u"Enter the new value for %s (value only):") % choice)
922 if code != self._DLG_OK or not newval:
923 continue
924 if choice == "-O":
925 cflags += " "+choice+newval
926 else:
927 cflags += " "+choice+"="+newval
928 if cflags:
929 make_conf['CFLAGS'] = cflags
930 elif menuitem == "CHOST":
931 choices_list = GLIUtility.get_chosts(self._arch)
932 code, chost = self._d.menu(_(u"Choose from the available CHOSTs for your architecture."), choices=self._dmenu_list_to_choices(choices_list), width=77)
933 if code != self._DLG_OK:
934 continue
935 chost = choices_list[int(chost)-1]
936 make_conf['CHOST'] = chost
937 elif menuitem == "MAKEOPTS":
938 makeopt_string = _(u"Presently the only use is for specifying the number of parallel makes (-j) to perform. The suggested number for parallel makes is CPUs+1. Enter the NUMBER ONLY:")
939 code, newval = self._d.inputbox(makeopt_string, width=60)
940 if code != self._DLG_OK:
941 continue
942 make_conf['MAKEOPTS'] = "-j"+str(newval)
943 elif menuitem == "FEATURES":
944 choices_list = [("sandbox",_(u"enables sandboxing when running emerge and ebuild."),0),
945 ("ccache",_(u"enables ccache support via CC."),0),
946 ("distcc",_(u"enables distcc support via CC."),0),
947 ("distlocks",_(u"enables distfiles locking using fcntl or hardlinks."),0),
948 ("buildpkg",_(u"create binaries of all packages emerged"),0),
949 (_(u"Other"),_(u"Input your list of FEATURES manually."),0) ]
950 features_string = _(u"FEATURES are settings that affect the functionality of portage. Most of these settings are for developer use, but some are available to non-developers as well.")
951 code, choices = self._d.checklist(features_string, choices=choices_list, width=75)
952 if code != self._DLG_OK:
953 continue
954 if _(u"Other") in choices:
955 code, features = self._d.inputbox(_(u"Enter the value of FEATURES: "))
956 elif choices:
957 features = string.join(choices, ' ')
958 else:
959 features = ""
960 if features:
961 make_conf['FEATURES'] = features
962 else:
963 code, newval = self._d.inputbox(_(u"Enter new value for ") + menuitem)
964 if code == self._DLG_OK and newval:
965 make_conf[menuitem] = newval
966
967 try:
968 if make_conf:
969 etc_files['make.conf'] = make_conf
970 self._install_profile.set_etc_files(etc_files)
971 except:
972 self._d.msgbox(_(u"ERROR! Could not set the make_conf correctly!"))
973
974 def set_distcc(self):
975 #Change the Yes/No buttons for this question.
976 if self._install_profile.get_dynamic_stage3() or not self.advanced_mode:
977 return
978 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
979 self._d.add_persistent_args(["--no-label", _(u"No")])
980 if self._d.yesno(_(u"Do you want to use distcc to compile your extra packages during the install and for future compilations as well?"), height=12, width=60, defaultno=1) == self._DLG_YES:
981 #Add distcc to the services list.
982 if self._install_profile.get_services():
983 services = self._install_profile.get_services()
984 if isinstance(services, str):
985 services = services.split(',')
986 else:
987 services = []
988 if not "distccd" in services:
989 services.append("distccd")
990 try:
991 services = string.join(services, ',')
992 if services:
993 self._install_profile.set_services(None, services, None)
994 except:
995 self._d.msgbox(_(u"ERROR! Could not set the services list."))
996 return
997 #Set the distcc flag to emerge earlier than other packages.
998 try:
999 self._install_profile.set_install_distcc(None, True, None)
1000 except:
1001 self._d.msgbox(_(u"ERROR! Could not set the install distcc flag!"))
1002 return
1003
1004 #Add distcc to the FEATURES in make.conf and add DISTCC_HOSTS too.
1005 etc_files = self._install_profile.get_etc_files()
1006 #load up the make.conf
1007 if etc_files.has_key("make.conf"):
1008 make_conf = etc_files['make.conf']
1009 else:
1010 make_conf = {}
1011 #Check for FEATURES and add if not already there.
1012 if make_conf.has_key("FEATURES"):
1013 if not "distcc" in make_conf['FEATURES']:
1014 make_conf['FEATURES'] += " distcc"
1015 else:
1016 make_conf['FEATURES'] = "distcc"
1017 #Now while still working in make.conf, figure out what HOSTS to set.
1018 if make_conf.has_key("DISTCC_HOSTS"):
1019 initval = make_conf['DISTCC_HOSTS']
1020 else:
1021 initval = "localhost "
1022 distcc_string = _(u"Enter the hosts to be used by distcc for compilation:\nExample: localhost 192.168.0.2 192.168.0.3:4000/10")
1023 code, hosts = self._d.inputbox(distcc_string, width=75, init=initval)
1024 if code != self._DLG_OK:
1025 hosts = initval
1026 make_conf['DISTCC_HOSTS'] = hosts
1027 try:
1028 etc_files['make.conf'] = make_conf
1029 self._install_profile.set_etc_files(etc_files)
1030 except:
1031 self._d.msgbox(_(u"ERROR! Could not set the make_conf correctly!"))
1032
1033 def set_etc_portage(self):
1034 if self.networkless: return
1035 #This section will be for editing the /etc/portage/* files and other /etc/* files. This should be for advanced users only.
1036 etc_files = self._install_profile.get_etc_files()
1037 while self.advanced_mode:
1038
1039 menulist = [("portage/package.mask",_(u"A list of DEPEND atoms to mask.")),
1040 ("portage/package.unmask",_(u"A list of packages to unmask.")),
1041 ("portage/package.keywords",_(u"Per-package KEYWORDS (like ACCEPT_KEYWORDS).")),
1042 ("portage/package.use",_(u"Per-package USE flags.")),
1043 (_(u"Other"),_(u"Type your own name of a file to edit in /etc/"))]
1044 code, menuitem = self._d.menu(_(u"For experienced users, the following /etc/* variables can also be defined. Choose a variable to edit or Done to continue."), choices=menulist, cancel=_(u"Done"), width=77)
1045 if code != self._DLG_OK:
1046 break #get out of the while loop. then save and continue
1047
1048 if menuitem == _(u"Other"):
1049 code, menuitem = self._d.inputbox(_(u"Enter the name of the /etc/ file you would like to edit (DO NOT type /etc/)"))
1050 if code != self._DLG_OK:
1051 return
1052 oldval = ""
1053 if etc_files.has_key(menuitem):
1054 oldval = etc_files[menuitem]
1055
1056 code, newval = self._d.inputbox(_(u"Enter new contents (use \\n for newline) of ") + menuitem, init=oldval)
1057 if code == self._DLG_OK:
1058 etc_files[menuitem] = []
1059 etc_files[menuitem].append(newval)
1060 try:
1061 self._install_profile.set_etc_files(etc_files)
1062 except:
1063 self._d.msgbox(_(u"ERROR! Could not set etc/portage/* correctly!"))
1064
1065
1066
1067 def set_kernel(self):
1068 if self.networkless: return
1069 # This section will be for choosing kernel sources, choosing (and specifying) a custom config or genkernel, modules to load at startup, etc.
1070 kernel_sources = [("livecd-kernel", _(u"Copy over the current running kernel (fastest)")),
1071 ("vanilla-sources", _(u"The Unaltered Linux Kernel ver 2.6+ (safest)")),
1072 ("gentoo-sources", _(u"Gentoo's optimized 2.6+ kernel. (less safe)")),
1073 ("hardened-sources", _(u"Hardened sources for the 2.6 kernel tree")),
1074 ("grsec-sources",_(u"Vanilla sources with grsecurity patches")),
1075 (_(u"Other"), _(u"Choose one of the other sources available."))]
1076 code, menuitem = self._d.menu(_(u"Choose which kernel sources to use for your system. If using a previously-made kernel configuration, make sure the sources match the kernel used to create the configuration."), choices=kernel_sources, width=77, height=17)
1077 if code != self._DLG_OK:
1078 return
1079 if menuitem == _(u"Other"):
1080 code, menuitem = self._d.inputbox(_(u"Please enter the desired kernel sources package name:"))
1081 if code != self._DLG_OK: return
1082 try:
1083 self._install_profile.set_kernel_source_pkg(None, menuitem, None)
1084 except:
1085 self._d.msgbox(_(u"ERROR! Could not set the kernel source package!"))
1086 if not menuitem == "livecd-kernel":
1087 #Change the Yes/No buttons to new labels for this question.
1088 self._d.add_persistent_args(["--yes-label", _(u"Genkernel")])
1089 self._d.add_persistent_args(["--no-label", _(u"Traditional (requires a config!)")])
1090 kernel_string1 = _(u"There are currently two ways the installer can compile a kernel for your new system. You can either provide a previously-made kernel configuration file and use the traditional kernel-compiling procedure (no initrd) or have genkernel automatically create your kernel for you (with initrd). \n\n If you do not have a previously-made kernel configuration, YOU MUST CHOOSE Genkernel. Choose which method you want to use.")
1091 if self._d.yesno(kernel_string1, width=76,height=13) == self._DLG_YES: #Genkernel
1092 self._install_profile.set_kernel_build_method(None,"genkernel", None)
1093 if self.advanced_mode:
1094 #Change the Yes/No buttons back.
1095 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
1096 self._d.add_persistent_args(["--no-label", _(u"No")])
1097 if self._d.yesno(_(u"Do you want the bootsplash screen to show up on bootup?")) == self._DLG_YES:
1098 self._install_profile.set_kernel_bootsplash(None, True, None)
1099 else:
1100 self._install_profile.set_kernel_bootsplash(None, False, None)
1101 else: #Custom
1102 self._install_profile.set_kernel_build_method(None,"custom", None)
1103 if self.advanced_mode:
1104 code, custom_kernel_uri = self._d.inputbox(_(u"If you have a custom kernel configuration, enter its location (otherwise just press Enter to continue):"), height=13, width=50)
1105 if code == self._DLG_OK:
1106 if custom_kernel_uri:
1107 if not GLIUtility.is_uri(custom_kernel_uri, checklocal=self.local_install):
1108 self._d.msgbox(_(u"The specified URI is invalid. It was not saved. Please go back and try again."))
1109 else:
1110 try:
1111 self._install_profile.set_kernel_config_uri(None, custom_kernel_uri, None)
1112 except:
1113 self._d.msgbox(_(u"ERROR! Could not set the kernel config URI!"))
1114 #else: self._d.msgbox(_(u"No URI was specified! Reverting to using genkernel"))
1115
1116 def set_boot_loader(self):
1117 mounts = self._install_profile.get_mounts()
1118 boot_drive_choices = []
1119 #Bootloader code yanked from the x86ArchTemplate
1120 kernel_params = self._install_profile.get_bootloader_kernel_args()
1121 if self._install_profile.get_boot_device():
1122 boot_device = self._install_profile.get_boot_device()
1123 else:
1124 boot_device = ""
1125 foundboot = False
1126 for mount in mounts:
1127 #if not mount['devnode'][:-1] in boot_drive_choices:
1128 # boot_drive_choices.append(mount['devnode'][:-1])
1129 mountpoint = mount['mountpoint']
1130 if (mountpoint == "/boot"):
1131 foundboot = True
1132 if (( (mountpoint == "/") and (not foundboot) ) or (mountpoint == "/boot")):
1133 if not "doscsi" in kernel_params.split():
1134 if mount['devnode'].startswith("/dev/sd"): kernel_params += " doscsi"
1135 for drive in self._drives:
1136 boot_drive_choices.append((drive, self._devices[drive].get_model()))
1137 arch_loaders = { 'x86': [
1138 ("grub",_(u"GRand Unified Bootloader, newer, RECOMMENDED"))],
1139 'amd64': [
1140 ("grub",_(u"GRand Unified Bootloader, newer, RECOMMENDED"))]} #FIXME ADD OTHER ARCHS
1141 if not self.networkless:
1142 arch_loaders['x86'].append(("lilo",_(u"LInux LOader, older, traditional.(detects windows partitions)")))
1143 boot_loaders = arch_loaders[self._arch]
1144 boot_loaders.append(("none", _(u"Do not install a bootloader. (System may be unbootable!)")))
1145 boot_string1 = _(u"To boot successfully into your new Linux system, a bootloader will be needed. If you already have a bootloader you want to use you can select None here. The bootloader choices available are dependent on what GLI supports and what architecture your system is. Choose a bootloader")
1146 code, menuitem = self._d.menu(boot_string1, choices=boot_loaders, height=16, width=74)
1147 if code != self._DLG_OK:
1148 return
1149 try:
1150 self._install_profile.set_boot_loader_pkg(None, menuitem, None)
1151 except:
1152 self._d.msgbox(_(u"ERROR! Could not set boot loader pkg! ")+menuitem)
1153 if menuitem != "none" and self.advanced_mode:
1154 #Reset the Yes/No labels.
1155 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
1156 self._d.add_persistent_args(["--no-label",_(u"No")])
1157 boot_string2 = _(u"Most bootloaders have the ability to install to either the Master Boot Record (MBR) or some other partition. Most people will want their bootloader installed on the MBR for successful boots, but if you have special circumstances, you can have the bootloader installed to the /boot partition instead. Do you want the boot loader installed in the MBR? (YES is RECOMMENDED)")
1158 if self._d.yesno(boot_string2, height=13, width=55) == self._DLG_YES:
1159 self._install_profile.set_boot_loader_mbr(None, True, None)
1160 else:
1161 self._install_profile.set_boot_loader_mbr(None, False, None)
1162 if self._install_profile.get_boot_loader_mbr(): #If we're installing to MBR gotta check the device.
1163 if self.advanced_mode or (boot_device and boot_device[-1] != 'a'):
1164 #show the menu.
1165 boot_string3_std = _(u"Your boot device may not be correct. It is currently set to %s, but this device may not be the first to boot. Usually boot devices end in 'a' such as hda or sda.") % boot_device
1166 boot_string3 = _(u" Please confirm your boot device by choosing it from the menu.")
1167 if not self.advanced_mode:
1168 boot_string3 = boot_string3_std + boot_string3
1169 if not boot_drive_choices:
1170 self._d.msgbox(_(u"ERROR: No drives set up. Please complete the Partitioning screen first!"))
1171 return
1172 code, boot_drive_choice = self._d.menu(boot_string3, choices=boot_drive_choices, height=16, width=70)
1173 if code != self._DLG_OK:
1174 return
1175 try:
1176 self._install_profile.set_boot_device(None,boot_drive_choice,None)
1177 except:
1178 self._d.msgbox(_(u"ERROR! Could not set the boot device!")+boot_drive_choice)
1179 if self.advanced_mode:
1180 code, bootloader_kernel_args = self._d.inputbox(_(u"If you have any additional optional arguments you want to pass to the kernel at boot, type them here or just press Enter to continue:"), height=12, width=55, init=kernel_params)
1181 if code == self._DLG_OK:
1182 try:
1183 self._install_profile.set_bootloader_kernel_args(None, bootloader_kernel_args, None)
1184 except:
1185 self._d.msgbox(_(u"ERROR! Could not set bootloader kernel arguments! ")+bootloader_kernel_args)
1186 elif kernel_params: #If we are in standard mode but have the dosci to add.
1187 try:
1188 self._install_profile.set_bootloader_kernel_args(None, kernel_params, None)
1189 except:
1190 self._d.msgbox(_(u"ERROR! Could not set bootloader kernel arguments! ")+bootloader_kernel_args)
1191
1192
1193 def set_timezone(self):
1194 # This section will be for setting the timezone.
1195 zonepath = "/usr/share/zoneinfo"
1196 skiplist = ["zone.tab","iso3166.tab","posixrules"]
1197 while 1:
1198 tzlist = []
1199 for entry in os.listdir(zonepath):
1200 if entry not in skiplist:
1201 if os.path.isdir(zonepath + "/" + entry): entry += "/"
1202 tzlist.append(entry)
1203 tzlist.sort()
1204 timezone_string = _(u"Please select the timezone for the new installation. Entries ending with a / can be selected to reveal a sub-list of more specific locations. For example, you can select America/ and then Chicago.")
1205 code, tznum = self._d.menu(timezone_string, choices=self._dmenu_list_to_choices(tzlist), height=20, cancel="Back")
1206 if code == self._DLG_OK:
1207 zonepath = os.path.join(zonepath,tzlist[int(tznum)-1])
1208 if tzlist[int(tznum)-1][-1:] != "/":
1209 break
1210 else:
1211 if zonepath == "/usr/share/zoneinfo":
1212 return
1213 slashloc = zonepath[:-1].rfind("/")
1214 zonepath = zonepath[:slashloc]
1215 try:
1216 self._install_profile.set_time_zone(None, zonepath[20:], None)
1217 except:
1218 self._d.msgbox(_(u"ERROR: Could not set that timezone!"))
1219
1220 def set_networking(self):
1221 # This section will be for setting up network interfaces
1222 interfaces = self._install_profile.get_network_interfaces()
1223
1224 while 1:
1225 net_string1 = _(u"Here you will enter all of your network interface information for the new system. You can either choose a network interface to edit, add a network interface, delete an interface, or edit the miscellaneous options such as hostname and proxy servers.")
1226 net_string2 = _(u"To setup your network interface, you can either use DHCP if enabled, or manually enter your network information.\n DHCP (Dynamic Host Configuration Protocol) makes it possible to automatically receive networking information (IP address, netmask, broadcast address, gateway, nameservers etc.). This only works if you have a DHCP server in your network (or if your provider provides a DHCP service). If you do not, you must enter the information manually. Please select your networking configuration method:")
1227 choice_list = []
1228 for iface in interfaces:
1229 if interfaces[iface][0] == 'dhcp':
1230 choice_list.append((iface, _(u"Settings: DHCP. Options: ")+ interfaces[iface][1]))
1231 else:
1232 choice_list.append((iface, _(u"IP: ")+interfaces[iface][0]+_(u" Broadcast: ")+interfaces[iface][1]+_(u" Netmask: ")+interfaces[iface][2]))
1233 choice_list.append((_(u"Add"),_(u"Add a new network interface")))
1234 code, iface_choice = self._d.menu(net_string1, choices=choice_list, cancel=_(u"Save and Continue"), height=18, width=77)
1235 if code != self._DLG_OK:
1236 try:
1237 self._install_profile.set_network_interfaces(interfaces)
1238 except:
1239 self._d.msgbox(_(u"ERROR! Could not set the network interfaces!"))
1240 break #This should hopefully move the user down to part two of set_networking
1241 if iface_choice == _(u"Add"):
1242
1243 device_list = GLIUtility.get_eth_devices()
1244 newchoice_list = []
1245 for device in device_list:
1246 if device not in interfaces:
1247 newchoice_list.append((device, GLIUtility.get_interface_realname(device)))
1248 newchoice_list.append((_(u"Other"),_(u"Type your own.")))
1249 code, newnic = self._d.menu(_(u"Choose an interface from the list or Other to type your own if it was not detected."), choices=newchoice_list, width=75)
1250
1251 if newnic == _(u"Other"):
1252 code, newnic = self._d.inputbox(_(u"Enter name for new interface (eth0, ppp0, etc.)"))
1253 if code != self._DLG_OK:
1254 continue
1255 if newnic in interfaces:
1256 self._d.msgbox(_(u"An interface with the name is already defined."))
1257 continue
1258 #create the interface in the data structure.
1259 #interfaces[newnic] = ("", "", "")
1260 #Change the Yes/No buttons to new labels for this question.
1261 self._d.add_persistent_args(["--yes-label", _(u"DHCP")])
1262 self._d.add_persistent_args(["--no-label", _(u"Static IP/Manual")])
1263 if self._d.yesno(net_string2, height=15, width=60) == self._DLG_YES: #DHCP
1264 dhcp_options = ""
1265 if self.advanced_mode:
1266 code, dhcp_options = self._d.inputbox(_(u"If you have any additional DHCP options to pass, type them here in a space-separated list. If you have none, just press Enter."), height=13, width=50)
1267 interfaces[newnic] = ('dhcp', dhcp_options, None)
1268 else:
1269 network_type = 'static'
1270 code, data = self._d.form(_(u'Enter your networking information: (See Chapter 3 of the Handbook for more information) Your broadcast address is probably your IP address with 255 as the last tuple. Do not press Enter until all fields are complete!'),
1271 ((_(u'Enter your IP address:'), 15),
1272 (_(u'Enter your Broadcast address:'), 15),
1273 (_(u'Enter your Netmask:'),15,'255.255.255.0')))
1274 (ip_address, broadcast, netmask) = data[:-1].split('\n')
1275 if code != self._DLG_OK:
1276 continue
1277 #Set the info now that it's all gathered.
1278 interfaces[newnic] = (ip_address, broadcast, netmask)
1279 else: #they have chosen an interface, present them with edit/delete
1280 #Change the Yes/No buttons to new labels for this question.
1281 self._d.add_persistent_args(["--yes-label", _(u"Edit")])
1282 self._d.add_persistent_args(["--no-label", _(u"Delete")])
1283 if self._d.yesno(_(u"For interface %s, you can either edit the interface information (IP Address, Broadcast, Netmask) or Delete the interface.") % iface_choice) == self._DLG_YES:
1284 #Edit
1285 #Change the Yes/No buttons to new labels for this question.
1286 self._d.add_persistent_args(["--yes-label", _(u"DHCP")])
1287 self._d.add_persistent_args(["--no-label", _(u"Static IP/Manual")])
1288 if self._d.yesno(net_string2, height=15, width=60) == self._DLG_YES: #DHCP
1289 dhcp_options = ""
1290 if self.advanced_mode:
1291 code, dhcp_options = self._d.inputbox(_(u"If you have any additional DHCP options to pass, type them here in a space-separated list. If you have none, just press Enter."), height=13, width=50)
1292 interfaces[iface_choice] = ('dhcp', dhcp_options, None)
1293 else:
1294 network_type = 'static'
1295 code, data = self._d.form(_(u'Enter your networking information: (See Chapter 3 of the Handbook for more information) Your broadcast address is probably your IP address with 255 as the last tuple. Do not press Enter until all fields are complete!'),
1296 ((_(u'Enter your IP address:'), 15, interfaces[iface_choice][0]),
1297 (_(u'Enter your Broadcast address:'), 15, interfaces[iface_choice][1]),
1298 (_(u'Enter your Netmask:'),15,interfaces[iface_choice][2])))
1299 (ip_address, broadcast, netmask) = data[:-1].split('\n')
1300 if code != self._DLG_OK:
1301 continue
1302 #Set the info now that it's all gathered.
1303 interfaces[iface_choice] = (ip_address, broadcast, netmask)
1304 else:
1305 #Delete
1306 #Reset the Yes/No buttons
1307 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
1308 self._d.add_persistent_args(["--no-label", _(u"No")])
1309 if self._d.yesno(_(u"Are you sure you want to remove the interface ") + iface_choice + "?") == self._DLG_YES:
1310 del interfaces[iface_choice]
1311
1312 #This section is for defining DNS servers, default routes/gateways, hostname, etc.
1313 #First ask for the default gateway device and IP
1314 interfaces = self._install_profile.get_network_interfaces()
1315 choice_list = []
1316 for iface in interfaces:
1317 if interfaces[iface][0] == 'dhcp':
1318 choice_list.append((iface, _(u"Settings: DHCP. Options: ")+ interfaces[iface][1],0))
1319 else:
1320 choice_list.append((iface, _(u"IP: ")+interfaces[iface][0]+_(u" Broadcast: ")+interfaces[iface][1]+_(u" Netmask: ")+interfaces[iface][2],0))
1321 net_string3 = _(u"To be able to surf on the internet, you must know which host shares the Internet connection. This host is called the gateway. It is usually similar to your IP address, but ending in .1\nIf you have DHCP then just select your primary Internet interface (no IP will be needed) Start by choosing which interface accesses the Internet:")
1322 if choice_list:
1323 if len(choice_list) == 1: #Only one, no need for menu.
1324 gateway_iface = choice_list[0][0]
1325 else:
1326 code, gateway_iface = self._d.radiolist(net_string3, choices=choice_list, height=20, width=67)
1327 if (code == self._DLG_OK) or gateway_iface: #They made a choice. Ask the IP if not DHCP.
1328 while interfaces[gateway_iface][0] != 'dhcp':
1329 code, ip = self._d.inputbox(_(u"Enter the gateway IP address for ") + gateway_iface, init=interfaces[gateway_iface][0])
1330 if code != self._DLG_OK:
1331 break
1332 if not GLIUtility.is_ip(ip):
1333 self._d.msgbox(_(u"Invalid IP Entered! Please try again."))
1334 continue
1335 try:
1336 self._install_profile.set_default_gateway(None, ip,{'interface': gateway_iface})
1337 except:
1338 self._d.msgbox(_(u"ERROR! Coult not set the default gateway with IP %(ip)s for interface %(iface)s" % {'ip': ip, 'iface' : gateway_iface}))
1339 break
1340 #Now ask for the other info in a large form.
1341 error = True
1342 hostname = ""
1343 domainname = ""
1344 nisdomainname = ""
1345 primary_dns = ""
1346 backup_dns = ""
1347 http_proxy = ""
1348 ftp_proxy = ""
1349 rsync_proxy = ""
1350 while error:
1351 error = False
1352 if self.advanced_mode:
1353 code, data = self._d.form(_(u'Fill out the remaining networking settings. The hostname is manditory as that is the name of your computer. Leave the other fields blank if you are not using them. If using DHCP you do not need to enter DNS servers. Do not press Enter until all fields are complete!'),
1354 ((_(u'Enter your Hostname:'), 25, self._install_profile.get_hostname()),
1355 (_(u'Enter your Domain Name:'), 25, self._install_profile.get_domainname()),
1356 (_(u'Enter your NIS Domain Name:'),25,self._install_profile.get_nisdomainname()),
1357 (_(u'Enter a primary DNS server:'),15),
1358 (_(u'Enter a backup DNS server:'),15),
1359 (_(u'Enter a HTTP Proxy IP:'), 15,self._install_profile.get_http_proxy()),
1360 (_(u'Enter a FTP Proxy IP:'), 15, self._install_profile.get_ftp_proxy()),
1361 (_(u'Enter a RSYNC Proxy:'),15,self._install_profile.get_rsync_proxy())))
1362 if code != self._DLG_OK:
1363 return
1364 (hostname, domainname, nisdomainname, primary_dns, backup_dns, http_proxy, ftp_proxy, rsync_proxy) = data[:-1].split('\n')
1365 else: #standard mode
1366 code, data = self._d.form(_(u'Fill out the remaining networking settings. The hostname is manditory as that is the name of your computer. Leave the other fields blank if you are not using them. If using DHCP you do not need to enter DNS servers. Do not press Enter until all fields are complete!'),
1367 ((_(u'Enter your Hostname:'), 25, self._install_profile.get_hostname()),
1368 (_(u'Enter your Domain Name:'), 25, self._install_profile.get_domainname()),
1369 (_(u'Enter a primary DNS server:'),15),
1370 (_(u'Enter a backup DNS server:'),15)))
1371 if code != self._DLG_OK:
1372 return
1373 (hostname, domainname, primary_dns, backup_dns) = data[:-1].split('\n')
1374 #Check the data before entering it.
1375 if hostname:
1376 if type(hostname) != str:
1377 self._d.msgbox(_(u"Incorrect hostname! It must be a string. Not saved."))
1378 error = True
1379 else:
1380 try:
1381 self._install_profile.set_hostname(None, hostname, None)
1382 except:
1383 self._d.msgbox(_(u"ERROR! Could not set the hostname:")+hostname)
1384 error = True
1385 if domainname:
1386 if type(domainname) != str:
1387 self._d.msgbox(_(u"Incorrect domainname! It must be a string. Not saved."))
1388 error = True
1389 else:
1390 try:
1391 self._install_profile.set_domainname(None, domainname, None)
1392 except:
1393 self._d.msgbox(_(u"ERROR! Could not set the domainname:")+domainname)
1394 error = True
1395 if nisdomainname:
1396 if type(nisdomainname) != str:
1397 self._d.msgbox(_(u"Incorrect nisdomainname! It must be a string. Not saved."))
1398 error = True
1399 else:
1400 try:
1401 self._install_profile.set_nisdomainname(None, nisdomainname, None)
1402 except:
1403 self._d.msgbox(_(u"ERROR! Could not set the nisdomainname:")+nisdomainname)
1404 error = True
1405 if primary_dns:
1406 if not GLIUtility.is_ip(primary_dns):
1407 self._d.msgbox(_(u"Incorrect Primary DNS Server! Not saved."))
1408 error = True
1409 else:
1410 if backup_dns:
1411 if not GLIUtility.is_ip(backup_dns):
1412 self._d.msgbox(_(u"Incorrect Backup DNS Server! Not saved."))
1413 error = True
1414 else:
1415 primary_dns = primary_dns + " " + backup_dns
1416 try:
1417 self._install_profile.set_dns_servers(None, primary_dns, None)
1418 except:
1419 self._d.msgbox(_(u"ERROR! Could not set the DNS Servers:")+primary_dns)
1420 error = True
1421 if http_proxy:
1422 if not GLIUtility.is_uri(http_proxy):
1423 self._d.msgbox(_(u"Incorrect HTTP Proxy! It must be a uri. Not saved."))
1424 error = True
1425 else:
1426 try:
1427 self._install_profile.set_http_proxy(None, http_proxy, None)
1428 except:
1429 self._d.msgbox(_(u"ERROR! Could not set the HTTP Proxy:")+http_proxy)
1430 error = True
1431 if ftp_proxy:
1432 if not GLIUtility.is_uri(ftp_proxy):
1433 self._d.msgbox(_(u"Incorrect FTP Proxy! It must be a uri. Not saved."))
1434 error = True
1435 else:
1436 try:
1437 self._install_profile.set_ftp_proxy(None, ftp_proxy, None)
1438 except:
1439 self._d.msgbox(_(u"ERROR! Could not set the FTP Proxy:")+ftp_proxy)
1440 error = True
1441 if rsync_proxy:
1442 if not GLIUtility.is_uri(rsync_proxy):
1443 self._d.msgbox(_(u"Incorrect RSYNC Proxy! It must be a uri. Not saved."))
1444 error = True
1445 else:
1446 try:
1447 self._install_profile.set_rsync_proxy(None, rsync_proxy, None)
1448 except:
1449 self._d.msgbox(_(u"ERROR! Could not set the RSYNC Proxy:")+rsync_proxy)
1450 error = True
1451
1452
1453 def set_cron_daemon(self):
1454 if self.networkless: return
1455 cron_daemons = (("vixie-cron", _(u"Paul Vixie's cron daemon, fully featured, RECOMMENDED.")),
1456 ("dcron",_(u"A cute little cron from Matt Dillon.")),
1457 ("fcron", _(u"A scheduler with extended capabilities over cron & anacron")),
1458 ("None", _(u"Don't use a cron daemon. (NOT Recommended!)")))
1459 cron_string = _(u"A cron daemon executes scheduled commands. It is very handy if you need to execute some command regularly (for instance daily, weekly or monthly). Gentoo offers three possible cron daemons: dcron, fcron and vixie-cron. Installing one of them is similar to installing a system logger. However, dcron and fcron require an extra configuration command, namely crontab /etc/crontab. If you don't know what to choose, use vixie-cron. If doing a networkless install, choose vixie-cron. Choose your cron daemon:")
1460 code, menuitem = self._d.menu(cron_string, choices=cron_daemons, height=21, width=77)
1461 if code == self._DLG_OK:
1462 if menuitem == "None":
1463 menuitem = ""
1464 self._install_profile.set_cron_daemon_pkg(None, menuitem, None)
1465
1466 def set_logger(self):
1467 if self.networkless: return
1468 loggers = (("syslog-ng", _(u"An advanced system logger.")),
1469 ("metalog", _(u"A Highly-configurable system logger.")),
1470 ("syslogkd", _(u"The traditional set of system logging daemons.")))
1471 logger_string = _(u"Linux has an excellent history of logging capabilities -- if you want you can log everything that happens on your system in logfiles. This happens through the system logger. Gentoo offers several system loggers to choose from. If you plan on using sysklogd or syslog-ng you might want to install logrotate afterwards as those system loggers don't provide any rotation mechanism for the log files. If doing networkless, choose syslog-ng. Choose a system logger:")
1472 code, menuitem = self._d.menu(logger_string, choices=loggers, height=21, width=68)
1473 if code == self._DLG_OK:
1474 self._install_profile.set_logging_daemon_pkg(None, menuitem, None)
1475
1476 def set_extra_packages(self):
1477 #d.msgbox("This section is for selecting extra packages (pcmcia-cs, rp-pppoe, xorg-x11, etc.) and setting them up")
1478 if self._install_profile.get_install_packages():
1479 install_packages = self._install_profile.get_install_packages()
1480 if isinstance(install_packages, str):
1481 install_packages = install_packages.split()
1482 else:
1483 install_packages = []
1484 package_list = self._install_profile.get_install_package_list()
1485 highlevel_menu = []
1486 for group in package_list:
1487 highlevel_menu.append( (group, package_list[group][0]) )
1488 highlevel_menu.append( (_(u"Manual"), "Type your own space-separated list of packages.") )
1489
1490 while 1:
1491 extra_string1 = _(u"There are thousands of applications available to Gentoo users through Portage, Gentoo's package management system. Select some of the more common ones below or add your own additional package list by choosing 'Manual'.")
1492 code, submenu = self._d.menu(extra_string1+ _(u"\nYour current package list is: ")+string.join(install_packages, ','), choices=highlevel_menu, cancel=_(u"Save and Continue"), width=70, height=23)
1493 if code != self._DLG_OK: #Save and move on.
1494 try:
1495 packages = string.join(install_packages, ' ')
1496 if packages:
1497 self._install_profile.set_install_packages(None, packages, None)
1498 except:
1499 self._d.msgbox(_(u"ERROR! Could not set the install packages! List of packages:"))
1500 return
1501 #Popular Desktop Applications
1502 choices_list = []
1503 #pkgs = {}
1504
1505 #Special case first.
1506 if submenu == _(u"Manual"):
1507 code, tmp_install_packages = self._d.inputbox(_(u"Enter a space-separated list of extra packages to install on the system"), init=string.join(install_packages, ' '), width=70)
1508 if code == self._DLG_OK:
1509 install_packages = tmp_install_packages.split()
1510 continue
1511
1512 #All other cases load pkgs and GRP
1513 pkgs = package_list[submenu][1]
1514 grp_list = GLIUtility.get_grp_pkgs_from_cd()
1515 for pkg in pkgs:
1516 if pkg in grp_list:
1517 choices_list.append((pkg, "(GRP) "+pkgs[pkg], int(pkg in install_packages)))
1518 else:
1519 if not self.networkless:
1520 choices_list.append((pkg, pkgs[pkg], int(pkg in install_packages)))
1521 if not choices_list: continue
1522 code, choices = self._d.checklist(_(u"Choose from the listed packages. If doing a networkless install, only choose (GRP) packages."), choices=choices_list, height=19, list_height=10, width=77)
1523 if code != self._DLG_OK:
1524 continue
1525 for pkg in pkgs: #clear out packages from this list that are already in install_packages so that you can uncheck packages and they will be removed. the ones that remain checked will be re-added.
1526 for i, tmppkg in enumerate(install_packages):
1527 if tmppkg == pkg:
1528 del install_packages[i]
1529
1530 for package in choices:
1531 install_packages.append(package)
1532 #special cases for desktop environments
1533 if package in ["xorg-x11", "gnome","kde", "kde-meta","blackbox","enlightenment","e17", "fluxbox","xfce4"]: #ask about X
1534 #Add xorg-x11 if not already there.
1535 if not 'xorg-x11' in install_packages:
1536 install_packages.append('xorg-x11')
1537
1538 #Reset the Yes/No buttons
1539 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
1540 self._d.add_persistent_args(["--no-label", _(u"No")])
1541 if not self.advanced_mode or self._d.yesno(_(u"Do you want to start X on bootup?")) == self._DLG_YES:
1542 services = self._install_profile.get_services() or 'xdm'
1543 if isinstance(services, list):
1544 services = string.join(services, ',')
1545 if not 'xdm' in services:
1546 services += ',xdm'
1547 try:
1548 self._install_profile.set_services(None, services, None)
1549 except:
1550 self._d.msgbox(_(u"ERROR! Could not set the services list."))
1551 #rc.conf changes specific to packages.
1552 if package == "gnome":
1553 etc_files = self._install_profile.get_etc_files()
1554 if not "rc.conf" in etc_files:
1555 etc_files['rc.conf'] = {}
1556 etc_files['rc.conf']['DISPLAYMANAGER'] = "gdm"
1557 self._install_profile.set_etc_files(etc_files)
1558 if package == "kde" or package == "kde-meta":
1559 etc_files = self._install_profile.get_etc_files()
1560 if not "rc.conf" in etc_files:
1561 etc_files['rc.conf'] = {}
1562 etc_files['rc.conf']['DISPLAYMANAGER'] = "kdm"
1563 self._install_profile.set_etc_files(etc_files)
1564 if package == "enlightenment":
1565 etc_files = self._install_profile.get_etc_files()
1566 if not "rc.conf" in etc_files:
1567 etc_files['rc.conf'] = {}
1568 etc_files['rc.conf']['DISPLAYMANAGER'] = "entrance"
1569 self._install_profile.set_etc_files(etc_files)
1570 if package == "fluxbox":
1571 etc_files = self._install_profile.get_etc_files()
1572 if not "rc.conf" in etc_files:
1573 etc_files['rc.conf'] = {}
1574 etc_files['rc.conf']['XSESSION'] = "fluxbox"
1575 self._install_profile.set_etc_files(etc_files)
1576
1577
1578
1579 def set_services(self):
1580 if self._install_profile.get_services():
1581 services = self._install_profile.get_services()
1582 if isinstance(services, str):
1583 services = services.split(',')
1584 else:
1585 services = []
1586 choice_list = [("alsasound", _(u"ALSA Sound Daemon"),int("alsasound" in services)),
1587 ("apache", _(u"Common web server (version 1.x)"),int("apache" in services)),
1588 ("apache2", _(u"Common web server (version 2.x)"),int("apache2" in services)),
1589 ("distccd", _(u"Distributed Compiling System"),int("distccd" in services)),
1590 ("esound", _(u"ESD Sound Daemon"),int("esound" in services)),
1591 ("hdparm", _(u"Hard Drive Tweaking Utility"),int("hdparm" in services)),
1592 ("local", _(u"Run scripts found in /etc/conf.d/local.start"),int("local" in services)),
1593 ("portmap", _(u"Port Mapping Service"),int("portmap" in services)),
1594 ("proftpd", _(u"Common FTP server"),int("proftpd" in services)),
1595 ("sshd", _(u"SSH Daemon (allows remote logins)"),int("sshd" in services)),
1596 ("xfs", _(u"X Font Server"),int("xfs" in services)),
1597 ("xdm", _(u"X Daemon"),int("xdm" in services)),
1598 (_(u"Other"),_(u"Manually specify your services in a comma-separated list."),0)]
1599 services_string = _(u"Choose the services you want started on bootup. Note that depending on what packages are selected, some services listed will not exist.")
1600 code, services_list = self._d.checklist(services_string, choices=choice_list, height=21, list_height=12, width=77)
1601 if code != self._DLG_OK:
1602 return
1603 services = []
1604 for service in services_list:
1605 services.append(service)
1606 if _(u"Other") in services_list:
1607 code, services = self._d.inputbox(_(u"Enter a comma-separated list of services to start on boot"), init=string.join(services, ','))
1608 if code != self._DLG_OK:
1609 return
1610 try:
1611 services = string.join(services, ',')
1612 if services:
1613 self._install_profile.set_services(None, services, None)
1614 except:
1615 self._d.msgbox(_(u"ERROR! Could not set the services list."))
1616 return
1617
1618 def set_rc_conf(self):
1619 # This section is for editing /etc/rc.conf
1620 if not self.advanced_mode:
1621 return
1622 etc_files = self._install_profile.get_etc_files()
1623 keymap = ""
1624 windowkeys = ""
1625 ext_keymap = ""
1626 font = ""
1627 trans = ""
1628 clock = ""
1629 editor = ""
1630 disp_manager = ""
1631 xsession = ""
1632 rc_string1 = _(u"Additional configuration settings for Advanced users (rc.conf)\nHere are some other variables you can set in various configuration files on the new system. If you don't know what a variable does, don't change it!")
1633 menulist = [("KEYMAP",_(u"Use KEYMAP to specify the default console keymap.")),
1634 ("SET_WINDOWKEYS", _(u"Decision to first load the 'windowkeys' console keymap")),
1635 ("EXTENDED_KEYMAPS", _(u"maps to load for extended keyboards. Most users will leave this as is.")),
1636 ("CONSOLEFONT", _(u"Specifies the default font that you'd like Linux to use on the console.")),
1637 ("CONSOLETRANSLATION", _(u"The charset map file to use.")),
1638 ("CLOCK", _(u"Set the clock to either UTC or local")),
1639 ("EDITOR", _(u"Set EDITOR to your preferred editor.")),
1640 ("DISPLAYMANAGER", _(u"What display manager do you use ? [ xdm | gdm | kdm | entrance ]")),
1641 ("XSESSION", _(u"a new variable to control what window manager to start default with X"))]
1642 while 1:
1643 code, variable = self._d.menu(rc_string1, choices=menulist, cancel=_(u"Save and Continue"), width=77, height=19)
1644 if code != self._DLG_OK:
1645 break
1646 if variable == "KEYMAP":
1647 keymap_list = GLIUtility.generate_keymap_list()
1648 code, keymap = self._d.menu(_(u"Choose your desired keymap:"), choices=self._dmenu_list_to_choices(keymap_list), height=19)
1649 if code != self._DLG_OK:
1650 continue
1651 keymap = keymap_list[int(keymap)-1]
1652
1653 elif variable == "SET_WINDOWKEYS":
1654 #Reset the Yes/No buttons
1655 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
1656 self._d.add_persistent_args(["--no-label", _(u"No")])
1657 if self._d.yesno(_(u"Should we first load the 'windowkeys' console keymap? Most x86 users will say 'yes' here. Note that non-x86 users should leave it as 'no'.")) == self._DLG_YES:
1658 windowkeys = "yes"
1659 else:
1660 windowkeys = "no"
1661 elif variable == "EXTENDED_KEYMAPS":
1662 code, ext_keymap = self._d.inputbox(_(u"This sets the maps to load for extended keyboards. Most users will leave this as is. Enter new value for EXTENDED_KEYMAPS"), width=60)
1663 elif variable == "CONSOLEFONT":
1664 font_list = GLIUtility.generate_consolefont_list()
1665 code, font = self._d.menu(_(u"Choose your desired console font:"), choices=self._dmenu_list_to_choices(font_list), height=19)
1666 if code != self._DLG_OK:
1667 continue
1668 font = font_list[int(font)-1]
1669 elif variable == "CONSOLETRANSLATION":
1670 trans_list = GLIUtility.generate_consoletranslation_list()
1671 code, trans = self._d.menu(_(u"Choose your desired console translation:"), choices=self._dmenu_list_to_choices(trans_list), height=19)
1672 if code != self._DLG_OK:
1673 continue
1674 trans = trans_list[int(trans)-1]
1675 elif variable == "CLOCK":
1676 #Change the Yes/No buttons to new labels for this question.
1677 self._d.add_persistent_args(["--yes-label", "UTC"])
1678 self._d.add_persistent_args(["--no-label", "local"])
1679 if self._d.yesno(_(u"Should CLOCK be set to UTC or local? Unless you set your timezone to UTC you will want to choose local.")) == self._DLG_YES:
1680 clock = "UTC"
1681 else:
1682 clock = "local"
1683 elif variable == "EDITOR":
1684 choice_list = [("/bin/nano", _(u"Default editor.")), ("/usr/bin/vim", _(u"vi improved editor.")), ("/usr/bin/emacs", _(u"The emacs editor."))]
1685 code, editor = self._d.menu(_(u"Choose your default editor: "), choices=choice_list)
1686 elif variable == "DISPLAYMANAGER":
1687 choice_list = [("xdm", _(u"X Display Manager")),
1688 ("gdm", _(u"Gnome Display Manager")),
1689 ("kdm", _(u"KDE Display Manager")),
1690 ("entrance", _(u"Login Manager for Enlightenment"))]
1691 code, disp_manager = self._d.menu(_(u"Choose your desired display manager to use when starting X (note you must make sure that package also gets installed for it to work):"), choices=choice_list, width=65)
1692 elif variable == "XSESSION":
1693 code, xsession = self._d.inputbox(_(u"Choose what window manager you want to start default with X if run with xdm, startx, or xinit. (common options are Gnome or Xsession):"), width=65, height=12)
1694
1695 if not "conf.d/keymaps" in etc_files:
1696 if keymap or windowkeys or ext_keymap:
1697 etc_files['conf.d/keymaps'] = {}
1698 if not "conf.d/consolefont" in etc_files:
1699 if font or trans:
1700 etc_files['conf.d/consolefont'] = {}
1701 if not "conf.d/clock" in etc_files:
1702 if clock:
1703 etc_files['conf.d/clock'] = {}
1704 if not "rc.conf" in etc_files:
1705 if editor or disp_manager or xsession:
1706 etc_files['rc.conf'] = {}
1707 if keymap:
1708 etc_files['conf.d/keymaps']['KEYMAP'] = keymap
1709 if windowkeys:
1710 etc_files['conf.d/keymaps']['SET_WINDOWKEYS'] = windowkeys
1711 if ext_keymap:
1712 etc_files['conf.d/keymaps']['EXTENDED_KEYMAPS'] = ext_keymap
1713 if font:
1714 etc_files['conf.d/consolefont']['CONSOLEFONT'] = font
1715 if trans:
1716 etc_files['conf.d/consolefont']['CONSOLETRANSLATION'] = trans
1717 if clock:
1718 etc_files['conf.d/clock']['CLOCK'] = clock
1719 if editor:
1720 etc_files['rc.conf']['EDITOR'] = editor
1721 if disp_manager:
1722 etc_files['rc.conf']['DISPLAYMANAGER'] = disp_manager
1723 if xsession:
1724 etc_files['rc.conf']['XSESSION'] = xsession
1725 self._install_profile.set_etc_files(etc_files)
1726
1727 def set_root_password(self):
1728 # The root password will be set here
1729 while 1:
1730 code, passwd1 = self._d.passwordbox(_(u"Please enter your desired password for the root account. (note it will not show the password. Also do not try to use backspace.):"))
1731 if code != self._DLG_OK:
1732 return
1733 code, passwd2 = self._d.passwordbox(_(u"Enter the new root password again for confirmation"))
1734 if code != self._DLG_OK:
1735 return
1736 if passwd1 != passwd2:
1737 self._d.msgbox(_(u"The passwords do not match. Please try again or cancel."))
1738 else:
1739 try:
1740 self._install_profile.set_root_pass_hash(None, GLIUtility.hash_password(passwd1), None)
1741 except:
1742 self._d.msgbox(_(u"ERROR! Could not set the new system root password!"))
1743 self._d.msgbox(_(u"Password saved. Press Enter to continue."))
1744 return
1745
1746 def set_additional_users(self):
1747 # This section will be for adding non-root users
1748 users = {}
1749 for user in self._install_profile.get_users():
1750 users[user[0]] = (user[0], user[1], user[2], user[3], user[4], user[5], user[6])
1751 while 1:
1752 menu_list = []
1753 for user in users:
1754 menu_list.append(user)
1755 menu_list.sort()
1756 menu_list.append(_(u"Add user"))
1757 users_string1 = _(u"Working as root on a Unix/Linux system is dangerous and should be avoided as much as possible. Therefore it is strongly recommended to add a user for day-to-day use. Choose a user to edit:")
1758 code, menuitem = self._d.menu(users_string1, choices=self._dmenu_list_to_choices(menu_list), cancel=_(u"Save and Continue"), height=19)
1759 if code != self._DLG_OK:
1760 #if self._d.yesno("Do you want to save changes?") == self._DLG_YES:
1761 tmpusers = []
1762 for user in users:
1763 tmpusers.append(users[user])
1764 try:
1765 self._install_profile.set_users(tmpusers)
1766 except:
1767 self._d.msgbox(_(u"ERROR! Could not set the additional users!"))
1768 break
1769 menuitem = menu_list[int(menuitem)-1]
1770 if menuitem == _(u"Add user"):
1771 code, newuser = self._d.inputbox(_(u"Enter the username for the new user"))
1772 if code != self._DLG_OK:
1773 continue
1774 if newuser in users:
1775 self._d.msgbox(_(u"A user with that name already exists"))
1776 continue
1777 match = False
1778 while not match:
1779 code, passwd1 = self._d.passwordbox(_(u"Enter the new password for user %s. (will not be echoed)") % newuser)
1780 code, passwd2 = self._d.passwordbox(_(u"Enter the new password again for confirmation"))
1781 if code == self._DLG_OK:
1782 if passwd1 != passwd2:
1783 self._d.msgbox(_(u"The passwords do not match! Please try again."))
1784 else:
1785 match = True
1786 else:
1787 self._d.msgbox(_(u"You must enter a password for the user! Even a blank password will do. You can always edit it again later from the menu."));
1788 #Create the entry for the new user
1789 new_user = [newuser, GLIUtility.hash_password(passwd1), ('users',), '/bin/bash', '/home/' + newuser, '', '']
1790 users[newuser] = new_user
1791 menuitem = newuser
1792 while 1:
1793 menulist = [_(u"Password"), _(u"Group Membership"), _(u"Shell"), _(u"Home Directory"), _(u"UID"), _(u"Comment"), _(u"Delete")]
1794 code, menuitem2 = self._d.menu(_(u"Choose an option for user %s") % menuitem, choices=self._dmenu_list_to_choices(menulist), cancel=_(u"Back"))
1795 if code != self._DLG_OK:
1796 break
1797 menuitem2 = menulist[int(menuitem2)-1]
1798 if menuitem2 == _(u"Password"):
1799 code, passwd1 = self._d.passwordbox(_(u"Enter the new password"))
1800 if code != self._DLG_OK:
1801 continue
1802 code, passwd2 = self._d.passwordbox(_(u"Enter the new password again"))
1803 if code != self._DLG_OK:
1804 continue
1805 if passwd1 != passwd2:
1806 self._d.msgbox(_(u"The passwords do not match! Try again."))
1807 continue
1808 self._d.msgbox(_(u"Password saved. Press Enter to continue."))
1809 users[menuitem][1] = GLIUtility.hash_password(passwd1)
1810 elif menuitem2 == _(u"Group Membership"):
1811 prechk = users[menuitem][2]
1812 choice_list = [("users", _(u"The usual group for normal users."), int("users" in prechk)),
1813 ("wheel", _(u"Allows users to attempt to su to root."), int("wheel" in prechk)),
1814 ("audio", _(u"Allows access to audio devices."), int("audio" in prechk)),
1815 ("games", _(u"Allows access to games."), int("games" in prechk)),
1816 ("apache", _(u"For users who know what they're doing only."), int("apache" in prechk)),
1817 ("cdrom", _(u"For users who know what they're doing only."), int("cdrom" in prechk)),
1818 ("ftp", _(u"For users who know what they're doing only."), int("ftp" in prechk)),
1819 ("video", _(u"For users who know what they're doing only."), int("video" in prechk)),
1820 (_(u"Other"), _(u"Manually specify your groups in a comma-separated list."), 0)]
1821 users_string2 = _(u"Select which groups you would like the user %s to be in." % menuitem)
1822 code, group_list = self._d.checklist(users_string2, choices=choice_list, height=19, list_height=10, width=77)
1823 if code != self._DLG_OK:
1824 break
1825 groups = ""
1826 for group in group_list:
1827 groups += group + ","
1828 if groups:
1829 groups = groups[:-1]
1830 if _(u"Other") in group_list:
1831 code, groups = self._d.inputbox(_(u"Enter a comma-separated list of groups the user is to be in"), init=",".join(users[menuitem][2]))
1832 if code != self._DLG_OK: continue
1833 users[menuitem][2] = string.split(groups, ",")
1834 elif menuitem2 == _(u"Shell"):
1835 code, shell = self._d.inputbox(_(u"Enter the shell you want the user to use. default is /bin/bash. "), init=users[menuitem][3])
1836 if code != self._DLG_OK:
1837 continue
1838 users[menuitem][3] = shell
1839 elif menuitem2 == _(u"Home Directory"):
1840 code, homedir = self._d.inputbox(_(u"Enter the user's home directory. default is /home/username. "), init=users[menuitem][4])
1841 if code != self._DLG_OK:
1842 continue
1843 users[menuitem][4] = homedir
1844 elif menuitem2 == _(u"UID"):
1845 code, uid = self._d.inputbox(_(u"Enter the user's UID. If left blank the system will choose a default value (this is recommended)."), init=users[menuitem][5], height=11, width=55)
1846 if code != self._DLG_OK:
1847 continue
1848 if type(uid) != int:
1849 continue
1850 users[menuitem][5] = uid
1851 elif menuitem2 == _(u"Comment"):
1852 code, comment = self._d.inputbox(_(u"Enter the user's comment. This is completely optional."), init=users[menuitem][6])
1853 if code != self._DLG_OK:
1854 continue
1855 users[menuitem][6] = comment
1856 elif menuitem2 == _(u"Delete"):
1857 #Reset the Yes/No buttons
1858 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
1859 self._d.add_persistent_args(["--no-label", _(u"No")])
1860 if self._d.yesno(_(u"Are you sure you want to delete the user %s ?") % menuitem) == self._DLG_YES:
1861 del users[menuitem]
1862 break
1863
1864 def save_install_profile(self, xmlfilename="", askforfilename=True):
1865 #Reset the Yes/No buttons
1866 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
1867 self._d.add_persistent_args(["--no-label", _(u"No")])
1868 if self._d.yesno(_(u"Would you like to save these install settings for use again later?")) == self._DLG_YES:
1869 code = 0
1870 filename = xmlfilename
1871 if askforfilename:
1872 code, filename = self._d.inputbox(_(u"Enter a filename for the XML file. Use full path!"), init=xmlfilename)
1873 if code != self._DLG_OK or not filename:
1874 return None
1875 if GLIUtility.is_file(filename):
1876 if not self._d.yesno(_(u"The file %s already exists. Do you want to overwrite it?") % filename) == self._DLG_YES:
1877 return None
1878 try:
1879 configuration = open(filename ,"w")
1880 configuration.write(self._install_profile.serialize())
1881 configuration.close()
1882 except:
1883 self._d.msgbox(_(u"Error. File couldn't be saved. Saving to /tmp/installprofile.xml instead."))
1884 else:
1885 filename = "/tmp/installprofile.xml"
1886 try:
1887 configuration = open("/tmp/installprofile.xml", "w")
1888 configuration.write(self._install_profile.serialize())
1889 configuration.close()
1890 except:
1891 self._d.msgbox(_(u"Complete failure to save install profile!"))
1892 return filename
1893
1894 ############ RUN PHASE FUNCTIONS ############
1895 def run_phase1(self):
1896 self.set_arch_template()
1897 self.set_verbose()
1898 self.set_client_networking()
1899 self.set_enable_ssh()
1900 self.set_livecd_password()
1901 self.set_client_kernel_modules()
1902 def run_phase2(self):
1903 self.set_partitions()
1904 self.set_mounts()
1905 self.set_network_mounts()
1906 self.try_steps(['mount_local_partitions','mount_network_shares'])
1907 def run_phase3(self):
1908 self.set_install_stage()
1909 self.set_portage_tree()
1910 self.try_steps(['unpack_stage_tarball', 'update_config_files', 'configure_make_conf','prepare_chroot','install_portage_tree'])
1911 def run_phase4(self):
1912 self.set_make_conf()
1913 self.set_etc_portage()
1914 self.set_distcc()
1915 self.try_steps(['update_config_files', 'configure_make_conf', 'stage1', 'stage2', 'install_distcc'])
1916
1917 self.set_root_password()
1918 self.set_timezone()
1919 self.try_steps(['set_root_password','set_timezone'])
1920
1921 self.set_kernel()
1922 self.try_steps(['emerge_kernel_sources','build_kernel'])
1923
1924 self.set_networking()
1925 self.try_steps(['setup_network_post'])
1926
1927 if self.advanced_mode:
1928 self.set_cron_daemon()
1929 self.set_logger()
1930 self.try_steps(['install_logging_daemon','install_cron_daemon','install_filesystem_tools'])
1931
1932 self.set_boot_loader()
1933 self.try_steps(['install_bootloader','setup_and_run_bootloader'])
1934
1935 self.set_additional_users()
1936 self.try_steps(['set_users'])
1937
1938 self.set_extra_packages()
1939 if self.advanced_mode:
1940 self.set_services()
1941 self.set_rc_conf()
1942
1943 #Save the profile
1944 self.save_install_profile()
1945
1946 self.try_steps(['update_config_files','install_mta','install_packages','set_services','run_post_install_script','finishing_cleanup'])
1947
1948
1949
1950
1951 def run_phase5(self):
1952 #test function for getting steps.
1953 steps = ['do_recommended_partitioning',
1954 'mount_local_partitions',
1955 'mount_network_shares',
1956 'unpack_stage_tarball',
1957 'update_config_files',
1958 'configure_make_conf',
1959 'prepare_chroot',
1960 'install_portage_tree',
1961 'stage1',
1962 'stage2',
1963 'set_root_password',
1964 'set_timezone',
1965 'emerge_kernel_sources',
1966 'build_kernel',
1967 'install_distcc',
1968 'install_mta',
1969 'install_logging_daemon',
1970 'install_cron_daemon',
1971 'install_filesystem_tools',
1972 'setup_network_post',
1973 'install_bootloader',
1974 'setup_and_run_bootloader',
1975 'update_config_files',
1976 'set_users',
1977 'install_packages',
1978 # services for startup need to come after installing extra packages
1979 # otherwise some of the scripts will not exist.
1980 'set_services',
1981 'run_post_install_script',
1982 'finishing_cleanup']
1983
1984 self.try_steps(steps)
1985
1986 def finish_up(self):
1987 self._d.gauge_update(100, _(u"Install completed!"), update_text=1)
1988 self._d.gauge_stop()
1989 print _(u"Install done!")
1990 sys.exit(0)
1991
1992 def try_steps(self, steps):
1993 try:
1994 self.do_steps(steps)
1995 sys.stderr.write('\07') #BEEP
1996 except GLIException.GLIException, e:
1997 sys.stderr.write('\07') #BEEP
1998 error = e.get_error_msg()
1999 self.handle_exception(error,steps)
2000
2001 def handle_exception(self, error, steps):
2002 #Reset the Yes/No labels.
2003 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
2004 self._d.add_persistent_args(["--no-label",_(u"No")])
2005 message = _(u"There was an Exception received during the install that is outside of the normal install errors. This is a bad thing. The error was: %s \n You have several ways of handling this. If you cannot resolve it, please submit a bug report (after searching to make sure it's not a known issue and verifying you didn't do something stupid) with the contents of /var/log/install.log and /tmp/installprofile.xml and the version of the installer you used." % str(error))
2006 #options: 1. drop to console and retry 2. retry. 3. restart the phase 4. clean up and exit 5. don't clean up and exit.
2007 choices = ['Drop to console and then retry on return.',
2008 'Just retry the step.',
2009 #'Go back and change your choices.',
2010 'Clean up (unmount partitions) and exit.',
2011 'Just exit']
2012 code, choice = self._d.menu(message,choices=self._dmenu_list_to_choices(choices), width=77, height=22)
2013 if code == self._DLG_CANCEL:
2014 sys.exit(0)
2015 choice = choices[int(choice)-1]
2016 if choice == 'Drop to console and then retry on return.':
2017 GLIUtility.spawn_bash()
2018 self.try_steps(steps)
2019 elif choice == 'Just retry the step.':
2020 self.try_steps(steps) #Not sure if this will leave me in a bad spot.
2021 elif choice == 'Go back and change your choices.':
2022 sys.exit(0)
2023 elif choice == 'Clean up (unmount partitions) and exit.':
2024 self.do_steps(['install_failed_cleanup'])
2025 configuration = open("/tmp/installprofile.xml", "w")
2026 configuration.write(self._install_profile.serialize())
2027 configuration.close()
2028 sys.exit(0)
2029 else: #just exit
2030 configuration = open("/tmp/installprofile.xml", "w")
2031 configuration.write(self._install_profile.serialize())
2032 configuration.close()
2033 sys.exit(0)
2034
2035 def do_steps(self, install_steps):
2036 #Start the rest of the installation
2037 # INSTALLATION TIME
2038 # current_item = 0
2039 # self._cc.set_install_profile(self._install_profile)
2040 install_steps = list(install_steps)
2041 # self._cc.start_install()
2042 if self.just_starting == 1:
2043 self._d.gauge_start(_(u"Installation Started!"), title=_(u"Installation progress"), height="10")
2044 self.just_starting = 0
2045 else:
2046 self._d.gauge_start(_(u"Continuing Installation"), title=_(u"Installation progress"), height="10")
2047 self.num_steps_completed = 1
2048 self.num_steps = len(install_steps)
2049 step_name = install_steps.pop(0)
2050 next_step = self._cc.get_step_info(step_name)
2051 self._cc.run_step(step_name)
2052 i = 0
2053 while 1:
2054 notification = self._cc.getNotification()
2055 if notification == None:
2056 time.sleep(1)
2057 continue
2058 type_r = notification.get_type()
2059 data = notification.get_data()
2060 if type_r == "exception":
2061 #We need to raise an exception here. This will hopefully be caught by the calling function in a try/except block so that they can decide how best to handle this.
2062 raise GLIException.GLIException("DoStepFailure",'fatal','do_steps',str(data))
2063 elif type_r == "progress":
2064 #SECONDARY UPDATIN' GOIN ON IN HERE
2065 diff = (data[0]*100)/self.num_steps
2066 self._d.gauge_update(i+diff, _(u"On step %(A)d of %(B)d. Current step: %(C)s\n%(D)s" % {'A': self.num_steps_completed, 'B': self.num_steps, 'C': next_step, 'D': data[1]}), update_text=1)
2067 elif type_r == "int":
2068 if data == GLIClientController.NEXT_STEP_READY:
2069 if len(install_steps):
2070 step_name = install_steps.pop(0)
2071 else:
2072 return
2073 #print "Step name: " + step_name
2074 next_step = self._cc.get_step_info(step_name)
2075 # num_steps = self._cc.get_num_steps()
2076 i = (self.num_steps_completed*100)/self.num_steps
2077 self._d.gauge_update(i, _(u"On step %(A)d of %(B)d. Current step: %(C)s" % {'A': self.num_steps_completed, 'B': self.num_steps, 'C': next_step}), update_text=1)
2078 self.num_steps_completed += 1
2079 #print "Next step: " + next_step
2080 #if self._cc.has_more_steps():
2081 self._cc.run_step(step_name)
2082 continue
2083
2084 # --------------------------End of functions------------------------
2085 # --------------------------Beginning of MAIN-----------------------
2086 if __name__ == '__main__':
2087
2088
2089 #d = dialog.Dialog()
2090
2091 gli = GLIDialog()
2092
2093 gli.show_welcome_screen()
2094 gli.ask_load_profile()
2095 gli.ask_advanced_mode()
2096 gli.ask_networkless()
2097
2098
2099 gli.run_phase1() #Set up networking
2100 gli.run_phase2() #Do partitioning
2101 gli.run_phase3() #Install stage tarball and portage
2102 gli.run_phase4() #Do everything else
2103
2104 gli.finish_up()
2105
2106 sys.exit(0)
2107 #########################End of main#################################

Properties

Name Value
svn:eol-style native
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20