/[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 1745 - (show annotations) (download) (as text)
Sat Mar 3 20:58:14 2007 UTC (10 years, 11 months ago) by codeman
File MIME type: text/x-python
File size: 13406 byte(s)
fix boot device detection.  was only looking at drives with mounts b4. untested.
fixed silly bug in save filename
adding back in set_etc_portage to install process.
putting an exit(0) back in trunk just because.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20