Merge lp:~superm1/ubiquity/mythbuntu-plugin-enhance into lp:ubiquity
- mythbuntu-plugin-enhance
- Merge into trunk
Proposed by
Mario Limonciello
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | not available | ||||
Proposed branch: | lp:~superm1/ubiquity/mythbuntu-plugin-enhance | ||||
Merge into: | lp:ubiquity | ||||
Diff against target: |
3077 lines (+1066/-1182) 29 files modified
bin/ubiquity (+3/-3) bin/ubiquity-dm (+5/-8) bin/ubiquity-wrapper (+2/-2) debian/changelog (+20/-0) debian/rules (+0/-1) debian/ubiquity-frontend-mythbuntu.install (+3/-3) debian/ubiquity-frontend-mythbuntu.preinst (+4/-2) desktop/Makefile.am (+1/-2) desktop/Makefile.in (+1/-2) desktop/ubiquity-mythbuntu.desktop.in (+0/-13) gui/gtk/mythbuntu_stepCustomInstallType.ui (+0/-5) gui/gtk/mythbuntu_stepServices.ui (+0/-1) scripts/install.py (+53/-218) scripts/mythbuntu/60mythbuntu_user (+18/-0) scripts/mythbuntu/mythbuntu-setup (+1/-1) scripts/mythbuntu/mythbuntu_install.py (+0/-389) ubiquity/components/myth-backend-setup.py (+17/-7) ubiquity/components/myth-drivers.py (+180/-9) ubiquity/components/myth-install-type.py (+107/-10) ubiquity/components/myth-passwords.py (+118/-16) ubiquity/components/myth-remote.py (+147/-8) ubiquity/components/myth-services.py (+99/-10) ubiquity/components/myth-summary.py (+2/-5) ubiquity/components/mythbuntu_install.py (+0/-28) ubiquity/frontend/base.py (+6/-4) ubiquity/frontend/gtk_ui.py (+41/-29) ubiquity/frontend/kde_ui.py (+7/-0) ubiquity/frontend/mythbuntu_ui.py (+0/-406) ubiquity/install_misc.py (+231/-0) |
||||
To merge this branch: | bzr merge lp:~superm1/ubiquity/mythbuntu-plugin-enhance | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Installer Team | Pending | ||
Review via email: mp+18114@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Mario Limonciello (superm1) wrote : | # |
- 3710. By Mario Limonciello
-
Fix unmount command in chroot_cleanup to actually release /target/dev.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'bin/ubiquity' |
2 | --- bin/ubiquity 2010-01-21 09:03:10 +0000 |
3 | +++ bin/ubiquity 2010-01-27 01:47:13 +0000 |
4 | @@ -205,11 +205,11 @@ |
5 | '''install(frontend=None) -> none |
6 | |
7 | Get the type of frontend to use and load the module for that. |
8 | - If frontend is None, defaults to the first of mythbuntu_ui, |
9 | + If frontend is None, defaults to the first of |
10 | gtk_ui, kde_ui, and debconf_ui that exists. |
11 | ''' |
12 | if frontend is None: |
13 | - frontends = ['mythbuntu_ui', 'gtk_ui', 'kde_ui', 'debconf_ui'] |
14 | + frontends = ['gtk_ui', 'kde_ui', 'debconf_ui'] |
15 | else: |
16 | frontends = [frontend] |
17 | chosen = None |
18 | @@ -428,7 +428,7 @@ |
19 | os.environ['UBIQUITY_DEBUG_CORE'] = '1' |
20 | |
21 | # Clean up old state. |
22 | - for name in ('apt-installed', 'apt-install-direct', 'remove-kernels'): |
23 | + for name in ('apt-installed', 'apt-install-direct', 'remove-kernels', 'apt-removed'): |
24 | osextras.unlink_force(os.path.join('/var/lib/ubiquity', name)) |
25 | shutil.rmtree("/var/lib/partman", ignore_errors=True) |
26 | |
27 | |
28 | === modified file 'bin/ubiquity-dm' |
29 | --- bin/ubiquity-dm 2010-01-22 09:17:02 +0000 |
30 | +++ bin/ubiquity-dm 2010-01-27 01:47:13 +0000 |
31 | @@ -45,7 +45,7 @@ |
32 | # this lets us find out which window manager etc. to launch. Be |
33 | # careful that importing this here will cause the underlying library |
34 | # to try to talk to the X server, which won't go well. |
35 | - frontend_names = ['mythbuntu_ui', 'gtk_ui', 'kde_ui'] |
36 | + frontend_names = ['gtk_ui', 'kde_ui'] |
37 | self.frontend = None |
38 | for f in frontend_names: |
39 | try: |
40 | @@ -108,9 +108,6 @@ |
41 | servercommand.append('-nr') |
42 | |
43 | servercommand.extend([self.vt, self.display]) |
44 | - if self.frontend == 'mythbuntu_ui': |
45 | - servercommand.append('-dpi') |
46 | - servercommand.append('100') |
47 | |
48 | server = subprocess.Popen(servercommand, stdin=null, stdout=logfile, stderr=logfile, preexec_fn=self.server_preexec) |
49 | |
50 | @@ -154,7 +151,7 @@ |
51 | dbus_subp.wait() |
52 | |
53 | gconfd_running = False |
54 | - if ((self.frontend == 'gtk_ui' or self.frontend == 'mythbuntu_ui') and |
55 | + if (self.frontend == 'gtk_ui' and |
56 | osextras.find_on_path('gconftool-2')): |
57 | subprocess.call(['gconftool-2', '--spawn'], |
58 | stdin=null, stdout=logfile, stderr=logfile, |
59 | @@ -162,7 +159,7 @@ |
60 | gconfd_running = True |
61 | |
62 | extras = [] |
63 | - if self.frontend == 'gtk_ui' or self.frontend == 'mythbuntu_ui': |
64 | + if self.frontend == 'gtk_ui': |
65 | gconf_dir = ('xml:readwrite:%s' % |
66 | os.path.expanduser('~%s/.gconf' % |
67 | self.username)) |
68 | @@ -206,7 +203,7 @@ |
69 | gtk.gdk.flush() |
70 | fp.close() |
71 | |
72 | - if self.frontend in ('gtk_ui', 'mythbuntu_ui'): |
73 | + if self.frontend == 'gtk_ui': |
74 | if gconfd_running and osextras.find_on_path('metacity'): |
75 | wm = subprocess.Popen(['metacity', '--sm-disable'], |
76 | stdin=null, stdout=logfile, stderr=logfile, |
77 | @@ -301,7 +298,7 @@ |
78 | except XStartupError: |
79 | sys.exit(1) |
80 | proc = None |
81 | -if dm.frontend == 'gtk_ui' or dm.frontend == 'mythbuntu_ui': |
82 | +if dm.frontend == 'gtk_ui': |
83 | proc = ['/etc/init.d/gdm', 'start'] |
84 | elif dm.frontend == 'kde_ui': |
85 | proc = ['/etc/init.d/kdm', 'start'] |
86 | |
87 | === modified file 'bin/ubiquity-wrapper' |
88 | --- bin/ubiquity-wrapper 2010-01-06 07:31:36 +0000 |
89 | +++ bin/ubiquity-wrapper 2010-01-27 01:47:13 +0000 |
90 | @@ -53,7 +53,7 @@ |
91 | # frontend module. |
92 | import imp |
93 | import ubiquity.frontend |
94 | - frontend_names = ['mythbuntu_ui', 'gtk_ui', 'kde_ui'] |
95 | + frontend_names = ['gtk_ui', 'kde_ui'] |
96 | for f in frontend_names: |
97 | try: |
98 | imp.find_module(f, ubiquity.frontend.__path__) |
99 | @@ -62,7 +62,7 @@ |
100 | except ImportError: |
101 | pass |
102 | |
103 | - if frontend in ('gtk_ui', 'mythbuntu_ui'): |
104 | + if frontend == 'gtk_ui': |
105 | toexec = ['gksudo', '--preserve-env'] |
106 | if desktop: |
107 | toexec.extend(['--desktop', desktop]) |
108 | |
109 | === modified file 'debian/changelog' |
110 | --- debian/changelog 2010-01-26 12:10:57 +0000 |
111 | +++ debian/changelog 2010-01-27 01:47:14 +0000 |
112 | @@ -4,6 +4,24 @@ |
113 | * Add a new template, ubiquity/only-show-installable-languages for modifying |
114 | the behavior of what languages to offer on an invokation based upon |
115 | what's installed or "available" to install according to an apt cache. |
116 | + * Expose extra functions get and substitute to plugins via it's |
117 | + second argument (currently called Progress). |
118 | + * Drop extraneous handlers from Mythbuntu pages. |
119 | + * Move all handlers from mythbuntu_ui directly into plugins themselves. |
120 | + * Move some functions from the install.py script into a new file, |
121 | + install_misc. The intention here is that they can then be used more |
122 | + directly by ubiquity plugins. |
123 | + * Add a new method for package removals to install_misc to allow |
124 | + plugins to mark packages to be removed later in remove_extras. |
125 | + * Modify the Mythbuntu services plugin to not even offer VNC if a short |
126 | + pw. (LP: #469312) |
127 | + * Convert most of the functions from mythbuntu_install.py into plugin |
128 | + type Install methods. |
129 | + * Support using pkgsel/install-language-support preseeded to false to |
130 | + ignore installation of language packs (just like alternates). |
131 | + * Drop mythbuntu_ui and all references to it. The (former) Mythbuntu |
132 | + frontend is now fully pluggable into ubiquity's gtk_ui on it's own. |
133 | + * Fix unmount command in chroot_cleanup to actually release /target/dev. |
134 | |
135 | [ Evan Dandrea ] |
136 | * Support getting the timezone from a geoip server (LP: #229884). |
137 | @@ -43,6 +61,8 @@ |
138 | [ Mario Limonciello ] |
139 | * Remove another reference to a long dead xserver-xorg debconf question. |
140 | * Don't try reconfiguring LRM, it's been superceded by DKMS based packages. |
141 | + * Add a new top function to the Controller to allow toggling the |
142 | + visibility of the live installer from a plugin. |
143 | |
144 | -- Evan Dandrea <evand@ubuntu.com> Fri, 22 Jan 2010 09:24:12 +0000 |
145 | |
146 | |
147 | === modified file 'debian/rules' |
148 | --- debian/rules 2010-01-21 08:49:32 +0000 |
149 | +++ debian/rules 2010-01-27 01:47:14 +0000 |
150 | @@ -111,7 +111,6 @@ |
151 | # Bits of manual installation that can't be done by dh_install |
152 | |
153 | # Get rid of duplicate mythbuntu scripts and move some mythbuntu stuff around |
154 | - mv debian/ubiquity-frontend-mythbuntu/usr/share/applications/ubiquity-mythbuntu.desktop debian/ubiquity-frontend-mythbuntu/usr/share/applications/ubiquity-gtkui.desktop |
155 | mv debian/ubiquity-frontend-mythbuntu/usr/share/pixmaps/ubiquity-mythbuntu.png debian/ubiquity-frontend-mythbuntu/usr/share/pixmaps/ubiquity.png |
156 | rm -rf debian/ubiquity/usr/share/ubiquity/mythbuntu |
157 | |
158 | |
159 | === modified file 'debian/ubiquity-frontend-mythbuntu.install' |
160 | --- debian/ubiquity-frontend-mythbuntu.install 2009-09-01 15:22:02 +0000 |
161 | +++ debian/ubiquity-frontend-mythbuntu.install 2010-01-27 01:47:14 +0000 |
162 | @@ -1,16 +1,16 @@ |
163 | #install scripts |
164 | scripts/mythbuntu/* usr/share/ubiquity |
165 | |
166 | +#target config |
167 | +scripts/mythbuntu/60mythbuntu_user usr/lib/ubiquity/target-config |
168 | + |
169 | #individual python components |
170 | #Summary generation Page |
171 | #GTK->Final installer glue |
172 | ubiquity/components/myth-*.py usr/lib/ubiquity/plugins |
173 | -ubiquity/components/mythbuntu_install.py usr/lib/ubiquity/ubiquity/components |
174 | |
175 | #GTK |
176 | -ubiquity/frontend/mythbuntu_ui.py usr/lib/ubiquity/ubiquity/frontend |
177 | gui/gtk/mythbuntu*.ui usr/share/ubiquity/gtk |
178 | |
179 | #Desktop install file |
180 | -desktop/ubiquity-mythbuntu.desktop usr/share/applications |
181 | desktop/ubiquity-mythbuntu.png usr/share/pixmaps |
182 | |
183 | === modified file 'debian/ubiquity-frontend-mythbuntu.preinst' |
184 | --- debian/ubiquity-frontend-mythbuntu.preinst 2009-05-29 09:46:13 +0000 |
185 | +++ debian/ubiquity-frontend-mythbuntu.preinst 2010-01-27 01:47:14 +0000 |
186 | @@ -7,9 +7,11 @@ |
187 | case "$1" in |
188 | install|upgrade) |
189 | dpkg-divert --package ubiquity-frontend-mythbuntu --add --rename \ |
190 | - --divert /usr/share/ubiquity/ubiquity-gtkui.desktop.diverted /usr/share/applications/ubiquity-gtkui.desktop |
191 | - dpkg-divert --package ubiquity-frontend-mythbuntu --add --rename \ |
192 | --divert /usr/share/pixmaps/ubiquity-diverted.png /usr/share/pixmaps/ubiquity.png |
193 | ;; |
194 | + upgrade) |
195 | + dpkg-divert --package ubiquity-frontend-mythbuntu --remove \ |
196 | + --rename --divert /usr/share/ubiquity/ubiquity-gtkui.desktop.diverted /usr/share/applications/ubiquity-gtkui.desktop |
197 | + ;; |
198 | esac |
199 | |
200 | |
201 | === modified file 'desktop/Makefile.am' |
202 | --- desktop/Makefile.am 2009-06-24 13:57:01 +0000 |
203 | +++ desktop/Makefile.am 2010-01-27 01:47:14 +0000 |
204 | @@ -6,8 +6,7 @@ |
205 | oem-config-prepare-gtk.desktop.in \ |
206 | oem-config-prepare-kde.desktop.in \ |
207 | ubiquity-gtkui.desktop.in \ |
208 | - ubiquity-kdeui.desktop.in \ |
209 | - ubiquity-mythbuntu.desktop.in |
210 | + ubiquity-kdeui.desktop.in |
211 | |
212 | EXTRA_DIST = $(desktop_in_files) |
213 | |
214 | |
215 | === modified file 'desktop/Makefile.in' |
216 | --- desktop/Makefile.in 2009-08-25 12:37:56 +0000 |
217 | +++ desktop/Makefile.in 2010-01-27 01:47:14 +0000 |
218 | @@ -197,8 +197,7 @@ |
219 | oem-config-prepare-gtk.desktop.in \ |
220 | oem-config-prepare-kde.desktop.in \ |
221 | ubiquity-gtkui.desktop.in \ |
222 | - ubiquity-kdeui.desktop.in \ |
223 | - ubiquity-mythbuntu.desktop.in |
224 | + ubiquity-kdeui.desktop.in |
225 | |
226 | EXTRA_DIST = $(desktop_in_files) |
227 | CLEANFILES = $(desktop_DATA) |
228 | |
229 | === removed file 'desktop/ubiquity-mythbuntu.desktop.in' |
230 | --- desktop/ubiquity-mythbuntu.desktop.in 2009-07-15 10:49:32 +0000 |
231 | +++ desktop/ubiquity-mythbuntu.desktop.in 1970-01-01 00:00:00 +0000 |
232 | @@ -1,13 +0,0 @@ |
233 | -[Desktop Entry] |
234 | -Type=Application |
235 | -Version=1.0 |
236 | -Encoding=UTF-8 |
237 | -# Do not translate the word "RELEASE". It is used as a marker by casper. |
238 | -_Name=Install RELEASE |
239 | -_Comment=Install this system permanently to your hard disk |
240 | -Exec=ubiquity mythbuntu_ui |
241 | -Icon=ubiquity.png |
242 | -Terminal=false |
243 | -Categories=GTK;System;Settings; |
244 | -OnlyShowIn=GNOME;XFCE; |
245 | -#X-Ubuntu-Gettext-Domain=ubiquity |
246 | |
247 | === modified file 'gui/gtk/mythbuntu_stepCustomInstallType.ui' |
248 | --- gui/gtk/mythbuntu_stepCustomInstallType.ui 2009-08-14 15:22:14 +0000 |
249 | +++ gui/gtk/mythbuntu_stepCustomInstallType.ui 2010-01-27 01:47:14 +0000 |
250 | @@ -63,7 +63,6 @@ |
251 | <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> |
252 | <property name="active">True</property> |
253 | <property name="draw_indicator">True</property> |
254 | - <signal name="toggled" handler="toggle_customtype"/> |
255 | </object> |
256 | <packing> |
257 | <property name="expand">False</property> |
258 | @@ -94,7 +93,6 @@ |
259 | <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> |
260 | <property name="draw_indicator">True</property> |
261 | <property name="group">master_be_fe</property> |
262 | - <signal name="toggled" handler="toggle_customtype"/> |
263 | </object> |
264 | <packing> |
265 | <property name="expand">False</property> |
266 | @@ -126,7 +124,6 @@ |
267 | <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> |
268 | <property name="draw_indicator">True</property> |
269 | <property name="group">master_be_fe</property> |
270 | - <signal name="toggled" handler="toggle_customtype"/> |
271 | </object> |
272 | <packing> |
273 | <property name="expand">False</property> |
274 | @@ -157,7 +154,6 @@ |
275 | <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> |
276 | <property name="draw_indicator">True</property> |
277 | <property name="group">master_be_fe</property> |
278 | - <signal name="toggled" handler="toggle_customtype"/> |
279 | </object> |
280 | <packing> |
281 | <property name="expand">False</property> |
282 | @@ -188,7 +184,6 @@ |
283 | <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> |
284 | <property name="draw_indicator">True</property> |
285 | <property name="group">master_be_fe</property> |
286 | - <signal name="toggled" handler="toggle_customtype"/> |
287 | </object> |
288 | <packing> |
289 | <property name="expand">False</property> |
290 | |
291 | === modified file 'gui/gtk/mythbuntu_stepServices.ui' |
292 | --- gui/gtk/mythbuntu_stepServices.ui 2009-08-14 15:22:14 +0000 |
293 | +++ gui/gtk/mythbuntu_stepServices.ui 2010-01-27 01:47:14 +0000 |
294 | @@ -64,7 +64,6 @@ |
295 | <property name="receives_default">False</property> |
296 | <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> |
297 | <property name="draw_indicator">True</property> |
298 | - <signal name="toggled" handler="toggle_enablevnc"/> |
299 | </object> |
300 | <packing> |
301 | <property name="expand">False</property> |
302 | |
303 | === modified file 'scripts/install.py' |
304 | --- scripts/install.py 2010-01-26 13:18:36 +0000 |
305 | +++ scripts/install.py 2010-01-27 01:47:14 +0000 |
306 | @@ -46,6 +46,7 @@ |
307 | sys.path.insert(0, '/usr/lib/ubiquity') |
308 | |
309 | from ubiquity import misc |
310 | +from ubiquity import install_misc |
311 | from ubiquity import osextras |
312 | from ubiquity import plugin_manager |
313 | from ubiquity.casper import get_casper |
314 | @@ -53,15 +54,6 @@ |
315 | hw_detect, check_kernels, \ |
316 | migrationassistant_apply |
317 | |
318 | -def debconf_disconnect(): |
319 | - """Disconnect from debconf. This is only to be used as a subprocess |
320 | - preexec_fn helper.""" |
321 | - os.environ['DEBIAN_FRONTEND'] = 'noninteractive' |
322 | - if 'DEBIAN_HAS_FRONTEND' in os.environ: |
323 | - del os.environ['DEBIAN_HAS_FRONTEND'] |
324 | - if 'DEBCONF_USE_CDEBCONF' in os.environ: |
325 | - # Probably not a good idea to use this in /target too ... |
326 | - del os.environ['DEBCONF_USE_CDEBCONF'] |
327 | |
328 | class DebconfFetchProgress(FetchProgress): |
329 | """An object that reports apt's fetching progress using debconf.""" |
330 | @@ -608,7 +600,7 @@ |
331 | difference.add(pkg) |
332 | |
333 | # Keep packages we explicitly installed. |
334 | - keep = self.query_recorded_installed() |
335 | + keep = install_misc.query_recorded_installed() |
336 | arch, subarch = self.archdetect() |
337 | |
338 | # Less than ideal. Since we cannot know which bootloader we'll need |
339 | @@ -1002,97 +994,6 @@ |
340 | raise InstallStepError( |
341 | "Failed to detach loopback device %s" % dev) |
342 | |
343 | - |
344 | - def chroot_setup(self, x11=False): |
345 | - """Set up /target for safe package management operations.""" |
346 | - if self.target == '/': |
347 | - return |
348 | - |
349 | - policy_rc_d = os.path.join(self.target, 'usr/sbin/policy-rc.d') |
350 | - f = open(policy_rc_d, 'w') |
351 | - print >>f, """\ |
352 | -#!/bin/sh |
353 | -exit 101""" |
354 | - f.close() |
355 | - os.chmod(policy_rc_d, 0755) |
356 | - |
357 | - start_stop_daemon = os.path.join(self.target, 'sbin/start-stop-daemon') |
358 | - if os.path.exists(start_stop_daemon): |
359 | - os.rename(start_stop_daemon, '%s.REAL' % start_stop_daemon) |
360 | - f = open(start_stop_daemon, 'w') |
361 | - print >>f, """\ |
362 | -#!/bin/sh |
363 | -echo 1>&2 |
364 | -echo 'Warning: Fake start-stop-daemon called, doing nothing.' 1>&2 |
365 | -exit 0""" |
366 | - f.close() |
367 | - os.chmod(start_stop_daemon, 0755) |
368 | - |
369 | - initctl = os.path.join(self.target, 'sbin/initctl') |
370 | - if os.path.exists(initctl): |
371 | - os.rename(initctl, '%s.REAL' % initctl) |
372 | - f = open(initctl, 'w') |
373 | - print >>f, """\ |
374 | -#!/bin/sh |
375 | -echo 1>&2 |
376 | -echo 'Warning: Fake initctl called, doing nothing.' 1>&2 |
377 | -exit 0""" |
378 | - f.close() |
379 | - os.chmod(initctl, 0755) |
380 | - |
381 | - if not os.path.exists(os.path.join(self.target, 'proc/cmdline')): |
382 | - self.chrex('mount', '-t', 'proc', 'proc', '/proc') |
383 | - if not os.path.exists(os.path.join(self.target, 'sys/devices')): |
384 | - self.chrex('mount', '-t', 'sysfs', 'sysfs', '/sys') |
385 | - misc.execute('mount', '--bind', '/dev', os.path.join(self.target, 'dev')) |
386 | - |
387 | - if x11 and 'DISPLAY' in os.environ: |
388 | - if 'SUDO_USER' in os.environ: |
389 | - xauthority = os.path.expanduser('~%s/.Xauthority' % |
390 | - os.environ['SUDO_USER']) |
391 | - else: |
392 | - xauthority = os.path.expanduser('~/.Xauthority') |
393 | - if os.path.exists(xauthority): |
394 | - shutil.copy(xauthority, |
395 | - os.path.join(self.target, 'root/.Xauthority')) |
396 | - |
397 | - if not os.path.isdir(os.path.join(self.target, 'tmp/.X11-unix')): |
398 | - os.mkdir(os.path.join(self.target, 'tmp/.X11-unix')) |
399 | - misc.execute('mount', '--bind', '/tmp/.X11-unix', |
400 | - os.path.join(self.target, 'tmp/.X11-unix')) |
401 | - |
402 | - def chroot_cleanup(self, x11=False): |
403 | - """Undo the work done by chroot_setup.""" |
404 | - if self.target == '/': |
405 | - return |
406 | - |
407 | - if x11 and 'DISPLAY' in os.environ: |
408 | - misc.execute('umount', os.path.join(self.target, 'tmp/.X11-unix')) |
409 | - try: |
410 | - os.rmdir(os.path.join(self.target, 'tmp/.X11-unix')) |
411 | - except OSError: |
412 | - pass |
413 | - osextras.unlink_force(os.path.join(self.target, |
414 | - 'root/.Xauthority')) |
415 | - |
416 | - self.chrex('umount', '/dev') |
417 | - self.chrex('umount', '/sys') |
418 | - self.chrex('umount', '/proc') |
419 | - |
420 | - initctl = os.path.join(self.target, 'sbin/initctl') |
421 | - if os.path.exists('%s.REAL' % initctl): |
422 | - os.rename('%s.REAL' % initctl, initctl) |
423 | - |
424 | - start_stop_daemon = os.path.join(self.target, 'sbin/start-stop-daemon') |
425 | - if os.path.exists('%s.REAL' % start_stop_daemon): |
426 | - os.rename('%s.REAL' % start_stop_daemon, start_stop_daemon) |
427 | - else: |
428 | - osextras.unlink_force(start_stop_daemon) |
429 | - |
430 | - policy_rc_d = os.path.join(self.target, 'usr/sbin/policy-rc.d') |
431 | - osextras.unlink_force(policy_rc_d) |
432 | - |
433 | - |
434 | def run_target_config_hooks(self): |
435 | """Run hook scripts from /usr/lib/ubiquity/target-config. This allows |
436 | casper to hook into us and repeat bits of its configuration in the |
437 | @@ -1127,6 +1028,10 @@ |
438 | self._db = db |
439 | def info(self, title): |
440 | self._db.progress('INFO', title) |
441 | + def get(self, question): |
442 | + return self._db.get(question) |
443 | + def substitute(self, template, substr, data): |
444 | + self._db.subst(template, substr, data) |
445 | |
446 | for plugin in self.plugins: |
447 | self.db.progress('SET', count) |
448 | @@ -1222,32 +1127,6 @@ |
449 | except KeyError: |
450 | return None |
451 | |
452 | - |
453 | - def record_installed(self, pkgs): |
454 | - """Record which packages we've explicitly installed so that we don't |
455 | - try to remove them later.""" |
456 | - |
457 | - record_file = "/var/lib/ubiquity/apt-installed" |
458 | - if not os.path.exists(os.path.dirname(record_file)): |
459 | - os.makedirs(os.path.dirname(record_file)) |
460 | - record = open(record_file, "a") |
461 | - |
462 | - for pkg in pkgs: |
463 | - print >>record, pkg |
464 | - |
465 | - record.close() |
466 | - |
467 | - |
468 | - def query_recorded_installed(self): |
469 | - apt_installed = set() |
470 | - if os.path.exists("/var/lib/ubiquity/apt-installed"): |
471 | - record_file = open("/var/lib/ubiquity/apt-installed") |
472 | - for line in record_file: |
473 | - apt_installed.add(line.strip()) |
474 | - record_file.close() |
475 | - return apt_installed |
476 | - |
477 | - |
478 | def mark_install(self, cache, pkg): |
479 | cachedpkg = self.get_cache_pkg(cache, pkg) |
480 | if cachedpkg is not None and not cachedpkg.isInstalled: |
481 | @@ -1270,11 +1149,17 @@ |
482 | |
483 | def select_language_packs(self): |
484 | try: |
485 | + master_disable = self.db.get('pkgsel/install-language-support') |
486 | + if master_disable != '' and not misc.create_bool(master_disable): |
487 | + return |
488 | + except debconf.DebconfError: |
489 | + pass |
490 | + try: |
491 | keep_packages = self.db.get('ubiquity/keep-installed') |
492 | keep_packages = keep_packages.replace(',', '').split() |
493 | syslog.syslog('keeping packages due to preseeding: %s' % |
494 | ' '.join(keep_packages)) |
495 | - self.record_installed(keep_packages) |
496 | + install_misc.record_installed(keep_packages) |
497 | except debconf.DebconfError: |
498 | pass |
499 | |
500 | @@ -1359,7 +1244,7 @@ |
501 | |
502 | del cache |
503 | |
504 | - self.record_installed(to_install) |
505 | + install_misc.record_installed(to_install) |
506 | self.langpacks = to_install |
507 | |
508 | def install_language_packs(self): |
509 | @@ -1416,7 +1301,7 @@ |
510 | if os.path.isdir(os.path.join(home, homedir, '.ecryptfs')): |
511 | syslog.syslog('ecryptfs already in use in %s' % |
512 | os.path.join(home, homedir)) |
513 | - self.record_installed(['ecryptfs-utils']) |
514 | + install_misc.record_installed(['ecryptfs-utils']) |
515 | break |
516 | |
517 | |
518 | @@ -1466,14 +1351,14 @@ |
519 | hardware system in which has been installed on and need some |
520 | automatic configurations to get work.""" |
521 | |
522 | - self.chroot_setup() |
523 | + install_misc.chroot_setup(self.target) |
524 | try: |
525 | dbfilter = hw_detect.HwDetect(None, self.db) |
526 | ret = dbfilter.run_command(auto_process=True) |
527 | if ret != 0: |
528 | raise InstallStepError("HwDetect failed with code %d" % ret) |
529 | finally: |
530 | - self.chroot_cleanup() |
531 | + install_misc.chroot_cleanup(self.target) |
532 | |
533 | self.db.progress('INFO', 'ubiquity/install/hardware') |
534 | |
535 | @@ -1514,16 +1399,16 @@ |
536 | 'etc/popularity-contest.conf')) |
537 | try: |
538 | participate = self.db.get('popularity-contest/participate') |
539 | - self.set_debconf('popularity-contest/participate', participate) |
540 | + install_misc.set_debconf(self.target, 'popularity-contest/participate', participate, self.db) |
541 | except debconf.DebconfError: |
542 | pass |
543 | |
544 | osextras.unlink_force(os.path.join(self.target, 'etc/papersize')) |
545 | subprocess.call(['log-output', '-t', 'ubiquity', 'chroot', self.target, |
546 | 'ucf', '--purge', '/etc/papersize'], |
547 | - preexec_fn=debconf_disconnect, close_fds=True) |
548 | + preexec_fn=install_misc.debconf_disconnect, close_fds=True) |
549 | try: |
550 | - self.set_debconf('libpaper/defaultpaper', '') |
551 | + install_misc.set_debconf(self.target, 'libpaper/defaultpaper', '', self.db) |
552 | except debconf.DebconfError: |
553 | pass |
554 | |
555 | @@ -1532,8 +1417,8 @@ |
556 | osextras.unlink_force(os.path.join( |
557 | self.target, 'etc/ssl/private/ssl-cert-snakeoil.key')) |
558 | |
559 | - self.chroot_setup(x11=True) |
560 | - self.chrex('dpkg-divert', '--package', 'ubiquity', '--rename', |
561 | + install_misc.chroot_setup(self.target, x11=True) |
562 | + install_misc.chrex(self.target,'dpkg-divert', '--package', 'ubiquity', '--rename', |
563 | '--quiet', '--add', '/usr/sbin/update-initramfs') |
564 | try: |
565 | os.symlink('/bin/true', os.path.join(self.target, |
566 | @@ -1550,14 +1435,14 @@ |
567 | |
568 | try: |
569 | for package in packages: |
570 | - self.reconfigure(package) |
571 | + install_misc.reconfigure(self.target, package) |
572 | finally: |
573 | osextras.unlink_force(os.path.join(self.target, |
574 | 'usr/sbin/update-initramfs')) |
575 | - self.chrex('dpkg-divert', '--package', 'ubiquity', '--rename', |
576 | + install_misc.chrex(self.target,'dpkg-divert', '--package', 'ubiquity', '--rename', |
577 | '--quiet', '--remove', '/usr/sbin/update-initramfs') |
578 | - self.chrex('update-initramfs', '-c', '-k', self.kernel_version) |
579 | - self.chroot_cleanup(x11=True) |
580 | + install_misc.chrex(self.target,'update-initramfs', '-c', '-k', self.kernel_version) |
581 | + install_misc.chroot_cleanup(self.target, x11=True) |
582 | |
583 | # Fix up kernel symlinks now that the initrd exists. Depending on |
584 | # the architecture, these may be in / or in /boot. |
585 | @@ -1603,25 +1488,6 @@ |
586 | continue |
587 | os.symlink(linksrc, linkdst) |
588 | |
589 | - |
590 | - def get_all_interfaces(self): |
591 | - """Get all non-local network interfaces.""" |
592 | - ifs = [] |
593 | - ifs_file = open('/proc/net/dev') |
594 | - # eat header |
595 | - ifs_file.readline() |
596 | - ifs_file.readline() |
597 | - |
598 | - for line in ifs_file: |
599 | - name = re.match('(.*?(?::\d+)?):', line.strip()).group(1) |
600 | - if name == 'lo': |
601 | - continue |
602 | - ifs.append(name) |
603 | - |
604 | - ifs_file.close() |
605 | - return ifs |
606 | - |
607 | - |
608 | def configure_network(self): |
609 | """Automatically configure the network. |
610 | |
611 | @@ -1695,7 +1561,7 @@ |
612 | |
613 | if_names = {} |
614 | sock = socket.socket(socket.SOCK_DGRAM) |
615 | - interfaces = self.get_all_interfaces() |
616 | + interfaces = install_misc.get_all_interfaces() |
617 | for i in range(len(interfaces)): |
618 | if_names[interfaces[i]] = struct.unpack('H6s', |
619 | fcntl.ioctl(sock.fileno(), SIOCGIFHWADDR, |
620 | @@ -1868,7 +1734,7 @@ |
621 | self.db, 'ubiquity/install/title', |
622 | 'ubiquity/install/apt_info', |
623 | 'ubiquity/install/apt_error_install') |
624 | - self.chroot_setup() |
625 | + install_misc.chroot_setup(self.target) |
626 | commit_error = None |
627 | try: |
628 | try: |
629 | @@ -1889,7 +1755,7 @@ |
630 | syslog.syslog(syslog.LOG_ERR, line) |
631 | commit_error = str(e) |
632 | finally: |
633 | - self.chroot_cleanup() |
634 | + install_misc.chroot_cleanup(self.target) |
635 | self.db.progress('SET', 10) |
636 | |
637 | cache.open(None) |
638 | @@ -2040,7 +1906,7 @@ |
639 | installprogress = DebconfInstallProgress( |
640 | self.db, 'ubiquity/install/title', 'ubiquity/install/apt_info', |
641 | 'ubiquity/install/apt_error_remove') |
642 | - self.chroot_setup() |
643 | + install_misc.chroot_setup(self.target) |
644 | commit_error = None |
645 | try: |
646 | try: |
647 | @@ -2054,7 +1920,7 @@ |
648 | syslog.syslog(syslog.LOG_ERR, line) |
649 | commit_error = str(e) |
650 | finally: |
651 | - self.chroot_cleanup() |
652 | + install_misc.chroot_cleanup(self.target) |
653 | self.db.progress('SET', 5) |
654 | |
655 | cache.open(None) |
656 | @@ -2160,7 +2026,7 @@ |
657 | self.db.progress('REGION', 2, 5) |
658 | try: |
659 | if remove_kernels: |
660 | - self.do_remove(remove_kernels, recursive=True) |
661 | + install_misc.record_removed(remove_kernels, recursive=True) |
662 | except: |
663 | self.db.progress('STOP') |
664 | raise |
665 | @@ -2226,7 +2092,7 @@ |
666 | if not found_cdrom: |
667 | os.rename("%s.apt-setup" % sources_list, sources_list) |
668 | |
669 | - self.do_install(self.query_recorded_installed()) |
670 | + self.do_install(install_misc.query_recorded_installed()) |
671 | |
672 | if found_cdrom: |
673 | os.rename("%s.apt-setup" % sources_list, sources_list) |
674 | @@ -2247,10 +2113,10 @@ |
675 | if os.path.exists(os.path.join(self.target, |
676 | desktop_file)): |
677 | desktop_base = os.path.basename(desktop_file) |
678 | - self.chrex('install', '-d', |
679 | + install_misc.chrex(self.target,'install', '-d', |
680 | '-o', 'oem', '-g', 'oem', |
681 | '/home/oem/Desktop') |
682 | - self.chrex('install', '-o', 'oem', '-g', 'oem', |
683 | + install_misc.chrex(self.target,'install', '-o', 'oem', '-g', 'oem', |
684 | '/%s' % desktop_file, |
685 | '/home/oem/Desktop/%s' % desktop_base) |
686 | break |
687 | @@ -2259,13 +2125,16 @@ |
688 | # This mimics the behavior in 01oem-config-udeb. |
689 | di_locale = self.db.get('debian-installer/locale') |
690 | if di_locale: |
691 | - self.set_debconf('debian-installer/locale', di_locale) |
692 | - |
693 | + install_misc.set_debconf(self.target, 'debian-installer/locale', di_locale, self.db) |
694 | #in an automated install, this key needs to carry over |
695 | installable_lang = self.db.get('ubiquity/only-show-installable-languages') |
696 | if installable_lang: |
697 | +<<<<<<< TREE |
698 | self.set_debconf('ubiquity/only-show-installable-languages', |
699 | installable_lang) |
700 | +======= |
701 | + install_misc.set_debconf(self.target, 'ubiquity/only-show-installable-languages', self.db) |
702 | +>>>>>>> MERGE-SOURCE |
703 | except debconf.DebconfError: |
704 | pass |
705 | |
706 | @@ -2303,7 +2172,7 @@ |
707 | difference = set() |
708 | |
709 | # Keep packages we explicitly installed. |
710 | - keep = self.query_recorded_installed() |
711 | + keep = install_misc.query_recorded_installed() |
712 | |
713 | arch, subarch = self.archdetect() |
714 | |
715 | @@ -2336,11 +2205,15 @@ |
716 | difference.add(pkg) |
717 | del cache |
718 | |
719 | + install_misc.record_removed(difference) |
720 | + |
721 | # Don't worry about failures removing packages; it will be easier |
722 | # for the user to sort them out with a graphical package manager (or |
723 | # whatever) after installation than it will be to try to deal with |
724 | # them automatically here. |
725 | - self.do_remove(difference) |
726 | + (regular, recursive) = install_misc.query_recorded_removed() |
727 | + self.do_remove(regular) |
728 | + self.do_remove(recursive, recursive=True) |
729 | |
730 | def remove_broken_cdrom(self): |
731 | if 'UBIQUITY_OEM_USER_CONFIG' in os.environ: |
732 | @@ -2494,14 +2367,14 @@ |
733 | if not os.path.exists(os.path.join(self.target, 'etc/init.d/apparmor')): |
734 | syslog.syslog('Apparmor is not installed, so not generating cache.') |
735 | return |
736 | - self.chrex('mount', '-t', 'proc', 'proc', '/proc') |
737 | - self.chrex('mount', '-t', 'sysfs', 'sysfs', '/sys') |
738 | - self.chrex('mount', '-t', 'securityfs', |
739 | + install_misc.chrex(self.target,'mount', '-t', 'proc', 'proc', '/proc') |
740 | + install_misc.chrex(self.target,'mount', '-t', 'sysfs', 'sysfs', '/sys') |
741 | + install_misc.chrex(self.target,'mount', '-t', 'securityfs', |
742 | 'securityfs', '/sys/kernel/security') |
743 | - self.chrex('/etc/init.d/apparmor', 'recache') |
744 | - self.chrex('umount', '/proc') |
745 | - self.chrex('umount', '/sys/kernel/security') |
746 | - self.chrex('umount', '/sys') |
747 | + install_misc.chrex(self.target,'/etc/init.d/apparmor', 'recache') |
748 | + install_misc.chrex(self.target,'umount', '/proc') |
749 | + install_misc.chrex(self.target,'umount', '/sys/kernel/security') |
750 | + install_misc.chrex(self.target,'umount', '/sys') |
751 | |
752 | def cleanup(self): |
753 | """Miscellaneous cleanup tasks.""" |
754 | @@ -2522,11 +2395,6 @@ |
755 | self.umount_source() |
756 | |
757 | |
758 | - def chrex(self, *args): |
759 | - """executes commands on chroot system (provided by *args).""" |
760 | - return misc.execute('chroot', self.target, *args) |
761 | - |
762 | - |
763 | def copy_debconf(self, package): |
764 | """setting debconf database into installed system.""" |
765 | |
766 | @@ -2541,39 +2409,6 @@ |
767 | '--config=Driver:File','--config=Filename:' + targetdb) |
768 | |
769 | |
770 | - def set_debconf(self, question, value): |
771 | - try: |
772 | - if 'UBIQUITY_OEM_USER_CONFIG' in os.environ: |
773 | - dccomm = None |
774 | - dc = self.db |
775 | - else: |
776 | - dccomm = subprocess.Popen(['log-output', '-t', 'ubiquity', |
777 | - '--pass-stdout', |
778 | - 'chroot', self.target, |
779 | - 'debconf-communicate', |
780 | - '-fnoninteractive', 'ubiquity'], |
781 | - stdin=subprocess.PIPE, |
782 | - stdout=subprocess.PIPE, close_fds=True) |
783 | - dc = debconf.Debconf(read=dccomm.stdout, write=dccomm.stdin) |
784 | - dc.set(question, value) |
785 | - dc.fset(question, 'seen', 'true') |
786 | - finally: |
787 | - if dccomm: |
788 | - dccomm.stdin.close() |
789 | - dccomm.wait() |
790 | - |
791 | - |
792 | - def reconfigure_preexec(self): |
793 | - debconf_disconnect() |
794 | - os.environ['XAUTHORITY'] = '/root/.Xauthority' |
795 | - |
796 | - def reconfigure(self, package): |
797 | - """executes a dpkg-reconfigure into installed system to each |
798 | - package which provided by args.""" |
799 | - subprocess.call(['log-output', '-t', 'ubiquity', 'chroot', self.target, |
800 | - 'dpkg-reconfigure', '-fnoninteractive', package], |
801 | - preexec_fn=self.reconfigure_preexec, close_fds=True) |
802 | - |
803 | |
804 | if __name__ == '__main__': |
805 | if not os.path.exists('/var/lib/ubiquity'): |
806 | |
807 | === added file 'scripts/mythbuntu/60mythbuntu_user' |
808 | --- scripts/mythbuntu/60mythbuntu_user 1970-01-01 00:00:00 +0000 |
809 | +++ scripts/mythbuntu/60mythbuntu_user 2010-01-27 01:47:14 +0000 |
810 | @@ -0,0 +1,18 @@ |
811 | +#!/bin/sh |
812 | +. /usr/share/debconf/confmodule |
813 | + |
814 | +# The mythbuntu plugins make changes in the HOME of the new user before |
815 | +# it's made, so some things need to be cleaned up |
816 | + |
817 | +#TODO 01-10: remove me. I'm a hack, mostly because usersetup is still not a |
818 | +#ubiquity plugin. That appears to be a pretty big task though, so i'll |
819 | +#get by for now. |
820 | + |
821 | +db_get passwd/username |
822 | +CHROOT="chroot /target" |
823 | +TARGET_USERNAME="$RET" |
824 | +TARGET_HOME=$($CHROOT getent passwd $TARGET_USERNAME | cut -d : -f6) |
825 | + |
826 | +$CHROOT adduser $TARGET_USERNAME mythtv |
827 | +$CHROOT adduser $TARGET_USERNAME video |
828 | +$CHROOT chown 1000:1000 $TARGET_HOME -R |
829 | |
830 | === modified file 'scripts/mythbuntu/mythbuntu-setup' |
831 | --- scripts/mythbuntu/mythbuntu-setup 2009-12-10 15:32:58 +0000 |
832 | +++ scripts/mythbuntu/mythbuntu-setup 2010-01-27 01:47:14 +0000 |
833 | @@ -38,6 +38,6 @@ |
834 | |
835 | #Stop MySQL if we started it |
836 | if [ -f $ROOT/etc/mysql/debian.cnf ]; then |
837 | - $log unmount /var/run/mysqld |
838 | + $log umount $ROOT/var/run/mysqld |
839 | $log $chroot $ROOT mysqladmin --defaults-file=/etc/mysql/debian.cnf shutdown |
840 | fi |
841 | |
842 | === removed file 'scripts/mythbuntu/mythbuntu_install.py' |
843 | --- scripts/mythbuntu/mythbuntu_install.py 2010-01-18 07:14:22 +0000 |
844 | +++ scripts/mythbuntu/mythbuntu_install.py 1970-01-01 00:00:00 +0000 |
845 | @@ -1,389 +0,0 @@ |
846 | -#!/usr/bin/python |
847 | -# -*- coding: utf-8; Mode: Python; indent-tabs-mode: nil; tab-width: 4 -*- |
848 | - |
849 | -# Copyright (C) 2005 Javier Carranza and others for Guadalinex |
850 | -# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd. |
851 | -# Copyright (C) 2007-2009 Mario Limonciello |
852 | -# |
853 | -# This program is free software; you can redistribute it and/or modify |
854 | -# it under the terms of the GNU General Public License as published by |
855 | -# the Free Software Foundation; either version 2 of the License, or |
856 | -# (at your option) any later version. |
857 | -# |
858 | -# This program is distributed in the hope that it will be useful, |
859 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
860 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
861 | -# GNU General Public License for more details. |
862 | -# |
863 | -# You should have received a copy of the GNU General Public License |
864 | -# along with this program; if not, write to the Free Software |
865 | -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
866 | - |
867 | -import sys |
868 | -import os |
869 | -import errno |
870 | -import re |
871 | -import syslog |
872 | -import debconf |
873 | -import shutil |
874 | -import XKit.xutils |
875 | -import subprocess |
876 | - |
877 | -import string |
878 | - |
879 | -sys.path.insert(0, '/usr/lib/ubiquity') |
880 | - |
881 | -from ubiquity import osextras |
882 | -from install import Install as ParentInstall |
883 | -from install import InstallStepError |
884 | -from ubiquity.components import mythbuntu_install |
885 | - |
886 | -from mythbuntu_common.lirc import LircHandler |
887 | -from mythbuntu_common.vnc import VNCHandler |
888 | - |
889 | -class Install(ParentInstall): |
890 | - |
891 | - def __init__(self): |
892 | - """Initializes the Mythbuntu installer extra objects""" |
893 | - |
894 | - #Configure Parent cclass First so we can override things |
895 | - ParentInstall.__init__(self) |
896 | - |
897 | - self.lirc=LircHandler() |
898 | - self.vnc=VNCHandler() |
899 | - self.type = self.db.get('mythbuntu/install_type') |
900 | - |
901 | - #This forces install_langpacks to do Nothing |
902 | - self.langpacks={} |
903 | - |
904 | - def configure_user(self): |
905 | - """Configures by the regular user configuration stuff |
906 | - followed by mythbuntu specific user addons""" |
907 | - |
908 | - #Before beginning, set the initial root sql pass to the user pass |
909 | - self.passwd=self.db.get('passwd/user-password') |
910 | - self.set_debconf('mythtv/mysql_admin_password',self.passwd) |
911 | - self.set_debconf('mysql-server/root_password',self.passwd) |
912 | - self.set_debconf('mysql-server/root_password_again',self.passwd) |
913 | - |
914 | - #Regular ubuntu user configuration |
915 | - ParentInstall.configure_user(self) |
916 | - |
917 | - #We'll be needing the username, uid, gid |
918 | - self.user = self.db.get('passwd/username') |
919 | - self.uid = self.gid = '' |
920 | - try: |
921 | - self.uid = self.db.get('passwd/user-uid') |
922 | - except debconf.DebconfError: |
923 | - pass |
924 | - try: |
925 | - self.gid = self.db.get('passwd/user-gid') |
926 | - except debconf.DebconfError: |
927 | - pass |
928 | - if self.uid == '': |
929 | - self.uid = 1000 |
930 | - else: |
931 | - self.uid = int(self.uid) |
932 | - if self.gid == '': |
933 | - self.gid = 1000 |
934 | - else: |
935 | - self.gid = int(self.gid) |
936 | - |
937 | - #Create a .mythtv directory |
938 | - home_mythtv_dir = self.target + '/home/' + self.user + '/.mythtv' |
939 | - if not os.path.isdir(home_mythtv_dir): |
940 | - #in case someone made a symlink or file for the directory |
941 | - if os.path.islink(home_mythtv_dir) or os.path.exists(home_mythtv_dir): |
942 | - os.remove(home_mythtv_dir) |
943 | - os.mkdir(home_mythtv_dir) |
944 | - os.chown(home_mythtv_dir,self.uid,self.gid) |
945 | - |
946 | - #Remove mysql.txt from home directory if it's there, then make one |
947 | - sql_txt= home_mythtv_dir + '/mysql.txt' |
948 | - if os.path.islink(sql_txt) or os.path.exists(sql_txt): |
949 | - os.remove(sql_txt) |
950 | - try: |
951 | - os.symlink('/etc/mythtv/mysql.txt',sql_txt) |
952 | - except OSError: |
953 | - #on a live disk there is a chance this was a broken link |
954 | - #depending on what the user did in the livefs |
955 | - pass |
956 | - |
957 | - #mythtv.desktop autostart |
958 | - if 'Frontend' in self.type: |
959 | - config_dir = self.target + '/home/' + self.user + '/.config' |
960 | - autostart_dir = config_dir + '/autostart' |
961 | - autostart_link = autostart_dir + '/mythtv.desktop' |
962 | - if not os.path.isdir(config_dir): |
963 | - os.makedirs(config_dir) |
964 | - os.chown(config_dir,self.uid,self.gid) |
965 | - if not os.path.isdir(autostart_dir): |
966 | - os.makedirs(autostart_dir) |
967 | - os.chown(autostart_dir,self.uid,self.gid) |
968 | - elif os.path.islink(autostart_link) or os.path.exists(autostart_link): |
969 | - os.remove(autostart_link) |
970 | - try: |
971 | - os.symlink('/usr/share/applications/mythtv.desktop',autostart_link) |
972 | - except OSError: |
973 | - #on a live disk, this will appear a broken link, but it works |
974 | - pass |
975 | - |
976 | - #group membership |
977 | - self.chrex('adduser', self.user, 'mythtv') |
978 | - self.chrex('adduser', self.user, 'video') |
979 | - |
980 | - def configure_ma(self): |
981 | - """Overrides module assistant configuration method. Mythbuntu doesn't |
982 | - use module assistant, but we can instead run MySQL and mythweb config |
983 | - here""" |
984 | - self.db.progress('INFO', 'ubiquity/install/mythbuntu') |
985 | - |
986 | - #Copy a few debconf questions that were answered in the installer |
987 | - for question in ('mythtv/mysql_mythtv_user','mythtv/mysql_mythtv_password',\ |
988 | - 'mythtv/mysql_mythtv_dbname','mythtv/mysql_host'): |
989 | - answer=self.db.get(question) |
990 | - self.set_debconf(question,answer) |
991 | - |
992 | - #Setup mysql.txt nicely |
993 | - os.remove(self.target + '/etc/mythtv/mysql.txt') |
994 | - self.reconfigure('mythtv-common') |
995 | - |
996 | - #only reconfigure database if appropriate |
997 | - if 'Master' in self.type: |
998 | - #Prepare |
999 | - |
1000 | - #Setup database |
1001 | - self.reconfigure('mysql-server-5.1') |
1002 | - proc=subprocess.Popen(['chroot',self.target,'mysqld']) |
1003 | - self.reconfigure('mythtv-database') |
1004 | - |
1005 | - #Cleanup |
1006 | - self.chrex('mysqladmin','--defaults-file=/etc/mysql/debian.cnf','shutdown') |
1007 | - proc.communicate() |
1008 | - |
1009 | - #Mythweb |
1010 | - self.set_debconf('mythweb/enable', 'true') |
1011 | - self.set_debconf('mythweb/username', self.user) |
1012 | - self.set_debconf('mythweb/password', self.passwd) |
1013 | - self.reconfigure('mythweb') |
1014 | - |
1015 | - def install_extras(self): |
1016 | - """Overrides main install_extras function to add in Mythbuntu |
1017 | - drivers and services, and then call the parent function""" |
1018 | - video_driver = self.db.get('mythbuntu/video_driver') |
1019 | - vnc = self.db.get('mythbuntu/x11vnc') |
1020 | - nfs = self.db.get('mythbuntu/nfs-kernel-server') |
1021 | - to_install = [] |
1022 | - to_remove = set() |
1023 | - if video_driver != "Open Source Driver": |
1024 | - to_install.append(video_driver) |
1025 | - if vnc == 'true': |
1026 | - to_install.append('x11vnc') |
1027 | - if nfs == 'true': |
1028 | - to_install.append('nfs-kernel-server') |
1029 | - to_install.append('portmap') |
1030 | - |
1031 | - #Remove any conflicts before installing new items |
1032 | - if to_remove != []: |
1033 | - self.do_remove(to_remove) |
1034 | - #Mark new items |
1035 | - self.record_installed(to_install) |
1036 | - |
1037 | - #Actually install extras |
1038 | - ParentInstall.install_extras(self) |
1039 | - |
1040 | - #Run depmod if we might be using a DKMS enabled driver |
1041 | - if video_driver != "Open Source Driver": |
1042 | - self.chrex('/sbin/depmod','-a') |
1043 | - |
1044 | - def configure_hardware(self): |
1045 | - """Overrides parent function to add in hooks for configuring |
1046 | - drivers and services""" |
1047 | - |
1048 | - #Drivers |
1049 | - self.db.progress('INFO', 'ubiquity/install/drivers') |
1050 | - video_driver = self.db.get('mythbuntu/video_driver') |
1051 | - out = self.db.get('mythbuntu/tvout') |
1052 | - standard = self.db.get('mythbuntu/tvstandard') |
1053 | - if 'nvidia' in video_driver: |
1054 | - self.enable_nvidia(out,standard) |
1055 | - elif 'fglrx' in video_driver: |
1056 | - self.enable_amd(out,standard) |
1057 | - |
1058 | - #Services |
1059 | - self.db.progress('INFO', 'ubiquity/install/services') |
1060 | - if self.db.get('mythbuntu/samba') == 'true': |
1061 | - shutil.copy('/usr/share/mythbuntu/examples/smb.conf.dist',self.target + '/etc/samba/smb.conf') |
1062 | - if self.db.get('mythbuntu/nfs-kernel-server') == 'true': |
1063 | - shutil.copy('/usr/share/mythbuntu/examples/exports.dist',self.target + '/etc/exports') |
1064 | - if self.db.get('mythbuntu/openssh-server') == 'true': |
1065 | - for file in ['ssh_host_dsa_key','ssh_host_dsa_key.pub','ssh_host_rsa_key','ssh_host_rsa_key.pub']: |
1066 | - os.remove(self.target + '/etc/ssh/' + file) |
1067 | - self.reconfigure('openssh-server') |
1068 | - if self.db.get('mythbuntu/mysql-server') == 'true': |
1069 | - f=open(self.target + '/etc/mysql/conf.d/mythtv.cnf','w') |
1070 | - print >>f, """\ |
1071 | -[mysqld] |
1072 | -bind-address=0.0.0.0""" |
1073 | - f.close() |
1074 | - if self.db.get('mythbuntu/x11vnc') == 'true': |
1075 | - self.vnc.create_password(self.passwd) |
1076 | - directory = self.target + '/home/' + self.user + '/.vnc' |
1077 | - if not os.path.exists(directory): |
1078 | - os.mkdir(directory) |
1079 | - shutil.move('/root/.vnc/passwd', directory + '/passwd') |
1080 | - os.system('chown ' + str(self.uid) + ':' + str(self.gid) + ' -R ' + directory) |
1081 | - |
1082 | - #Remotes & Transmitters |
1083 | - self.db.progress('INFO', 'ubiquity/install/ir') |
1084 | - self.configure_ir() |
1085 | - |
1086 | - #Regular parent hardware configure f/n |
1087 | - self.db.progress('INFO', 'ubiquity/install/hardware') |
1088 | - ParentInstall.configure_hardware(self) |
1089 | - |
1090 | - def configure_ir(self): |
1091 | - """Configures the remote & transmitter per user choices""" |
1092 | - #configure lircd for remote and transmitter |
1093 | - ir_device={"modules":"","driver":"","device":"","lircd_conf":"","remote":"","transmitter":""} |
1094 | - self.chroot_setup() |
1095 | - self.chrex('dpkg-divert', '--package', 'ubiquity', '--rename', |
1096 | - '--quiet', '--add', '/sbin/udevd') |
1097 | - try: |
1098 | - os.symlink('/bin/true', '/target/sbin/udevd') |
1099 | - except OSError: |
1100 | - pass |
1101 | - |
1102 | - try: |
1103 | - ir_device["remote"] = self.db.get('lirc/remote') |
1104 | - self.set_debconf('lirc/remote',ir_device["remote"]) |
1105 | - ir_device["modules"] = "" |
1106 | - ir_device["driver"] = "" |
1107 | - ir_device["device"] = "" |
1108 | - ir_device["lircd_conf"] = "" |
1109 | - self.lirc.set_device(ir_device,"remote") |
1110 | - except debconf.DebconfError: |
1111 | - pass |
1112 | - |
1113 | - try: |
1114 | - ir_device["transmitter"] = self.db.get('lirc/transmitter') |
1115 | - self.set_debconf('lirc/transmitter',ir_device["transmitter"]) |
1116 | - ir_device["modules"] = "" |
1117 | - ir_device["driver"] = "" |
1118 | - ir_device["device"] = "" |
1119 | - ir_device["lircd_conf"] = "" |
1120 | - self.lirc.set_device(ir_device,"transmitter") |
1121 | - except debconf.DebconfError: |
1122 | - pass |
1123 | - |
1124 | - self.lirc.write_hardware_conf(self.target + '/etc/lirc/hardware.conf') |
1125 | - |
1126 | - try: |
1127 | - self.reconfigure('lirc') |
1128 | - finally: |
1129 | - osextras.unlink_force('/target/sbin/udevd') |
1130 | - self.chrex('dpkg-divert', '--package', 'ubiquity', '--rename', |
1131 | - '--quiet', '--remove', '/sbin/udevd') |
1132 | - self.chroot_cleanup() |
1133 | - |
1134 | - #configure lircrc |
1135 | - home = '/target/home/' + self.db.get('passwd/username') |
1136 | - os.putenv('HOME',home) |
1137 | - self.lirc.create_lircrc(self.target + "/etc/lirc/lircd.conf",False) |
1138 | - os.system('chown ' + str(self.uid) + ':' + str(self.gid) + ' -R ' + home + '/.lirc*') |
1139 | - |
1140 | - def enable_amd(self, type, fmt): |
1141 | - if type == 'Composite Video Output': |
1142 | - self.chrex('/usr/bin/aticonfig','--tvs VIDEO', '--tvf ' + fmt) |
1143 | - elif type == 'S-Video Video Output': |
1144 | - self.chrex('/usr/bin/aticonfig','--tvs VIDEO', '--tvf ' + fmt) |
1145 | - elif type == 'Component Video Output': |
1146 | - self.chrex('/usr/bin/aticonfig','--tvs YUV', '--tvf ' + fmt) |
1147 | - else: |
1148 | - self.chrex('/usr/bin/aticonfig') |
1149 | - |
1150 | - def enable_nvidia(self, type, fmt): |
1151 | - """Enables an NVIDIA graphics driver using XKit""" |
1152 | - xorg_conf=XKit.xutils.XUtils() |
1153 | - |
1154 | - extra_conf_options={'NoLogo': '1', |
1155 | - 'DPI': '100x100'} |
1156 | - |
1157 | - if type == 'Composite Video Output': |
1158 | - extra_conf_options["ConnectedMonitor"]="TV" |
1159 | - extra_conf_options["TVOutFormat"]="COMPOSITE" |
1160 | - extra_conf_options["TVStandard"]=fmt |
1161 | - elif type == 'S-Video Video Output': |
1162 | - extra_conf_options["ConnectedMonitor"]="TV" |
1163 | - extra_conf_options["TVOutFormat"]="SVIDEO" |
1164 | - extra_conf_options["TVStandard"]=fmt |
1165 | - elif type == 'Component Video Output': |
1166 | - extra_conf_options["ConnectedMonitor"]="TV" |
1167 | - extra_conf_options["TVOutFormat"]="COMPONENT" |
1168 | - extra_conf_options["TVStandard"]=fmt |
1169 | - |
1170 | - #Set up device section |
1171 | - relevant_devices = [] |
1172 | - if len(xorg_conf.globaldict['Device']) == 0: |
1173 | - device = xorg_conf.makeSection('Device', identifier='Default Device') |
1174 | - relevant_devices.append(device) |
1175 | - xorg_conf.setDriver('Device', 'nvidia', device) |
1176 | - else: |
1177 | - devices = xorg_conf.getDevicesInUse() |
1178 | - if len(devices) > 0: |
1179 | - relevant_devices = devices |
1180 | - else: |
1181 | - relevant_devices = xorg_conf.globaldict['Device'].keys() |
1182 | - for device in relevant_devices: |
1183 | - xorg_conf.setDriver('Device', 'nvidia', device) |
1184 | - |
1185 | - for device_section in relevant_devices: |
1186 | - for k, v in extra_conf_options.iteritems(): |
1187 | - xorg_conf.addOption('Device', k, v, optiontype='Option', position=device_section) |
1188 | - |
1189 | - #Set up screen section |
1190 | - if len(xorg_conf.globaldict['Screen']) == 0: |
1191 | - screen = xorg_conf.makeSection('Screen', identifier='Default Screen') |
1192 | - |
1193 | - xorg_conf.addOption('Screen', 'DefaultDepth', '24', position=0, prefix='') |
1194 | - |
1195 | - xorg_conf.writeFile(self.target + "/etc/X11/xorg.conf") |
1196 | - |
1197 | - def remove_extras(self): |
1198 | - """Try to remove packages that are installed on the live CD but not on |
1199 | - the installed system.""" |
1200 | - #First remove normal live-desktop packages |
1201 | - ParentInstall.remove_extras(self) |
1202 | - |
1203 | - #now take care of mythbuntu specifics |
1204 | - packages=set() |
1205 | - ## system role |
1206 | - if 'Backend' not in self.type: |
1207 | - packages.add('libnet-upnp-perl') #causes mythtv-backend to be removed |
1208 | - packages.add('php5-common') #causes mythweb to be removed |
1209 | - packages.add('libaprutil1') #causes apache2 to be removed |
1210 | - if 'Slave' in self.type or self.type == 'Frontend': |
1211 | - packages.add('ntp') #causes mythtv-backend-master to go |
1212 | - packages.add('mythtv-database') |
1213 | - packages.add('mysql-server-core-5.1') |
1214 | - if 'Frontend' not in self.type: |
1215 | - packages.add('mythtv-frontend') |
1216 | - ## services that are installed by default |
1217 | - for service in ['samba','openssh-server']: |
1218 | - if self.db.get('mythbuntu/' + service) == "false": |
1219 | - packages.add(service) |
1220 | - |
1221 | - if len(packages) >= 0: |
1222 | - #recursively remove to make sure we get plugins and services that |
1223 | - #aren't necessary anymore |
1224 | - self.do_remove(packages,True) |
1225 | - |
1226 | -if __name__ == '__main__': |
1227 | - if not os.path.exists('/var/lib/ubiquity'): |
1228 | - os.makedirs('/var/lib/ubiquity') |
1229 | - osextras.unlink_force('/var/lib/ubiquity/install.trace') |
1230 | - |
1231 | - install = Install() |
1232 | - sys.excepthook = install.excepthook |
1233 | - install.run() |
1234 | - sys.exit(0) |
1235 | |
1236 | === modified file 'ubiquity/components/myth-backend-setup.py' |
1237 | --- ubiquity/components/myth-backend-setup.py 2009-09-01 18:20:59 +0000 |
1238 | +++ ubiquity/components/myth-backend-setup.py 2010-01-27 01:47:14 +0000 |
1239 | @@ -2,7 +2,7 @@ |
1240 | # |
1241 | # Copyright (C) 2006, 2007, 2009 Canonical Ltd. |
1242 | # Written by Colin Watson <cjwatson@ubuntu.com>. |
1243 | -# Copyright (C) 2007 Mario Limonciello |
1244 | +# Copyright (C) 2007-2010 Mario Limonciello |
1245 | # |
1246 | # This file is part of Ubiquity. |
1247 | # |
1248 | @@ -19,17 +19,27 @@ |
1249 | # You should have received a copy of the GNU General Public License |
1250 | # along with Ubiquity. If not, see <http://www.gnu.org/licenses/>. |
1251 | |
1252 | +from ubiquity.misc import execute_root |
1253 | +from mythbuntu_common.installer import MythPageGtk |
1254 | +from ubiquity.plugin import * |
1255 | import os |
1256 | -from ubiquity.plugin import * |
1257 | |
1258 | NAME = 'myth-backend-setup' |
1259 | AFTER = 'myth-summary' |
1260 | WEIGHT = 10 |
1261 | |
1262 | -class PageGtk(PluginUI): |
1263 | - def __init__(self, *args, **kwargs): |
1264 | - if os.environ['UBIQUITY_FRONTEND'] == 'mythbuntu_ui': |
1265 | - self.plugin_optional_widgets = 'mythbuntu_stepBackendSetup' |
1266 | +class PageGtk(MythPageGtk): |
1267 | + def __init__(self, controller, *args, **kwargs): |
1268 | + self.ui_file='mythbuntu_stepBackendSetup' |
1269 | + MythPageGtk.__init__(self,controller, *args, **kwargs) |
1270 | |
1271 | def plugin_get_current_page(self): |
1272 | - return None |
1273 | + if not os.path.exists('/target/usr/bin/mythtv-setup'): |
1274 | + self.controller.go_forward() |
1275 | + return self.plugin_widgets |
1276 | + |
1277 | + def do_mythtv_setup(self,widget): |
1278 | + """Spawn MythTV-Setup binary.""" |
1279 | + self.controller.toggle_top_level() |
1280 | + execute_root("/usr/share/ubiquity/mythbuntu-setup") |
1281 | + self.controller.toggle_top_level() |
1282 | |
1283 | === modified file 'ubiquity/components/myth-drivers.py' |
1284 | --- ubiquity/components/myth-drivers.py 2009-09-01 18:20:59 +0000 |
1285 | +++ ubiquity/components/myth-drivers.py 2010-01-27 01:47:14 +0000 |
1286 | @@ -2,7 +2,7 @@ |
1287 | # |
1288 | # Copyright (C) 2006, 2007, 2009 Canonical Ltd. |
1289 | # Written by Colin Watson <cjwatson@ubuntu.com>. |
1290 | -# Copyright (C) 2007 Mario Limonciello |
1291 | +# Copyright (C) 2007-2010 Mario Limonciello |
1292 | # |
1293 | # This file is part of Ubiquity. |
1294 | # |
1295 | @@ -21,32 +21,104 @@ |
1296 | |
1297 | from ubiquity.plugin import * |
1298 | from mythbuntu_common.dictionaries import get_graphics_dictionary |
1299 | +from mythbuntu_common.installer import * |
1300 | +from ubiquity import install_misc |
1301 | +import XKit.xutils |
1302 | import os |
1303 | |
1304 | NAME = 'myth-drivers' |
1305 | AFTER = 'myth-remote' |
1306 | WEIGHT = 10 |
1307 | |
1308 | -class PageGtk(PluginUI): |
1309 | - def __init__(self, *args, **kwargs): |
1310 | - if os.environ['UBIQUITY_FRONTEND'] == 'mythbuntu_ui' and \ |
1311 | - len(get_graphics_dictionary()) > 0: |
1312 | - self.plugin_widgets = 'mythbuntu_stepDrivers' |
1313 | +class PageGtk(MythPageGtk): |
1314 | + def __init__(self, controller, *args, **kwargs): |
1315 | + if len(get_graphics_dictionary()) > 0: |
1316 | + self.ui_file = 'mythbuntu_stepDrivers' |
1317 | + MythPageGtk.__init__(self, controller, *args, **kwargs) |
1318 | + self.populate_video() |
1319 | + |
1320 | + def populate_video(self): |
1321 | + """Finds the currently active video driver""" |
1322 | + dictionary=get_graphics_dictionary() |
1323 | + if len(dictionary) > 0: |
1324 | + for driver in dictionary: |
1325 | + self.video_driver.append_text(driver) |
1326 | + self.video_driver.append_text("Open Source Driver") |
1327 | + self.video_driver.set_active(len(dictionary)) |
1328 | + self.tvoutstandard.set_active(0) |
1329 | + self.tvouttype.set_active(0) |
1330 | + |
1331 | + def toggle_tv_out (self,widget): |
1332 | + """Called when the tv-out type is toggled""" |
1333 | + if (self.tvouttype.get_active() == 0): |
1334 | + self.tvoutstandard.set_active(0) |
1335 | + elif ((self.tvouttype.get_active() == 1 or self.tvouttype.get_active() == 2) and (self.tvoutstandard.get_active() == 0 or self.tvoutstandard.get_active() >= 11 )): |
1336 | + self.tvoutstandard.set_active(10) |
1337 | + elif self.tvouttype.get_active() == 3: |
1338 | + self.tvoutstandard.set_active(11) |
1339 | + |
1340 | + def toggle_tv_standard(self,widget): |
1341 | + """Called when the tv standard is toggled""" |
1342 | + if (self.tvoutstandard.get_active() >= 11): |
1343 | + self.tvouttype.set_active(3) |
1344 | + elif (self.tvoutstandard.get_active() < 11 and self.tvoutstandard.get_active() > 0 and self.tvouttype.get_active() == 0): |
1345 | + self.tvouttype.set_active(1) |
1346 | + elif (self.tvoutstandard.get_active() < 11 and self.tvouttype.get_active() ==3): |
1347 | + self.tvouttype.set_active(1) |
1348 | + elif (self.tvoutstandard.get_active() == 0): |
1349 | + self.tvouttype.set_active(0) |
1350 | + |
1351 | + def video_changed (self,widget): |
1352 | + """Called whenever the modify video driver option is toggled or its kids""" |
1353 | + drivers=get_graphics_dictionary() |
1354 | + if (widget is not None and widget.get_name() == 'video_driver'): |
1355 | + try: |
1356 | + self.controller.allow_go_forward(True) |
1357 | + except AttributeError: |
1358 | + #depends on when video_changed got called |
1359 | + #the UI might not be ready yet |
1360 | + pass |
1361 | + type = widget.get_active() |
1362 | + if (type < len(drivers)): |
1363 | + self.tvout_vbox.set_sensitive(True) |
1364 | + else: |
1365 | + self.tvout_vbox.set_sensitive(False) |
1366 | + self.tvoutstandard.set_active(0) |
1367 | + self.tvouttype.set_active(0) |
1368 | + |
1369 | + |
1370 | + def set_driver(self,name,value): |
1371 | + """Preseeds the status of a driver""" |
1372 | + lists = [{'video_driver': self.video_driver, |
1373 | + 'tvout': self.tvouttype, |
1374 | + 'tvstandard': self.tvoutstandard}] |
1375 | + preseed_list(lists,name,value) |
1376 | + |
1377 | + def get_drivers(self): |
1378 | + video_drivers=get_graphics_dictionary() |
1379 | + active_video_driver=self.video_driver.get_active_text() |
1380 | + for item in video_drivers: |
1381 | + if (active_video_driver == item): |
1382 | + active_video_driver=video_drivers[item] |
1383 | + break |
1384 | + return build_static_list([{'video_driver': active_video_driver, |
1385 | + 'tvout': self.tvouttype, |
1386 | + 'tvstandard': self.tvoutstandard}]) |
1387 | |
1388 | class Page(Plugin): |
1389 | def prepare(self): |
1390 | #drivers |
1391 | - drivers = self.frontend.get_drivers() |
1392 | + drivers = self.ui.get_drivers() |
1393 | questions = [] |
1394 | for this_driver in drivers: |
1395 | answer = self.db.get('mythbuntu/' + this_driver) |
1396 | if answer != '': |
1397 | - self.frontend.set_driver(this_driver,answer) |
1398 | + self.ui.set_driver(this_driver,answer) |
1399 | questions.append('^mythbuntu/' + this_driver) |
1400 | return (['/usr/share/ubiquity/ask-mythbuntu','drivers'], questions) |
1401 | |
1402 | def ok_handler(self): |
1403 | - drivers = self.frontend.get_drivers() |
1404 | + drivers = self.ui.get_drivers() |
1405 | |
1406 | for this_driver in drivers: |
1407 | if drivers[this_driver] is True or drivers[this_driver] is False: |
1408 | @@ -54,3 +126,102 @@ |
1409 | else: |
1410 | self.preseed('mythbuntu/' + this_driver, drivers[this_driver]) |
1411 | Plugin.ok_handler(self) |
1412 | + |
1413 | +class Install(InstallPlugin): |
1414 | + |
1415 | + def enable_nvidia(self, type, fmt): |
1416 | + """Enables an NVIDIA graphics driver using XKit""" |
1417 | + xorg_conf=XKit.xutils.XUtils() |
1418 | + |
1419 | + extra_conf_options={'NoLogo': '1', |
1420 | + 'DPI': '100x100'} |
1421 | + |
1422 | + if type == 'Composite Video Output': |
1423 | + extra_conf_options["ConnectedMonitor"]="TV" |
1424 | + extra_conf_options["TVOutFormat"]="COMPOSITE" |
1425 | + extra_conf_options["TVStandard"]=fmt |
1426 | + elif type == 'S-Video Video Output': |
1427 | + extra_conf_options["ConnectedMonitor"]="TV" |
1428 | + extra_conf_options["TVOutFormat"]="SVIDEO" |
1429 | + extra_conf_options["TVStandard"]=fmt |
1430 | + elif type == 'Component Video Output': |
1431 | + extra_conf_options["ConnectedMonitor"]="TV" |
1432 | + extra_conf_options["TVOutFormat"]="COMPONENT" |
1433 | + extra_conf_options["TVStandard"]=fmt |
1434 | + |
1435 | + #Set up device section |
1436 | + relevant_devices = [] |
1437 | + if len(xorg_conf.globaldict['Device']) == 0: |
1438 | + device = xorg_conf.makeSection('Device', identifier='Default Device') |
1439 | + relevant_devices.append(device) |
1440 | + xorg_conf.setDriver('Device', 'nvidia', device) |
1441 | + else: |
1442 | + devices = xorg_conf.getDevicesInUse() |
1443 | + if len(devices) > 0: |
1444 | + relevant_devices = devices |
1445 | + else: |
1446 | + relevant_devices = xorg_conf.globaldict['Device'].keys() |
1447 | + for device in relevant_devices: |
1448 | + xorg_conf.setDriver('Device', 'nvidia', device) |
1449 | + |
1450 | + for device_section in relevant_devices: |
1451 | + for k, v in extra_conf_options.iteritems(): |
1452 | + xorg_conf.addOption('Device', k, v, optiontype='Option', position=device_section) |
1453 | + |
1454 | + #Set up screen section |
1455 | + if len(xorg_conf.globaldict['Screen']) == 0: |
1456 | + screen = xorg_conf.makeSection('Screen', identifier='Default Screen') |
1457 | + |
1458 | + xorg_conf.addOption('Screen', 'DefaultDepth', '24', position=0, prefix='') |
1459 | + |
1460 | + xorg_conf.writeFile(self.target + "/etc/X11/xorg.conf") |
1461 | + |
1462 | + def enable_amd(self): |
1463 | + """Enables an AMD graphics driver using XKit""" |
1464 | + xorg_conf=XKit.xutils.XUtils() |
1465 | + |
1466 | + #Set up device section |
1467 | + relevant_devices = [] |
1468 | + if len(xorg_conf.globaldict['Device']) == 0: |
1469 | + device = xorg_conf.makeSection('Device', identifier='Default Device') |
1470 | + relevant_devices.append(device) |
1471 | + xorg_conf.setDriver('Device', 'fglrx', device) |
1472 | + else: |
1473 | + devices = xorg_conf.getDevicesInUse() |
1474 | + if len(devices) > 0: |
1475 | + relevant_devices = devices |
1476 | + else: |
1477 | + relevant_devices = xorg_conf.globaldict['Device'].keys() |
1478 | + for device in relevant_devices: |
1479 | + xorg_conf.setDriver('Device', 'fglrx', device) |
1480 | + |
1481 | + #Set up screen section |
1482 | + if len(xorg_conf.globaldict['Screen']) == 0: |
1483 | + screen = xorg_conf.makeSection('Screen', identifier='Default Screen') |
1484 | + |
1485 | + xorg_conf.addOption('Screen', 'DefaultDepth', '24', position=0, prefix='') |
1486 | + |
1487 | + xorg_conf.writeFile(self.target + "/etc/X11/xorg.conf") |
1488 | + |
1489 | + def install(self, target, progress, *args, **kwargs): |
1490 | + progress.info('ubiquity/install/drivers') |
1491 | + self.target = target |
1492 | + to_install = [] |
1493 | + video_driver = progress.get('mythbuntu/video_driver') |
1494 | + if video_driver != "Open Source Driver": |
1495 | + #Install driver |
1496 | + to_install.append(video_driver) |
1497 | + |
1498 | + #Build tvout/tvstandard |
1499 | + out = progress.get('mythbuntu/tvout') |
1500 | + standard = progress.get('mythbuntu/tvstandard') |
1501 | + #Enabling xorg.conf stuff |
1502 | + if 'nvidia' in video_driver: |
1503 | + self.enable_nvidia(out,standard) |
1504 | + else: |
1505 | + self.enable_amd() |
1506 | + |
1507 | + #Mark new items |
1508 | + install_misc.record_installed(to_install) |
1509 | + |
1510 | + return InstallPlugin.install(self, target, progress, *args, **kwargs) |
1511 | |
1512 | === modified file 'ubiquity/components/myth-install-type.py' |
1513 | --- ubiquity/components/myth-install-type.py 2009-09-01 18:20:59 +0000 |
1514 | +++ ubiquity/components/myth-install-type.py 2010-01-27 01:47:14 +0000 |
1515 | @@ -2,7 +2,7 @@ |
1516 | # |
1517 | # Copyright (C) 2006, 2007, 2009 Canonical Ltd. |
1518 | # Written by Colin Watson <cjwatson@ubuntu.com>. |
1519 | -# Copyright (C) 2007 Mario Limonciello |
1520 | +# Copyright (C) 2007-2010 Mario Limonciello |
1521 | # |
1522 | # This file is part of Ubiquity. |
1523 | # |
1524 | @@ -20,30 +20,127 @@ |
1525 | # along with Ubiquity. If not, see <http://www.gnu.org/licenses/>. |
1526 | |
1527 | from ubiquity.plugin import * |
1528 | +from mythbuntu_common.installer import MythPageGtk |
1529 | +from ubiquity import install_misc |
1530 | +from ubiquity import misc |
1531 | import os |
1532 | +import subprocess |
1533 | |
1534 | NAME = 'myth-installtype' |
1535 | -AFTER = 'usersetup' |
1536 | +AFTER = ['usersetup', None] |
1537 | WEIGHT = 12 |
1538 | |
1539 | -class PageGtk(PluginUI): |
1540 | - def __init__(self, *args, **kwargs): |
1541 | - if os.environ['UBIQUITY_FRONTEND'] == 'mythbuntu_ui': |
1542 | - self.plugin_widgets = 'mythbuntu_stepCustomInstallType' |
1543 | +class PageGtk(MythPageGtk): |
1544 | + def __init__(self, controller, *args, **kwargs): |
1545 | + self.ui_file='mythbuntu_stepCustomInstallType' |
1546 | + MythPageGtk.__init__(self,controller,*args,**kwargs) |
1547 | + |
1548 | + def set_installtype(self,type): |
1549 | + """Preseeds the type of custom install""" |
1550 | + #if type == "Set Top Box": |
1551 | + # self.stb.set_active(True) |
1552 | + if type == "Frontend": |
1553 | + self.fe.set_active(True) |
1554 | + elif type == "Slave Backend": |
1555 | + self.slave_be.set_active(True) |
1556 | + elif type == "Master Backend": |
1557 | + self.master_be.set_active(True) |
1558 | + elif type == "Slave Backend/Frontend": |
1559 | + self.slave_be_fe.set_active(True) |
1560 | + else: |
1561 | + self.master_be_fe.set_active(True) |
1562 | + |
1563 | + def get_installtype(self): |
1564 | + """Returns the current custom installation type""" |
1565 | + if self.master_be_fe.get_active(): |
1566 | + return "Master Backend/Frontend" |
1567 | + elif self.slave_be_fe.get_active(): |
1568 | + return "Slave Backend/Frontend" |
1569 | + elif self.master_be.get_active(): |
1570 | + return "Master Backend" |
1571 | + elif self.slave_be.get_active(): |
1572 | + return "Slave Backend" |
1573 | + elif self.fe.get_active(): |
1574 | + return "Frontend" |
1575 | + elif self.stb.get_active(): |
1576 | + return "Set Top Box" |
1577 | |
1578 | class Page(Plugin): |
1579 | -#we are seeding one of the possible install types |
1580 | - |
1581 | def prepare(self): |
1582 | self.questions = ['install_type'] |
1583 | questions = [] |
1584 | for question in self.questions: |
1585 | answer = self.db.get('mythbuntu/' + question) |
1586 | if answer != '': |
1587 | - self.frontend.set_installtype(answer) |
1588 | + self.ui.set_installtype(answer) |
1589 | questions.append('^mythbuntu/' + question) |
1590 | return (['/usr/share/ubiquity/ask-mythbuntu','type'], questions) |
1591 | |
1592 | def ok_handler(self): |
1593 | - self.preseed('mythbuntu/' + self.questions[0],self.frontend.get_installtype()) |
1594 | + self.preseed('mythbuntu/' + self.questions[0],self.ui.get_installtype()) |
1595 | Plugin.ok_handler(self) |
1596 | + |
1597 | +class Install(InstallPlugin): |
1598 | + def process_package_removals(self): |
1599 | + packages=set() |
1600 | + ## system role |
1601 | + if 'Backend' not in self.type: |
1602 | + packages.add('libnet-upnp-perl') #causes mythtv-backend to be removed |
1603 | + packages.add('php5-common') #causes mythweb to be removed |
1604 | + packages.add('libaprutil1') #causes apache2 to be removed |
1605 | + if 'Slave' in self.type or self.type == 'Frontend': |
1606 | + packages.add('ntp') #causes mythtv-backend-master to go |
1607 | + packages.add('mythtv-database') |
1608 | + packages.add('mysql-server-core-5.1') |
1609 | + if 'Frontend' not in self.type: |
1610 | + packages.add('mythtv-frontend') |
1611 | + ## services that are installed by default |
1612 | + for service in ['samba','openssh-server']: |
1613 | + if not misc.create_bool(self.db.get('mythbuntu/' + service)): |
1614 | + packages.add(service) |
1615 | + if len(packages) >= 0: |
1616 | + #recursively remove to make sure we get plugins and services that |
1617 | + #aren't necessary anymore |
1618 | + install_misc.record_removed(packages,True) |
1619 | + |
1620 | + def setup_common(self): |
1621 | + #All types |
1622 | + for question in ('mythtv/mysql_mythtv_user','mythtv/mysql_mythtv_password',\ |
1623 | + 'mythtv/mysql_mythtv_dbname','mythtv/mysql_host'): |
1624 | + answer = self.progress.get(question) |
1625 | + install_misc.set_debconf(self.target, question,answer) |
1626 | + |
1627 | + os.remove(self.target + '/etc/mythtv/mysql.txt') |
1628 | + install_misc.reconfigure(self.target, 'mythtv-common') |
1629 | + |
1630 | + def setup_master_backend(self): |
1631 | + if 'Master' in self.type: |
1632 | + #Setup database |
1633 | + install_misc.reconfigure(self.target, 'mysql-server-5.1') |
1634 | + proc=subprocess.Popen(['chroot',self.target,'mysqld']) |
1635 | + install_misc.reconfigure(self.target, 'mythtv-database') |
1636 | + |
1637 | + #Cleanup |
1638 | + install_misc.chrex(self.target,'mysqladmin','--defaults-file=/etc/mysql/debian.cnf','shutdown') |
1639 | + proc.communicate() |
1640 | + |
1641 | + #Mythweb |
1642 | + passwd = self.progress.get('passwd/user-password') |
1643 | + user = self.progress.get('passwd/username') |
1644 | + install_misc.set_debconf(self.target, 'mythweb/enable', 'true') |
1645 | + install_misc.set_debconf(self.target, 'mythweb/username', user) |
1646 | + install_misc.set_debconf(self.target, 'mythweb/password', passwd) |
1647 | + install_misc.reconfigure(self.target, 'mythweb') |
1648 | + |
1649 | + def install(self, target, progress, *args, **kwargs): |
1650 | + self.target = target |
1651 | + self.progress = progress |
1652 | + |
1653 | + self.progress.info('ubiquity/install/mythbuntu') |
1654 | + self.type = self.progress.get('mythbuntu/install_type') |
1655 | + |
1656 | + self.setup_common() |
1657 | + self.setup_master_backend() |
1658 | + self.process_package_removals() |
1659 | + |
1660 | + return InstallPlugin.install(self, target, progress, *args, **kwargs) |
1661 | |
1662 | === modified file 'ubiquity/components/myth-passwords.py' |
1663 | --- ubiquity/components/myth-passwords.py 2009-09-01 18:20:59 +0000 |
1664 | +++ ubiquity/components/myth-passwords.py 2010-01-27 01:47:14 +0000 |
1665 | @@ -2,7 +2,7 @@ |
1666 | # |
1667 | # Copyright (C) 2006, 2007, 2009 Canonical Ltd. |
1668 | # Written by Colin Watson <cjwatson@ubuntu.com>. |
1669 | -# Copyright (C) 2007 Mario Limonciello |
1670 | +# Copyright (C) 2007-2010 Mario Limonciello |
1671 | # |
1672 | # This file is part of Ubiquity. |
1673 | # |
1674 | @@ -19,43 +19,94 @@ |
1675 | # You should have received a copy of the GNU General Public License |
1676 | # along with Ubiquity. If not, see <http://www.gnu.org/licenses/>. |
1677 | |
1678 | +import string |
1679 | +import debconf |
1680 | +import subprocess |
1681 | from ubiquity.plugin import * |
1682 | +from mythbuntu_common.installer import * |
1683 | +from mythbuntu_common.mysql import MySQLHandler |
1684 | +from ubiquity import install_misc |
1685 | import os |
1686 | |
1687 | NAME = 'myth-passwords' |
1688 | AFTER = 'myth-drivers' |
1689 | WEIGHT = 10 |
1690 | |
1691 | -class PageGtk(PluginUI): |
1692 | - def __init__(self, *args, **kwargs): |
1693 | - if os.environ['UBIQUITY_FRONTEND'] == 'mythbuntu_ui': |
1694 | - self.plugin_widgets = 'mythbuntu_stepPasswords' |
1695 | +class PageGtk(MythPageGtk): |
1696 | + def __init__(self, controller, *args, **kwargs): |
1697 | + self.ui_file = 'mythbuntu_stepPasswords' |
1698 | + MythPageGtk.__init__(self, controller, *args, **kwargs) |
1699 | + self.populate_mysql() |
1700 | + |
1701 | + def set_type(self,type): |
1702 | + """Prevents the user from going forward initially because of the |
1703 | + type that was selected""" |
1704 | + if "Master" not in type: |
1705 | + self.controller.allow_go_forward(False) |
1706 | + |
1707 | + def populate_mysql(self): |
1708 | + """Puts a new random mysql password into the UI for each run |
1709 | + This ensures that passwords don't ever get cached""" |
1710 | + self.mysql=MySQLHandler() |
1711 | + new_pass_caller = subprocess.Popen(['pwgen','-s','8'],stdout=subprocess.PIPE) |
1712 | + self.mysql_password.set_text(string.split(new_pass_caller.communicate()[0])[0]) |
1713 | + |
1714 | + def do_connection_test(self,widget): |
1715 | + """Tests to make sure that the backend is accessible""" |
1716 | + config={} |
1717 | + config["user"]=self.mysql_user.get_text() |
1718 | + config["password"]=self.mysql_password.get_text() |
1719 | + config["server"]=self.mysql_server.get_text() |
1720 | + config["database"]=self.mysql_database.get_text() |
1721 | + self.mysql.update_config(config) |
1722 | + result=self.mysql.do_connection_test() |
1723 | + self.controller.allow_go_forward(True) |
1724 | + self.connection_results_label.show() |
1725 | + self.connection_results.set_text(result) |
1726 | + |
1727 | + def set_password(self,name,value): |
1728 | + """Preseeds a password""" |
1729 | + lists = [{'mysql_mythtv_user':self.mysql_user, |
1730 | + 'mysql_mythtv_password':self.mysql_password, |
1731 | + 'mysql_mythtv_dbname':self.mysql_database, |
1732 | + 'mysql_host':self.mysql_server}] |
1733 | + preseed_list(lists,name,value) |
1734 | + |
1735 | + def get_mythtv_passwords(self): |
1736 | + return build_static_list([{'mysql_mythtv_user':self.mysql_user, |
1737 | + 'mysql_mythtv_password':self.mysql_password, |
1738 | + 'mysql_mythtv_dbname':self.mysql_database, |
1739 | + 'mysql_host':self.mysql_server}]) |
1740 | |
1741 | class Page(Plugin): |
1742 | - |
1743 | def prepare(self): |
1744 | #mythtv passwords |
1745 | - passwords = self.frontend.get_mythtv_passwords() |
1746 | + passwords = self.ui.get_mythtv_passwords() |
1747 | questions = [] |
1748 | for this_password in passwords: |
1749 | answer = self.db.get('mythtv/' + this_password) |
1750 | if answer != '': |
1751 | - self.frontend.set_password(this_password,answer) |
1752 | + self.ui.set_password(this_password,answer) |
1753 | questions.append('^mythtv/' + this_password) |
1754 | |
1755 | - #if we are a Master type, we'll skip this page |
1756 | - if 'Master' in self.frontend.get_installtype() and 'UBIQUITY_AUTOMATIC' not in os.environ: |
1757 | - os.environ['UBIQUITY_AUTOMATIC'] = "2" |
1758 | - #regrab the passwords in case any of them actually were supposed preseeded |
1759 | - passwords = self.frontend.get_mythtv_passwords() |
1760 | - for this_password in passwords: |
1761 | - self.preseed('mythtv/' + this_password, passwords[this_password]) |
1762 | + if 'UBIQUITY_AUTOMATIC' not in os.environ: |
1763 | + #if we are a Master type, we'll skip this page |
1764 | + type = self.db.get('mythbuntu/install_type') |
1765 | + if 'Master' in type: |
1766 | + os.environ['UBIQUITY_AUTOMATIC'] = "2" |
1767 | + #regrab the passwords in case any of them actually were supposed preseeded |
1768 | + passwords = self.ui.get_mythtv_passwords() |
1769 | + for this_password in passwords: |
1770 | + self.preseed('mythtv/' + this_password, passwords[this_password]) |
1771 | + else: |
1772 | + self.ui.set_type(type) |
1773 | + |
1774 | |
1775 | return (['/usr/share/ubiquity/ask-mythbuntu','passwords'], questions) |
1776 | |
1777 | def ok_handler(self): |
1778 | #mythtv passwords |
1779 | - passwords = self.frontend.get_mythtv_passwords() |
1780 | + passwords = self.ui.get_mythtv_passwords() |
1781 | for this_password in passwords: |
1782 | self.preseed('mythtv/' + this_password, passwords[this_password]) |
1783 | |
1784 | @@ -67,3 +118,54 @@ |
1785 | del os.environ['UBIQUITY_AUTOMATIC'] |
1786 | |
1787 | Plugin.cleanup(self) |
1788 | + |
1789 | +class Install(InstallPlugin): |
1790 | + def install(self, target, progress, *args, **kwargs): |
1791 | + passwd = progress.get('passwd/user-password') |
1792 | + user = progress.get('passwd/username') |
1793 | + type = progress.get('mythbuntu/install_type') |
1794 | + |
1795 | + #Before beginning, set the initial root sql pass to the user pass |
1796 | + for key in [ 'mythtv/mysql_admin_password', |
1797 | + 'mysql-server/root_password', |
1798 | + 'mysql-server/root_password_again' ]: |
1799 | + install_misc.set_debconf(target, key, passwd) |
1800 | + |
1801 | + |
1802 | + #Create a .mythtv directory |
1803 | + home_mythtv_dir = target + '/home/' + user + '/.mythtv' |
1804 | + if not os.path.isdir(home_mythtv_dir): |
1805 | + #in case someone made a symlink or file for the directory |
1806 | + if os.path.islink(home_mythtv_dir) or os.path.exists(home_mythtv_dir): |
1807 | + os.remove(home_mythtv_dir) |
1808 | + os.makedirs(home_mythtv_dir) |
1809 | + |
1810 | + #Remove mysql.txt from home directory if it's there, then make one |
1811 | + sql_txt= home_mythtv_dir + '/mysql.txt' |
1812 | + if os.path.islink(sql_txt) or os.path.exists(sql_txt): |
1813 | + os.remove(sql_txt) |
1814 | + try: |
1815 | + os.symlink('/etc/mythtv/mysql.txt', sql_txt) |
1816 | + except OSError: |
1817 | + #on a live disk there is a chance this was a broken link |
1818 | + #depending on what the user did in the livefs |
1819 | + pass |
1820 | + |
1821 | + #mythtv.desktop autostart |
1822 | + if 'Frontend' in type: |
1823 | + config_dir = target + '/home/' + user + '/.config' |
1824 | + autostart_dir = config_dir + '/autostart' |
1825 | + autostart_link = autostart_dir + '/mythtv.desktop' |
1826 | + if not os.path.isdir(config_dir): |
1827 | + os.makedirs(config_dir) |
1828 | + if not os.path.isdir(autostart_dir): |
1829 | + os.makedirs(autostart_dir) |
1830 | + elif os.path.islink(autostart_link) or os.path.exists(autostart_link): |
1831 | + os.remove(autostart_link) |
1832 | + try: |
1833 | + os.symlink('/usr/share/applications/mythtv.desktop',autostart_link) |
1834 | + except OSError: |
1835 | + #on a live disk, this will appear a broken link, but it works |
1836 | + pass |
1837 | + |
1838 | + return InstallPlugin.install(self, target, progress, *args, **kwargs) |
1839 | |
1840 | === modified file 'ubiquity/components/myth-remote.py' |
1841 | --- ubiquity/components/myth-remote.py 2009-09-01 18:20:59 +0000 |
1842 | +++ ubiquity/components/myth-remote.py 2010-01-27 01:47:14 +0000 |
1843 | @@ -2,7 +2,7 @@ |
1844 | # |
1845 | # Copyright (C) 2006, 2007, 2009 Canonical Ltd. |
1846 | # Written by Colin Watson <cjwatson@ubuntu.com>. |
1847 | -# Copyright (C) 2007 Mario Limonciello |
1848 | +# Copyright (C) 2007-2010 Mario Limonciello |
1849 | # |
1850 | # This file is part of Ubiquity. |
1851 | # |
1852 | @@ -20,31 +20,170 @@ |
1853 | # along with Ubiquity. If not, see <http://www.gnu.org/licenses/>. |
1854 | |
1855 | from ubiquity.plugin import * |
1856 | +from ubiquity import osextras |
1857 | +from mythbuntu_common.installer import * |
1858 | +from mythbuntu_common.lirc import LircHandler |
1859 | +from ubiquity import install_misc |
1860 | import os |
1861 | +import debconf |
1862 | + |
1863 | |
1864 | NAME = 'myth-remote' |
1865 | AFTER = 'myth-services' |
1866 | WEIGHT = 10 |
1867 | |
1868 | -class PageGtk(PluginUI): |
1869 | - def __init__(self, *args, **kwargs): |
1870 | - if os.environ['UBIQUITY_FRONTEND'] == 'mythbuntu_ui': |
1871 | - self.plugin_widgets = 'tab_remote_control' |
1872 | +class PageGtk(MythPageGtk): |
1873 | + def __init__(self, controller, *args, **kwargs): |
1874 | + self.ui_file = 'tab_remote_control' |
1875 | + MythPageGtk.__init__(self, controller, *args, **kwargs) |
1876 | + self.populate_lirc() |
1877 | + self.remote_control_support.hide() |
1878 | + |
1879 | + def populate_lirc(self): |
1880 | + """Fills the lirc pages with the appropriate data""" |
1881 | + self.remote_count = 0 |
1882 | + self.transmitter_count = 0 |
1883 | + lirchandler=LircHandler() |
1884 | + for item in lirchandler.get_possible_devices("remote"): |
1885 | + if "Custom" not in item and "Blaster" not in item: |
1886 | + self.remote_list.append_text(item) |
1887 | + self.remote_count = self.remote_count + 1 |
1888 | + for item in lirchandler.get_possible_devices("transmitter"): |
1889 | + if "Custom" not in item: |
1890 | + self.transmitter_list.append_text(item) |
1891 | + self.transmitter_count = self.transmitter_count + 1 |
1892 | + self.remote_list.set_active(0) |
1893 | + self.transmitter_list.set_active(0) |
1894 | + |
1895 | + def toggle_ir(self,widget): |
1896 | + """Called whenever a request to enable/disable remote is called""" |
1897 | + if widget is not None: |
1898 | + #turn on/off IR remote |
1899 | + if widget.get_name() == 'remotecontrol': |
1900 | + self.remote_hbox.set_sensitive(widget.get_active()) |
1901 | + self.generate_lircrc_checkbox.set_sensitive(widget.get_active()) |
1902 | + if widget.get_active() and self.remote_list.get_active() == 0: |
1903 | + self.remote_list.set_active(1) |
1904 | + else: |
1905 | + self.remote_list.set_active(0) |
1906 | + #turn on/off IR transmitter |
1907 | + elif widget.get_name() == "transmittercontrol": |
1908 | + self.transmitter_hbox.set_sensitive(widget.get_active()) |
1909 | + if widget.get_active(): |
1910 | + if self.transmitter_list.get_active() == 0: |
1911 | + self.transmitter_list.set_active(1) |
1912 | + else: |
1913 | + self.transmitter_list.set_active(0) |
1914 | + #if our selected remote itself changed |
1915 | + elif widget.get_name() == 'remote_list': |
1916 | + self.generate_lircrc_checkbox.set_active(True) |
1917 | + if self.remote_list.get_active() == 0: |
1918 | + self.remotecontrol.set_active(False) |
1919 | + self.generate_lircrc_checkbox.set_active(False) |
1920 | + #if our selected transmitter itself changed |
1921 | + elif widget.get_name() == 'transmitter_list': |
1922 | + if self.transmitter_list.get_active() == 0: |
1923 | + self.transmittercontrol.set_active(False) |
1924 | + |
1925 | + def set_lirc(self,question,answer): |
1926 | + """Preseeds a lirc configuration item""" |
1927 | + if question == "remote": |
1928 | + for i in range(0,self.remote_count): |
1929 | + self.remote_list.set_active(i) |
1930 | + found=False |
1931 | + if self.remote_list.get_active_text() == answer: |
1932 | + found = True |
1933 | + break |
1934 | + if not found: |
1935 | + self.remote_list.set_active(0) |
1936 | + if question == "transmitter": |
1937 | + for i in range(0,self.transmitter_count): |
1938 | + self.transmitter_list.set_active(i) |
1939 | + found=False |
1940 | + if self.transmitter_list.get_active_text() == answer: |
1941 | + found = True |
1942 | + break |
1943 | + if not found: |
1944 | + self.transmitter_list.set_active(0) |
1945 | + |
1946 | + def get_lirc(self,type): |
1947 | + item = {"modules":"","device":"","driver":"","lircd_conf":""} |
1948 | + if type == "remote": |
1949 | + item["remote"]=self.remote_list.get_active_text() |
1950 | + elif type == "transmitter": |
1951 | + item["transmitter"]=self.transmitter_list.get_active_text() |
1952 | + return item |
1953 | |
1954 | class Page(Plugin): |
1955 | - |
1956 | def prepare(self): |
1957 | self.top = ['remote', 'transmitter'] |
1958 | questions = [] |
1959 | for question in self.top: |
1960 | answer = self.db.get('lirc/' + question) |
1961 | if answer != '': |
1962 | - self.frontend.set_lirc(question,answer) |
1963 | + self.ui.set_lirc(question,answer) |
1964 | questions.append('^lirc/' + question) |
1965 | return (['/usr/share/ubiquity/ask-mythbuntu','ir'], questions) |
1966 | |
1967 | def ok_handler(self): |
1968 | for question in self.top: |
1969 | - device = self.frontend.get_lirc(question) |
1970 | + device = self.ui.get_lirc(question) |
1971 | self.preseed('lirc/' + question,device[question]) |
1972 | Plugin.ok_handler(self) |
1973 | + |
1974 | +class Install(InstallPlugin): |
1975 | + def install(self, target, progress, *args, **kwargs): |
1976 | + progress.info('ubiquity/install/ir') |
1977 | + |
1978 | + lirchandler = LircHandler() |
1979 | + |
1980 | + #configure lircd for remote and transmitter |
1981 | + ir_device = {"modules":"","driver":"","device":"","lircd_conf":"","remote":"","transmitter":""} |
1982 | + install_misc.chroot_setup(target) |
1983 | + install_misc.chrex(target,'dpkg-divert', '--package', 'ubiquity', '--rename', |
1984 | + '--quiet', '--add', '/sbin/udevd') |
1985 | + try: |
1986 | + os.symlink('/bin/true', '/target/sbin/udevd') |
1987 | + except OSError: |
1988 | + pass |
1989 | + |
1990 | + try: |
1991 | + ir_device["remote"] = progress.get('lirc/remote') |
1992 | + install_misc.set_debconf(target, 'lirc/remote',ir_device["remote"]) |
1993 | + ir_device["modules"] = "" |
1994 | + ir_device["driver"] = "" |
1995 | + ir_device["device"] = "" |
1996 | + ir_device["lircd_conf"] = "" |
1997 | + lirchandler.set_device(ir_device,"remote") |
1998 | + except debconf.DebconfError: |
1999 | + pass |
2000 | + |
2001 | + try: |
2002 | + ir_device["transmitter"] = progress.get('lirc/transmitter') |
2003 | + install_misc.set_debconf(target, 'lirc/transmitter',ir_device["transmitter"]) |
2004 | + ir_device["modules"] = "" |
2005 | + ir_device["driver"] = "" |
2006 | + ir_device["device"] = "" |
2007 | + ir_device["lircd_conf"] = "" |
2008 | + lirchandler.set_device(ir_device,"transmitter") |
2009 | + except debconf.DebconfError: |
2010 | + pass |
2011 | + |
2012 | + lirchandler.write_hardware_conf(target + '/etc/lirc/hardware.conf') |
2013 | + |
2014 | + try: |
2015 | + install_misc.reconfigure(target, 'lirc') |
2016 | + finally: |
2017 | + osextras.unlink_force('/target/sbin/udevd') |
2018 | + install_misc.chrex(target,'dpkg-divert', '--package', 'ubiquity', '--rename', |
2019 | + '--quiet', '--remove', '/sbin/udevd') |
2020 | + install_misc.chroot_cleanup(target) |
2021 | + |
2022 | + #configure lircrc |
2023 | + home = '/target/home/' + progress.get('passwd/username') |
2024 | + os.putenv('HOME',home) |
2025 | + if not os.path.isdir(home): |
2026 | + os.makedirs(home) |
2027 | + lirchandler.create_lircrc(os.path.join(target,"etc/lirc/lircd.conf"),False) |
2028 | + |
2029 | + return InstallPlugin.install(self, target, progress, *args, **kwargs) |
2030 | |
2031 | === modified file 'ubiquity/components/myth-services.py' |
2032 | --- ubiquity/components/myth-services.py 2009-09-01 18:20:59 +0000 |
2033 | +++ ubiquity/components/myth-services.py 2010-01-27 01:47:14 +0000 |
2034 | @@ -2,7 +2,7 @@ |
2035 | # |
2036 | # Copyright (C) 2006, 2007, 2009 Canonical Ltd. |
2037 | # Written by Colin Watson <cjwatson@ubuntu.com>. |
2038 | -# Copyright (C) 2007 Mario Limonciello |
2039 | +# Copyright (C) 2007-2010 Mario Limonciello |
2040 | # |
2041 | # This file is part of Ubiquity. |
2042 | # |
2043 | @@ -20,32 +20,80 @@ |
2044 | # along with Ubiquity. If not, see <http://www.gnu.org/licenses/>. |
2045 | |
2046 | from ubiquity.plugin import * |
2047 | +from mythbuntu_common.installer import * |
2048 | +from mythbuntu_common.dictionaries import get_services_dictionary |
2049 | +from mythbuntu_common.vnc import VNCHandler |
2050 | +from ubiquity import install_misc |
2051 | +from ubiquity import misc |
2052 | + |
2053 | import os |
2054 | +import shutil |
2055 | |
2056 | NAME = 'myth-services' |
2057 | AFTER = 'myth-installtype' |
2058 | WEIGHT = 10 |
2059 | |
2060 | -class PageGtk(PluginUI): |
2061 | - def __init__(self, *args, **kwargs): |
2062 | - if os.environ['UBIQUITY_FRONTEND'] == 'mythbuntu_ui': |
2063 | - self.plugin_widgets = 'mythbuntu_stepServices' |
2064 | +class PageGtk(MythPageGtk): |
2065 | + def __init__(self, controller, *args, **kwargs): |
2066 | + self.ui_file = 'mythbuntu_stepServices' |
2067 | + MythPageGtk.__init__(self, controller, *args, **kwargs) |
2068 | + |
2069 | + def toggle_customtype (self,type): |
2070 | + """Called whenever a custom type is toggled""" |
2071 | + |
2072 | + if "Master" in type: |
2073 | + self.mysql_option_hbox.show() |
2074 | + else: |
2075 | + self.enablemysql.set_active(False) |
2076 | + self.mysql_option_hbox.hide() |
2077 | + |
2078 | + if "Backend" in type: |
2079 | + self.samba_option_hbox.show() |
2080 | + self.nfs_option_hbox.show() |
2081 | + else: |
2082 | + self.enablesamba.set_active(False) |
2083 | + self.enablenfs.set_active(False) |
2084 | + self.samba_option_hbox.hide() |
2085 | + self.nfs_option_hbox.hide() |
2086 | + |
2087 | + def set_service(self,name,value): |
2088 | + """Preseeds the status of a service""" |
2089 | + lists = [get_services_dictionary(self,self.enablemysql)] |
2090 | + preseed_list(lists,name,value) |
2091 | + |
2092 | + def get_services(self): |
2093 | + """Returns the status of all installable services""" |
2094 | + return build_static_list([get_services_dictionary(self,self.enablemysql)]) |
2095 | + |
2096 | + def toggle_offer_vnc(self, sensitive): |
2097 | + """Decides whether or not to offer VNC""" |
2098 | + if sensitive: |
2099 | + self.vnc_option_hbox.show() |
2100 | + else: |
2101 | + self.enablevnc.set_active(False) |
2102 | + self.vnc_option_hbox.hide() |
2103 | |
2104 | class Page(Plugin): |
2105 | -#we are seeding the status of each service |
2106 | - |
2107 | def prepare(self): |
2108 | - services = self.frontend.get_services() |
2109 | + services = self.ui.get_services() |
2110 | questions = [] |
2111 | for this_service in services: |
2112 | answer = self.db.get('mythbuntu/' + this_service) |
2113 | if answer != '': |
2114 | - self.frontend.set_service(this_service,answer) |
2115 | + self.ui.set_service(this_service,answer) |
2116 | questions.append('^mythbuntu/' + this_service) |
2117 | + |
2118 | + #Hide some stuff depending on the type previously selected |
2119 | + type = self.db.get('mythbuntu/install_type') |
2120 | + self.ui.toggle_customtype(type) |
2121 | + |
2122 | + #VNC hates us if we have short passwords |
2123 | + self.ui.toggle_offer_vnc(len(self.frontend.get_password()) >= 6) |
2124 | + |
2125 | return (['/usr/share/ubiquity/ask-mythbuntu','services'], questions) |
2126 | |
2127 | def ok_handler(self): |
2128 | - services = self.frontend.get_services() |
2129 | + services = self.ui.get_services() |
2130 | for this_service in services: |
2131 | answer = services[this_service] |
2132 | if answer is True or answer is False: |
2133 | @@ -53,3 +101,44 @@ |
2134 | else: |
2135 | self.preseed('mythbuntu/' + this_service, answer) |
2136 | Plugin.ok_handler(self) |
2137 | + |
2138 | +class Install(InstallPlugin): |
2139 | + def install(self, target, progress, *args, **kwargs): |
2140 | + to_install = [] |
2141 | + |
2142 | + progress.info('ubiquity/install/services') |
2143 | + |
2144 | + if misc.create_bool(progress.get('mythbuntu/samba')): |
2145 | + shutil.copy('/usr/share/mythbuntu/examples/smb.conf.dist', target + '/etc/samba/smb.conf') |
2146 | + |
2147 | + if misc.create_bool(progress.get('mythbuntu/nfs-kernel-server')): |
2148 | + shutil.copy('/usr/share/mythbuntu/examples/exports.dist', target + '/etc/exports') |
2149 | + to_install.append('nfs-kernel-server') |
2150 | + to_install.append('portmap') |
2151 | + |
2152 | + if misc.create_bool(progress.get('mythbuntu/openssh-server')): |
2153 | + for file in ['ssh_host_dsa_key','ssh_host_dsa_key.pub','ssh_host_rsa_key','ssh_host_rsa_key.pub']: |
2154 | + os.remove(target + '/etc/ssh/' + file) |
2155 | + install_misc.reconfigure(target, 'openssh-server') |
2156 | + |
2157 | + if misc.create_bool(progress.get('mythbuntu/mysql-server')): |
2158 | + f=open(target + '/etc/mysql/conf.d/mythtv.cnf','w') |
2159 | + print >>f, """\ |
2160 | +[mysqld] |
2161 | +bind-address=0.0.0.0""" |
2162 | + f.close() |
2163 | + |
2164 | + if misc.create_bool(progress.get('mythbuntu/x11vnc')): |
2165 | + vnc=VNCHandler() |
2166 | + vnc.create_password(progress.get('passwd/user-password')) |
2167 | + directory = target + '/home/' + progress.get('passwd/username') + '/.vnc' |
2168 | + if not os.path.exists(directory): |
2169 | + os.makedirs(directory) |
2170 | + shutil.move('/root/.vnc/passwd', directory + '/passwd') |
2171 | + to_install.append('x11vnc') |
2172 | + |
2173 | + #Mark new items |
2174 | + install_misc.record_installed(to_install) |
2175 | + |
2176 | + return InstallPlugin.install(self, target, progress, *args, **kwargs) |
2177 | + |
2178 | |
2179 | === modified file 'ubiquity/components/myth-summary.py' |
2180 | --- ubiquity/components/myth-summary.py 2009-10-28 13:04:43 +0000 |
2181 | +++ ubiquity/components/myth-summary.py 2010-01-27 01:47:14 +0000 |
2182 | @@ -27,16 +27,13 @@ |
2183 | AFTER = 'myth-passwords' |
2184 | WEIGHT = 10 |
2185 | |
2186 | -if ('UBIQUITY_FRONTEND' in os.environ and |
2187 | - os.environ['UBIQUITY_FRONTEND'] == 'mythbuntu_ui'): |
2188 | - HIDDEN = ['summary', 'migrationassistant'] |
2189 | +HIDDEN = ['summary', 'migrationassistant'] |
2190 | |
2191 | class PageGtk(PluginUI): |
2192 | plugin_is_install = True |
2193 | |
2194 | def __init__(self, *args, **kwargs): |
2195 | - if os.environ['UBIQUITY_FRONTEND'] == 'mythbuntu_ui': |
2196 | - self.plugin_widgets = 'stepReady' |
2197 | + self.plugin_widgets = 'stepReady' |
2198 | |
2199 | class Page(ubiquity.components.summary.Page): |
2200 | """This class is used for populating the Mythbuntu summary page |
2201 | |
2202 | === removed file 'ubiquity/components/mythbuntu_install.py' |
2203 | --- ubiquity/components/mythbuntu_install.py 2009-07-28 20:46:56 +0000 |
2204 | +++ ubiquity/components/mythbuntu_install.py 1970-01-01 00:00:00 +0000 |
2205 | @@ -1,28 +0,0 @@ |
2206 | -# -*- coding: utf-8; Mode: Python; indent-tabs-mode: nil; tab-width: 4 -*- |
2207 | - |
2208 | -# Copyright (C) 2006, 2007 Canonical Ltd. |
2209 | -# Written by Colin Watson <cjwatson@ubuntu.com>. |
2210 | -# Copyright (C) 2007 Mario Limonciello |
2211 | -# |
2212 | -# This program is free software; you can redistribute it and/or modify |
2213 | -# it under the terms of the GNU General Public License as published by |
2214 | -# the Free Software Foundation; either version 2 of the License, or |
2215 | -# (at your option) any later version. |
2216 | -# |
2217 | -# This program is distributed in the hope that it will be useful, |
2218 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2219 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2220 | -# GNU General Public License for more details. |
2221 | -# |
2222 | -# You should have received a copy of the GNU General Public License |
2223 | -# along with this program; if not, write to the Free Software |
2224 | -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
2225 | - |
2226 | -import ubiquity.components.install |
2227 | -class Install(ubiquity.components.install.Install): |
2228 | - """This class calls out to the main ubiquity processing script. Control |
2229 | - is handled off from the part of the UI asking questions by this class""" |
2230 | - def prepare(self): |
2231 | - prep = list(ubiquity.components.install.Install.prepare(self)) |
2232 | - prep[0] = ['/usr/share/ubiquity/mythbuntu_install.py'] |
2233 | - return prep |
2234 | |
2235 | === modified file 'ubiquity/frontend/base.py' |
2236 | --- ubiquity/frontend/base.py 2010-01-21 09:03:10 +0000 |
2237 | +++ ubiquity/frontend/base.py 2010-01-27 01:47:14 +0000 |
2238 | @@ -60,6 +60,8 @@ |
2239 | pass |
2240 | def go_backward(self): |
2241 | pass |
2242 | + def toggle_top_level(self): |
2243 | + pass |
2244 | |
2245 | class Component: |
2246 | def __init__(self): |
2247 | @@ -251,7 +253,7 @@ |
2248 | def post_mortem(self, exctype, excvalue, exctb): |
2249 | """Drop into the debugger if possible.""" |
2250 | self.run_error_cmd() |
2251 | - |
2252 | + |
2253 | # Did the user request this? |
2254 | if 'UBIQUITY_DEBUG_PDB' not in os.environ: |
2255 | return |
2256 | @@ -269,7 +271,7 @@ |
2257 | import pdb |
2258 | pdb.post_mortem(exctb) |
2259 | sys.exit(1) |
2260 | - |
2261 | + |
2262 | def set_page(self, page): |
2263 | """A question has been asked. Set the interface to the appropriate |
2264 | page given the component, page.""" |
2265 | @@ -524,7 +526,7 @@ |
2266 | def question_dialog(self, title, msg, options, use_templates=True): |
2267 | """Ask a question.""" |
2268 | self._abstract('question_dialog') |
2269 | - |
2270 | + |
2271 | def run_automation_error_cmd(self): |
2272 | if self.automation_error_cmd != '': |
2273 | execute_root('sh', '-c', self.automation_error_cmd) |
2274 | @@ -532,7 +534,7 @@ |
2275 | def run_error_cmd(self): |
2276 | if self.error_cmd != '': |
2277 | execute_root('sh', '-c', self.error_cmd) |
2278 | - |
2279 | + |
2280 | def run_success_cmd(self): |
2281 | if self.success_cmd != '': |
2282 | self.debconf_progress_info( |
2283 | |
2284 | === modified file 'ubiquity/frontend/gtk_ui.py' |
2285 | --- ubiquity/frontend/gtk_ui.py 2010-01-21 09:03:10 +0000 |
2286 | +++ ubiquity/frontend/gtk_ui.py 2010-01-27 01:47:14 +0000 |
2287 | @@ -123,6 +123,13 @@ |
2288 | def go_to_page(self, widget): |
2289 | self._wizard.set_current_page(self._wizard.steps.page_num(widget)) |
2290 | |
2291 | + def toggle_top_level(self): |
2292 | + if self._wizard.live_installer.get_property('visible'): |
2293 | + self._wizard.live_installer.hide() |
2294 | + else: |
2295 | + self._wizard.live_installer.show() |
2296 | + self._wizard.refresh() |
2297 | + |
2298 | class Wizard(BaseFrontend): |
2299 | |
2300 | def __init__(self, distro): |
2301 | @@ -455,9 +462,7 @@ |
2302 | |
2303 | self.set_current_page(0) |
2304 | |
2305 | - while(self.pagesindex < self.pageslen): |
2306 | - if self.current_page == None: |
2307 | - break |
2308 | + while(self.pagesindex < len(self.pages)): |
2309 | |
2310 | if not self.pages[self.pagesindex].filter_class: |
2311 | # This page is just a UI page |
2312 | @@ -485,9 +490,11 @@ |
2313 | self.pages[self.pagesindex].controller.dbfilter = None |
2314 | |
2315 | if self.backup or self.dbfilter_handle_status(): |
2316 | - if self.installing: |
2317 | - self.progress_loop() |
2318 | - elif self.current_page is not None and not self.backup: |
2319 | + #TODO: superm1, Jan 2010 is there some kind of way that we are entering this normally? |
2320 | + #if self.installing: |
2321 | + # self.progress_loop() |
2322 | + #elif |
2323 | + if self.current_page is not None and not self.backup: |
2324 | self.process_step() |
2325 | if not self.stay_on_page: |
2326 | self.pagesindex = self.pagesindex + 1 |
2327 | @@ -498,18 +505,23 @@ |
2328 | if self.backup: |
2329 | self.pagesindex = self.pop_history() |
2330 | |
2331 | + |
2332 | while gtk.events_pending(): |
2333 | gtk.main_iteration() |
2334 | |
2335 | - # needed to be here for --automatic as there might not be any |
2336 | - # current page in the event all of the questions have been |
2337 | - # preseeded. |
2338 | - if self.pagesindex == self.pageslen: |
2339 | - # Ready to install |
2340 | - self.live_installer.hide() |
2341 | - self.current_page = None |
2342 | - self.installing = True |
2343 | - self.progress_loop() |
2344 | + if self.oem_user_config: |
2345 | + self.quit_installer() |
2346 | + elif not self.get_reboot_seen(): |
2347 | + self.live_installer.hide() |
2348 | + if 'UBIQUITY_ONLY' in os.environ: |
2349 | + txt = self.get_string('ubiquity/finished_restart_only') |
2350 | + self.finished_label.set_label(txt) |
2351 | + self.quit_button.hide() |
2352 | + self.finished_dialog.set_keep_above(True) |
2353 | + self.finished_dialog.run() |
2354 | + elif self.get_reboot(): |
2355 | + self.reboot() |
2356 | + |
2357 | return self.returncode |
2358 | |
2359 | |
2360 | @@ -943,9 +955,11 @@ |
2361 | |
2362 | def progress_loop(self): |
2363 | """prepare, copy and config the system in the core install process.""" |
2364 | + self.installing = True |
2365 | |
2366 | syslog.syslog('progress_loop()') |
2367 | |
2368 | + self.live_installer.hide() |
2369 | self.current_page = None |
2370 | |
2371 | slideshow_dir = '/usr/share/ubiquity-slideshow' |
2372 | @@ -1030,21 +1044,15 @@ |
2373 | # just to make sure |
2374 | self.debconf_progress_window.hide() |
2375 | |
2376 | - self.installing = False |
2377 | - |
2378 | self.run_success_cmd() |
2379 | - if self.oem_user_config: |
2380 | - self.quit_installer() |
2381 | - elif not self.get_reboot_seen(): |
2382 | - if 'UBIQUITY_ONLY' in os.environ: |
2383 | - txt = self.get_string('ubiquity/finished_restart_only') |
2384 | - self.finished_label.set_label(txt) |
2385 | - self.quit_button.hide() |
2386 | - self.finished_dialog.set_keep_above(True) |
2387 | - self.finished_dialog.run() |
2388 | - elif self.get_reboot(): |
2389 | - self.reboot() |
2390 | - |
2391 | + |
2392 | + #in case there are extra pages |
2393 | + self.back.hide() |
2394 | + self.quit.hide() |
2395 | + self.next.set_label("gtk-go-forward") |
2396 | + self.translate_widget(self.next) |
2397 | + |
2398 | + self.installing = False |
2399 | |
2400 | def reboot(self, *args): |
2401 | """reboot the system after installing process.""" |
2402 | @@ -1191,6 +1199,10 @@ |
2403 | elif step == "stepUserInfo": |
2404 | self.process_identification() |
2405 | |
2406 | + # Ready to install |
2407 | + elif self.pages[self.pagesindex].ui.get('plugin_is_install'): |
2408 | + self.progress_loop() |
2409 | + |
2410 | def process_identification (self): |
2411 | """Processing identification step tasks.""" |
2412 | |
2413 | |
2414 | === modified file 'ubiquity/frontend/kde_ui.py' |
2415 | --- ubiquity/frontend/kde_ui.py 2010-01-21 09:03:10 +0000 |
2416 | +++ ubiquity/frontend/kde_ui.py 2010-01-27 01:47:16 +0000 |
2417 | @@ -123,6 +123,13 @@ |
2418 | def go_to_page(self, widget): |
2419 | self._wizard.set_current_page(self._wizard.ui.widgetStack.indexOf(widget)) |
2420 | |
2421 | + def toggle_top_level(self): |
2422 | + if self._wizard.ui.isVisible(): |
2423 | + self._wizard.ui.hide() |
2424 | + else: |
2425 | + self._wizard.ui.show() |
2426 | + self._wizard.refresh() |
2427 | + |
2428 | class Wizard(BaseFrontend): |
2429 | |
2430 | def __init__(self, distro): |
2431 | |
2432 | === removed file 'ubiquity/frontend/mythbuntu_ui.py' |
2433 | --- ubiquity/frontend/mythbuntu_ui.py 2009-10-17 22:30:05 +0000 |
2434 | +++ ubiquity/frontend/mythbuntu_ui.py 1970-01-01 00:00:00 +0000 |
2435 | @@ -1,406 +0,0 @@ |
2436 | -# -*- coding: utf-8; Mode: Python; indent-tabs-mode: nil; tab-width: 4 -*- |
2437 | -# |
2438 | -# «mythbuntu-ui» - Mythbuntu user interface |
2439 | -# |
2440 | -# Copyright (C) 2005 Junta de AndalucÃa |
2441 | -# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd. |
2442 | -# Copyright (C) 2007-2009, Mario Limonciello, for Mythbuntu |
2443 | -# Copyright (C) 2007, Jared Greenwald, for Mythbuntu |
2444 | -# |
2445 | -# Authors: |
2446 | -# |
2447 | -# - Original gtk-ui.py that this is based upon: |
2448 | -# - Javier Carranza <javier.carranza#interactors._coop> |
2449 | -# - Juan Jesús Ojeda Croissier <juanje#interactors._coop> |
2450 | -# - Antonio Olmo Titos <aolmo#emergya._info> |
2451 | -# - Gumer Coronel Pérez <gcoronel#emergya._info> |
2452 | -# - Colin Watson <cjwatson@ubuntu.com> |
2453 | -# - Evan Dandrea <evand@ubuntu.com> |
2454 | -# - Mario Limonciello <superm1@ubuntu.com> |
2455 | -# |
2456 | -# - This Document: |
2457 | -# - Mario Limonciello <superm1@mythbuntu.org> |
2458 | -# - Jared Greenwald <greenwaldjared@gmail.com> |
2459 | -# |
2460 | -# This file is part of Ubiquity. |
2461 | -# |
2462 | -# Ubiquity is free software; you can redistribute it and/or modify it under |
2463 | -# the terms of the GNU General Public License as published by the Free |
2464 | -# Software Foundation; either version 2 of the License, or at your option) |
2465 | -# any later version. |
2466 | -# |
2467 | -# Ubiquity is distributed in the hope that it will be useful, but WITHOUT |
2468 | -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2469 | -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
2470 | -# more details. |
2471 | -# |
2472 | -# You should have received a copy of the GNU General Public License along |
2473 | -# with Ubiquity; if not, write to the Free Software Foundation, Inc., 51 |
2474 | -# Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
2475 | - |
2476 | -import sys |
2477 | -import os |
2478 | -import re |
2479 | -import string |
2480 | -import subprocess |
2481 | -import syslog |
2482 | -import signal |
2483 | - |
2484 | -import gtk |
2485 | - |
2486 | -#Mythbuntu common functionality |
2487 | -from mythbuntu_common.lirc import LircHandler |
2488 | -from mythbuntu_common.mysql import MySQLHandler |
2489 | -from mythbuntu_common.dictionaries import * |
2490 | - |
2491 | -#Mythbuntu ubiquity imports |
2492 | -from ubiquity.components import mythbuntu_install |
2493 | - |
2494 | -#Ubiquity imports |
2495 | -from ubiquity.misc import * |
2496 | -import ubiquity.frontend.gtk_ui as ParentFrontend |
2497 | -ParentFrontend.install = mythbuntu_install |
2498 | - |
2499 | -class Wizard(ParentFrontend.Wizard): |
2500 | - |
2501 | -#Overriden Methods |
2502 | - def __init__(self, distro): |
2503 | - ParentFrontend.Wizard.__init__(self,distro) |
2504 | - |
2505 | - def customize_installer(self): |
2506 | - """Initial UI setup.""" |
2507 | - #Default to auto login, but don't make it mandatory |
2508 | - #This requires disabling encrypted FS |
2509 | - self.set_auto_login(True) |
2510 | - self.login_encrypt.set_sensitive(False) |
2511 | - |
2512 | - #we aren't allowed to remove lirc right now |
2513 | - self.remote_control_support.hide() |
2514 | - |
2515 | - #Prepopulate some dynamic pages |
2516 | - self.populate_lirc() |
2517 | - self.populate_video() |
2518 | - self.populate_mysql() |
2519 | - self.backup=False |
2520 | - |
2521 | - ParentFrontend.Wizard.customize_installer(self) |
2522 | - |
2523 | - def run_success_cmd(self): |
2524 | - """Runs mythbuntu post post install GUI step""" |
2525 | - if not 'UBIQUITY_AUTOMATIC' in os.environ and self.get_installtype() != "Frontend": |
2526 | - # Ideally, this next bit (showing the backend-setup page) would |
2527 | - # be fixed by re-architecting gtk_ui to run the install step after |
2528 | - # the first 'is_install' plugin and just naturally ask for the rest |
2529 | - # of the plugins afterward. |
2530 | - for page in self.pages: |
2531 | - if page.module.NAME == 'myth-backend-setup': |
2532 | - pagenum = self.steps.page_num(page.optional_widgets[0]) |
2533 | - self.set_current_page(pagenum) |
2534 | - self.live_installer.show() |
2535 | - self.installing = False |
2536 | - self.back.hide() |
2537 | - self.quit.hide() |
2538 | - self.next.set_label("Finish") |
2539 | - self.step_label.set_text("") |
2540 | - gtk.main() |
2541 | - self.live_installer.hide() |
2542 | - break |
2543 | - ParentFrontend.Wizard.run_success_cmd(self) |
2544 | - |
2545 | - def set_page(self, n): |
2546 | - if n == 'myth-passwords': |
2547 | - if "Master" not in self.get_installtype(): |
2548 | - self.allow_go_forward(False) |
2549 | - elif n == 'myth-services': |
2550 | - self.vnc_option_hbox.set_sensitive(len(self.get_password()) >= 6) |
2551 | - return ParentFrontend.Wizard.set_page(self,n) |
2552 | - |
2553 | -#################### |
2554 | -#Helper Functions # |
2555 | -#################### |
2556 | -#Called for initialization and calculation on a page |
2557 | - |
2558 | - def populate_lirc(self): |
2559 | - """Fills the lirc pages with the appropriate data""" |
2560 | - self.remote_count = 0 |
2561 | - self.transmitter_count = 0 |
2562 | - self.lirc=LircHandler() |
2563 | - for item in self.lirc.get_possible_devices("remote"): |
2564 | - if "Custom" not in item and "Blaster" not in item: |
2565 | - self.remote_list.append_text(item) |
2566 | - self.remote_count = self.remote_count + 1 |
2567 | - for item in self.lirc.get_possible_devices("transmitter"): |
2568 | - if "Custom" not in item: |
2569 | - self.transmitter_list.append_text(item) |
2570 | - self.transmitter_count = self.transmitter_count + 1 |
2571 | - self.remote_list.set_active(0) |
2572 | - self.transmitter_list.set_active(0) |
2573 | - |
2574 | - def populate_video(self): |
2575 | - """Finds the currently active video driver""" |
2576 | - dictionary=get_graphics_dictionary() |
2577 | - if len(dictionary) > 0: |
2578 | - for driver in dictionary: |
2579 | - self.video_driver.append_text(driver) |
2580 | - self.video_driver.append_text("Open Source Driver") |
2581 | - self.video_driver.set_active(len(dictionary)) |
2582 | - self.tvoutstandard.set_active(0) |
2583 | - self.tvouttype.set_active(0) |
2584 | - |
2585 | - def populate_mysql(self): |
2586 | - """Puts a new random mysql password into the UI for each run |
2587 | - This ensures that passwords don't ever get cached""" |
2588 | - self.mysql=MySQLHandler() |
2589 | - new_pass_caller = subprocess.Popen(['pwgen','-s','8'],stdout=subprocess.PIPE) |
2590 | - self.mysql_password.set_text(string.split(new_pass_caller.communicate()[0])[0]) |
2591 | - |
2592 | - def do_mythtv_setup(self,widget): |
2593 | - """Spawn MythTV-Setup binary.""" |
2594 | - self.live_installer.hide() |
2595 | - self.refresh() |
2596 | - execute_root("/usr/share/ubiquity/mythbuntu-setup") |
2597 | - self.live_installer.show() |
2598 | - |
2599 | - def do_connection_test(self,widget): |
2600 | - """Tests to make sure that the backend is accessible""" |
2601 | - config={} |
2602 | - config["user"]=self.mysql_user.get_text() |
2603 | - config["password"]=self.mysql_password.get_text() |
2604 | - config["server"]=self.mysql_server.get_text() |
2605 | - config["database"]=self.mysql_database.get_text() |
2606 | - self.mysql.update_config(config) |
2607 | - result=self.mysql.do_connection_test() |
2608 | - self.allow_go_forward(True) |
2609 | - self.connection_results_label.show() |
2610 | - self.connection_results.set_text(result) |
2611 | - |
2612 | -##################### |
2613 | -#Preseeding Functions# |
2614 | -##################### |
2615 | -#Used to preset the status of an element in the GUI |
2616 | - |
2617 | - def set_installtype(self,type): |
2618 | - """Preseeds the type of custom install""" |
2619 | - if type == "Set Top Box": |
2620 | - self.stb.set_active(True) |
2621 | - elif type == "Frontend": |
2622 | - self.fe.set_active(True) |
2623 | - elif type == "Slave Backend": |
2624 | - self.slave_be.set_active(True) |
2625 | - elif type == "Master Backend": |
2626 | - self.master_be.set_active(True) |
2627 | - elif type == "Slave Backend/Frontend": |
2628 | - self.slave_be_fe.set_active(True) |
2629 | - else: |
2630 | - self.master_be_fe.set_active(True) |
2631 | - |
2632 | - def set_service(self,name,value): |
2633 | - """Preseeds the status of a service""" |
2634 | - lists = [get_services_dictionary(self,self.enablemysql)] |
2635 | - self._preseed_list(lists,name,value) |
2636 | - |
2637 | - def set_driver(self,name,value): |
2638 | - """Preseeds the status of a driver""" |
2639 | - lists = [{'video_driver': self.video_driver, |
2640 | - 'tvout': self.tvouttype, |
2641 | - 'tvstandard': self.tvoutstandard}] |
2642 | - self._preseed_list(lists,name,value) |
2643 | - |
2644 | - def set_password(self,name,value): |
2645 | - """Preseeds a password""" |
2646 | - lists = [{'mysql_mythtv_user':self.mysql_user, |
2647 | - 'mysql_mythtv_password':self.mysql_password, |
2648 | - 'mysql_mythtv_dbname':self.mysql_database, |
2649 | - 'mysql_host':self.mysql_server}] |
2650 | - self._preseed_list(lists,name,value) |
2651 | - |
2652 | - def set_lirc(self,question,answer): |
2653 | - """Preseeds a lirc configuration item""" |
2654 | - if question == "remote": |
2655 | - for i in range(0,self.remote_count): |
2656 | - self.remote_list.set_active(i) |
2657 | - found=False |
2658 | - if self.remote_list.get_active_text() == answer: |
2659 | - found = True |
2660 | - break |
2661 | - if not found: |
2662 | - self.remote_list.set_active(0) |
2663 | - if question == "transmitter": |
2664 | - for i in range(0,self.transmitter_count): |
2665 | - self.transmitter_list.set_active(i) |
2666 | - found=False |
2667 | - if self.transmitter_list.get_active_text() == answer: |
2668 | - found = True |
2669 | - break |
2670 | - if not found: |
2671 | - self.transmitter_list.set_active(0) |
2672 | - |
2673 | - def _preseed_list(self,lists,names,value): |
2674 | - """Helper function for preseeding dictionary based lists""" |
2675 | - new_value = create_bool(value) |
2676 | - for list in lists: |
2677 | - for item in list: |
2678 | - for name in string.split(names): |
2679 | - if item == name: |
2680 | - #be careful what type of item we are deealing with |
2681 | - if type(list[item]) == gtk.CheckButton: |
2682 | - list[item].set_active(new_value) |
2683 | - elif type(list[item]) == gtk.Entry: |
2684 | - list[item].set_text(new_value) |
2685 | - elif type(list[item]) == gtk.ComboBox: |
2686 | - for iteration in range(len(list[item]),0): |
2687 | - list[item].set_active(iteration) |
2688 | - if list[item].get_active_text() == new_value: |
2689 | - break |
2690 | - else: |
2691 | - list[item].set_active_text(new_value) |
2692 | - |
2693 | -################## |
2694 | -#Status Reading # |
2695 | -################## |
2696 | -#Functions for reading the status of Frontend elements |
2697 | - |
2698 | - def get_installtype(self): |
2699 | - """Returns the current custom installation type""" |
2700 | - if self.master_be_fe.get_active(): |
2701 | - return "Master Backend/Frontend" |
2702 | - elif self.slave_be_fe.get_active(): |
2703 | - return "Slave Backend/Frontend" |
2704 | - elif self.master_be.get_active(): |
2705 | - return "Master Backend" |
2706 | - elif self.slave_be.get_active(): |
2707 | - return "Slave Backend" |
2708 | - elif self.fe.get_active(): |
2709 | - return "Frontend" |
2710 | - elif self.stb.get_active(): |
2711 | - return "Set Top Box" |
2712 | - |
2713 | - def _build_static_list(self,lists): |
2714 | - """Creates a flat list""" |
2715 | - total_list= {} |
2716 | - for list in lists: |
2717 | - for item in list: |
2718 | - if type(list[item]) == str: |
2719 | - total_list[item]=list[item] |
2720 | - elif type(list[item]) == gtk.CheckButton: |
2721 | - total_list[item]=list[item].get_active() |
2722 | - elif type(list[item]) == gtk.Entry: |
2723 | - total_list[item]=list[item].get_text() |
2724 | - else: |
2725 | - total_list[item]=list[item].get_active_text() |
2726 | - return total_list |
2727 | - |
2728 | - def get_services(self): |
2729 | - """Returns the status of all installable services""" |
2730 | - return self._build_static_list([get_services_dictionary(self,self.enablemysql)]) |
2731 | - |
2732 | - def get_drivers(self): |
2733 | - video_drivers=get_graphics_dictionary() |
2734 | - active_video_driver=self.video_driver.get_active_text() |
2735 | - for item in video_drivers: |
2736 | - if (active_video_driver == item): |
2737 | - active_video_driver=video_drivers[item] |
2738 | - break |
2739 | - return self._build_static_list([{'video_driver': active_video_driver, |
2740 | - 'tvout': self.tvouttype, |
2741 | - 'tvstandard': self.tvoutstandard}]) |
2742 | - |
2743 | - def get_mythtv_passwords(self): |
2744 | - return self._build_static_list([{'mysql_mythtv_user':self.mysql_user, |
2745 | - 'mysql_mythtv_password':self.mysql_password, |
2746 | - 'mysql_mythtv_dbname':self.mysql_database, |
2747 | - 'mysql_host':self.mysql_server}]) |
2748 | - |
2749 | - def get_lirc(self,type): |
2750 | - item = {"modules":"","device":"","driver":"","lircd_conf":""} |
2751 | - if type == "remote": |
2752 | - item["remote"]=self.remote_list.get_active_text() |
2753 | - elif type == "transmitter": |
2754 | - item["transmitter"]=self.transmitter_list.get_active_text() |
2755 | - return item |
2756 | - |
2757 | -################## |
2758 | -#Toggle functions# |
2759 | -################## |
2760 | -#Called when a widget changes and other GUI elements need to react |
2761 | - |
2762 | - def toggle_tv_out (self,widget): |
2763 | - """Called when the tv-out type is toggled""" |
2764 | - if (self.tvouttype.get_active() == 0): |
2765 | - self.tvoutstandard.set_active(0) |
2766 | - elif ((self.tvouttype.get_active() == 1 or self.tvouttype.get_active() == 2) and (self.tvoutstandard.get_active() == 0 or self.tvoutstandard.get_active() >= 11 )): |
2767 | - self.tvoutstandard.set_active(10) |
2768 | - elif self.tvouttype.get_active() == 3: |
2769 | - self.tvoutstandard.set_active(11) |
2770 | - |
2771 | - def toggle_tv_standard(self,widget): |
2772 | - """Called when the tv standard is toggled""" |
2773 | - if (self.tvoutstandard.get_active() >= 11): |
2774 | - self.tvouttype.set_active(3) |
2775 | - elif (self.tvoutstandard.get_active() < 11 and self.tvoutstandard.get_active() > 0 and self.tvouttype.get_active() == 0): |
2776 | - self.tvouttype.set_active(1) |
2777 | - elif (self.tvoutstandard.get_active() < 11 and self.tvouttype.get_active() ==3): |
2778 | - self.tvouttype.set_active(1) |
2779 | - elif (self.tvoutstandard.get_active() == 0): |
2780 | - self.tvouttype.set_active(0) |
2781 | - |
2782 | - def video_changed (self,widget): |
2783 | - """Called whenever the modify video driver option is toggled or its kids""" |
2784 | - drivers=get_graphics_dictionary() |
2785 | - if (widget is not None and widget.get_name() == 'video_driver'): |
2786 | - self.allow_go_forward(True) |
2787 | - type = widget.get_active() |
2788 | - if (type < len(drivers)): |
2789 | - self.tvout_vbox.set_sensitive(True) |
2790 | - else: |
2791 | - self.tvout_vbox.set_sensitive(False) |
2792 | - self.tvoutstandard.set_active(0) |
2793 | - self.tvouttype.set_active(0) |
2794 | - |
2795 | - def toggle_customtype (self,widget): |
2796 | - """Called whenever a custom type is toggled""" |
2797 | - |
2798 | - if "Master" in self.get_installtype(): |
2799 | - self.mysql_option_hbox.show() |
2800 | - else: |
2801 | - self.enablemysql.set_active(False) |
2802 | - self.mysql_option_hbox.hide() |
2803 | - |
2804 | - if "Backend" in self.get_installtype(): |
2805 | - self.samba_option_hbox.show() |
2806 | - self.nfs_option_hbox.show() |
2807 | - else: |
2808 | - self.enablesamba.set_active(False) |
2809 | - self.enablenfs.set_active(False) |
2810 | - self.samba_option_hbox.hide() |
2811 | - self.nfs_option_hbox.hide() |
2812 | - |
2813 | - def toggle_ir(self,widget): |
2814 | - """Called whenever a request to enable/disable remote is called""" |
2815 | - if widget is not None: |
2816 | - #turn on/off IR remote |
2817 | - if widget.get_name() == 'remotecontrol': |
2818 | - self.remote_hbox.set_sensitive(widget.get_active()) |
2819 | - self.generate_lircrc_checkbox.set_sensitive(widget.get_active()) |
2820 | - if widget.get_active() and self.remote_list.get_active() == 0: |
2821 | - self.remote_list.set_active(1) |
2822 | - else: |
2823 | - self.remote_list.set_active(0) |
2824 | - #turn on/off IR transmitter |
2825 | - elif widget.get_name() == "transmittercontrol": |
2826 | - self.transmitter_hbox.set_sensitive(widget.get_active()) |
2827 | - if widget.get_active(): |
2828 | - if self.transmitter_list.get_active() == 0: |
2829 | - self.transmitter_list.set_active(1) |
2830 | - else: |
2831 | - self.transmitter_list.set_active(0) |
2832 | - #if our selected remote itself changed |
2833 | - elif widget.get_name() == 'remote_list': |
2834 | - self.generate_lircrc_checkbox.set_active(True) |
2835 | - if self.remote_list.get_active() == 0: |
2836 | - self.remotecontrol.set_active(False) |
2837 | - self.generate_lircrc_checkbox.set_active(False) |
2838 | - #if our selected transmitter itself changed |
2839 | - elif widget.get_name() == 'transmitter_list': |
2840 | - if self.transmitter_list.get_active() == 0: |
2841 | - self.transmittercontrol.set_active(False) |
2842 | |
2843 | === added file 'ubiquity/install_misc.py' |
2844 | --- ubiquity/install_misc.py 1970-01-01 00:00:00 +0000 |
2845 | +++ ubiquity/install_misc.py 2010-01-27 01:47:14 +0000 |
2846 | @@ -0,0 +1,231 @@ |
2847 | +#!/usr/bin/python |
2848 | +# -*- coding: utf-8; Mode: Python; indent-tabs-mode: nil; tab-width: 4 -*- |
2849 | + |
2850 | +# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd. |
2851 | +# Copyright (C) 2010 Mario Limonciello |
2852 | +# |
2853 | +# Functions useful for the final install.py script and for ubiquity |
2854 | +# plugins to use |
2855 | +# |
2856 | +# This program is free software; you can redistribute it and/or modify |
2857 | +# it under the terms of the GNU General Public License as published by |
2858 | +# the Free Software Foundation; either version 2 of the License, or |
2859 | +# (at your option) any later version. |
2860 | +# |
2861 | +# This program is distributed in the hope that it will be useful, |
2862 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2863 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2864 | +# GNU General Public License for more details. |
2865 | +# |
2866 | +# You should have received a copy of the GNU General Public License |
2867 | +# along with this program; if not, write to the Free Software |
2868 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
2869 | + |
2870 | +import subprocess |
2871 | +import os |
2872 | +import debconf |
2873 | +from ubiquity import misc |
2874 | +from ubiquity import osextras |
2875 | + |
2876 | +def debconf_disconnect(): |
2877 | + """Disconnect from debconf. This is only to be used as a subprocess |
2878 | + preexec_fn helper.""" |
2879 | + os.environ['DEBIAN_FRONTEND'] = 'noninteractive' |
2880 | + if 'DEBIAN_HAS_FRONTEND' in os.environ: |
2881 | + del os.environ['DEBIAN_HAS_FRONTEND'] |
2882 | + if 'DEBCONF_USE_CDEBCONF' in os.environ: |
2883 | + # Probably not a good idea to use this in /target too ... |
2884 | + del os.environ['DEBCONF_USE_CDEBCONF'] |
2885 | + |
2886 | +def reconfigure_preexec(): |
2887 | + debconf_disconnect() |
2888 | + os.environ['XAUTHORITY'] = '/root/.Xauthority' |
2889 | + |
2890 | +def reconfigure(target, package): |
2891 | + """executes a dpkg-reconfigure into installed system to each |
2892 | + package which provided by args.""" |
2893 | + subprocess.call(['log-output', '-t', 'ubiquity', 'chroot', target, |
2894 | + 'dpkg-reconfigure', '-fnoninteractive', package], |
2895 | + preexec_fn=reconfigure_preexec, close_fds=True) |
2896 | + |
2897 | +def chrex(target, *args): |
2898 | + """executes commands on chroot system (provided by *args).""" |
2899 | + return misc.execute('chroot', target, *args) |
2900 | + |
2901 | +def set_debconf(target, question, value, db=None): |
2902 | + try: |
2903 | + if 'UBIQUITY_OEM_USER_CONFIG' in os.environ and db: |
2904 | + dccomm = None |
2905 | + dc = db |
2906 | + else: |
2907 | + dccomm = subprocess.Popen(['log-output', '-t', 'ubiquity', |
2908 | + '--pass-stdout', |
2909 | + 'chroot', target, |
2910 | + 'debconf-communicate', |
2911 | + '-fnoninteractive', 'ubiquity'], |
2912 | + stdin=subprocess.PIPE, |
2913 | + stdout=subprocess.PIPE, close_fds=True) |
2914 | + dc = debconf.Debconf(read=dccomm.stdout, write=dccomm.stdin) |
2915 | + dc.set(question, value) |
2916 | + dc.fset(question, 'seen', 'true') |
2917 | + finally: |
2918 | + if dccomm: |
2919 | + dccomm.stdin.close() |
2920 | + dccomm.wait() |
2921 | + |
2922 | +def get_all_interfaces(): |
2923 | + """Get all non-local network interfaces.""" |
2924 | + ifs = [] |
2925 | + ifs_file = open('/proc/net/dev') |
2926 | + # eat header |
2927 | + ifs_file.readline() |
2928 | + ifs_file.readline() |
2929 | + |
2930 | + for line in ifs_file: |
2931 | + name = re.match('(.*?(?::\d+)?):', line.strip()).group(1) |
2932 | + if name == 'lo': |
2933 | + continue |
2934 | + ifs.append(name) |
2935 | + |
2936 | + ifs_file.close() |
2937 | + return ifs |
2938 | + |
2939 | +def chroot_setup(target, x11=False): |
2940 | + """Set up /target for safe package management operations.""" |
2941 | + if target == '/': |
2942 | + return |
2943 | + |
2944 | + policy_rc_d = os.path.join(target, 'usr/sbin/policy-rc.d') |
2945 | + f = open(policy_rc_d, 'w') |
2946 | + print >>f, """\ |
2947 | +#!/bin/sh |
2948 | +exit 101""" |
2949 | + f.close() |
2950 | + os.chmod(policy_rc_d, 0755) |
2951 | + |
2952 | + start_stop_daemon = os.path.join(target, 'sbin/start-stop-daemon') |
2953 | + if os.path.exists(start_stop_daemon): |
2954 | + os.rename(start_stop_daemon, '%s.REAL' % start_stop_daemon) |
2955 | + f = open(start_stop_daemon, 'w') |
2956 | + print >>f, """\ |
2957 | +#!/bin/sh |
2958 | +echo 1>&2 |
2959 | +echo 'Warning: Fake start-stop-daemon called, doing nothing.' 1>&2 |
2960 | +exit 0""" |
2961 | + f.close() |
2962 | + os.chmod(start_stop_daemon, 0755) |
2963 | + |
2964 | + initctl = os.path.join(target, 'sbin/initctl') |
2965 | + if os.path.exists(initctl): |
2966 | + os.rename(initctl, '%s.REAL' % initctl) |
2967 | + f = open(initctl, 'w') |
2968 | + print >>f, """\ |
2969 | +#!/bin/sh |
2970 | +echo 1>&2 |
2971 | +echo 'Warning: Fake initctl called, doing nothing.' 1>&2 |
2972 | +exit 0""" |
2973 | + f.close() |
2974 | + os.chmod(initctl, 0755) |
2975 | + |
2976 | + if not os.path.exists(os.path.join(target, 'proc/cmdline')): |
2977 | + chrex(target,'mount', '-t', 'proc', 'proc', '/proc') |
2978 | + if not os.path.exists(os.path.join(target, 'sys/devices')): |
2979 | + chrex(target,'mount', '-t', 'sysfs', 'sysfs', '/sys') |
2980 | + misc.execute('mount', '--bind', '/dev', os.path.join(target, 'dev')) |
2981 | + |
2982 | + if x11 and 'DISPLAY' in os.environ: |
2983 | + if 'SUDO_USER' in os.environ: |
2984 | + xauthority = os.path.expanduser('~%s/.Xauthority' % |
2985 | + os.environ['SUDO_USER']) |
2986 | + else: |
2987 | + xauthority = os.path.expanduser('~/.Xauthority') |
2988 | + if os.path.exists(xauthority): |
2989 | + shutil.copy(xauthority, |
2990 | + os.path.join(target, 'root/.Xauthority')) |
2991 | + |
2992 | + if not os.path.isdir(os.path.join(target, 'tmp/.X11-unix')): |
2993 | + os.mkdir(os.path.join(target, 'tmp/.X11-unix')) |
2994 | + misc.execute('mount', '--bind', '/tmp/.X11-unix', |
2995 | + os.path.join(target, 'tmp/.X11-unix')) |
2996 | + |
2997 | +def chroot_cleanup(target, x11=False): |
2998 | + """Undo the work done by chroot_setup.""" |
2999 | + if target == '/': |
3000 | + return |
3001 | + |
3002 | + if x11 and 'DISPLAY' in os.environ: |
3003 | + misc.execute('umount', os.path.join(target, 'tmp/.X11-unix')) |
3004 | + try: |
3005 | + os.rmdir(os.path.join(target, 'tmp/.X11-unix')) |
3006 | + except OSError: |
3007 | + passo |
3008 | + osextras.unlink_force(os.path.join(target, |
3009 | + 'root/.Xauthority')) |
3010 | + |
3011 | + chrex(target,'umount', '/sys') |
3012 | + chrex(target,'umount', '/proc') |
3013 | + misc.execute('umount', os.path.join(target,'/dev')) |
3014 | + |
3015 | + initctl = os.path.join(target, 'sbin/initctl') |
3016 | + if os.path.exists('%s.REAL' % initctl): |
3017 | + os.rename('%s.REAL' % initctl, initctl) |
3018 | + |
3019 | + start_stop_daemon = os.path.join(target, 'sbin/start-stop-daemon') |
3020 | + if os.path.exists('%s.REAL' % start_stop_daemon): |
3021 | + os.rename('%s.REAL' % start_stop_daemon, start_stop_daemon) |
3022 | + else: |
3023 | + osextras.unlink_force(start_stop_daemon) |
3024 | + |
3025 | + policy_rc_d = os.path.join(target, 'usr/sbin/policy-rc.d') |
3026 | + osextras.unlink_force(policy_rc_d) |
3027 | + |
3028 | +def record_installed(pkgs): |
3029 | + """Record which packages we've explicitly installed so that we don't |
3030 | + try to remove them later.""" |
3031 | + |
3032 | + record_file = "/var/lib/ubiquity/apt-installed" |
3033 | + if not os.path.exists(os.path.dirname(record_file)): |
3034 | + os.makedirs(os.path.dirname(record_file)) |
3035 | + record = open(record_file, "a") |
3036 | + |
3037 | + for pkg in pkgs: |
3038 | + print >>record, pkg |
3039 | + |
3040 | + record.close() |
3041 | + |
3042 | +def query_recorded_installed(): |
3043 | + apt_installed = set() |
3044 | + if os.path.exists("/var/lib/ubiquity/apt-installed"): |
3045 | + record_file = open("/var/lib/ubiquity/apt-installed") |
3046 | + for line in record_file: |
3047 | + apt_installed.add(line.strip()) |
3048 | + record_file.close() |
3049 | + return apt_installed |
3050 | + |
3051 | +def record_removed(pkgs, recursive=False): |
3052 | + """Record which packages we've like removed later""" |
3053 | + |
3054 | + record_file = "/var/lib/ubiquity/apt-removed" |
3055 | + if not os.path.exists(os.path.dirname(record_file)): |
3056 | + os.makedirs(os.path.dirname(record_file)) |
3057 | + record = open(record_file, "a") |
3058 | + |
3059 | + for pkg in pkgs: |
3060 | + print >>record, pkg, str(recursive).lower() |
3061 | + |
3062 | + record.close() |
3063 | + |
3064 | +def query_recorded_removed(): |
3065 | + apt_removed = set() |
3066 | + apt_removed_recursive = set() |
3067 | + if os.path.exists("/var/lib/ubiquity/apt-removed"): |
3068 | + record_file = open("/var/lib/ubiquity/apt-removed") |
3069 | + for line in record_file: |
3070 | + if misc.create_bool(line.split()[1]): |
3071 | + apt_removed_recursive.add(line.split()[0]) |
3072 | + else: |
3073 | + apt_removed.add(line.split()[0]) |
3074 | + record_file.close() |
3075 | + return (apt_removed, apt_removed_recursive) |
3076 | + |
3077 | +# vim:ai:et:sts=4:tw=80:sw=4: |
This converts the mythbuntu frontend entirely into plugins for the gtk frontend. Later on those plugins may be moved out of the ubiquity tree.