/[gli]/trunk/src/GLIGenDialog.py
Gentoo

Contents of /trunk/src/GLIGenDialog.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 769 - (show annotations) (download) (as text)
Sat Jul 30 19:44:28 2005 UTC (15 years, 4 months ago) by codeman
File MIME type: text/x-python
File size: 80182 byte(s)
  fixed livecd-kernel bug in bootloader code.

1 import dialog, platform, string, os, glob, copy, re
2 import GLIInstallProfile
3 import GLIClientConfiguration
4 import GLIStorageDevice
5 import GLIUtility
6 import gettext
7 _ = gettext.gettext
8 #This is a parent class to centralize the code between UserGenCC and UserGenIP
9
10 class GLIGen(object):
11 def __init__(self):
12 self._d = dialog.Dialog()
13 self._DLG_OK = 0
14 self._DLG_YES = 0
15 self._DLG_CANCEL = 1
16 self._DLG_NO = 1
17 self._DLG_ESC = 2
18 self._DLG_ERROR = 3
19 self._DLG_EXTRA = 4
20 self._DLG_HELP = 5
21
22 def _dmenu_list_to_choices(self, list):
23 choices = []
24 for i in range(0, len(list)):
25 choices.append((str(i + 1), list[i]))
26
27 return choices
28
29 def client_profile(self):
30 return self._client_profile
31
32 def install_profile(self):
33 return self._install_profile
34
35 #This class will generate a client config and return it as a xml string
36 class GLIGenCF(GLIGen):
37 def __init__(self, client_profile, local_install=True, advanced_mode=True):
38 GLIGen.__init__(self)
39 self._client_profile = client_profile
40 self.local_install = local_install
41 self.advanced_mode = advanced_mode
42
43 def serialize(self):
44 return self._client_profile.serialize()
45 #-----------------------------------------------
46 #Functions for generating a client configuration
47 #-----------------------------------------------
48 def set_arch_template(self):
49 subarches = { 'i386': 'x86', 'i486': 'x86', 'i586': 'x86', 'i686': 'x86', 'x86_64': 'amd64', 'parisc': 'hppa' }
50 arch = platform.machine()
51 if arch in subarches:
52 arch = subarches[arch]
53 if self.local_install:
54 try:
55 self._client_profile.set_architecture_template(None, arch, None)
56 except:
57 self._d.msgbox(_(u"Error! Undefined architecture template specified or found on the current machine"))
58 else:
59 template_choices = ["x86", "amd64", "sparc", "alpha", "hppa", "ppc"]
60 string = _(u"Please select the architecture of the computer that gentoo will be installed on. For pentium and AMD 32-bit processors, choose x86. If you don't know your architecture, you should consider another Linux distribution.")
61 code, menuitem = self._d.menu(string, choices=self._dmenu_list_to_choices(template_choices), default_item=str(template_choices.index(arch)+1), height=20)
62 if code == self._DLG_OK:
63 menuitem = template_choices[int(menuitem)-1]
64 try:
65 self._client_profile.set_architecture_template(None, menuitem, None)
66 except:
67 self._d.msgbox(_(u"Error! Undefined architecture template specified or found on the current machine"))
68
69 def set_logfile(self):
70 #If not advanced, the default will suffice.
71 if self.advanced_mode:
72 string = _(u"""The installer logs all important events during the install process to a logfile for debugging purposes.
73 The file gets copied to the new system once the install is complete.
74 Enter the desired filename and path for the install log (the default is recommended):""")
75 initval = self._client_profile.get_log_file()
76 code, logfile = self._d.inputbox(string, init=initval, width=60, height=15)
77 if code == self._DLG_OK:
78
79 self._client_profile.set_log_file(None, logfile, None)
80
81 def set_root_mount_point(self):
82 #If not advanced, the default will suffice.
83 if self.advanced_mode:
84 string = _(u"Enter the mount point to be used to mount the partition(s) where the new system will be installed. The default is /mnt/gentoo and is greatly recommended, but any mount point will do.")
85 initval = self._client_profile.get_root_mount_point()
86 code, rootmountpoint = self._d.inputbox(string, init=initval, width=60, height=11)
87 if code == self._DLG_OK:
88 self._client_profile.set_root_mount_point(None, rootmountpoint, None)
89
90 def set_client_networking(self):
91 if GLIUtility.ping("www.gentoo.org") and self.local_install: #If an active connection exists, ignore this step if doing a local install.
92 return
93 if self.local_install:
94 device_list = GLIUtility.get_eth_devices()
95 else:
96 device_list = []
97 choice_list = []
98 for device in device_list:
99 choice_list.append((device, GLIUtility.get_interface_realname(device)))
100 choice_list.append(("Other",_(u"Type your own.")))
101 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.")
102 code, interface = self._d.menu(string1, width=75, height=20, choices=choice_list)
103 if code != self._DLG_OK:
104 return
105 if interface == "Other":
106 code, interface = self._d.inputbox(_(u"Enter the interface (NIC) you would like to use for installation (e.g. eth0):"))
107 if code != self._DLG_OK:
108 return
109
110 dhcp_options = ""
111
112 #Change the Yes/No buttons to new labels for this question.
113 self._d.add_persistent_args(["--yes-label", _(u"DHCP")])
114 self._d.add_persistent_args(["--no-label", _(u"Static IP/Manual")])
115 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:")
116 if self._d.yesno(string2, height=15, width=60) == self._DLG_YES: #DHCP
117 network_type = 'dhcp'
118 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)
119 else:
120 network_type = 'static'
121 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!'), ((_(u'Enter your IP address:'), 15),(_(u'Enter your Broadcast address:'), 15),(_(u'Enter your Netmask:'),15,'255.255.255.0'),(_(u'Enter your default gateway:'),15), (_(u'Enter a DNS server:'),15,'128.118.25.3')))
122 (ip_address, broadcast, netmask, gateway, dnsservers) = data[:-1].split('\n')
123 if code != self._DLG_OK:
124 return
125 #Set the info now that it's all gathered.
126 try:
127 self._client_profile.set_network_type(None, network_type, None)
128 self._client_profile.set_network_interface(None, interface, None)
129 if not network_type == 'dhcp':
130 self._client_profile.set_network_ip(None, ip_address, None)
131 self._client_profile.set_network_broadcast(None, broadcast, None)
132 self._client_profile.set_network_netmask(None, netmask, None)
133 self._client_profile.set_network_gateway(None, gateway, None)
134 self._client_profile.set_dns_servers(None, dnsservers, None)
135 else:
136 if dhcp_options:
137 self._client_profile.set_network_dhcp_options(None, dhcp_options, None)
138 except:
139 self._d.msgbox(_(u"ERROR! Could not set networking information!"))
140
141 def set_enable_ssh(self):
142 #Change the Yes/No buttons back.
143 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
144 self._d.add_persistent_args(["--no-label", _(u"No")])
145 if self.advanced_mode:
146 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:
147 self._client_profile.set_enable_ssh(None, True, None)
148 else:
149 self._client_profile.set_enable_ssh(None, False, None)
150
151 def set_livecd_password(self):
152 # The root password will be set here only if in advanced mode. Otherwise it is auto-scrambled.
153 if self.advanced_mode:
154 match = False;
155 while not match:
156 string = _(u"""If you want to be able to login to your machine from another console during the installation,
157 you will want to enter a new root password for the LIVECD.
158 Note that this can be different from your new system's root password.
159 Presss Enter twice to skip this step.
160 Enter the new LIVECD root password: """)
161 code, passwd1 = self._d.passwordbox(string, width=60, height=16)
162 if code != self._DLG_OK:
163 return
164 code, passwd2 = self._d.passwordbox(_(u"Enter the new LIVECD root password again to verify:"))
165 if code != self._DLG_OK:
166 return
167 if passwd1 != passwd2:
168 self._d.msgbox(_(u"The passwords do not match. Please try again."))
169 return
170 else:
171 match = True;
172 if passwd1 != "": #don't want to hash an empty password.
173 try:
174 self._client_profile.set_root_passwd(None, GLIUtility.hash_password(passwd1), None)
175 except:
176 d.msgbox(_(u"ERROR! Could not set the root password on the LiveCD!"))
177 self._d.msgbox(_(u"Password saved. Press Enter to continue."))
178
179 def set_client_kernel_modules(self):
180 if self.advanced_mode:
181 status, output = GLIUtility.spawn("lsmod", return_output=True)
182 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")
183 self._d.add_persistent_args(["--exit-label", _(u"Continue")])
184 self._d.scrollbox(string1+output, height=20, width=70, title=_(u"Loaded Modules"))
185 string2 = _(u"\nIf you have additional modules you would like loaded before the installation begins (ex. a network driver), enter them in a space-separated list.")
186 code, kernel_modules_list = self._d.inputbox(string2, init="", width=60, height=12)
187 if code == self._DLG_OK:
188 try:
189 self._client_profile.set_kernel_modules(None, kernel_modules_list, None)
190 except:
191 d.msgbox(_(u"ERROR! Could not set the list of kernel modules!"))
192
193 def save_client_profile(self, xmlfilename="", askforfilename=True):
194 code = 0
195 filename = xmlfilename
196 if askforfilename:
197 code, filename = self._d.inputbox(_(u"Enter a filename for the XML file"), init=xmlfilename)
198 if code != self._DLG_OK or not filename:
199 return
200 if GLIUtility.is_file(filename):
201 #Change the Yes/No buttons back.
202 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
203 self._d.add_persistent_args(["--no-label", _(u"No")])
204 if not self._d.yesno(_(u"The file %s already exists. Do you want to overwrite it?") % filename) == self._DLG_YES:
205 return
206 configuration = open(filename ,"w")
207 configuration.write(self._client_profile.serialize())
208 configuration.close()
209
210 class GLIGenIP(GLIGen):
211 def __init__(self, client_profile, install_profile, local_install=True, advanced_mode=True):
212 GLIGen.__init__(self)
213 self._client_profile = client_profile
214 self._install_profile = install_profile
215 self.local_install = local_install
216 self.advanced_mode = advanced_mode
217
218
219 def serialize(self):
220 return self._install_profile.serialize()
221 #---------------------------------------
222 #Functions to generate a install profile
223 #---------------------------------------
224
225 def set_partitions(self):
226 string1 = _("""The first thing on the new system to setup is the partitoning on the new system.
227 You will first select a drive and then edit its partitions.
228 No changes will be saved until the end of the step.
229 No changes to your disk will be made until the installation.
230 NOTE: YOU MUST AT LEAST SELECT ONE PARTITION AS YOUR ROOT PARTITION "/"
231 If your drive is pre-partitioned, just select the mountpoints and make
232 sure that the format option is set to FALSE or it will erase your data.
233 The installer does not yet support resizing of partitions (its not safe).
234 Please refer to the Gentoo Installation Handbook for more information
235 on partitioning and the various filesystem types available in Linux.""")
236 self._d.msgbox(string1, height=17, width=78)
237 devices = self._install_profile.get_partition_tables()
238 drives = devices.keys()
239 drives.sort()
240 choice_list = []
241 if not devices:
242 tmp_drives = GLIStorageDevice.detect_devices()
243 tmp_drives.sort()
244 for drive in tmp_drives:
245 devices[drive] = GLIStorageDevice.Device(drive)
246 #if self.local_install: #when uncommenting please indent the next line.
247 devices[drive].set_partitions_from_disk()
248 drives.append(drive)
249 choice_list.append((drive, devices[drive].get_model()))
250 #choice_list.append(("Other", "Type your own drive name)) # I DONT THINK GLISD CAN DO NONEXISTANT DRIVES
251 while 1:
252 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"))
253 if code != self._DLG_OK: break
254 while 1:
255 partitions = devices[drive_to_partition].get_partitions()
256 partlist = devices[drive_to_partition].get_ordered_partition_list()
257 tmpparts = devices[drive_to_partition].get_partitions()
258 partsmenu = []
259 for part in partlist:
260 tmppart = tmpparts[part]
261 entry = ""
262 if tmppart.get_type() == "free":
263 #partschoice = "New"
264 entry = _(u" - Unallocated space (")
265 if tmppart.is_logical():
266 entry += _(u"logical, ")
267 entry += str(tmppart.get_mb()) + "MB)"
268 elif tmppart.get_type() == "extended":
269 entry = str(int(tmppart.get_minor()))
270 entry += _(u" - Extended Partition (") + str(tmppart.get_mb()) + "MB)"
271 else:
272 entry = str(int(tmppart.get_minor())) + " - "
273 # Type: " + tmppart.get_type() + ", Mountpoint: " + tmppart.get_mountpoint() + ", Mountopts: " + tmppart.get_mountopts() + "("
274 if tmppart.is_logical():
275 entry += _(u"Logical (")
276 else:
277 entry += _(u"Primary (")
278 entry += tmppart.get_type() + ", "
279 entry += (tmppart.get_mkfsopts() or "none") + ", "
280 entry += (tmppart.get_mountpoint() or "none") + ", "
281 entry += (tmppart.get_mountopts() or "none") + ", "
282 entry += str(tmppart.get_mb()) + "MB)"
283 partsmenu.append(entry)
284 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"))
285 if code != self._DLG_OK: break
286 part_to_edit = partlist[int(part_to_edit)-1]
287 tmppart = tmpparts[part_to_edit]
288 if tmppart.get_type() == "free":
289 # partition size first
290 free_mb = tmppart.get_mb()
291 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))
292 if code != self._DLG_OK: continue
293 if int(new_mb) > free_mb:
294 self._d.msgbox(_(u"The size you entered (%s MB) is larger than the maximum of %s MB") % (new_mb, str(free_mb)))
295 continue
296 # partition type
297 part_types = [("ext2", _(u"Old, stable, but no journaling")), ("ext3", _(u"ext2 with journaling and b-tree indexing (RECOMMENDED)")), ("linux-swap", _(u"Swap partition for memory overhead")), ("fat32", _(u"Windows filesystem format used in Win9X and XP")), ("ntfs", _(u"Windows filesystem format used in Win2K and NT")),("jfs", _(u"IBM's journaling filesystem. stability unknown.")), ("xfs", _(u"Don't use this unless you know you need it.")), ("reiserfs", _(u"B*-tree based filesystem. great performance. Only V3 supported.")), ("extended", _(u"Create an extended partition containing other logical partitions")), ("other", _(u"Something else we probably don't support."))]
298 code, type = self._d.menu(_(u"Choose the filesystem type for this new partition."), height=20, width=77, choices=part_types)
299 if code != self._DLG_OK: continue
300
301 # 'other' partition type
302 if type == "other":
303 code, type = self._d.inputbox(_(u"Please enter the new partition's type:"))
304 if code != self._DLG_OK: continue
305
306 # now add it to the data structure
307 devices[drive_to_partition].add_partition(part_to_edit, int(new_mb), 0, 0, type)
308 else:
309 while 1:
310 tmppart = tmpparts[part_to_edit]
311 tmptitle = drive_to_partition + str(part_to_edit) + " - "
312 if tmppart.is_logical():
313 tmptitle += _(u"Logical (")
314 else:
315 tmptitle += _(u"Primary (")
316 tmptitle += tmppart.get_type() + ", "
317 tmptitle += (tmppart.get_mkfsopts() or "none") + ", "
318 tmptitle += (tmppart.get_mountpoint() or "none") + ", "
319 tmptitle += (tmppart.get_mountopts() or "none") + ", "
320 tmptitle += str(tmppart.get_mb()) + "MB)"
321 menulist = [_(u"Delete"), _(u"Mount Point"), _(u"Mount Options"), _(u"Format"), _(u"Extra mkfs.* Parameters")]
322 code, part_action = self._d.menu(tmptitle, choices=self._dmenu_list_to_choices(menulist), cancel=_(u"Back"))
323 if code != self._DLG_OK: break
324 part_action = menulist[int(part_action)-1]
325 if part_action == _(u"Delete"):
326 answer = (self._d.yesno(_(u"Are you sure you want to delete the partition ") + drive_to_partition + str(part_to_edit) + "?") == self._DLG_YES)
327 if answer == True:
328 tmpdev = tmppart.get_device()
329 tmpdev.remove_partition(part_to_edit)
330 break
331 elif part_action == _(u"Mount Point"):
332 code, answer = self._d.inputbox(_(u"Enter a mountpoint for partition ") + str(part_to_edit), init=tmppart.get_mountpoint())
333 if code == self._DLG_OK: tmppart.set_mountpoint(answer)
334 elif part_action == _(u"Mount Options"):
335 code, answer = self._d.inputbox(_(u"Enter your mount options for partition ") + str(part_to_edit), init=(tmppart.get_mountopts() or "defaults"))
336 if code == self._DLG_OK: tmppart.set_mountopts(answer)
337 elif part_action == _(u"Format"):
338 #Change the Yes/No buttons back.
339 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
340 self._d.add_persistent_args(["--no-label", _(u"No")])
341 code = self._d.yesno(_(u"Do you want to format this partition?"))
342 if code == self._DLG_YES:
343 tmppart.set_format(True)
344 else:
345 tmppart.set_format(False)
346 elif part_action == _(u"Extra mkfs.* Parameters"):
347 new_mkfsopts = tmppart.get_mkfsopts()
348 # extra mkfs options
349 if tmppart.get_type() != "extended":
350 code, new_mkfsopts = self._d.inputbox(_(u"Extra mkfs.* Parameters"), init=new_mkfsopts)
351 if code == self._DLG_OK: tmppart.set_mkfsopts(new_mkfsopts)
352 try:
353 self._install_profile.set_partition_tables(devices)
354 except:
355 self._d.msgbox(_(u"ERROR: The partition tables could not be set correctly!"))
356
357 def set_network_mounts(self):
358 # This is where any NFS mounts will be specified
359 network_mounts = copy.deepcopy(self._install_profile.get_network_mounts())
360 while 1:
361 menulist = []
362 for mount in network_mounts:
363 menulist.append(mount['host'] + ":" + mount['export'])
364 menulist.append(_(u"Add a new network mount"))
365 choices = self._dmenu_list_to_choices(menulist)
366 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)
367 if code == self._DLG_CANCEL:
368 try:
369 self._install_profile.set_network_mounts(network_mounts)
370 except:
371 self._d.msgbox(_(u"ERROR: Could net set network mounts!"))
372 break
373 menuitem = menulist[int(menuitemidx)-1]
374 if menuitem == _(u"Add a new network mount"):
375 code, nfsmount = self._d.inputbox(_(u"Enter NFS mount or just enter the IP/hostname to search for available mounts"), height=13, width=50)
376 if code != self._DLG_OK:
377 continue
378 if not GLIUtility.is_nfs(nfsmount):
379 if GLIUtility.is_ip(nfsmount) or GLIUtility.is_hostname(nfsmount):
380 status, remotemounts = GLIUtility.spawn("/usr/sbin/showmount -e " + nfsmount + " 2>&1 | egrep '^/' | cut -d ' ' -f 1 && echo", return_output=True)
381 if (not GLIUtility.exitsuccess(status)) or (not len(remotemounts)):
382 self._d.msgbox(_(u"No NFS exports were detected on ") + nfsmount)
383 continue
384 for i in range(0, len(remotemounts)):
385 remotemounts[i] = remotemounts[i].strip()
386 code, nfsmount2 = self._d.menu(_(u"Select a NFS export"), choices=self._dmenu_list_to_choices(remotemounts), cancel=_(u"Back"))
387 if code != self._DLG_OK:
388 continue
389 nfsmount2 = remotemounts[int(nfsmount2)-1]
390 else:
391 self._d.msgbox(_(u"The address you entered, %s, is not a valid IP or hostname. Please try again.") % nfsmount)
392 continue
393 else:
394 colon_location = nfsmount.find(':')
395 menuitem = nfsmount
396 nfsmount = menuitem[:colon_location]
397 nfsmount2 = menuitem[colon_location+1:]
398 for mount in network_mounts:
399 if nfsmount == mount['host'] and nfsmount2 == mount['export']:
400 self._d.msgbox(_(u"There is already an entry for ") + nfsmount + ":" + nfsmount2 + ".")
401 nfsmount = None
402 break
403 if nfsmount == None:
404 continue
405 network_mounts.append({'export': nfsmount2, 'host': nfsmount, 'mountopts': '', 'mountpoint': '', 'type': 'nfs'})
406 menuitem = nfsmount + ":" + nfsmount2
407 menuitemidx = len(network_mounts)
408
409 if menuitem.find(':') != -1:
410 colon_location = menuitem.find(':')
411 tmpmount = network_mounts[int(menuitemidx)-1]
412 code, mountpoint = self._d.inputbox(_(u"Enter a mountpoint"), init=tmpmount['mountpoint'])
413 if code == self._DLG_OK:
414 tmpmount['mountpoint'] = mountpoint
415 code, mountopts = self._d.inputbox(_(u"Enter mount options"), init=tmpmount['mountopts'])
416 if code == self._DLG_OK:
417 tmpmount['mountopts'] = mountopts
418 network_mounts[int(menuitemidx)-1] = tmpmount
419
420 def set_install_stage(self):
421 # The install stage and stage tarball will be selected here
422 install_stages = (("1",_(u"Stage1 is used when you want to bootstrap&build from scratch.")),
423 ("2",_(u"Stage2 is used for building from a bootstrapped semi-compiled state.")),
424 ("3",_(u"Stage3 is a basic system that has been built for you (no compiling).")),
425 ("3+GRP", _(u"A Stage3 install but using binaries from the LiveCD when able.")))
426 code, install_stage = self._d.menu(_(u"Which stage do you want to start at?"), choices=install_stages, cancel=_(u"Back"), width=78)
427 if code == self._DLG_OK:
428 if install_stage == "3+GRP":
429 install_stage = "3"
430 try:
431 self._install_profile.set_grp_install(None, True, None)
432 self._install_profile.set_install_stage(None, install_stage, None)
433 except:
434 self._d.msgbox(_(u"ERROR! Could not set install stage!"))
435 if install_stage == "3":
436 #Change the Yes/No buttons to new labels for this question.
437 self._d.add_persistent_args(["--yes-label", _(u"Create from CD")])
438 self._d.add_persistent_args(["--no-label", _(u"Specify URI")])
439 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?"), width=55) == self._DLG_YES:
440 #Generate on the FLY
441 try:
442 self._install_profile.set_stage_tarball_uri(None, "networkless", None)
443 except:
444 self._d.msgbox(_(u"ERROR: Could not set the stage tarball URI!"))
445 return
446 #Specify URI
447 #subarches = { 'x86': ("x86", "i686", "pentium3", "pentium4", "athlon-xp"), 'hppa': ("hppa1.1", "hppa2.0"), 'ppc': ("g3", "g4", "g5", "ppc"), 'sparc': ("sparc32", "sparc64")}
448 type_it_in = False
449 stage_tarball = ""
450 if GLIUtility.ping("www.gentoo.org"): #Test for network connectivity
451 mirrors = GLIUtility.list_mirrors()
452 mirrornames = []
453 mirrorurls = []
454 for item in mirrors:
455 mirrornames.append(item[1])
456 mirrorurls.append(item[0])
457 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)
458 if code != self._DLG_OK:
459 type_it_in = True
460 else:
461 mirror = mirrorurls[int(mirror)-1]
462 arch = self._client_profile.get_architecture_template()
463 subarches = GLIUtility.list_subarch_from_mirror(mirror,arch)
464 code, subarch = self._d.menu(_(u"Select the sub-architecture that most closely matches your system (this changes the amount of optimization):"), choices=self._dmenu_list_to_choices(subarches))
465 if code != self._DLG_OK:
466 type_it_in = True
467 else:
468 subarch = subarches[int(subarch)-1]
469 tarballs = GLIUtility.list_stage_tarballs_from_mirror(mirror, arch, subarch)
470 code, stage_tarball = self._d.menu(_(u"Select your desired stage tarball:"), choices=self._dmenu_list_to_choices(tarballs))
471 if (code != self._DLG_OK):
472 type_it_in = True
473 else:
474 stage_tarball = mirror + "/releases/" + arch + "/current/stages/" + subarch + tarballs[int(stage_tarball)-1]
475 #get portageq envvar value of cflags and look for x86, i686,etc.
476 #URL SYNTAX
477 #http://gentoo.osuosl.org/releases/ARCHITECTURE/current/stages/SUB-ARCH/
478 else:
479 type_it_in = True
480 if type_it_in:
481 code, stage_tarball = self._d.inputbox(_(u"Specify the stage tarball URI or local file:"), init=self._install_profile.get_stage_tarball_uri())
482 if code != self._DLG_OK:
483 return
484 #If Doing a local install, check for valid file:/// uri
485 if stage_tarball:
486 if not GLIUtility.is_uri(stage_tarball, checklocal=self.local_install):
487 self._d.msgbox(_(u"The specified URI is invalid. It was not saved. Please go back and try again."));
488 else: self._install_profile.set_stage_tarball_uri(None, stage_tarball, None)
489 else: self._d.msgbox(_(u"No URI was specified!"))
490 #if d.yesno("The specified URI is invalid. Use it anyway?") == DLG_YES: install_profile.set_stage_tarball_uri(None, stage_tarball, None)
491
492 def set_portage_tree(self):
493 # This section will ask whether to sync the tree, whether to use a snapshot, etc.
494 menulist = [("Sync", _(u"Normal. Use emerge sync RECOMMENDED!")), ("Webrsync", _(u"HTTP daily snapshot. Use when rsync is firewalled.")), ("Snapshot", _(u"Use a portage snapshot, either a local file or a URL")), ("None", _(u"Extra cases such as if /usr/portage is an NFS mount"))]
495 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)
496 if code != self._DLG_OK:
497 return
498 self._install_profile.set_portage_tree_sync_type(None, portage_tree_sync.lower(), None)
499 if portage_tree_sync == "Snapshot":
500 code, snapshot = self._d.inputbox(_(u"Enter portage tree snapshot URI"), init=self._install_profile.get_portage_tree_snapshot_uri())
501 if code == self._DLG_OK:
502 if snapshot:
503 if not GLIUtility.is_uri(snapshot, checklocal=self.local_install):
504 self._d.msgbox(_(u"The specified URI is invalid. It was not saved. Please go back and try again."))
505 else:
506 self._install_profile.set_portage_tree_snapshot_uri(None, snapshot, None)
507
508 else:
509 self._d.msgbox(_(u"No URI was specified! Returning to default emerge sync."))
510 #if d.yesno("The specified URI is invalid. Use it anyway?") == DLG_YES: install_profile.set_stage_tarball_uri(None, stage_tarball, None)
511
512
513
514 def set_make_conf(self):
515 # This section will be for setting things like CFLAGS, ACCEPT_KEYWORDS, and USE
516 make_conf = self._install_profile.get_make_conf()
517
518 self._d.msgbox(_(u"""The installer will now gather information regarding the contents of /etc/make.conf
519 One of the unique (and best) features of Gentoo is the ability to
520 define flags (called USE flags) that define what components are
521 compiled into applications. For example, you can enable the alsa
522 flag and programs that have alsa capability will use it.
523 The result is a finely tuned OS with no unnecessary components to
524 slow you down.
525 The installer divides USE flag selection into two screens, one for
526 global USE flags and one for local flags specific to each program.
527 Please be patient while the screens load. It may take awhile."""), width=73, height=16)
528
529 #First set the USE flags, this is a biggie.
530 if make_conf.has_key("USE"):
531 system_use_flags = make_conf["USE"]
532 else: #not a preloaded config. this is the NORMAL case.
533 system_use_flags = GLIUtility.spawn("portageq envvar USE", return_output=True)[1].strip().split()
534 use_flags = []
535 use_local_flags = []
536 use_desc = GLIUtility.get_global_use_flags()
537 use_local_desc = GLIUtility.get_local_use_flags()
538
539 #populate the choices list
540 sorted_use = use_desc.keys()
541 sorted_use.sort()
542 for flagname in sorted_use:
543 use_flags.append((flagname, use_desc[flagname], int(flagname in system_use_flags)))
544 #present the menu
545 code, 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)
546
547 #populate the chocies list
548 sorted_use = use_local_desc.keys()
549 sorted_use.sort()
550 for flagname in sorted_use:
551 use_local_flags.append((flagname, use_local_desc[flagname], int(flagname in system_use_flags)))
552 #present the menu
553 code, 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)
554 temp_use = "-* "
555 for flag in use_flags:
556 temp_use += flag + " "
557 for flag in use_local_flags:
558 temp_use += flag + " "
559 make_conf["USE"] = temp_use
560
561 if self.advanced_mode:
562 #Second, set the ACCEPT_KEYWORDS
563 #Change the Yes/No buttons to new labels for this question.
564 self._d.add_persistent_args(["--yes-label", _(u"Stable")])
565 self._d.add_persistent_args(["--no-label", _(u"Unstable")])
566 if self._d.yesno(_(u"Do you want to run the normal stable portage tree, or the bleeding edge unstable (i.e. ACCEPT_KEYWORDS=arch)? If unsure select stable. Stable is required for GRP installs."), height=12, width=55) == self._DLG_YES:
567 #Stable
568 make_conf["ACCEPT_KEYWORDS"] = ""
569 else: #Unstable
570 make_conf["ACCEPT_KEYWORDS"] = "~" + self._client_profile.get_architecture_template()
571 #Third, misc. stuff.
572 while self.advanced_mode:
573 menulist = [("CFLAGS",_(u"Edit your C Flags and Optimization level")), ("CHOST", _(u"Change the Host Setting")), ("MAKEOPTS", _(u"Specify number of parallel makes (-j) to perform.")), ("FEATURES", _(u"Change portage functionality settings.")), ("GENTOO_MIRRORS", _(u"Specify mirrors to use for source retrieval.")), ("SYNC", _(u"Specify server used by rsync to sync the portage tree."))]
574 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)
575 if code != self._DLG_OK:
576 break
577 oldval = ""
578 if make_conf.has_key(menuitem):
579 oldval = make_conf[menuitem]
580 code, newval = self._d.inputbox(_(u"Enter new value for ") + menuitem, init=oldval)
581 if code == self._DLG_OK:
582 make_conf[menuitem] = newval
583 try:
584 self._install_profile.set_make_conf(make_conf)
585 except:
586 self._d.msgbox(_(u"ERROR! Could not set the make_conf correctly!"))
587
588 def set_kernel(self):
589 # This section will be for choosing kernel sources, choosing (and specifying) a custom config or genkernel, modules to load at startup, etc.
590 kernel_sources = [("vanilla-sources", _(u"The Unaltered Linux Kernel ver 2.6+ (safest)")), ("gentoo-sources", _(u"Gentoo's optimized 2.6+ kernel. (less safe)")), ("hardened-sources", _(u"Hardened sources for the 2.6 kernel tree")), ("grsec-sources",_(u"Vanilla sources with grsecurity patches")), ("livecd-kernel", _(u"Copy over the current running kernel (fastest)")), (_(u"Other"), _(u"Choose one of the other sources available."))]
591 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)
592 if code != self._DLG_OK:
593 return
594 if menuitem == _(u"Other"):
595 code, menuitem = self._d.inputbox(_(u"Please enter the desired kernel sources package name:"))
596 if code != self._DLG_OK: return
597 try:
598 self._install_profile.set_kernel_source_pkg(None, menuitem, None)
599 except:
600 self._d.msgbox(_(u"ERROR! Could not set the kernel source package!"))
601 if not menuitem == "livecd-kernel":
602 #Change the Yes/No buttons to new labels for this question.
603 self._d.add_persistent_args(["--yes-label", _(u"Genkernel")])
604 self._d.add_persistent_args(["--no-label", _(u"Traditional (requires a config!)")])
605 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.")
606 if self._d.yesno(string1, width=76,height=13) == self._DLG_YES: #Genkernel
607 self._install_profile.set_kernel_build_method(None,"genkernel", None)
608 if self.advanced_mode:
609 #Change the Yes/No buttons back.
610 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
611 self._d.add_persistent_args(["--no-label", _(u"No")])
612 if self._d.yesno(_(u"Do you want the bootsplash screen to show up on bootup?")) == self._DLG_YES:
613 self._install_profile.set_kernel_bootsplash(None, True, None)
614 else:
615 self._install_profile.set_kernel_bootsplash(None, False, None)
616 else: #Custom
617 self._install_profile.set_kernel_build_method(None,"custom", None)
618 if self.advanced_mode:
619 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)
620 if code == self._DLG_OK:
621 if custom_kernel_uri:
622 if not GLIUtility.is_uri(custom_kernel_uri, checklocal=self.local_install):
623 self._d.msgbox(_(u"The specified URI is invalid. It was not saved. Please go back and try again."))
624 else:
625 try:
626 self._install_profile.set_kernel_config_uri(None, custom_kernel_uri, None)
627 except:
628 self._d.msgbox(_(u"ERROR! Could not set the kernel config URI!"))
629 #else: self._d.msgbox(_(u"No URI was specified! Reverting to using genkernel"))
630
631 def set_boot_loader(self):
632 arch = self._client_profile.get_architecture_template()
633 arch_loaders = { 'x86': [("grub",_(u"GRand Unified Bootloader, newer, RECOMMENDED")),("lilo",_(u"LInux LOader, older, traditional.(detects windows partitions)"))], 'amd64': [("grub",_(u"GRand Unified Bootloader, newer, RECOMMENDED"))]} #FIXME ADD OTHER ARCHS
634 boot_loaders = arch_loaders[arch]
635 boot_loaders.append(("none", _(u"Do not install a bootloader. (System may be unbootable!)")))
636 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")
637 code, menuitem = self._d.menu(string1, choices=boot_loaders, height=16, width=74)
638 if code != self._DLG_OK:
639 return
640 try:
641 self._install_profile.set_boot_loader_pkg(None, menuitem, None)
642 except:
643 self._d.msgbox(_(u"ERROR! Could not set boot loader pkg! ")+menuitem)
644 if menuitem != "none" and self.advanced_mode:
645 #Reset the Yes/No labels.
646 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
647 self._d.add_persistent_args(["--no-label",_(u"No")])
648 if self._d.yesno(_(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)"), height=13, width=55) == self._DLG_YES:
649 self._install_profile.set_boot_loader_mbr(None, True, None)
650 else:
651 self._install_profile.set_boot_loader_mbr(None, False, None)
652 if self.advanced_mode:
653 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)
654 if code == self._DLG_OK:
655 try:
656 self._install_profile.set_bootloader_kernel_args(None, bootloader_kernel_args, None)
657 except:
658 self._d.msgbox(_(u"ERROR! Could not set bootloader kernel arguments! ")+bootloader_kernel_args)
659
660
661 def set_timezone(self):
662 # This section will be for setting the timezone.
663 zonepath = "/usr/share/zoneinfo"
664 skiplist = ["zone.tab","iso3166.tab","posixrules"]
665 while 1:
666 tzlist = []
667 for entry in os.listdir(zonepath):
668 if entry not in skiplist:
669 if os.path.isdir(zonepath + "/" + entry): entry += "/"
670 tzlist.append(entry)
671 tzlist.sort()
672 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.")
673 code, tznum = self._d.menu(string, choices=self._dmenu_list_to_choices(tzlist), height=20, cancel="Back")
674 if code == self._DLG_OK:
675 zonepath = os.path.join(zonepath,tzlist[int(tznum)-1])
676 if tzlist[int(tznum)-1][-1:] != "/":
677 break
678 else:
679 if zonepath == "/usr/share/zoneinfo":
680 return
681 slashloc = zonepath[:-1].rfind("/")
682 zonepath = zonepath[:slashloc]
683 try:
684 self._install_profile.set_time_zone(None, zonepath[20:], None)
685 except:
686 self._d.msgbox(_(u"ERROR: Could not set that timezone!"))
687
688 def set_networking(self):
689 # This section will be for setting up network interfaces
690 interfaces = self._install_profile.get_network_interfaces()
691 CC_iface = self._client_profile.get_network_interface()
692 if CC_iface and (CC_iface not in interfaces):
693 #The CC has a network config that's not already there. Preload it.
694 CC_net_type = self._client_profile.get_network_type()
695 if CC_net_type == 'dhcp':
696 try:
697 interfaces[CC_iface] = ('dhcp', self._client_profile.get_network_dhcp_options(), None)
698 except:
699 pass
700 else:
701 try:
702 interfaces[CC_iface] = (self._client_profile.get_network_ip(), self._client_profile.get_network_broadcast(), self._client_profile.get_network_netmask())
703 except:
704 pass
705
706 while 1:
707 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.")
708 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:")
709 choice_list = []
710 for iface in interfaces:
711 if interfaces[iface][0] == 'dhcp':
712 choice_list.append((iface, _(u"Settings: DHCP. Options: ")+ interfaces[iface][1]))
713 else:
714 choice_list.append((iface, _(u"IP: ")+interfaces[iface][0]+_(u" Broadcast: ")+interfaces[iface][1]+_(u" Netmask: ")+interfaces[iface][2]))
715 choice_list.append(("Add",_(u"Add a new network interface")))
716 code, iface_choice = self._d.menu(string1, choices=choice_list, cancel=_(u"Save and Continue"), height=18, width=77)
717 if code != self._DLG_OK:
718 try:
719 self._install_profile.set_network_interfaces(interfaces)
720 except:
721 self_d.msgbox(_(u"ERROR! Could not set the network interfaces!"))
722 break #This should hopefully move the user down to part two of set_networking
723 if iface_choice == "Add":
724 if self.local_install:
725 device_list = GLIUtility.get_eth_devices()
726 newchoice_list = []
727 for device in device_list:
728 if device not in interfaces:
729 newchoice_list.append((device, GLIUtility.get_interface_realname(device)))
730 newchoice_list.append((_(u"Other"),_(u"Type your own.")))
731 code, newnic = self._d.menu(_("Choose an interface from the list or Other to type your own if it was not detected."), choices=newchoice_list, width=75)
732 else:
733 newnic == _(u"Other")
734 if newnic == _(u"Other"):
735 code, newnic = self._d.inputbox(_(u"Enter name for new interface (eth0, ppp0, etc.)"))
736 if code != self._DLG_OK:
737 continue
738 if newnic in interfaces:
739 self._d.msgbox(_(u"An interface with the name is already defined."))
740 continue
741 #create the interface in the data structure.
742 #interfaces[newnic] = ("", "", "")
743 #Change the Yes/No buttons to new labels for this question.
744 self._d.add_persistent_args(["--yes-label", _(u"DHCP")])
745 self._d.add_persistent_args(["--no-label", _(u"Static IP/Manual")])
746 if self._d.yesno(string2, height=15, width=60) == self._DLG_YES: #DHCP
747 dhcp_options = ""
748 if self.advanced_mode:
749 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)
750 interfaces[newnic] = ('dhcp', dhcp_options, None)
751 else:
752 network_type = 'static'
753 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!'), ((_(u'Enter your IP address:'), 15),(_(u'Enter your Broadcast address:'), 15),(_(u'Enter your Netmask:'),15,'255.255.255.0')))
754 (ip_address, broadcast, netmask) = data[:-1].split('\n')
755 if code != self._DLG_OK:
756 continue
757 #Set the info now that it's all gathered.
758 interfaces[newnic] = (ip_address, broadcast, netmask)
759 else: #they have chosen an interface, present them with edit/delete
760 #Change the Yes/No buttons to new labels for this question.
761 self._d.add_persistent_args(["--yes-label", _(u"Edit")])
762 self._d.add_persistent_args(["--no-label", _(u"Delete")])
763 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:
764 #Edit
765 #Change the Yes/No buttons to new labels for this question.
766 self._d.add_persistent_args(["--yes-label", _(u"DHCP")])
767 self._d.add_persistent_args(["--no-label", _(u"Static IP/Manual")])
768 if self._d.yesno(string2, height=15, width=60) == self._DLG_YES: #DHCP
769 dhcp_options = ""
770 if self.advanced_mode:
771 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)
772 interfaces[iface_choice] = ('dhcp', dhcp_options, None)
773 else:
774 network_type = 'static'
775 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!'), ((_(u'Enter your IP address:'), 15, interfaces[iface_choice][0]),(_(u'Enter your Broadcast address:'), 15, interfaces[iface_choice][1]),(_(u'Enter your Netmask:'),15,interfaces[iface_choice][2])))
776 (ip_address, broadcast, netmask) = data[:-1].split('\n')
777 if code != self._DLG_OK:
778 continue
779 #Set the info now that it's all gathered.
780 interfaces[iface_choice] = (ip_address, broadcast, netmask)
781 else:
782 #Delete
783 #Reset the Yes/No buttons
784 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
785 self._d.add_persistent_args(["--no-label", _(u"No")])
786 if self._d.yesno(_(u"Are you sure you want to remove the interface ") + iface_choice + "?") == self._DLG_YES:
787 del interfaces[iface_choice]
788
789 #This section is for defining DNS servers, default routes/gateways, hostname, etc.
790 #First ask for the default gateway device and IP
791 interfaces = self._install_profile.get_network_interfaces()
792 choice_list = []
793 for iface in interfaces:
794 if interfaces[iface][0] == 'dhcp':
795 choice_list.append((iface, _(u"Settings: DHCP. Options: ")+ interfaces[iface][1],0))
796 else:
797 choice_list.append((iface, _(u"IP: ")+interfaces[iface][0]+_(u" Broadcast: ")+interfaces[iface][1]+_(u" Netmask: ")+interfaces[iface][2],0))
798 string3 = _("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:")
799 code, gateway_iface = self._d.radiolist(string3, choices=choice_list, height=20, width=67)
800 if code == self._DLG_OK: #They made a choice. Ask the IP if not DHCP.
801 while interfaces[gateway_iface][0] != 'dhcp':
802 code, ip = self._d.inputbox(_(u"Enter the gateway IP address for ") + gateway_iface, init=interfaces[gateway_iface][0])
803 if code != self._DLG_OK:
804 break
805 if not GLIUtility.is_ip(ip):
806 self._d.msgbox(_(u"Invalid IP Entered! Please try again."))
807 continue
808 try:
809 self._install_profile.set_default_gateway(None, ip,{'interface': gateway_iface})
810 except:
811 self._d.msgbox(_(u"ERROR! Coult not set the default gateway with IP %s for interface %s") % (ip, gateway_iface))
812 break
813 #Now ask for the other info in a large form.
814 error = True
815 hostname = ""
816 domainname = ""
817 nisdomainname = ""
818 primary_dns = ""
819 backup_dns = ""
820 http_proxy = ""
821 ftp_proxy = ""
822 rsync_proxy = ""
823 while error:
824 error = False
825 if self.advanced_mode:
826 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!'), ((_(u'Enter your Hostname:'), 25, self._install_profile.get_hostname()),(_(u'Enter your Domain Name:'), 25, self._install_profile.get_domainname()),(_(u'Enter your NIS Domain Name:'),25,self._install_profile.get_nisdomainname()),(_(u'Enter a primary DNS server:'),15),(_(u'Enter a backup DNS server:'),15), (_(u'Enter a HTTP Proxy IP:'), 15,self._install_profile.get_http_proxy()),(_(u'Enter a FTP Proxy IP:'), 15, self._install_profile.get_ftp_proxy()), (_(u'Enter a RSYNC Proxy:'),15,self._install_profile.get_rsync_proxy())))
827 if code != self._DLG_OK:
828 return
829 (hostname, domainname, nisdomainname, primary_dns, backup_dns, http_proxy, ftp_proxy, rsync_proxy) = data[:-1].split('\n')
830 else: #standard mode
831 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!'), ((_(u'Enter your Hostname:'), 25, self._install_profile.get_hostname()),(_(u'Enter your Domain Name:'), 25, self._install_profile.get_domainname()),(_(u'Enter a primary DNS server:'),15),(_(u'Enter a backup DNS server:'),15)))
832 if code != self._DLG_OK:
833 return
834 (hostname, domainname, primary_dns, backup_dns) = data[:-1].split('\n')
835 #Check the data before entering it.
836 if hostname:
837 if type(hostname) != str:
838 self._d.msgbox(_(u"Incorrect hostname! It must be a string. Not saved."))
839 error = True
840 else:
841 try:
842 self._install_profile.set_hostname(None, hostname, None)
843 except:
844 self._d.msgbox(_(u"ERROR! Could not set the hostname:")+hostname)
845 error = True
846 if domainname:
847 if type(domainname) != str:
848 self._d.msgbox(_(u"Incorrect domainname! It must be a string. Not saved."))
849 error = True
850 else:
851 try:
852 self._install_profile.set_domainname(None, domainname, None)
853 except:
854 self._d.msgbox(_(u"ERROR! Could not set the domainname:")+domainname)
855 error = True
856 if nisdomainname:
857 if type(nisdomainname) != str:
858 self._d.msgbox(_(u"Incorrect nisdomainname! It must be a string. Not saved."))
859 error = True
860 else:
861 try:
862 self._install_profile.set_nisdomainname(None, nisdomainname, None)
863 except:
864 self._d.msgbox(_(u"ERROR! Could not set the nisdomainname:")+nisdomainname)
865 error = True
866 if primary_dns:
867 if not GLIUtility.is_ip(primary_dns):
868 self._d.msgbox(_(u"Incorrect Primary DNS Server! Not saved."))
869 error = True
870 else:
871 if backup_dns:
872 if not GLIUtility.is_ip(backup_dns):
873 self._d.msgbox(_(u"Incorrect Backup DNS Server! Not saved."))
874 error = True
875 else:
876 primary_dns = primary_dns + " " + backup_dns
877 try:
878 self._install_profile.set_dns_servers(None, primary_dns, None)
879 except:
880 self._d.msgbox(_(u"ERROR! Could not set the DNS Servers:")+primary_dns)
881 error = True
882 if http_proxy:
883 if not GLIUtility.is_uri(http_proxy):
884 self._d.msgbox(_(u"Incorrect HTTP Proxy! It must be a uri. Not saved."))
885 error = True
886 else:
887 try:
888 self._install_profile.set_http_proxy(None, http_proxy, None)
889 except:
890 self._d.msgbox(_(u"ERROR! Could not set the HTTP Proxy:")+http_proxy)
891 error = True
892 if ftp_proxy:
893 if not GLIUtility.is_uri(ftp_proxy):
894 self._d.msgbox(_(u"Incorrect FTP Proxy! It must be a uri. Not saved."))
895 error = True
896 else:
897 try:
898 self._install_profile.set_ftp_proxy(None, ftp_proxy, None)
899 except:
900 self._d.msgbox(_(u"ERROR! Could not set the FTP Proxy:")+ftp_proxy)
901 error = True
902 if rsync_proxy:
903 if not GLIUtility.is_uri(rsync_proxy):
904 self._d.msgbox(_(u"Incorrect RSYNC Proxy! It must be a uri. Not saved."))
905 error = True
906 else:
907 try:
908 self._install_profile.set_rsync_proxy(None, rsync_proxy, None)
909 except:
910 self._d.msgbox(_(u"ERROR! Could not set the RSYNC Proxy:")+rsync_proxy)
911 error = True
912
913
914 def set_cron_daemon(self):
915 cron_daemons = (("vixie-cron", _(u"Paul Vixie's cron daemon, fully featured, RECOMMENDED.")), ("dcron",_(u"A cute little cron from Matt Dillon.")), ("fcron", _(u"A scheduler with extended capabilities over cron & anacron")), ("None", _(u"Don't use a cron daemon. (NOT Recommended!)")))
916 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:")
917 code, menuitem = self._d.menu(string, choices=cron_daemons, height=21, width=77)
918 if code == self._DLG_OK:
919 if menuitem == "None":
920 menuitem = ""
921 self._install_profile.set_cron_daemon_pkg(None, menuitem, None)
922
923 def set_logger(self):
924 loggers = (("syslog-ng", _(u"An advanced system logger.")), ("metalog", _(u"A Highly-configurable system logger.")), ("syslogkd", _(u"The traditional set of system logging daemons.")))
925 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:")
926 code, menuitem = self._d.menu(string, choices=loggers, height=21, width=68)
927 if code == self._DLG_OK:
928 self._install_profile.set_logging_daemon_pkg(None, menuitem, None)
929
930 def set_extra_packages(self):
931 #d.msgbox("This section is for selecting extra packages (pcmcia-cs, rp-pppoe, xorg-x11, etc.) and setting them up")
932 if self._install_profile.get_install_packages():
933 install_packages = self._install_profile.get_install_packages()
934 else:
935 install_packages = []
936 while 1:
937 highlevel_menu = [(_(u"Desktop"), _(u"Popular Desktop Applications")), (_(u"Servers"), _(u"Applications often found on servers.")), (_(u"X11"), _(u"Window managers and X selection.")), (_(u"Misc"), _(u"Miscellaneous Applications you may want.")), (_(u"Recommended"), _(u"Applications recommended by the GLI Team.")), (_(u"Manual"), _(u"Type your own space-separated list of packages."))]
938 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'.")
939 code, submenu = self._d.menu(string1+ _(u"\nYour current package list is: ")+string.join(install_packages, ','), choices=highlevel_menu, cancel=_(u"Save and Continue"), width=70, height=23)
940 if code != self._DLG_OK: #Save and move on.
941 try:
942 packages = string.join(install_packages, ' ')
943 if packages:
944 self._install_profile.set_install_packages(None, packages, None)
945 except:
946 self._d.msgbox(_(u"ERROR! Could not set the install packages! List of packages:"))
947 return
948 #Popular Desktop Applications
949 choices_list = []
950 if submenu == _(u"Desktop"):
951 choices_list = [("gaim",_(u"GTK Instant Messenger client"),int("gaim" in install_packages)),
952 ("gftp",_(u"Gnome based FTP Client"),int("gftp" in install_packages)),
953 ("evolution",_(u"A GNOME groupware application, a Microsoft Outlook workalike"),int("evolution" in install_packages)),
954 ("mozilla-firefox",_(u"The Mozilla Firefox Web Browser"),int("mozilla-firefox" in install_packages)),
955 ("mplayer",_(u"Media Player for Linux"),int("mplayer" in install_packages)),
956 ("openoffice",_(u"OpenOffice.org, a full office productivity suite."),int("openoffice" in install_packages)),
957 ("openoffice-bin",_(u"Same as OpenOffice but a binary package (no compiling!)"),int("openoffice-bin" in install_packages)),
958 ("realplayer",_(u"Real Media Player"),int("realplayer" in install_packages)),
959 ("xchat",_(u"Graphical IRC Client"),int("xchat" in install_packages)),
960 ("xmms", _(u"X MultiMedia System"),int("xmms" in install_packages))]
961 #Applications often found on servers.
962 elif submenu == _(u"Servers"):
963 choices_list = [("apache",_(u"Apache Web Server"),int("apache" in install_packages)),
964 ("iptables",_(u"Linux kernel (2.4+) firewall, NAT and packet mangling tools"),int("iptables" in install_packages)),
965 ("proftpd",_(u"ProFTP Server"),int("proftpd" in install_packages)),
966 ("samba",_(u"SAMBA client/server programs for UNIX"),int("samba" in install_packages)),
967 ("traceroute",_(u"Utility to trace the route of IP packets"),int("traceroute" in install_packages))]
968 #Window managers and X selection.
969 elif submenu == _(u"X11"):
970 choices_list = [("xorg-x11",_(u"An X11 implementation maintained by the X.Org Foundation."),int("xorg-x11" in install_packages)),
971 ("gnome",_(u"The Gnome Desktop Environment"),int("gnome" in install_packages)),
972 ("kde",_(u"The K Desktop Environment"),int("kde" in install_packages)),
973 ("blackbox",_(u"A small, fast, full-featured window manager for X"),int("blackbox" in install_packages)),
974 ("enlightenment",_(u"Enlightenment Window Manager"),int("enlightenment" in install_packages)),
975 ("fluxbox",_(u"Fluxbox is an X11 window manager featuring tabs and an iconbar"),int("fluxbox" in install_packages)),
976 ("xfce4",_(u"XFCE Desktop Environment"),int("xfce4" in install_packages))]
977 #Miscellaneous Applications you may want.
978 elif submenu == _(u"Misc"):
979 choices_list = [("gkrellm",_(u"Single process stack of various system monitors"),int("gkrellm" in install_packages)),
980 ("logrotate",_(u"Rotates, compresses, and mails system logs"),int("logrotate" in install_packages)),
981 ("slocate",_(u"Secure way to index and quickly search for files on your system"),int("slocate" in install_packages)),
982 ("ufed",_(u"Gentoo Linux USE flags editor"),int("ufed" in install_packages))]
983 #Recommended by the Gentoo Linux Installer Team
984 elif submenu == _(u"Recommended"):
985 choices_list = [("anjuta",_(u"A versatile IDE for GNOME"),int("anjuta" in install_packages)),
986 ("chkrootkit",_(u"a tool to locally check for signs of a rootkit"),int("chkrootkit" in install_packages)),
987 ("crack-attack",_(u"Addictive OpenGL-based block game"),int("crack-attack" in install_packages)),
988 ("netcat",_(u"the network swiss army knife"),int("netcat" in install_packages)),
989 ("nmap",_(u"A utility for network exploration or security auditing"),int("nmap" in install_packages)),
990 ("screen",_(u"full-screen window manager that multiplexes between several processes"),int("screen" in install_packages))]
991 elif submenu == _(u"Manual"):
992 code, 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)
993 continue
994 code, choices = self._d.checklist(_(u"Choose from the listed packages"), choices=choices_list, height=19, list_height=10, width=77)
995 if code != self._DLG_OK:
996 continue
997 for package in choices:
998 install_packages.append(package)
999
1000 def set_services(self):
1001 services = self._install_profile.get_services()
1002 choice_list = [("alsasound", _(u"ALSA Sound Daemon"),int("alsasound" in services)), ("apache", _(u"Common web server (version 1.x)"),int("apache" in services)), ("apache2", _(u"Common web server (version 2.x)"),int("apache2" in services)), ("distccd", _(u"Distributed Compiling System"),int("distccd" in services)), ("esound", _(u"ESD Sound Daemon"),int("esound" in services)), ("hdparm", _(u"Hard Drive Tweaking Utility"),int("hdparm" in services)), ("local", _(u"Run scripts found in /etc/conf.d/local.start"),int("local" in services)), ("portmap", _(u"Port Mapping Service"),int("portmap" in services)), ("proftpd", _(u"Common FTP server"),int("proftpd" in services)), ("sshd", _(u"SSH Daemon (allows remote logins)"),int("sshd" in services)), (_(u"Other"),_(u"Manually specify your services in a comma-separated list."),0)]
1003 string = _(u"Choose the services you want started on bootup. Note that depending on what packages are selected, some services listed will not exist.")
1004 code, services_list = self._d.checklist(string, choices=choice_list, height=21, list_height=12, width=77)
1005 if code != self._DLG_OK:
1006 return
1007 services = ""
1008 for service in services_list:
1009 services += service + ","
1010 if services:
1011 services = services[:-1]
1012 if _(u"Other") in services_list:
1013 code, services = self._d.inputbox(_(u"Enter a comma-separated list of services to start on boot"))
1014 if code != self._DLG_OK:
1015 return
1016 try:
1017 if services:
1018 self._install_profile.set_services(None, services, None)
1019 except:
1020 self._d.msgbox(_(u"ERROR! Could not set the services list: "+ services))
1021
1022
1023 def set_rc_conf(self):
1024 # This section is for editing /etc/rc.conf
1025 if not self.advanced_mode:
1026 return
1027 etc_files = self._install_profile.get_etc_files()
1028 keymap = ""
1029 windowkeys = ""
1030 ext_keymap = ""
1031 font = ""
1032 trans = ""
1033 clock = ""
1034 editor = ""
1035 prots = ""
1036 disp_manager = ""
1037 xsession = ""
1038 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!")
1039 menulist = [("KEYMAP",_(u"Use KEYMAP to specify the default console keymap.")), ("SET_WINDOWSKEYS", _(u"Decision to first load the 'windowkeys' console keymap")), ("EXTENDED_KEYMAPS", _(u"maps to load for extended keyboards. Most users will leave this as is.")), ("CONSOLEFONT", _(u"Specifies the default font that you'd like Linux to use on the console.")), ("CONSOLETRANSLATION", _(u"The charset map file to use.")), ("CLOCK", _(u"Set the clock to either UTC or local")), ("EDITOR", _(u"Set EDITOR to your preferred editor.")), ("PROTOCOLS", _(u"Gentoo Linux will only enable module auto-loading for these protocols")), ("DISPLAYMANAGER", _(u"What display manager do you use ? [ xdm | gdm | kdm | entrance ]")), ("XSESSION", _(u"a new variable to control what window manager to start default with X"))]
1040 while 1:
1041 code, variable = self._d.menu(string1, choices=menulist, cancel=_(u"Save and Continue"), width=77, height=19)
1042 if code != self._DLG_OK:
1043 break
1044 if variable == "KEYMAP":
1045 keymap_list = GLIUtility.generate_keymap_list()
1046 code, keymap = self._d.menu(_(u"Choose your desired keymap:"), choices=self._dmenu_list_to_choices(keymap_list), height=19)
1047 if code != self._DLG_OK:
1048 continue
1049 keymap = keymap_list[int(keymap)-1]
1050
1051 elif variable == "SET_WINDOWSKEYS":
1052 #Reset the Yes/No buttons
1053 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
1054 self._d.add_persistent_args(["--no-label", _(u"No")])
1055 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:
1056 windowkeys = "yes"
1057 else:
1058 windowkeys = "no"
1059 elif variable == "EXTENDED_KEYMAPS":
1060 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)
1061 elif variable == "CONSOLEFONT":
1062 font_list = GLIUtility.generate_consolefont_list()
1063 code, font = self._d.menu(_(u"Choose your desired console font:"), choices=self._dmenu_list_to_choices(font_list), height=19)
1064 if code != self._DLG_OK:
1065 continue
1066 font = font_list[int(font)-1]
1067 elif variable == "CONSOLETRANSLATION":
1068 trans_list = GLIUtility.generate_consoletranslation_list()
1069 code, trans = self._d.menu(_(u"Choose your desired console translation:"), choices=self._dmenu_list_to_choices(trans_list), height=19)
1070 if code != self._DLG_OK:
1071 continue
1072 trans = trans_list[int(trans)-1]
1073 elif variable == "CLOCK":
1074 #Change the Yes/No buttons to new labels for this question.
1075 self._d.add_persistent_args(["--yes-label", "UTC"])
1076 self._d.add_persistent_args(["--no-label", "local"])
1077 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:
1078 clock = "UTC"
1079 else:
1080 clock = "local"
1081 elif variable == "EDITOR":
1082 choice_list = [("/bin/nano", _(u"Default editor.")), ("/usr/bin/vim", _(u"vi improved editor.")), ("/usr/bin/emacs", _(u"The emacs editor."))]
1083 code, editor = self._d.menu(_(u"Choose your default editor: "), choices=choice_list)
1084
1085 elif variable == "PROTOCOLS":
1086 choice_list = [("1", "Unix",1),("2","IPv4",1), ("3","Amateur Radio AX.25",0), ("4","IPX",0), ("5","DDP / appletalk",0), ("6","Amateur Radio NET/ROM",0), ("9","X.25",0), ("10","IPv6",0), ("11","ROSE / Amateur Radio X.25 PLP",0), ("19","Acorn Econet",0)]
1087 code, protocols = self._d.checklist(_(u"Choose the protocols that you plan to use. Gentoo Linux will only enable module auto-loading for these protocols, eliminating annoying module not found errors."), choices=choice_list, height=19, width=60)
1088 if code != self._DLG_OK:
1089 continue
1090 prots = ""
1091 for prot in protocols:
1092 prots += prot + " "
1093 elif variable == "DISPLAYMANAGER":
1094 choice_list = [("xdm", _(u"X Display Manager")), ("gdm", _(u"Gnome Display Manager")), ("kdm", _(u"KDE Display Manager")), ("entrance", _(u"Login Manager for Enlightenment"))]
1095 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)
1096 elif variable == "XSESSION":
1097 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)
1098
1099 if not "conf.d/keymaps" in etc_files:
1100 if keymap or windowkeys or ext_keymap:
1101 etc_files['conf.d/keymaps'] = {}
1102 if not "conf.d/consolefont" in etc_files:
1103 if font or trans:
1104 etc_files['conf.d/consolefont'] = {}
1105 if not "conf.d/clock" in etc_files:
1106 if clock:
1107 etc_files['conf.d/clock'] = {}
1108 if not "rc.conf" in etc_files:
1109 if editor or prots or disp_manager or xsession:
1110 etc_files['rc.conf'] = {}
1111 if keymap:
1112 etc_files['conf.d/keymaps']['KEYMAP'] = keymap
1113 if windowkeys:
1114 etc_files['conf.d/keymaps']['SET_WINDOWSKEYS'] = windowkeys
1115 if ext_keymap:
1116 etc_files['conf.d/keymaps']['EXTENDED_KEYMAPS'] = ext_keymap
1117 if font:
1118 etc_files['conf.d/consolefont']['CONSOLEFONT'] = font
1119 if trans:
1120 etc_files['conf.d/consolefont']['CONSOLETRANSLATION'] = trans
1121 if clock:
1122 etc_files['conf.d/clock']['CLOCK'] = clock
1123 if editor:
1124 etc_files['rc.conf']['EDITOR'] = editor
1125 if prots:
1126 etc_files['rc.conf']['PROTOCOLS'] = prots
1127 if disp_manager:
1128 etc_files['rc.conf']['DISPLAYMANAGER'] = disp_manager
1129 if xsession:
1130 etc_files['rc.conf']['XSESSION'] = xsession
1131 self._install_profile.set_etc_files(etc_files)
1132
1133 def set_root_password(self):
1134 # The root password will be set here
1135 while 1:
1136 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.):"))
1137 if code != self._DLG_OK:
1138 return
1139 code, passwd2 = self._d.passwordbox(_(u"Enter the new root password again for confirmation"))
1140 if code != self._DLG_OK:
1141 return
1142 if passwd1 != passwd2:
1143 self._d.msgbox(_(u"The passwords do not match. Please try again or cancel."))
1144 else:
1145 try:
1146 self._install_profile.set_root_pass_hash(None, GLIUtility.hash_password(passwd1), None)
1147 except:
1148 self._d.msgbox(_(u"ERROR! Could not set the new system root password!"))
1149 self._d.msgbox(_(u"Password saved. Press Enter to continue."))
1150 return
1151
1152 def set_additional_users(self):
1153 # This section will be for adding non-root users
1154 users = {}
1155 for user in self._install_profile.get_users():
1156 users[user[0]] = (user[0], user[1], user[2], user[3], user[4], user[5], user[6])
1157 while 1:
1158 menu_list = []
1159 for user in users:
1160 menu_list.append(user)
1161 menu_list.sort()
1162 menu_list.append(_(u"Add user"))
1163 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:")
1164 code, menuitem = self._d.menu(string1, choices=self._dmenu_list_to_choices(menu_list), cancel="Save and Continue", height=19)
1165 if code != self._DLG_OK:
1166 #if self._d.yesno("Do you want to save changes?") == self._DLG_YES:
1167 tmpusers = []
1168 for user in users:
1169 tmpusers.append(users[user])
1170 try:
1171 self._install_profile.set_users(tmpusers)
1172 except:
1173 self._d.msgbox(_(u"ERROR! Could not set the additional users!"))
1174 break
1175 menuitem = menu_list[int(menuitem)-1]
1176 if menuitem == _(u"Add user"):
1177 code, newuser = self._d.inputbox(_(u"Enter the username for the new user"))
1178 if code != self._DLG_OK:
1179 continue
1180 if newuser in users:
1181 self._d.msgbox(_(u"A user with that name already exists"))
1182 continue
1183 code, passwd1 = self._d.passwordbox(_(u"Enter the new password for user ")+ newuser)
1184 code, passwd2 = self._d.passwordbox(_(u"Enter the new password again for confirmation"))
1185 if code == self._DLG_OK:
1186 if passwd1 != passwd2:
1187 self._d.msgbox(_(u"The passwords do not match! Go to the menu and try again."))
1188 #Create the entry for the new user
1189 new_user = [newuser, GLIUtility.hash_password(passwd1), ('users',), '/bin/bash', '/home/' + newuser, '', '']
1190 users[newuser] = new_user
1191 menuitem = newuser
1192 while 1:
1193 menulist = [_(u"Password"), _(u"Group Membership"), _(u"Shell"), _(u"Home Directory"), _(u"UID"), _(u"Comment"), _(u"Delete")]
1194 code, menuitem2 = self._d.menu(_(u"Choose an option for user ") + menuitem, choices=self._dmenu_list_to_choices(menulist), cancel=_(u"Back"))
1195 if code != self._DLG_OK:
1196 break
1197 menuitem2 = menulist[int(menuitem2)-1]
1198 if menuitem2 == _(u"Password"):
1199 code, passwd1 = self._d.passwordbox(_(u"Enter the new password"))
1200 if code != self._DLG_OK:
1201 continue
1202 code, passwd2 = self._d.passwordbox(_(u"Enter the new password again"))
1203 if code != self._DLG_OK:
1204 continue
1205 if passwd1 != passwd2:
1206 self._d.msgbox(_(u"The passwords do not match! Try again."))
1207 continue
1208 self._d.msgbox(_(u"Password saved. Press Enter to continue."))
1209 users[menuitem][1] = GLIUtility.hash_password(passwd1)
1210 elif menuitem2 == _(u"Group Membership"):
1211 prechk = users[menuitem][2]
1212 choice_list = [("users", _(u"The usual group for normal users."), int("users" in prechk)),
1213 ("wheel", _(u"Allows users to attempt to su to root."), int("wheel" in prechk)),
1214 ("audio", _(u"Allows access to audio devices."), int("audio" in prechk)),
1215 ("games", _(u"Allows access to games."), int("games" in prechk)),
1216 ("apache", _(u"For users who know what they're doing only."), int("apache" in prechk)),
1217 ("cdrom", _(u"For users who know what they're doing only."), int("cdrom" in prechk)),
1218 ("ftp", _(u"For users who know what they're doing only."), int("ftp" in prechk)),
1219 ("video", _(u"For users who know what they're doing only."), int("video" in prechk)),
1220 (_(u"Other"), _(u"Manually specify your groups in a comma-separated list."), 0)]
1221 string2 = _(u"Select which groups you would like the user %s to be in." % menuitem)
1222 code, group_list = self._d.checklist(string2, choices=choice_list, height=19, list_height=10, width=77)
1223 if code != self._DLG_OK:
1224 break
1225 groups = ""
1226 for group in group_list:
1227 groups += group + ","
1228 if groups:
1229 groups = groups[:-1]
1230 if _(u"Other") in group_list:
1231 code, groups = self._d.inputbox(_(u"Enter a comma-separated list of groups the user is to be in"), init=",".join(users[menuitem][2]))
1232 if code != self._DLG_OK: continue
1233 users[menuitem][2] = string.split(groups, ",")
1234 elif menuitem2 == _(u"Shell"):
1235 code, shell = self._d.inputbox(_(u"Enter the shell you want the user to use. default is /bin/bash. "), init=users[menuitem][3])
1236 if code != self._DLG_OK:
1237 continue
1238 users[menuitem][3] = shell
1239 elif menuitem2 == _(u"Home Directory"):
1240 code, homedir = self._d.inputbox(_(u"Enter the user's home directory. default is /home/username. "), init=users[menuitem][4])
1241 if code != self._DLG_OK:
1242 continue
1243 users[menuitem][4] = homedir
1244 elif menuitem2 == _(u"UID"):
1245 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)
1246 if code != self._DLG_OK:
1247 continue
1248 if type(uid) != int:
1249 continue
1250 users[menuitem][5] = uid
1251 elif menuitem2 == _(u"Comment"):
1252 code, comment = self._d.inputbox(_(u"Enter the user's comment. This is completely optional."), init=users[menuitem][6])
1253 if code != self._DLG_OK:
1254 continue
1255 users[menuitem][6] = comment
1256 elif menuitem2 == _(u"Delete"):
1257 #Reset the Yes/No buttons
1258 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
1259 self._d.add_persistent_args(["--no-label", _(u"No")])
1260 if self._d.yesno(_(u"Are you sure you want to delete the user ") + menuitem + "?") == self._DLG_YES:
1261 del users[menuitem]
1262 break
1263
1264
1265 def save_install_profile(self, xmlfilename="", askforfilename=True):
1266 code = 0
1267 filename = xmlfilename
1268 if askforfilename:
1269 code, filename = self._d.inputbox(_(u"Enter a filename for the XML file"), init=xmlfilename)
1270 if code != self._DLG_OK:
1271 return None
1272 if GLIUtility.is_file(filename):
1273 if not self._d.yesno(_(u"The file %s already exists. Do you want to overwrite it?") % filename) == self._DLG_YES:
1274 return None
1275 configuration = open(filename ,"w")
1276 configuration.write(self._install_profile.serialize())
1277 configuration.close()
1278 return filename
1279 def show_settings(self):
1280 settings = _(u"Look carefully at the following settings to check for mistakes.\nThese are the installation settings you have chosen:\n\n")
1281 #Partitioning
1282 settings += "Partitioning: \n Key: Minor, Pri/Ext, Filesystem, MkfsOpts, Mountpoint, MountOpts, Size.\n"
1283 devices = self._install_profile.get_partition_tables()
1284 drives = devices.keys()
1285 drives.sort()
1286 for drive in drives:
1287 settings += " Drive: " + drive + devices[drive].get_model() + "\n"
1288 partlist = devices[drive].get_ordered_partition_list()
1289 tmpparts = devices[drive].get_partitions()
1290 for part in partlist:
1291 tmppart = tmpparts[part]
1292 entry = " "
1293 if tmppart.get_type() == "free":
1294 #partschoice = "New"
1295 entry = _(u" - Unallocated space (")
1296 if tmppart.is_logical():
1297 entry += _(u"logical, ")
1298 entry += str(tmppart.get_mb()) + "MB)"
1299 elif tmppart.get_type() == "extended":
1300 entry = str(int(tmppart.get_minor()))
1301 entry += _(u" - Extended Partition (") + str(tmppart.get_mb()) + "MB)"
1302 else:
1303 entry = str(int(tmppart.get_minor())) + " - "
1304 if tmppart.is_logical():
1305 entry += _(u"Logical (")
1306 else:
1307 entry += _(u"Primary (")
1308 entry += tmppart.get_type() + ", "
1309 entry += (tmppart.get_mkfsopts() or "none") + ", "
1310 entry += (tmppart.get_mountpoint() or "none") + ", "
1311 entry += (tmppart.get_mountopts() or "none") + ", "
1312 entry += str(tmppart.get_mb()) + "MB)"
1313 settings += entry + "\n"
1314
1315 #Network Mounts:
1316 network_mounts = copy.deepcopy(self._install_profile.get_network_mounts())
1317 settings += "\nNetwork Mounts: \n"
1318 for mount in network_mounts:
1319 settings += " "+mount['host']+":"+mount['export']+"\n"
1320
1321 #Install Stage:
1322 settings += "\nInstall Stage: " + str(self._install_profile.get_install_stage()) + "\n"
1323 if self._install_profile.get_stage_tarball_uri() == "networkless":
1324 settings += " Tarball will be generated on the fly from the CD.\n"
1325 else:
1326 settings += " Tarball URI: " + self._install_profile.get_stage_tarball_uri() + "\n"
1327
1328 #Portage Tree Sync Type:
1329 settings += "\nPortage Tree Sync Type: " + self._install_profile.get_portage_tree_sync_type() + "\n"
1330 if self._install_profile.get_portage_tree_sync_type() == "snapshot":
1331 settings += " Portage snapshot URI: " + self._install_profile.get_portage_tree_snapshot_uri() + "\n"
1332
1333 #Kernel Settings:
1334 settings += "\nKernel Settings:\n"
1335 settings += " Kernel Sources: " + self._install_profile.get_kernel_source_pkg() + "\n"
1336 if self._install_profile.get_kernel_source_pkg() != "livecd-kernel":
1337 settings += " Kernel Build Method: " + self._install_profile.get_kernel_build_method() + "\n"
1338 if self._install_profile.get_kernel_build_method() == "genkernel":
1339 settings += " Kernel Bootsplash Option: " + str(self._install_profile.get_kernel_bootsplash()) + "\n"
1340 if self._install_profile.get_kernel_config_uri():
1341 settings += " Kernel Configuration URI: " + self._install_profile.get_kernel_config_uri() + "\n"
1342
1343 #Bootloader Settings:
1344 settings += "\nBootloader Settings:\n"
1345 settings += " Bootloader package: " + self._install_profile.get_boot_loader_pkg() + "\n"
1346 if self._install_profile.get_boot_loader_pkg() != "none":
1347 settings += " Install bootloader to MBR: " + str(self._install_profile.get_boot_loader_mbr()) + "\n"
1348 settings += " Bootloader kernel arguments: " +self._install_profile.get_bootloader_kernel_args() + "\n"
1349
1350 #Timezone:
1351 settings += "\nTimezone: " + self._install_profile.get_time_zone() + "\n"
1352
1353 #Networking Settings:
1354 settings += "\nNetworking Settings: \n"
1355 interfaces = self._install_profile.get_network_interfaces()
1356 for iface in interfaces:
1357 if interfaces[iface][0] == 'dhcp':
1358 settings += " " + iface + _(u": Settings: DHCP. Options: ") + interfaces[iface][1] + "\n"
1359 else:
1360 settings += " " + iface + _(u"IP: ") + interfaces[iface][0] + _(u" Broadcast: ") + interfaces[iface][1] + _(u" Netmask: ") + interfaces[iface][2] + "\n"
1361 default_gateway = self._install_profile.get_default_gateway()
1362 if default_gateway:
1363 settings += " Default Gateway: " + default_gateway[0] + "/" + default_gateway[1] + "\n"
1364 settings += " Hostname: " + self._install_profile.get_hostname() + "\n"
1365 if self._install_profile.get_domainname():
1366 settings += " Domainname: " +self._install_profile.get_domainname() + "\n"
1367 if self._install_profile.get_nisdomainname():
1368 settings += " NIS Domainname: " +self._install_profile.get_nisdomainname() + "\n"
1369 if self._install_profile.get_dns_servers():
1370 for dns_server in dns_servers:
1371 settings += " DNS Server: " +dns_server + "\n"
1372 if self._install_profile.get_http_proxy():
1373 settings += " HTTP Proxy: " +self._install_profile.get_http_proxy() + "\n"
1374 if self._install_profile.get_ftp_proxy():
1375 settings += " FTP Proxy: " +self._install_profile.get_ftp_proxy() + "\n"
1376 if self._install_profile.get_rsync_proxy():
1377 settings += " RSYNC Proxy: " +self._install_profile.get_rsync_proxy() + "\n"
1378
1379 #Cron Daemon:
1380 settings += "\nCron Daemon: " + self._install_profile.get_cron_daemon_pkg() + "\n"
1381
1382 #Logger:
1383 settings += "\nLogging Daemon: " + self._install_profile.get_logging_daemon_pkg() + "\n"
1384
1385 #Extra packages:
1386 if self._install_profile.get_install_packages():
1387 install_packages = self._install_profile.get_install_packages()
1388 else:
1389 install_packages = []
1390 settings += "\nExtra Packages: "
1391 for package in install_packages:
1392 settings += package + " "
1393 settings += "\n"
1394 #Services:
1395 if self._install_profile.get_services():
1396 services = self._install_profile.get_services()
1397 else:
1398 services = []
1399 settings += "\nAdditional Services: "
1400 for service in services:
1401 settings += service + " "
1402 settings += "\n"
1403
1404 #Other Configuration Settings (rc.conf):
1405 #Make.conf Settings:
1406 settings += "\nConfiguration Files Settings:\n"
1407 etc_files = self._install_profile.get_etc_files()
1408 for etc_file in etc_files:
1409 settings += " File:" + etc_file + "\n"
1410 if isinstance(etc_files[etc_file], dict):
1411 for name in etc_files[etc_file]:
1412 settings += " Variable: " + name + " Value: " + etc_files[etc_file][name] + "\n"
1413 else:
1414 for entry in etc_files[etc_file]:
1415 settings += " Value: "+ entry + "\n"
1416
1417 #Additional Users:
1418 settings += "\nAdditional Users:\n"
1419 users = {}
1420 for user in self._install_profile.get_users():
1421 users[user[0]] = (user[0], user[1], user[2], user[3], user[4], user[5], user[6])
1422 for user in users:
1423 settings += " Username: " + user
1424 settings += "\n Group Membership: " + users[user][2]
1425 settings += "\n Shell: " + users[user][3]
1426 settings += "\n Home Directory: " + users[user][4]
1427 if users[user][5]:
1428 settings += "\n User Id: " + users[user][5]
1429 if users[user][6]:
1430 settings += "\n User Comment: " + users[user][6]
1431
1432 self._d.scrollbox(settings, height=20, width=77, title=_(u"A Review of your settings"))

Properties

Name Value
svn:eol-style native

  ViewVC Help
Powered by ViewVC 1.1.20