/[gli]/trunk/src/fe/dialog/gli-dialog.py
Gentoo

Contents of /trunk/src/fe/dialog/gli-dialog.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1463 - (show annotations) (download) (as text)
Sat Jun 17 18:22:44 2006 UTC (11 years, 8 months ago) by codeman
File MIME type: text/x-python
File size: 13063 byte(s)
abandoned local USE project.  no right way to do it.

1 #!/usr/bin/python
2 # Copyright 1999-2005 Gentoo Foundation
3 # This source code is distributed under the terms of version 2 of the GNU
4 # General Public License as published by the Free Software Foundation, a copy
5 # of which can be found in the main directory of this project.
6
7 import sys
8 sys.path.append("../..")
9
10 import dialog
11 import GLIException, GLIInstallProfile, GLIClientConfiguration, GLIClientController, GLIUtility, GLIStorageDevice
12 from GLIGenDialog import GLIGenCF,GLIGenIP
13 import string, copy, time, re, glob, os, platform
14 import gettext
15 _ = gettext.gettext
16
17 class Setup_CConfig(GLIGenCF):
18 def __init__(self, client_profile, local_install, advanced_mode, networkless):
19 GLIGenCF.__init__(self, client_profile, local_install, advanced_mode, networkless)
20 self.set_arch_template()
21 self.set_verbose()
22 self.set_logfile()
23 self.set_root_mount_point()
24 self.set_client_networking()
25 self.set_enable_ssh()
26 self.set_livecd_password()
27 self.set_client_kernel_modules()
28 self.client_config_xml_file = None
29 if advanced_mode:
30 if d.yesno(_(u"Do you want to save the ClientConfiguration XML file before continuing? (it will be automatically saved before the install begins)")) == DLG_YES:
31 self.client_config_xml_file = self.save_client_profile()
32
33 class Setup_InstallProfile(GLIGenIP):
34 def __init__(self, client_profile, install_profile, local_install, advanced_mode, skip_wizard_question, networkless):
35 GLIGenIP.__init__(self, client_profile, install_profile, local_install, advanced_mode, networkless)
36 show_review_menu = True
37 if not skip_wizard_question:
38 #Change the Yes/No buttons to new labels for this question.
39 d.add_persistent_args(["--yes-label", _(u"Wizard Mode")])
40 d.add_persistent_args(["--no-label", _(u"Skip to Menu")])
41 if d.yesno(_(u"The Gentoo Linux Installer can either take you step by step through the installation settings (recommended), or you can instead go straight to the Revisions menu to set your settings before the installation begins."), width=66) == DLG_YES:
42 self.set_partitions()
43 self.set_network_mounts()
44 self.set_install_stage()
45 self.set_portage_tree()
46 self.set_make_conf()
47 if advanced_mode:
48 self.set_distcc()
49 self.set_kernel()
50 self.set_boot_loader()
51 self.set_timezone()
52 self.set_networking()
53 if advanced_mode:
54 self.set_cron_daemon()
55 self.set_logger()
56 self.set_extra_packages()
57 if advanced_mode:
58 self.set_services()
59 self.set_rc_conf()
60 self.set_root_password()
61 self.set_additional_users()
62 self.show_settings()
63 #Reset the Yes/No labels.
64 d.add_persistent_args(["--yes-label", "Yes"])
65 d.add_persistent_args(["--no-label","No"])
66 if d.yesno(_(u"Do you want to change any of your settings before starting the actual installation?")) == DLG_NO:
67 show_review_menu = False
68 if show_review_menu:
69 self._fn = (
70 { 'text': "Partitioning", 'fn': self.set_partitions },
71 { 'text': "Network mounts", 'fn': self.set_network_mounts },
72 { 'text': "Install Stage", 'fn': self.set_install_stage },
73 { 'text': "Portage Tree", 'fn': self.set_portage_tree },
74 { 'text': "make.conf", 'fn': self.set_make_conf },
75 { 'text': "distcc", 'fn': self.set_distcc },
76 { 'text': "etc/portage/*", 'fn': self.set_etc_portage },
77 { 'text': "Kernel", 'fn': self.set_kernel },
78 { 'text': "Bootloader", 'fn': self.set_boot_loader },
79 { 'text': "Timezone", 'fn': self.set_timezone },
80 { 'text': "Networking", 'fn': self.set_networking },
81 { 'text': "Cron daemon", 'fn': self.set_cron_daemon },
82 { 'text': "Logging daemon", 'fn': self.set_logger },
83 { 'text': "Extra packages", 'fn': self.set_extra_packages },
84 { 'text': "Services", 'fn': self.set_services },
85 { 'text': "Configuration Settings", 'fn': self.set_rc_conf },
86 { 'text': "Root password", 'fn': self.set_root_password },
87 { 'text': "Additional Users", 'fn': self.set_additional_users })
88 self._menu_list = []
89 for item in self._fn:
90 self._menu_list.append(item['text'])
91 current_item = 0
92 while 1:
93 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")
94 if code != DLG_OK:
95 break
96 current_item = int(menuitem)
97 menuitem = self._menu_list[int(menuitem)-1]
98 for item in self._fn:
99 if menuitem == item['text']:
100 item['fn']()
101 current_item += 1
102 self.install_profile_xml_file = None
103 #Reset the Yes/No labels.
104 d.add_persistent_args(["--yes-label", "Yes"])
105 d.add_persistent_args(["--no-label","No"])
106 if d.yesno(_(u"Do you want to save the InstallProfile XML file?")) == DLG_YES:
107 self.install_profile_xml_file = self.save_install_profile()
108
109 # ------------------------------------------------------------------
110 if __name__ == '__main__':
111
112 d = dialog.Dialog()
113 client_profile = GLIClientConfiguration.ClientConfiguration()
114 install_profile = GLIInstallProfile.InstallProfile()
115 cc = GLIClientController.GLIClientController(pretend=False)
116 exception_waiting = None
117 client_config_xml_file = None
118 install_profile_xml_file = None
119 next_step_waiting = False
120 install_done = False
121 local_install = True
122 advanced_mode = False
123 networkless = False
124
125 DLG_OK = 0
126 DLG_YES = 0
127 DLG_CANCEL = 1
128 DLG_NO = 1
129 DLG_ESC = 2
130 DLG_ERROR = 3
131 DLG_EXTRA = 4
132 DLG_HELP = 5
133
134 d.setBackgroundTitle("Gentoo Linux Installer")
135 welcome_string = _(u"""Welcome to the Gentoo Linux Installer! This program will help install Gentoo on your computer.
136 Before proceeding please thoroughly read the Gentoo Installation Handbook available at
137 http://www.gentoo.org/doc/en/handbook/index.xml \n
138 This installer works by first asking a series of questions to generate an \"installation profile\",
139 which contains all the information needed to install Gentoo.\n
140 NO Changes will be made to your system until you select the "Install!" button.
141 You can save your profile at any time by exiting the installer.
142 You can also load a previously made profile at any time.\n
143 If choosing expert mode, you will make a second profile with configuration settings for the livecd environment and the installer.\n
144 Press OK to continue""")
145 d.msgbox(welcome_string, height=25, width=78, title="Welcome")
146
147 #Change the Yes/No buttons to new labels for this question.
148 d.add_persistent_args(["--yes-label", _(u"Simulate")])
149 d.add_persistent_args(["--no-label", _(u"Real Install")])
150 #This is a temporary question during the development process. In a beta release a real install will be implied.
151 if d.yesno(_(u"Are we performing an actual install or just simulating?"), width=45) == DLG_NO:
152 cc._pretend = False
153 else:
154 cc._pretend = True
155
156 #Set the Yes/No labels.
157 d.add_persistent_args(["--yes-label", "Standard"])
158 d.add_persistent_args(["--no-label","Advanced"])
159 advanced_string = _(u"""This installer has two modes, an advanced mode for those knowledgable with the inner details of their computer and a standard mode where many of the defaults will be chosen for the user for simplicity and to speed up the install process. The advanced mode offers full customizability and is required for generating profiles to be used other computers. \nThe advanced mode is recommended by the developers.
160 """)
161 if d.yesno(advanced_string, width=55, height=15) == DLG_NO:
162 advanced_mode = True
163 local_install = True
164
165 networkless_string = _(u"Do you want to do a networkless installation? This will limit the customizability of your install due to the limitations of the LiveCD. For example, choosing networkless will set your installation stage, portage snapshot, and limit your extra packages selections. NOTE: It is easily possible to do a networkless installation on a machine with an active Internet connection; in fact this may result in the fastest installations for many users.")
166 #Change the Yes/No buttons
167 d.add_persistent_args(["--yes-label", _(u"Networkless")])
168 d.add_persistent_args(["--no-label", _(u"Internet enabled")])
169 if d.yesno(networkless_string, width=65, height=20) == DLG_YES:
170 networkless = True
171 else:
172 networkless = False
173
174
175 #Reset the Yes/No labels.
176 d.add_persistent_args(["--yes-label", "Yes"])
177 d.add_persistent_args(["--no-label","No"])
178 if advanced_mode:
179 #Local install affects the pre-selection of partitions on the local hard drives, amongst other things.
180 if d.yesno(_(u"Are the profiles being generated to be used for an install on the current computer?")) == DLG_NO:
181 local_install = False
182 #Ask
183 while 1:
184 string = _(u"""
185 The first profile needed for an advanced install includes all the
186 necessary information for getting the livecd environment set up.
187 This includes the livecd networking configuration, where the
188 logfile and new root mount point are to be located, etc.
189 We call this the ClientConfiguration profile.
190 Do you have a previously generated XML file for the ClientConfiguration?
191 """)
192 if d.yesno(string, width=70, height=15, defaultno=1) == DLG_YES:
193 code, client_config_xml_file = d.inputbox(_(u"Enter the filename of the XML file"))
194 if code != DLG_OK:
195 break
196 if GLIUtility.is_file(client_config_xml_file):
197 break
198 d.msgbox(_(u"Cannot open file ") + client_config_xml_file, height=7, width=50)
199 client_config_xml_file = None
200 continue
201 else:
202 break
203
204 if client_config_xml_file != None:
205 client_profile.parse(client_config_xml_file)
206 # code to actually run the client_controller functions
207 else:
208 #This line does all the work.
209 gen_client_conf = Setup_CConfig(client_profile, local_install, advanced_mode, networkless)
210 client_profile = gen_client_conf.client_profile()
211
212 client_profile.set_interactive(None, True, None)
213 cc.set_configuration(client_profile)
214
215 #This will execute all of the CC functions, and set up networking if there is networking to set up.
216 cc.start_pre_install()
217
218 #Reset the Yes/No labels.
219 d.add_persistent_args(["--yes-label", "Yes"])
220 d.add_persistent_args(["--no-label","No"])
221 while 1:
222 if d.yesno(_(u"All of the installation settings are stored in an XML file, which we call the InstallProfile. If you have previously saved a profile and would like to load it for this install, say Yes. Otherwise say No. Do you have a previously generated InstallProfile XML file?"), width=55, defaultno=1) == DLG_YES:
223 code, install_profile_xml_file = d.inputbox(_(u"Enter the filename of the XML file"))
224 if code != DLG_OK:
225 break
226 if GLIUtility.is_file(install_profile_xml_file):
227 break
228 d.msgbox(_(u"Cannot open file ") + install_profile_xml_file, height=7, width=50)
229 install_profile_xml_file = None
230 else:
231 break
232 skip_wizard_question = False
233 if install_profile_xml_file != None:
234 install_profile.parse(install_profile_xml_file)
235 skip_wizard_question = True
236
237 #These are always done
238
239 gen_install_profile = Setup_InstallProfile(client_profile, install_profile, local_install, advanced_mode, skip_wizard_question, networkless)
240 install_profile = gen_install_profile.install_profile()
241
242
243 # INSTALLATION TIME
244 current_item = 0
245 while 1:
246 cc.set_install_profile(install_profile)
247 cc.start_install()
248 d.gauge_start(_(u"Installation Started!"), title=_(u"Installation progress"))
249 num_steps_completed = 1
250 next_step = 0
251 num_steps = 0
252 i = 0
253 while 1:
254 notification = cc.getNotification()
255 if notification == None:
256 time.sleep(1)
257 continue
258 type_r = notification.get_type()
259 data = notification.get_data()
260 if type_r == "exception":
261 #Reset the Yes/No labels.
262 d.add_persistent_args(["--yes-label", "Yes"])
263 d.add_persistent_args(["--no-label","No"])
264 if d.yesno(_(u"There was an Exception received during the install that is outside of the normal install errors. This is a bad thing. The error was:")+ str(data) + _(u"\nPlease submit a bug report (after searching to make sure it's not a known issue and verifying you didn't do something stupid) with the contents of /var/log/install.log and /tmp/installprofile.xml and the version of the installer you used\nDo you want to cleanup your system to attempt another install?"), width=70) == DLG_YES:
265 cc.start_failure_cleanup()
266 elif type_r == "progress":
267 #SECONDARY UPDATIN' GOIN ON IN HERE
268 diff = (data[0]*100)/num_steps
269 d.gauge_update(i+diff, "On step %d of %d. Current step: %s\n%s" % (num_steps_completed, num_steps, next_step, data[1]), update_text=1)
270 elif type_r == "int":
271 if data == GLIClientController.NEXT_STEP_READY:
272 next_step_waiting = False
273 next_step = cc.get_next_step_info()
274 num_steps = cc.get_num_steps()
275 i = (num_steps_completed*100)/num_steps
276 d.gauge_update(i, "On step %d of %d. Current step: %s" % (num_steps_completed, num_steps, next_step), update_text=1)
277 num_steps_completed += 1
278 #print "Next step: " + next_step
279 if cc.has_more_steps():
280 cc.next_step()
281 continue
282 if data == GLIClientController.INSTALL_DONE:
283 d.gauge_update(100, _(u"Install completed!"), update_text=1)
284 d.gauge_stop()
285 print _(u"Install done!")
286 sys.exit(0)

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20