/[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 1579 - (show annotations) (download) (as text)
Fri Jan 5 03:21:15 2007 UTC (7 years, 11 months ago) by codeman
File MIME type: text/x-python
File size: 101455 byte(s)
	install_profile() to self._install_profile
	fix reference to arch instaed of self._arch
updating changelog

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20