/[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 1581 - (show annotations) (download) (as text)
Sat Jan 6 04:11:42 2007 UTC (11 years, 6 months ago) by codeman
File MIME type: text/x-python
File size: 102109 byte(s)
fixing the usual typos and mistakes found when you finally test the code you write

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20