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

Contents of /trunk/src/GLIGenDialog.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 738 - (show annotations) (download) (as text)
Thu Jul 7 06:30:50 2005 UTC (13 years ago) by codeman
File MIME type: text/x-python
File size: 73932 byte(s)
  fix global USE flags to not include the arch types at the end.
  updates to GenDialog and gli-d.

fixed more heights/widths. fixed missing use_local_desc in set_make_conf

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"""
73 The installer logs all important events during the install process to a logfile for debugging purposes.
74 The file gets copied to the new system once the install is complete.
75 Enter the desired filename and path for the install log (the default is recommended):""")
76 initval = self._client_profile.get_log_file()
77 code, logfile = self._d.inputbox(string, init=initval, width=60, height=15)
78 if code == self._DLG_OK:
79
80 self._client_profile.set_log_file(None, logfile, None)
81
82 def set_root_mount_point(self):
83 #If not advanced, the default will suffice.
84 if self.advanced_mode:
85 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.")
86 initval = self._client_profile.get_root_mount_point()
87 code, rootmountpoint = self._d.inputbox(string, init=initval, width=60, height=11)
88 if code == self._DLG_OK:
89 self._client_profile.set_root_mount_point(None, rootmountpoint, None)
90
91 def set_client_networking(self):
92 if GLIUtility.ping("www.gentoo.org") and not self.advanced_mode: #If an active connection exists, ignore this step if standard mode
93 return
94 if self.local_install:
95 device_list = GLIUtility.get_eth_devices()
96 else:
97 device_list = []
98 choice_list = []
99 for device in device_list:
100 choice_list.append((device, GLIUtility.get_interface_realname(device)))
101 choice_list.append(("Other",_(u"Type your own.")))
102 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.")
103 code, interface = self._d.menu(string1, width=75, height=20, choices=choice_list)
104 if code != self._DLG_OK:
105 return
106 if interface == "Other":
107 code, interface = self._d.inputbox(_(u"Enter the interface (NIC) you would like to use for installation (e.g. eth0):"))
108 if code != self._DLG_OK:
109 return
110
111 #Not sure if I can get rid of these yet.
112 #network_type = ""
113 #ip_address = ""
114 #broadcast = ""
115 #netmask = ""
116 #gateway = ""
117 dhcp_options = ""
118
119 #Change the Yes/No buttons to new labels for this question.
120 self._d.add_persistent_args(["--yes-label", _(u"DHCP")])
121 self._d.add_persistent_args(["--no-label", _(u"Static IP/Manual")])
122 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:")
123 if self._d.yesno(string2, height=15, width=60) == self._DLG_YES: #DHCP
124 network_type = 'dhcp'
125 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)
126 else:
127 network_type = 'static'
128 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')))
129 (ip_address, broadcast, netmask, gateway, dnsservers) = data[:-1].split('\n')
130 if code != self._DLG_OK:
131 return
132 #Set the info now that it's all gathered.
133 try:
134 self._client_profile.set_network_type(None, network_type, None)
135 self._client_profile.set_network_interface(None, interface, None)
136 if not network_type == 'dhcp':
137 self._client_profile.set_network_ip(None, ip_address, None)
138 self._client_profile.set_network_broadcast(None, broadcast, None)
139 self._client_profile.set_network_netmask(None, netmask, None)
140 self._client_profile.set_network_gateway(None, gateway, None)
141 self._client_profile.set_dns_servers(None, dnsservers, None)
142 else:
143 if dhcp_options:
144 self._client_profile.set_network_dhcp_options(None, dhcp_options, None)
145 except:
146 self._d.msgbox(_(u"ERROR! Could not set networking information!"))
147
148 def set_enable_ssh(self):
149 #Change the Yes/No buttons back.
150 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
151 self._d.add_persistent_args(["--no-label", _(u"No")])
152 if self.advanced_mode:
153 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:
154 self._client_profile.set_enable_ssh(None, True, None)
155 else:
156 self._client_profile.set_enable_ssh(None, False, None)
157
158 def set_livecd_password(self):
159 # The root password will be set here only if in advanced mode. Otherwise it is auto-scrambled.
160 if self.advanced_mode:
161 match = False;
162 while not match:
163 string = _(u"""If you want to be able to login to your machine from another console during the installation,
164 you will want to enter a new root password for the LIVECD.
165 Note that this can be different from your new system's root password.
166 Presss Enter twice to skip this step.
167 Enter the new LIVECD root password: """)
168 code, passwd1 = self._d.passwordbox(string, width=60, height=16)
169 if code != self._DLG_OK:
170 return
171 code, passwd2 = self._d.passwordbox(_(u"Enter the new LIVECD root password again to verify:"))
172 if code != self._DLG_OK:
173 return
174 if passwd1 != passwd2:
175 self._d.msgbox(_(u"The passwords do not match. Please try again."))
176 return
177 else:
178 match = True;
179 if passwd1 != "": #don't want to hash an empty password.
180 try:
181 self._client_profile.set_root_passwd(None, GLIUtility.hash_password(passwd1), None)
182 except:
183 d.msgbox(_(u"ERROR! Could not set the root password on the LiveCD!"))
184 self._d.msgbox(_(u"Password saved. Press Enter to continue."))
185
186 def set_client_kernel_modules(self):
187 if self.advanced_mode:
188 status, output = GLIUtility.spawn("lsmod", return_output=True)
189 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")
190 self._d.add_persistent_args(["--exit-label", _(u"Continue")])
191 self._d.scrollbox(string1+output, height=20, width=70, title=_(u"Loaded Modules"))
192 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.")
193 code, kernel_modules_list = self._d.inputbox(string2, init="", width=60, height=12)
194 if code == self._DLG_OK:
195 try:
196 self._client_profile.set_kernel_modules(None, kernel_modules_list, None)
197 except:
198 d.msgbox(_(u"ERROR! Could not set the list of kernel modules!"))
199
200 def save_client_profile(self, xmlfilename="", askforfilename=True):
201 code = 0
202 filename = xmlfilename
203 if askforfilename:
204 code, filename = self._d.inputbox(_(u"Enter a filename for the XML file"), init=xmlfilename)
205 if code != self._DLG_OK or not filename:
206 return
207 if GLIUtility.is_file(filename):
208 #Change the Yes/No buttons back.
209 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
210 self._d.add_persistent_args(["--no-label", _(u"No")])
211 if not self._d.yesno(_(u"The file %s already exists. Do you want to overwrite it?") % filename) == self._DLG_YES:
212 return
213 configuration = open(filename ,"w")
214 configuration.write(self._client_profile.serialize())
215 configuration.close()
216
217 class GLIGenIP(GLIGen):
218 def __init__(self, client_profile, install_profile, local_install=True, advanced_mode=True):
219 GLIGen.__init__(self)
220 self._client_profile = client_profile
221 self._install_profile = install_profile
222 self.local_install = local_install
223 self.advanced_mode = advanced_mode
224 self._fn = (
225 { 'text': "Partitioning", 'fn': self._set_partitions },
226 { 'text': "Network mounts", 'fn': self._set_network_mounts },
227 { 'text': "Install Stage", 'fn': self._set_install_stage },
228 { 'text': "Portage Tree", 'fn': self._set_portage_tree },
229 { 'text': "make.conf", 'fn': self._set_make_conf },
230 { 'text': "Kernel", 'fn': self._set_kernel },
231 { 'text': "Bootloader", 'fn': self._set_boot_loader },
232 { 'text': "Timezone", 'fn': self._set_timezone },
233 { 'text': "Networking", 'fn': self._set_networking },
234 { 'text': "Cron daemon", 'fn': self._set_cron_daemon },
235 { 'text': "Logging daemon", 'fn': self._set_logger },
236 { 'text': "Extra packages", 'fn': self._set_extra_packages },
237 { 'text': "Services", 'fn': self._set_services },
238 { 'text': "rc.conf", 'fn': self._set_rc_conf },
239 { 'text': "Root password", 'fn': self._set_root_password },
240 { 'text': "Additional Users", 'fn': self._set_additional_users })
241 self._menu_list = []
242 for item in self._fn:
243 self._menu_list.append(item['text'])
244 current_item = 0
245 while 1:
246 code, menuitem = self._d.menu("Choose an option", choices=self._dmenu_list_to_choices(self._menu_list), default_item=str(current_item), height=23, menu_height=17, cancel="Done")
247 if code != self._DLG_OK:
248 break
249 current_item = int(menuitem)
250 menuitem = self._menu_list[int(menuitem)-1]
251 for item in self._fn:
252 if menuitem == item['text']:
253 item['fn']()
254 current_item += 1
255
256 def serialize(self):
257 return self._install_profile.serialize()
258 #---------------------------------------
259 #Functions to generate a install profile
260 #---------------------------------------
261 def _set_timezone(self):
262 # This section will be for setting the timezone.
263 zonepath = "/usr/share/zoneinfo"
264 skiplist = ["zone.tab","iso3166.tab","posixrules"]
265 while 1:
266 tzlist = []
267 for entry in os.listdir(zonepath):
268 if entry not in skiplist:
269 if os.path.isdir(zonepath + "/" + entry): entry += "/"
270 tzlist.append(entry)
271 tzlist.sort()
272 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.")
273 code, tznum = self._d.menu(string, choices=self._dmenu_list_to_choices(tzlist), height=20, cancel="Back")
274 if code == self._DLG_OK:
275 zonepath = os.path.join(zonepath,tzlist[int(tznum)-1])
276 if tzlist[int(tznum)-1][-1:] != "/":
277 break
278 else:
279 if zonepath == "/usr/share/zoneinfo":
280 return
281 slashloc = zonepath[:-1].rfind("/")
282 zonepath = zonepath[:slashloc]
283 try:
284 self._install_profile.set_time_zone(None, zonepath[20:], None)
285 except:
286 self._d.msgbox(_(u"ERROR: Could not set that timezone!"))
287
288 def _set_portage_tree(self):
289 # This section will ask whether to sync the tree, whether to use a snapshot, etc.
290 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"))]
291 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)
292 if code != self._DLG_OK:
293 return
294 #portage_tree_sync = menulist[int(portage_tree_sync)-1]
295 #FIX ME when python 2.4 comes out.
296 #if portage_tree_sync == "Normal 'emerge sync'":
297 # self._install_profile.set_portage_tree_sync_type(None, "sync", None)
298 #if portage_tree_sync == "Webrsync (rsync is firewalled)":
299 # self._install_profile.set_portage_tree_sync_type(None, "webrsync", None)
300 #if portage_tree_sync == "None (NFS mount)":
301 # self._install_profile.set_portage_tree_sync_type(None, "none", None)
302 #if portage_tree_sync == "Snapshot (using a portage snapshot)":
303 # self._install_profile.set_portage_tree_sync_type(None, "snapshot", None)
304 self._install_profile.set_portage_tree_sync_type(None, portage_tree_sync.lower(), None)
305 if portage_tree_sync.lower() == "Snapshot":
306 snapshot_options = (_(u"Use Local"), _(u"Specify URI"))
307 code, snapshot_option = self._d.menu(_(u"Select a local portage snapshot or manually specify a location:"), choices=self._dmenu_list_to_choices(snapshot_options))
308 snapshot_option = snapshot_options[int(snapshot_option)-1]
309 if snapshot_option == _(u"Use Local"):
310 snapshot_dir = "/mnt/cdrom/snapshots"
311 if os.path.isdir(snapshot_dir) and os.listdir(snapshot_dir):
312 local_snapshots = glob.glob(snapshot_dir + "/portage*.bz2")
313 if len(local_snapshots) == 1:
314 snapshot = local_snapshots[0]
315 else:
316 local_snapshots.sort()
317 code, snapshot = self._d.menu(_(u"Select a local portage snapshot:"), choices=self._dmenu_list_to_choices(local_snapshots))
318 if code != self._DLG_OK: return
319 snapshot = local_snapshots[int(snapshot)-1]
320 else:
321 self._d.msgbox(_(u"There don't seem to be any local portage snapshots available. Hit OK to manually specify a URI."))
322 snapshot_option = _(u"Specify URI")
323 if snapshot_option != _(u"Use Local"):
324 code, snapshot = self._d.inputbox(_(u"Enter portage tree snapshot URI"), init=self._install_profile.get_portage_tree_snapshot_uri())
325 if code == self._DLG_OK:
326 if snapshot:
327 if not GLIUtility.is_uri(snapshot, checklocal=self.local_install):
328 self._d.msgbox(_(u"The specified URI is invalid. It was not saved. Please go back and try again."))
329 else:
330 self._install_profile.set_portage_tree_snapshot_uri(None, snapshot, None)
331
332 else:
333 self._d.msgbox(_(u"No URI was specified! Returning to default emerge sync."))
334 #if d.yesno("The specified URI is invalid. Use it anyway?") == DLG_YES: install_profile.set_stage_tarball_uri(None, stage_tarball, None)
335
336 def _set_partitions(self):
337 string1 = _("""The first thing on the new system to setup is the partitoning on the new system.
338 You will first select a drive and then edit its partitions.
339 No changes will be saved until the end of the step.
340 No changes to your disk will be made until the installation.
341 NOTE: YOU MUST AT LEAST SELECT ONE PARTITION AS YOUR ROOT PARTITION "/"
342 If your drive is pre-partitioned, just select the mountpoints and make
343 sure that the format option is set to FALSE or it will erase your data.
344 The installer does not yet support resizing of partitions (its not safe).
345 Please refer to the Gentoo Installation Handbook for more information
346 on partitioning and the various filesystem types available in Linux.""")
347 self._d.msgbox(string1, height=17, width=78)
348 devices = self._install_profile.get_partition_tables()
349 drives = devices.keys()
350 drives.sort()
351 choice_list = []
352 if not devices:
353 tmp_drives = GLIStorageDevice.detect_devices()
354 tmp_drives.sort()
355 for drive in tmp_drives:
356 devices[drive] = GLIStorageDevice.Device(drive)
357 #if self.local_install: #when uncommenting please indent the next line.
358 devices[drive].set_partitions_from_disk()
359 drives.append(drive)
360 choice_list.append((drive, devices[drive].get_model()))
361 #choice_list.append(("Other", "Type your own drive name)) # I DONT THINK GLISD CAN DO NONEXISTANT DRIVES
362 while 1:
363 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"))
364 if code != self._DLG_OK: break
365 while 1:
366 partitions = devices[drive_to_partition].get_partitions()
367 partlist = devices[drive_to_partition].get_ordered_partition_list()
368 tmpparts = devices[drive_to_partition].get_partitions()
369 partsmenu = []
370 for part in partlist:
371 tmppart = tmpparts[part]
372 entry = ""
373 if tmppart.get_type() == "free":
374 #partschoice = "New"
375 entry = _(u" - Unallocated space (")
376 if tmppart.is_logical():
377 entry += _(u"logical, ")
378 entry += str(tmppart.get_mb()) + "MB)"
379 elif tmppart.get_type() == "extended":
380 entry = str(int(tmppart.get_minor()))
381 entry += _(u" - Extended Partition (") + str(tmppart.get_mb()) + "MB)"
382 else:
383 entry = str(int(tmppart.get_minor())) + " - "
384 # Type: " + tmppart.get_type() + ", Mountpoint: " + tmppart.get_mountpoint() + ", Mountopts: " + tmppart.get_mountopts() + "("
385 if tmppart.is_logical():
386 entry += _(u"Logical (")
387 else:
388 entry += _(u"Primary (")
389 entry += tmppart.get_type() + ", "
390 entry += (tmppart.get_mkfsopts() or "none") + ", "
391 entry += (tmppart.get_mountpoint() or "none") + ", "
392 entry += (tmppart.get_mountopts() or "none") + ", "
393 entry += str(tmppart.get_mb()) + "MB)"
394 partsmenu.append(entry)
395 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"))
396 if code != self._DLG_OK: break
397 part_to_edit = partlist[int(part_to_edit)-1]
398 tmppart = tmpparts[part_to_edit]
399 if tmppart.get_type() == "free":
400 # partition size first
401 free_mb = tmppart.get_mb()
402 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))
403 if code != self._DLG_OK: continue
404 if int(new_mb) > free_mb:
405 self._d.msgbox(_(u"The size you entered (%s MB) is larger than the maximum of %s MB") % (new_mb, str(free_mb)))
406 continue
407 # partition type
408 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."))]
409 code, type = self._d.menu(_(u"Choose the filesystem type for this new partition."), height=20, width=77, choices=part_types)
410 if code != self._DLG_OK: continue
411
412 # 'other' partition type
413 if type == "other":
414 code, type = self._d.inputbox(_(u"Please enter the new partition's type:"))
415 if code != self._DLG_OK: continue
416
417 # now add it to the data structure
418 devices[drive_to_partition].add_partition(part_to_edit, int(new_mb), 0, 0, type)
419 else:
420 while 1:
421 tmppart = tmpparts[part_to_edit]
422 tmptitle = drive_to_partition + str(part_to_edit) + " - "
423 if tmppart.is_logical():
424 tmptitle += _(u"Logical (")
425 else:
426 tmptitle += _(u"Primary (")
427 tmptitle += tmppart.get_type() + ", "
428 tmptitle += (tmppart.get_mkfsopts() or "none") + ", "
429 tmptitle += (tmppart.get_mountpoint() or "none") + ", "
430 tmptitle += (tmppart.get_mountopts() or "none") + ", "
431 tmptitle += str(tmppart.get_mb()) + "MB)"
432 menulist = [_(u"Delete"), _(u"Mount Point"), _(u"Mount Options"), _(u"Format"), _(u"Extra mkfs.* Parameters")]
433 code, part_action = self._d.menu(tmptitle, choices=self._dmenu_list_to_choices(menulist), cancel=_(u"Back"))
434 if code != self._DLG_OK: break
435 part_action = menulist[int(part_action)-1]
436 if part_action == _(u"Delete"):
437 answer = (self._d.yesno(_(u"Are you sure you want to delete the partition ") + drive_to_partition + str(part_to_edit) + "?") == self._DLG_YES)
438 if answer == True:
439 tmpdev = tmppart.get_device()
440 tmpdev.remove_partition(part_to_edit)
441 break
442 elif part_action == _(u"Mount Point"):
443 code, answer = self._d.inputbox(_(u"Enter a mountpoint for partition ") + str(part_to_edit), init=tmppart.get_mountpoint())
444 if code == self._DLG_OK: tmppart.set_mountpoint(answer)
445 elif part_action == _(u"Mount Options"):
446 code, answer = self._d.inputbox(_(u"Enter your mount options for partition ") + str(part_to_edit), init=(tmppart.get_mountopts() or "defaults"))
447 if code == self._DLG_OK: tmppart.set_mountopts(answer)
448 elif part_action == _(u"Format"):
449 #Change the Yes/No buttons back.
450 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
451 self._d.add_persistent_args(["--no-label", _(u"No")])
452 code = self._d.yesno(_(u"Do you want to format this partition?"))
453 if code == self._DLG_YES:
454 tmppart.set_format(True)
455 else:
456 tmppart.set_format(False)
457 elif part_action == _(u"Extra mkfs.* Parameters"):
458 new_mkfsopts = tmppart.get_mkfsopts()
459 # extra mkfs options
460 if tmppart.get_type() != "extended":
461 code, new_mkfsopts = self._d.inputbox(_(u"Extra mkfs.* Parameters"), init=new_mkfsopts)
462 if code == self._DLG_OK: tmppart.set_mkfsopts(new_mkfsopts)
463 try:
464 self._install_profile.set_partition_tables(devices)
465 except:
466 self._d.msgbox(_(u"ERROR: The partition tables could not be set correctly!"))
467
468 def _set_network_mounts(self):
469 # This is where any NFS mounts will be specified
470 network_mounts = copy.deepcopy(self._install_profile.get_network_mounts())
471 while 1:
472 menulist = []
473 for mount in network_mounts:
474 menulist.append(mount['host'] + ":" + mount['export'])
475 menulist.append(_(u"Add a new network mount"))
476 choices = self._dmenu_list_to_choices(menulist)
477 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)
478 if code == self._DLG_CANCEL:
479 try:
480 self._install_profile.set_network_mounts(network_mounts)
481 except:
482 self._d.msgbox(_(u"ERROR: Could net set network mounts!"))
483 break
484 menuitem = menulist[int(menuitemidx)-1]
485 if menuitem == _(u"Add a new network mount"):
486 code, nfsmount = self._d.inputbox(_(u"Enter NFS mount or just enter the IP/hostname to search for available mounts"), height=13, width=50)
487 if code != self._DLG_OK:
488 continue
489 if not GLIUtility.is_nfs(nfsmount):
490 if GLIUtility.is_ip(nfsmount) or GLIUtility.is_hostname(nfsmount):
491 status, remotemounts = GLIUtility.spawn("/usr/sbin/showmount -e " + nfsmount + " 2>&1 | egrep '^/' | cut -d ' ' -f 1 && echo", return_output=True)
492 if not len(remotemounts):
493 self._d.msgbox(_(u"No NFS exports were detected on ") + nfsmount)
494 continue
495 for i in range(0, len(remotemounts)):
496 remotemounts[i] = string.strip(remotemounts[i])
497 code, nfsmount2 = self._d.menu(_(u"Select a NFS export"), choices=self._dmenu_list_to_choices(remotemounts), cancel=_(u"Back"))
498 if code != self._DLG_OK:
499 continue
500 nfsmount2 = remotemounts[int(nfsmount2)-1]
501 else:
502 self._d.msgbox(_(u"The address you entered, %s, is not a valid IP or hostname. Please try again.") % nfsmount)
503 continue
504 else:
505 colon_location = nfsmount.find(':')
506 menuitem = nfsmount
507 nfsmount = menuitem[:colon_location]
508 nfsmount2 = menuitem[colon_location+1:]
509 for mount in network_mounts:
510 if nfsmount == mount['host'] and nfsmount2 == mount['export']:
511 self._d.msgbox(_(u"There is already an entry for ") + nfsmount + ":" + nfsmount2 + ".")
512 nfsmount = None
513 break
514 if nfsmount == None:
515 continue
516 network_mounts.append({'export': nfsmount2, 'host': nfsmount, 'mountopts': '', 'mountpoint': '', 'type': 'nfs'})
517 menuitem = nfsmount + ":" + nfsmount2
518 menuitemidx = len(network_mounts)
519
520 if menuitem.find(':') != -1:
521 colon_location = menuitem.find(':')
522 tmpmount = network_mounts[int(menuitemidx)-1]
523 code, mountpoint = self._d.inputbox(_(u"Enter a mountpoint"), init=tmpmount['mountpoint'])
524 if code == self._DLG_OK:
525 tmpmount['mountpoint'] = mountpoint
526 code, mountopts = self._d.inputbox(_(u"Enter mount options"), init=tmpmount['mountopts'])
527 if code == self._DLG_OK:
528 tmpmount['mountopts'] = mountopts
529 network_mounts[int(menuitemidx)-1] = tmpmount
530
531 def _set_make_conf(self):
532 # This section will be for setting things like CFLAGS, ACCEPT_KEYWORDS, and USE
533 make_conf = self._install_profile.get_make_conf()
534
535 self._d.msgbox(_(u"""The installer will now gather information regarding the contents of /etc/make.conf
536 One of the unique (and best) features of Gentoo is the ability to
537 define flags (called USE flags) that define what components are
538 compiled into applications. For example, you can enable the alsa
539 flag and programs that have alsa capability will use it.
540 The result is a finely tuned OS with no unnecessary components to
541 slow you down.
542 The installer divides USE flag selection into two screens, one for
543 global USE flags and one for local flags specific to each program.
544 Please be patient while the screens load. It may take awhile."""), width=73, height=16)
545
546 #Second set the USE flags, this is a biggie.
547 system_use_flags = GLIUtility.spawn("portageq envvar USE", return_output=True)[1].strip().split()
548 use_flags = []
549 use_local_flags = []
550 use_desc = GLIUtility.get_global_use_flags()
551 use_local_desc = GLIUtility.get_local_use_flags()
552
553 #populate the choices list
554 sorted_use = use_desc.keys()
555 sorted_use.sort()
556 for flagname in sorted_use:
557 use_flags.append((flagname, use_desc[flagname], int(flagname in system_use_flags)))
558 #present the menu
559 code, use_flags = self._d.checklist(_(u"Choose which *global* USE flags you want on the new system"), height=25, width=80,list_height=19, choices=use_flags)
560
561 #populate the chocies list
562 sorted_use = use_local_desc.keys()
563 sorted_use.sort()
564 for flagname in sorted_use:
565 use_local_flags.append((flagname, use_local_desc[flagname], int(flagname in system_use_flags)))
566 #present the menu
567 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=19, choices=use_local_flags)
568 temp_use = "-* "
569 for flag in use_flags:
570 temp_use += flag + " "
571 for flag in use_local_flags:
572 temp_use += flag + " "
573 make_conf["USE"] = temp_use
574
575 #Second, set the ACCEPT_KEYWORDS
576 #Change the Yes/No buttons to new labels for this question.
577 self._d.add_persistent_args(["--yes-label", _(u"Stable")])
578 self._d.add_persistent_args(["--no-label", _(u"Unstable")])
579 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=13, width=55) == self._DLG_YES:
580 #Stable
581 make_conf["ACCEPT_KEYWORDS"] = ""
582 else: #Unstable
583 make_conf["ACCEPT_KEYWORDS"] = "~" + self._client_profile.get_architecture_template()
584 #Third, misc. stuff.
585 while not self.advanced_mode:
586 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. (ex. CPUs+1)")), ("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."))]
587 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"))
588 if code != self._DLG_OK:
589 self._install_profile.set_make_conf(make_conf)
590 break
591 oldval = ""
592 if make_conf.has_key(menuitem):
593 oldval = make_conf[menuitem]
594 code, newval = self._d.inputbox(_(u"Enter new value for ") + menuitem, init=oldval)
595 if code == self._DLG_OK:
596 make_conf[menuitem] = newval
597
598
599 def _set_kernel(self):
600 # This section will be for choosing kernel sources, choosing (and specifying) a custom config or genkernel, modules to load at startup, etc.
601 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"Use the current running kernel for the new system (fastest)")), (_(u"Other"), _(u"Choose one of the other sources available."))]
602 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)
603 if code != self._DLG_OK:
604 return
605 if menuitem == _(u"Other"):
606 code, menuitem = self._d.inputbox(_(u"Please enter the desired kernel sources package name:"))
607 if code != self._DLG_OK: return
608 try:
609 self._install_profile.set_kernel_source_pkg(None, menuitem, None)
610 except:
611 self._d.msgbox(_(u"ERROR! Could not set the kernel source package!"))
612 if not menuitem == "livecd-kernel":
613 #Change the Yes/No buttons to new labels for this question.
614 self._d.add_persistent_args(["--yes-label", _(u"Genkernel")])
615 self._d.add_persistent_args(["--no-label", _(u"Traditional (requires config file!)")])
616 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.")
617 if self._d.yesno(string1, width=70, height=13) == self._DLG_YES: #Genkernel
618 self._install_profile.set_kernel_build_method(None,"genkernel", None)
619 if self.advanced_mode:
620 #Change the Yes/No buttons back.
621 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
622 self._d.add_persistent_args(["--no-label", _(u"No")])
623 if self._d.yesno(_(u"Do you want the bootsplash screen to show up on bootup?")) == self._DLG_YES:
624 self._install_profile.set_kernel_bootsplash(None, True, None)
625 else:
626 self._install_profile.set_kernel_bootsplash(None, False, None)
627 else: #Custom
628 self._install_profile.set_kernel_build_method(None,"custom", None)
629 if self.advanced_mode:
630 code, custom_kernel_uri = self._d.inputbox(_(u"If you have a custom kernel configuration, enter its location (otherwise just press Enter to continue):"))
631 if code == self._DLG_OK:
632 if custom_kernel_uri:
633 if not GLIUtility.is_uri(custom_kernel_uri, checklocal=self.local_install):
634 self._d.msgbox(_(u"The specified URI is invalid. It was not saved. Please go back and try again."))
635 else:
636 try:
637 self._install_profile.set_kernel_config_uri(None, custom_kernel_uri, None)
638 except:
639 self._d.msgbox(_(u"ERROR! Could not set the kernel config URI!"))
640 #else: self._d.msgbox(_(u"No URI was specified! Reverting to using genkernel"))
641
642
643
644 def _set_install_stage(self):
645 # The install stage and stage tarball will be selected here
646 install_stages = (("1",_(u"Stage1 is used when you want to bootstrap&build from scratch.")),
647 ("2",_(u"Stage2 is used for building from a bootstrapped semi-compiled state.")),
648 ("3",_(u"Stage3 is a basic system that has been built for you (no compiling).")),
649 ("3+GRP", _(u"A Stage3 install but using binaries from the LiveCD when able.")))
650 code, install_stage = self._d.menu(_(u"Which stage do you want to start at?"), choices=install_stages, cancel=_(u"Back"), width=78)
651 if code == self._DLG_OK:
652 if install_stage == "3+GRP":
653 install_stage = "3"
654 try:
655 self._install_profile.set_grp_install(None, True, None)
656 self._install_profile.set_install_stage(None, install_stage, None)
657 except:
658 self._d.msgbox(_(u"ERROR! Could not set install stage!"))
659 #Change the Yes/No buttons to new labels for this question.
660 self._d.add_persistent_args(["--yes-label", _(u"Use Local")])
661 self._d.add_persistent_args(["--no-label", _(u"Specify URI")])
662 if self._d.yesno(_(u"Do you want to use a local tarball on the LiveCD (or other local location) or do you want to grab your stage tarball from the Internet?")) == self._DLG_YES:
663 #Use Local
664 stages_dir = "/mnt/cdrom/stages"
665 if os.path.isdir(stages_dir) and os.listdir(stages_dir):
666 local_tarballs = glob.glob(stages_dir + "/stage" + install_stage + "*.bz2")
667 local_tarballs.sort()
668 code, stage_tarball = self._d.menu(_(u"Select a local tarball:"), choices=self._dmenu_list_to_choices(local_tarballs))
669 if code != self._DLG_OK:
670 return
671 stage_tarball = local_tarballs[int(stage_tarball)-1]
672 try:
673 self._install_profile.set_stage_tarball_uri(None, stage_tarball, None)
674 except:
675 self._d.msgbox(_(u"ERROR: Could not set the stage tarball URI!"))
676 return
677 else:
678 self._d.msgbox(_(u"There don't seem to be any local tarballs available. Hit OK to manually specify a URI."))
679
680 #Specify URI
681 #subarches = { 'x86': ("x86", "i686", "pentium3", "pentium4", "athlon-xp"), 'hppa': ("hppa1.1", "hppa2.0"), 'ppc': ("g3", "g4", "g5", "ppc"), 'sparc': ("sparc32", "sparc64")}
682 type_it_in = False
683 stage_tarball = ""
684 if GLIUtility.ping("www.gentoo.org"): #Test for network connectivity
685 mirrors = GLIUtility.list_mirrors()
686 mirrornames = []
687 mirrorurls = []
688 for item in mirrors:
689 mirrornames.append(item[1])
690 mirrorurls.append(item[0])
691 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)
692 if code != self._DLG_OK:
693 type_it_in = True
694 else:
695 mirror = mirrorurls[int(mirror)-1]
696 arch = self._client_profile.get_architecture_template()
697 subarches = GLIUtility.list_subarch_from_mirror(mirror,arch)
698 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))
699 if code != self._DLG_OK:
700 type_it_in = True
701 else:
702 subarch = subarches[int(subarch)-1]
703 tarballs = GLIUtility.list_stage_tarballs_from_mirror(mirror, arch, subarch)
704 code, stage_tarball = self._d.menu(_(u"Select your desired stage tarball:"), choices=self._dmenu_list_to_choices(tarballs))
705 if (code != self._DLG_OK):
706 type_it_in = True
707 else:
708 stage_tarball = mirror + "/releases/" + arch + "/current/stages/" + subarch + tarballs[int(stage_tarball)-1]
709 #get portageq envvar value of cflags and look for x86, i686,etc.
710 #URL SYNTAX
711 #http://gentoo.osuosl.org/releases/ARCHITECTURE/current/stages/SUB-ARCH/
712 else:
713 type_it_in = True
714 if type_it_in:
715 code, stage_tarball = self._d.inputbox(_(u"Specify the stage tarball URI or local file:"), init=self._install_profile.get_stage_tarball_uri())
716 if code != self._DLG_OK:
717 return
718 #If Doing a local install, check for valid file:/// uri
719 if stage_tarball:
720 if not GLIUtility.is_uri(stage_tarball, checklocal=self.local_install):
721 self._d.msgbox(_(u"The specified URI is invalid. It was not saved. Please go back and try again."));
722 else: self._install_profile.set_stage_tarball_uri(None, stage_tarball, None)
723 else: self._d.msgbox(_(u"No URI was specified!"))
724 #if d.yesno("The specified URI is invalid. Use it anyway?") == DLG_YES: install_profile.set_stage_tarball_uri(None, stage_tarball, None)
725
726 def _set_boot_loader(self):
727 arch = self._client_profile.get_architecture_template()
728 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
729 boot_loaders = arch_loaders[arch]
730 boot_loaders.append(("none", _(u"Do not install a bootloader. (System may be unbootable!)")))
731 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")
732 code, menuitem = self._d.menu(string1, choices=boot_loaders)
733 if code != self._DLG_OK:
734 return
735 try:
736 self._install_profile.set_boot_loader_pkg(None, menuitem, None)
737 except:
738 self._d.msgbox(_(u"ERROR! Could not set boot loader pkg! ")+menuitem)
739 if menuitem != "none" and self.advanced_mode:
740 #Reset the Yes/No labels.
741 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
742 self._d.add_persistent_args(["--no-label",_(u"No")])
743 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)")) == self._DLG_YES:
744 self._install_profile.set_boot_loader_mbr(None, True, None)
745 else:
746 self._install_profile.set_boot_loader_mbr(None, False, None)
747 if self.advanced_mode:
748 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:"))
749 if code == self._DLG_OK:
750 try:
751 self._install_profile.set_bootloader_kernel_args(None, bootloader_kernel_args, None)
752 except:
753 self._d.msgbox(_(u"ERROR! Could not set bootloader kernel arguments! ")+bootloader_kernel_args)
754
755 def _set_networking(self):
756 # This section will be for setting up network interfaces
757 interfaces = self._install_profile.get_network_interfaces()
758 CC_iface = self._client_profile.get_network_interface()
759 if CC_iface and (CC_iface not in interfaces):
760 #The CC has a network config that's not already there. Preload it.
761 CC_net_type = self._client_profile.get_network_type()
762 if CC_net_type == 'dhcp':
763 try:
764 interfaces[CC_iface] = ('dhcp', self._client_profile.get_network_dhcp_options(), None)
765 except:
766 pass
767 else:
768 try:
769 interfaces[CC_iface] = (self._client_profile.get_network_ip(), self._client_profile.get_network_broadcast(), self._client_profile.get_network_netmask())
770 except:
771 pass
772
773 while 1:
774 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.")
775 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:")
776 choice_list = []
777 for iface in interfaces:
778 if interfaces[iface][0] == 'dhcp':
779 choice_list.append((iface, _(u"Settings: DHCP. Options: ")+ interfaces[iface][1]))
780 else:
781 choice_list.append((iface, _(u"IP: ")+interfaces[iface][0]+_(u" Broadcast: ")+interfaces[iface][1]+" Netmask: "+interfaces[iface][2]))
782 choice_list.append(("Add",_(u"Add a new network interface")))
783 code, iface_choice = self._d.menu(string1, choices=choice_list, cancel=_(u"Save and Continue"), height=18, width=67)
784 if code != self._DLG_OK:
785 try:
786 self._install_profile.set_network_interfaces(interfaces)
787 except:
788 self_d.msgbox(_(u"ERROR! Could not set the network interfaces!"))
789 break #This should hopefully move the user down to part two of set_networking
790 if iface_choice == "Add":
791 if self.local_install:
792 device_list = GLIUtility.get_eth_devices()
793 newchoice_list = []
794 for device in device_list:
795 if device not in interfaces:
796 newchoice_list.append((device, GLIUtility.get_interface_realname(device)))
797 newchoice_list.append((_(u"Other"),_(u"Type your own.")))
798 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)
799 else:
800 newnic == _(u"Other")
801 if newnic == _(u"Other"):
802 code, newnic = self._d.inputbox(_(u"Enter name for new interface (eth0, ppp0, etc.)"))
803 if code != self._DLG_OK:
804 continue
805 if newnic in interfaces:
806 self._d.msgbox(_(u"An interface with the name is already defined."))
807 continue
808 #create the interface in the data structure.
809 #interfaces[newnic] = ("", "", "")
810 #Change the Yes/No buttons to new labels for this question.
811 self._d.add_persistent_args(["--yes-label", _(u"DHCP")])
812 self._d.add_persistent_args(["--no-label", _(u"Static IP/Manual")])
813 if self._d.yesno(string2, height=15, width=60) == self._DLG_YES: #DHCP
814 dhcp_options = ""
815 if self.advanced_mode:
816 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)
817 interfaces[newnic] = ('dhcp', dhcp_options, None)
818 else:
819 network_type = 'static'
820 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')))
821 (ip_address, broadcast, netmask) = data[:-1].split('\n')
822 if code != self._DLG_OK:
823 continue
824 #Set the info now that it's all gathered.
825 interfaces[newnic] = (ip_address, broadcast, netmask)
826 else: #they have chosen an interface, present them with edit/delete
827 #Change the Yes/No buttons to new labels for this question.
828 self._d.add_persistent_args(["--yes-label", _(u"Edit")])
829 self._d.add_persistent_args(["--no-label", _(u"Delete")])
830 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:
831 #Edit
832 #Change the Yes/No buttons to new labels for this question.
833 self._d.add_persistent_args(["--yes-label", _(u"DHCP")])
834 self._d.add_persistent_args(["--no-label", _(u"Static IP/Manual")])
835 if self._d.yesno(string2, height=15, width=60) == self._DLG_YES: #DHCP
836 dhcp_options = ""
837 if self.advanced_mode:
838 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)
839 interfaces[iface_choice] = ('dhcp', dhcp_options, None)
840 else:
841 network_type = 'static'
842 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])))
843 (ip_address, broadcast, netmask) = data[:-1].split('\n')
844 if code != self._DLG_OK:
845 continue
846 #Set the info now that it's all gathered.
847 interfaces[iface_choice] = (ip_address, broadcast, netmask)
848 else:
849 #Delete
850 #Reset the Yes/No buttons
851 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
852 self._d.add_persistent_args(["--no-label", _(u"No")])
853 if self._d.yesno(_(u"Are you sure you want to remove the interface ") + iface_choice + "?") == self._DLG_YES:
854 del interfaces[iface_choice]
855
856 #This section is for defining DNS servers, default routes/gateways, hostname, etc.
857 #First ask for the default gateway device and IP
858 interfaces = self._install_profile.get_network_interfaces()
859 choice_list = []
860 for iface in interfaces:
861 if interfaces[iface][0] == 'dhcp':
862 choice_list.append((iface, _(u"Settings: DHCP. Options: ")+ interfaces[iface][1],0))
863 else:
864 choice_list.append((iface, _(u"IP: ")+interfaces[iface][0]+_(u" Broadcast: ")+interfaces[iface][1]+" Netmask: "+interfaces[iface][2],0))
865 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:")
866 code, gateway_iface = self._d.radiolist(string3, choices=choice_list, height=18, width=67)
867 if code == self._DLG_OK: #They made a choice. Ask the IP if not DHCP.
868 while interfaces[gateway_iface][0] != 'dhcp':
869 code, ip = self._d.inputbox(_(u"Enter the gateway IP address for ") + gateway_iface, init=interfaces[gateway_iface][0])
870 if code != self._DLG_OK:
871 break
872 if not GLIUtility.is_ip(ip):
873 self._d.msgbox(_(u"Invalid IP Entered! Please try again."))
874 continue
875 try:
876 self._install_profile.set_default_gateway(None, ip,{'interface': gateway_iface})
877 except:
878 self._d.msgbox(_(u"ERROR! Coult not set the default gateway with IP %s for interface %s") % (ip, gateway_iface))
879 break
880 #Now ask for the other info in a large form.
881 error = True
882 hostname = ""
883 domainname = ""
884 nisdomainname = ""
885 primary_dns = ""
886 backup_dns = ""
887 http_proxy = ""
888 ftp_proxy = ""
889 rsync_proxy = ""
890 while error:
891 error = False
892 if self.advanced_mode:
893 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())))
894 if code != self._DLG_OK:
895 return
896 (hostname, domainname, nisdomainname, primary_dns, backup_dns, http_proxy, ftp_proxy, rsync_proxy) = data[:-1].split('\n')
897 else: #standard mode
898 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)))
899 if code != self._DLG_OK:
900 return
901 (hostname, domainname, primary_dns, backup_dns) = data[:-1].split('\n')
902 #Check the data before entering it.
903 if hostname:
904 if type(hostname) != str:
905 self._d.msgbox(_(u"Incorrect hostname! It must be a string. Not saved."))
906 error = True
907 else:
908 try:
909 self._install_profile.set_hostname(None, hostname, None)
910 except:
911 self._d.msgbox(_(u"ERROR! Could not set the hostname:")+hostname)
912 error = True
913 if domainname:
914 if type(domainname) != str:
915 self._d.msgbox(_(u"Incorrect domainname! It must be a string. Not saved."))
916 error = True
917 else:
918 try:
919 self._install_profile.set_domainname(None, domainname, None)
920 except:
921 self._d.msgbox(_(u"ERROR! Could not set the domainname:")+domainname)
922 error = True
923 if nisdomainname:
924 if type(nisdomainname) != str:
925 self._d.msgbox(_(u"Incorrect nisdomainname! It must be a string. Not saved."))
926 error = True
927 else:
928 try:
929 self._install_profile.set_nisdomainname(None, nisdomainname, None)
930 except:
931 self._d.msgbox(_(u"ERROR! Could not set the nisdomainname:")+nisdomainname)
932 error = True
933 if primary_dns:
934 if not GLIUtility.is_ip(primary_dns):
935 self._d.msgbox(_(u"Incorrect Primary DNS Server! Not saved."))
936 error = True
937 else:
938 if backup_dns:
939 if not GLIUtility.is_ip(backup_dns):
940 self._d.msgbox(_(u"Incorrect Backup DNS Server! Not saved."))
941 error = True
942 else:
943 primary_dns = primary_dns + " " + backup_dns
944 try:
945 self._install_profile.set_dns_servers(None, primary_dns, None)
946 except:
947 self._d.msgbox(_(u"ERROR! Could not set the DNS Servers:")+primary_dns)
948 error = True
949 if http_proxy:
950 if not GLIUtility.is_uri(http_proxy):
951 self._d.msgbox(_(u"Incorrect HTTP Proxy! It must be a uri. Not saved."))
952 error = True
953 else:
954 try:
955 self._install_profile.set_http_proxy(None, http_proxy, None)
956 except:
957 self._d.msgbox(_(u"ERROR! Could not set the HTTP Proxy:")+http_proxy)
958 error = True
959 if ftp_proxy:
960 if not GLIUtility.is_uri(ftp_proxy):
961 self._d.msgbox(_(u"Incorrect FTP Proxy! It must be a uri. Not saved."))
962 error = True
963 else:
964 try:
965 self._install_profile.set_ftp_proxy(None, ftp_proxy, None)
966 except:
967 self._d.msgbox(_(u"ERROR! Could not set the FTP Proxy:")+ftp_proxy)
968 error = True
969 if rsync_proxy:
970 if not GLIUtility.is_uri(rsync_proxy):
971 self._d.msgbox(_(u"Incorrect RSYNC Proxy! It must be a uri. Not saved."))
972 error = True
973 else:
974 try:
975 self._install_profile.set_rsync_proxy(None, rsync_proxy, None)
976 except:
977 self._d.msgbox(_(u"ERROR! Could not set the RSYNC Proxy:")+rsync_proxy)
978 error = True
979
980 def _set_cron_daemon(self):
981 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 command scheduler with extended capabilities over cron and anacron")), ("None", _(u"Don't use a cron daemon. (NOT Recommended!)")))
982 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:")
983 code, menuitem = self._d.menu(string, choices=cron_daemons, height=21, width=68)
984 if code == self._DLG_OK:
985 if menuitem == "None":
986 menuitem = ""
987 self._install_profile.set_cron_daemon_pkg(None, menuitem, None)
988
989 def _set_logger(self):
990 loggers = (("syslog-ng", _(u"An advanced system logger.")), ("metalog", _(u"A Highly-configurable system logger.")), ("syslogkd", _(u"The traditional set of system logging daemons.")))
991 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. Choose a system logger:")
992 code, menuitem = self._d.menu(string, choices=loggers, height=21, width=68)
993 if code == self._DLG_OK:
994 self._install_profile.set_logging_daemon_pkg(None, menuitem, None)
995
996 def _set_extra_packages(self):
997 #d.msgbox("This section is for selecting extra packages (pcmcia-cs, rp-pppoe, xorg-x11, etc.) and setting them up")
998 install_packages = ""
999 while 1:
1000 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 Gentoo Linux Installer Team.")), (_(u"Manual"), _(u"Type your own space-separated list of packages to install."))]
1001 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'.")
1002 code, submenu = self._d.menu(string1+ _(u"\nYour current package list is: ")+install_packages, choices=highlevel_menu, cancel=_(u"Save and Continue"), width=70, height=23)
1003 if code != self._DLG_OK: #Save and move on.
1004 try:
1005 if install_packages[-1] == " ":
1006 install_packages = install_packages[:-1]
1007 self._install_profile.set_install_packages(None, install_packages, None)
1008 except:
1009 self._d.msgbox(_(u"ERROR! Could not set the install packages! List of packages:")+install_packages)
1010 return
1011 #Popular Desktop Applications
1012 choices_list = []
1013 if submenu == _(u"Desktop"):
1014 choices_list = [("gaim","GTK Instant Messenger client",0), ("gftp","Gnome based FTP Client",0), ("evolution","A GNOME groupware application, a Microsoft Outlook workalike",0), ("mozilla-firefox","The Mozilla Firefox Web Browser",0), ("mplayer","Media Player for Linux",0), ("openoffice","OpenOffice.org, a full office productivity suite.",0), ("openoffice-bin","Same as OpenOffice but a binary package (no compiling!)",0), ("realplayer","Real Media Player",0), ("xchat","Graphical IRC Client",0), ("xmms", "X MultiMedia System",0)]
1015 #Applications often found on servers.
1016 elif submenu == _(u"Servers"):
1017 choices_list = [("apache","Apache Web Server",0), ("iptables","Linux kernel (2.4+) firewall, NAT and packet mangling tools",0), ("proftpd","ProFTP Server",0), ("samba","SAMBA client/server programs for UNIX",0), ("traceroute","Utility to trace the route of IP packets",0)]
1018 #Window managers and X selection.
1019 elif submenu == _(u"X11"):
1020 choices_list = [("xorg-x11","An X11 implementation maintained by the X.Org Foundation.",0), ("gnome","The Gnome Desktop Environment",0), ("kde","The K Desktop Environment",0), ("blackbox","A small, fast, full-featured window manager for X",0), ("enlightenment","Enlightenment Window Manager",0), ("fluxbox","Fluxbox is an X11 window manager featuring tabs and an iconbar",0), ("xfce4","XFCE Desktop Environment",0)]
1021 #Miscellaneous Applications you may want.
1022 elif submenu == _(u"Misc"):
1023 choices_list = [("gkrellm","Single process stack of various system monitors",0), ("logrotate","Rotates, compresses, and mails system logs",0), ("slocate","Secure way to index and quickly search for files on your system",0), ("ufed","Gentoo Linux USE flags editor",0)]
1024 #Recommended by the Gentoo Linux Installer Team
1025 elif submenu == _(u"Recommended"):
1026 choices_list = [("anjuta","A versatile IDE for GNOME",0), ("chkrootkit","a tool to locally check for signs of a rootkit",0), ("crack-attack","Addictive OpenGL-based block game",0), ("enemy-territory","Return to Castle Wolfenstein: Enemy Territory",0), ("netcat","the network swiss army knife",0), ("nmap","A utility for network exploration or security auditing",0), ("screen","full-screen window manager that multiplexes between several processes",0)]
1027 elif submenu == _(u"Manual"):
1028 code, install_packages = self._d.inputbox(_(u"Enter a space-separated list of extra packages to install on the system"), init=install_packages, width=70)
1029 continue
1030 code, choices = self._d.checklist(_(u"Choose from the listed packages"), choices=choices_list, height=19, list_height=10, width=77)
1031 if code != self._DLG_OK:
1032 continue
1033 for package in choices:
1034 install_packages += package + " "
1035 def _set_rc_conf(self):
1036 # This section is for editing /etc/rc.conf
1037 if not self.advanced_mode:
1038 return
1039 etc_files = self._install_profile.get_etc_files()
1040 keymap = ""
1041 windowkeys = ""
1042 ext_keymap = ""
1043 font = ""
1044 trans = ""
1045 clock = ""
1046 editor = ""
1047 prots = ""
1048 xsession = ""
1049 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!")
1050 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"))]
1051 while 1:
1052 code, variable = self._d.menu(string1, choices=menulist, cancel=_(u"Save and Continue"))
1053 if code != self._DLG_OK:
1054 break
1055 if variable == "KEYMAP":
1056 keymap_list = GLIUtility.generate_keymap_list()
1057 code, keymap = self._d.menu(_(u"Choose your desired keymap:"), choices=self._dmenu_list_to_choices(keymap_list), height=23)
1058 if code != self._DLG_OK:
1059 continue
1060 keymap = keymap_list[int(keymap)-1]
1061
1062 elif variable == "SET_WINDOWSKEYS":
1063 #Reset the Yes/No buttons
1064 self._d.add_persistent_args(["--yes-label", _(u"Yes")])
1065 self._d.add_persistent_args(["--no-label", _(u"No")])
1066 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:
1067 windowkeys = "yes"
1068 else:
1069 windowkeys = "no"
1070 elif variable == "EXTENDED_KEYMAPS":
1071 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"))
1072 elif variable == "CONSOLEFONT":
1073 font_list = GLIUtility.generate_consolefont_list()
1074 code, font = self._d.menu(_(u"Choose your desired console font:"), choices=self._dmenu_list_to_choices(font_list), height=23)
1075 if code != self._DLG_OK:
1076 continue
1077 font = font_list[int(font)-1]
1078 elif variable == "CONSOLETRANSLATION":
1079 trans_list = GLIUtility.generate_consoletranslation_list()
1080 code, trans = self._d.menu(_(u"Choose your desired console translation:"), choices=self._dmenu_list_to_choices(trans_list))
1081 if code != self._DLG_OK:
1082 continue
1083 trans = trans_list[int(trans)-1]
1084 elif variable == "CLOCK":
1085 #Change the Yes/No buttons to new labels for this question.
1086 self._d.add_persistent_args(["--yes-label", "UTC"])
1087 self._d.add_persistent_args(["--no-label", "local"])
1088 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:
1089 clock = "UTC"
1090 else:
1091 clock = "local"
1092 elif variable == "EDITOR":
1093 choice_list = [("/bin/nano", _(u"Default editor.")), ("/usr/bin/vim", _(u"vi improved editor.")), ("/usr/bin/emacs", _(u"The emacs editor."))]
1094 code, editor = self._d.menu(_(u"Choose your default editor: "), choices=choice_list)
1095
1096 elif variable == "PROTOCOLS":
1097 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)]
1098 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)
1099 if code != self._DLG_OK:
1100 continue
1101 prots = ""
1102 for prot in protocols:
1103 prots += prot + " "
1104 elif variable == "DISPLAYMANAGER":
1105 choice_list = [("xdm", _(u"X Display Manager")), ("gdm", _(u"Gnome Display Manager")), ("kdm", _(u"KDE Display Manager")), ("entrance", _(u"Login Manager for Enlightenment"))]
1106 elif variable == "XSESSION":
1107 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:"))
1108
1109 if not "conf.d/keymaps" in etc_files: etc_files['conf.d/keymaps'] = {}
1110 if not "conf.d/consolefont" in etc_files: etc_files['conf.d/consolefont'] = {}
1111 if not "conf.d/clock" in etc_files: etc_files['conf.d/clock'] = {}
1112 if not "rc.conf" in etc_files: etc_files['rc.conf'] = {}
1113 if keymap:
1114 etc_files['conf.d/keymaps']['KEYMAP'] = keymap
1115 if windowkeys:
1116 etc_files['conf.d/keymaps']['SET_WINDOWSKEYS'] = windowkeys
1117 if ext_keymap:
1118 etc_files['conf.d/keymaps']['EXTENDED_KEYMAPS'] = ext_keymap
1119 if font:
1120 etc_files['conf.d/consolefont']['CONSOLEFONT'] = font
1121 if trans:
1122 etc_files['conf.d/consolefont']['CONSOLETRANSLATION'] = trans
1123 if clock:
1124 etc_files['conf.d/clock']['CLOCK'] = clock
1125 if editor:
1126 etc_files['rc.conf']['EDITOR'] = editor
1127 if prots:
1128 etc_files['rc.conf']['PROTOCOLS'] = prots
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")
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 choice_list = [("users", _(u"The usual group for normal users."), 1), ("wheel", _(u"Allows users to attempt to su to root."), 0), ("audio", _(u"Allows access to audio devices."), 0), ("games", _(u"Allows access to games."), 0), ("apache", _(u"For users who know what they're doing only."), 0), ("cdrom", _(u"For users who know what they're doing only."), 0), ("ftp", _(u"For users who know what they're doing only."), 0), ("video", _(u"For users who know what they're doing only."), 0), (_(u"Other"), _(u"Manually specify your groups in a comma-separated list."), 0)]
1212 string2 = _(u"Select which groups you would like the user %s to be in." % menuitem)
1213 code, group_list = self._d.checklist(string2, choices=choice_list, height=19, list_height=10, width=68)
1214 groups = ""
1215 for group in group_list:
1216 groups += group + ","
1217 groups = groups[:-1]
1218 if _(u"Other") in group_list:
1219 code, groups = self._d.inputbox(_(u"Enter a comma-separated list of groups the user is to be in"), init=",".join(users[menuitem][2]))
1220 if code != self._DLG_OK: continue
1221 users[menuitem][2] = string.split(groups, ",")
1222 elif menuitem2 == _(u"Shell"):
1223 code, shell = self._d.inputbox(_(u"Enter the shell you want the user to use. default is /bin/bash. "), init=users[menuitem][3])
1224 if code != self._DLG_OK:
1225 continue
1226 users[menuitem][3] = shell
1227 elif menuitem2 == _(u"Home Directory"):
1228 code, homedir = self._d.inputbox(_(u"Enter the user's home directory. default is /home/username. "), init=users[menuitem][4])
1229 if code != self._DLG_OK:
1230 continue
1231 users[menuitem][4] = homedir
1232 elif menuitem2 == _(u"UID"):
1233 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])
1234 if code != self._DLG_OK:
1235 continue
1236 if type(uid) != int:
1237 continue
1238 users[menuitem][5] = uid
1239 elif menuitem2 == _(u"Comment"):
1240 code, comment = self._d.inputbox(_(u"Enter the user's comment. This is completely optional."), init=users[menuitem][6])
1241 if code != self._DLG_OK:
1242 continue
1243 users[menuitem][6] = comment
1244 elif menuitem2 == _(u"Delete"):
1245 if self._d.yesno(_(u"Are you sure you want to delete the user ") + menuitem + "?") == self._DLG_YES:
1246 del users[menuitem]
1247 break
1248
1249 def _set_services(self):
1250 choice_list = [("alsasound", _(u"ALSA Sound Daemon"),0), ("apache", _(u"Common web server (version 1.x)"),0), ("apache2", _(u"Common web server (version 2.x)"),0), ("distccd", _(u"Distributed Compiling System"),0), ("esound", _(u"ESD Sound Daemon"),0), ("hdparm", _(u"Hard Drive Tweaking Utility"),0), ("local", _(u"Run scripts found in /etc/conf.d/local.start"),0), ("portmap", _(u"Port Mapping Service"),0), ("proftpd", _(u"Common FTP server"),0), ("sshd", _(u"SSH Daemon (allows remote logins)"),0), (_(u"Other"),_(u"Manually specify your services in a comma-separated list."),0)]
1251 string = _(u"Choose the services you want started on bootup. Note that depending on what packages are selected, some services listed will not exist.")
1252 code, services_list = self._d.checklist(string, choices=choice_list, height=19, list_height=10, width=68)
1253 if code != self._DLG_OK:
1254 return
1255 services = ""
1256 for service in services_list:
1257 services += service + ","
1258 services = services[:-1]
1259 if _(u"Other") in services_list:
1260 code, services = self._d.inputbox(_(u"Enter a comma-separated list of services to start on boot"))
1261 if code != self._DLG_OK:
1262 return
1263 try:
1264 self._install_profile.set_services(None, services, None)
1265 except:
1266 self._d.msgbox(_(u"ERROR! Could not set the services list: "+ services))
1267
1268 def _save_install_profile(self, xmlfilename="", askforfilename=True):
1269 code = 0
1270 filename = xmlfilename
1271 if askforfilename:
1272 code, filename = self._d.inputbox(_(u"Enter a filename for the XML file"), init=xmlfilename)
1273 if code != self._DLG_OK:
1274 return None
1275 if GLIUtility.is_file(filename):
1276 if not self._d.yesno(_(u"The file %s already exists. Do you want to overwrite it?") % filename) == self._DLG_YES:
1277 return None
1278 configuration = open(filename ,"w")
1279 configuration.write(self._install_profile.serialize())
1280 configuration.close()
1281 return filename

Properties

Name Value
svn:eol-style native

  ViewVC Help
Powered by ViewVC 1.1.20