/[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 1679 - (show annotations) (download) (as text)
Wed Feb 7 04:15:16 2007 UTC (7 years, 5 months ago) by codeman
File MIME type: text/x-python
File size: 109094 byte(s)
more little fixes.  ask for a stage tarball uri
until you get a valid one.  progress height works now.
move install done to end of main.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20