5467
by Colin Watson
Finish Python 3 port: switch over #! lines and (build-)dependencies. |
1 |
#!/usr/bin/python3
|
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
2 |
|
5699
by Colin Watson
Partially revert r5662 (removal of more Python 2 support, from ubiquity |
3 |
from __future__ import print_function |
4 |
||
5822
by Colin Watson
Sort and consolidate imports. |
5 |
import errno |
6002.1.1
by Dmitrijs Ledkovs
* Add dependencies on python3-pam. |
6 |
import getpass |
5822
by Colin Watson
Sort and consolidate imports. |
7 |
import grp |
8 |
import imp |
|
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
9 |
import os |
5822
by Colin Watson
Sort and consolidate imports. |
10 |
import pwd |
11 |
import signal |
|
12 |
import subprocess |
|
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
13 |
import sys |
6105
by Dimitri John Ledkov
Fix loading indicators in ubiquity-dm. |
14 |
import sysconfig |
6104.1.2
by Aurélien Gâteau
Improve logging support |
15 |
import traceback |
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
16 |
import time |
17 |
||
4075
by Colin Watson
Display simple progress feedback using debconf-apt-progress while |
18 |
import debconf |
6002.1.1
by Dmitrijs Ledkovs
* Add dependencies on python3-pam. |
19 |
import PAM |
4075
by Colin Watson
Display simple progress feedback using debconf-apt-progress while |
20 |
|
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
21 |
sys.path.insert(0, '/usr/lib/ubiquity') |
22 |
||
5830
by Dmitrijs Ledkovs
* Migrate remaining gconf settings to gsettings in ubiquity-dm. |
23 |
from ubiquity import gsettings, osextras |
5822
by Colin Watson
Sort and consolidate imports. |
24 |
from ubiquity.casper import get_casper |
25 |
from ubiquity.debconfcommunicator import DebconfCommunicator |
|
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
26 |
import ubiquity.frontend |
5441
by Colin Watson
Replace all calls to unicode() with calls to six.text_type() or |
27 |
from ubiquity.misc import create_bool, utf8 |
2514
by Colin Watson
* In ubiquity-dm, fall back to xfwm4 if metacity fails (unifying gtk_ui |
28 |
|
5562
by Colin Watson
Make all Python code pass pep8(1), and add a test to enforce this. |
29 |
|
6104.1.2
by Aurélien Gâteau
Improve logging support |
30 |
logfile = None |
31 |
||
32 |
||
33 |
def log(msg): |
|
34 |
print('ubiquity-dm: ' + msg, file=logfile, flush=True) |
|
35 |
||
36 |
||
6002.1.1
by Dmitrijs Ledkovs
* Add dependencies on python3-pam. |
37 |
def _pam_conv(auth, query_list, userData): |
38 |
resp = [] |
|
6002.1.2
by Dmitrijs Ledkovs
Refactor & do not hard-code vt # |
39 |
for query, type in query_list: |
6002.1.1
by Dmitrijs Ledkovs
* Add dependencies on python3-pam. |
40 |
if type == PAM.PAM_PROMPT_ECHO_ON: |
41 |
val = input(query) |
|
42 |
resp.append((val, 0)) |
|
43 |
elif type == PAM.PAM_PROMPT_ECHO_OFF: |
|
44 |
val = getpass.getpass(query) |
|
45 |
resp.append((val, 0)) |
|
46 |
elif type in (PAM.PAM_PROMPT_ERROR_MSG, PAM.PAM_PROMPT_TEXT_INFO): |
|
47 |
print(query) |
|
48 |
resp.append(('', 0)) |
|
49 |
else: |
|
50 |
return None |
|
51 |
return resp |
|
52 |
||
53 |
||
3879
by Evan Dandrea
Restore Colin's set_locale function. However, this is only half the |
54 |
def set_locale(): |
55 |
db = DebconfCommunicator('ubiquity', cloexec=True) |
|
56 |
locale = '' |
|
57 |
try: |
|
58 |
locale = db.get('debian-installer/locale') |
|
59 |
except debconf.DebconfError: |
|
60 |
pass
|
|
4072
by Colin Watson
simplify set_locale |
61 |
db.shutdown() |
3949
by Colin Watson
remove trailing whitespace (and trailing semicolons in Python code); the red highlights and inability to use paragraph motions in vim were annoying me |
62 |
|
3879
by Evan Dandrea
Restore Colin's set_locale function. However, this is only half the |
63 |
if not locale: |
64 |
return
|
|
65 |
||
5427
by Colin Watson
Fix a slew of file handle leaks, including making much more liberal |
66 |
with open('/etc/default/locale', 'w') as default_locale: |
67 |
print('LANG="%s"' % locale, file=default_locale) |
|
3879
by Evan Dandrea
Restore Colin's set_locale function. However, this is only half the |
68 |
|
5427
by Colin Watson
Fix a slew of file handle leaks, including making much more liberal |
69 |
with open('/etc/environment') as environment: |
70 |
environment_lines = environment.readlines() |
|
71 |
with open('/etc/environment', 'w') as environment: |
|
72 |
seen_lang = False |
|
73 |
for line in environment_lines: |
|
74 |
if line.startswith('LANG='): |
|
75 |
print('LANG="%s"' % locale, file=environment) |
|
76 |
seen_lang = True |
|
77 |
else: |
|
78 |
print(line.rstrip('\n'), file=environment) |
|
79 |
if not seen_lang: |
|
5120.2.1
by Colin Watson
* Begin porting to Python 3: |
80 |
print('LANG="%s"' % locale, file=environment) |
5427
by Colin Watson
Fix a slew of file handle leaks, including making much more liberal |
81 |
|
82 |
with open('/etc/locale.gen', 'w') as locale_gen: |
|
83 |
print('%s UTF-8' % locale, file=locale_gen) |
|
84 |
||
6104.1.2
by Aurélien Gâteau
Improve logging support |
85 |
subprocess.call(['/usr/sbin/locale-gen', locale], |
86 |
stdout=logfile, stderr=logfile) |
|
3879
by Evan Dandrea
Restore Colin's set_locale function. However, this is only half the |
87 |
|
5562
by Colin Watson
Make all Python code pass pep8(1), and add a test to enforce this. |
88 |
|
6104.1.3
by Aurélien Gâteau
Hide all KWin buttons but the maximize/restore button |
89 |
def add_ubiquity_kdedir(): |
90 |
os.environ['KDEDIRS'] = '/usr/share/ubiquity/qt:' + \ |
|
91 |
os.environ.get('KDEDIRS', '') |
|
92 |
||
93 |
||
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
94 |
class XStartupError(EnvironmentError): |
95 |
pass
|
|
96 |
||
5562
by Colin Watson
Make all Python code pass pep8(1), and add a test to enforce this. |
97 |
|
2514
by Colin Watson
* In ubiquity-dm, fall back to xfwm4 if metacity fails (unifying gtk_ui |
98 |
class MissingProgramError(EnvironmentError): |
99 |
pass
|
|
100 |
||
5562
by Colin Watson
Make all Python code pass pep8(1), and add a test to enforce this. |
101 |
|
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
102 |
class DM: |
3285.2.17
by Michael Terry
don't partition in oem-mode and lots of small changes to get nearer a working state |
103 |
def __init__(self, vt, display, default_username): |
6002.1.1
by Dmitrijs Ledkovs
* Add dependencies on python3-pam. |
104 |
self.auth = PAM.pam() |
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
105 |
self.vt = vt |
106 |
self.display = display |
|
107 |
self.server_started = False |
|
108 |
||
3285.2.17
by Michael Terry
don't partition in oem-mode and lots of small changes to get nearer a working state |
109 |
self.username = get_casper('USERNAME', default_username) |
4358
by Evan Dandrea
Fall back to root if the regular user cannot be found in |
110 |
try: |
111 |
self.uid, self.gid = pwd.getpwnam(self.username)[2:4] |
|
112 |
except KeyError: |
|
113 |
import syslog |
|
114 |
syslog.syslog('Could not find %s, falling back to root.' % |
|
115 |
self.username) |
|
116 |
self.username = 'root' |
|
117 |
self.uid, self.gid = 0, 0 |
|
2494
by Evan Dandrea
* Minor changes to ubiquity-dm from suggestions by Colin Watson. |
118 |
self.homedir = pwd.getpwnam(self.username)[5] |
2482
by Evan Dandrea
* Properly drop privileges in ubiquity-dm. Previous attempts were |
119 |
self.uid = int(self.uid) |
120 |
self.gid = int(self.gid) |
|
2580
by Evan Dandrea
* bin/ubiquity-dm: Set groups in drop_privileges. |
121 |
self.groups = [] |
122 |
for g in grp.getgrall(): |
|
123 |
if self.username in g[3] or g[0] == self.username: |
|
124 |
self.groups.append(g[2]) |
|
125 |
||
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
126 |
# Look for a frontend module; we won't actually use it (yet), but
|
127 |
# this lets us find out which window manager etc. to launch. Be
|
|
128 |
# careful that importing this here will cause the underlying library
|
|
129 |
# to try to talk to the X server, which won't go well.
|
|
3682.1.26
by Mario Limonciello
Drop mythbuntu_ui and all references to it. The (former) Mythbuntu |
130 |
frontend_names = ['gtk_ui', 'kde_ui'] |
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
131 |
self.frontend = None |
132 |
for f in frontend_names: |
|
133 |
try: |
|
134 |
imp.find_module(f, ubiquity.frontend.__path__) |
|
135 |
self.frontend = f |
|
136 |
break
|
|
137 |
except ImportError: |
|
138 |
pass
|
|
139 |
else: |
|
4456
by Evan Dandrea
PEP-8, deprecated exception style and has_key. |
140 |
raise AttributeError('No frontend available; tried %s' % |
141 |
', '.join(frontend_names)) |
|
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
142 |
|
4143
by Mario Limonciello
Add a new template ubiquity/force_failsafe_graphics intended to force |
143 |
db = DebconfCommunicator('ubiquity', cloexec=True) |
144 |
try: |
|
5562
by Colin Watson
Make all Python code pass pep8(1), and add a test to enforce this. |
145 |
self.force_failsafe = create_bool( |
146 |
db.get('ubiquity/force_failsafe_graphics')) |
|
4143
by Mario Limonciello
Add a new template ubiquity/force_failsafe_graphics intended to force |
147 |
except debconf.DebconfError: |
148 |
self.force_failsafe = False |
|
149 |
db.shutdown() |
|
150 |
||
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
151 |
def sigusr1_handler(self, signum, frame): |
152 |
self.server_started = True |
|
153 |
||
3621.1.1
by Colin Watson
Handle transitioning away from plymouth in ubiquity-dm. |
154 |
def active_vt(self): |
155 |
import fcntl |
|
156 |
import array |
|
157 |
||
158 |
console = os.open('/dev/tty0', os.O_RDONLY | os.O_NOCTTY) |
|
159 |
try: |
|
160 |
VT_GETSTATE = 0x5603 |
|
161 |
vt_stat = array.array('H', [0, 0, 0]) |
|
162 |
fcntl.ioctl(console, VT_GETSTATE, vt_stat) |
|
163 |
return vt_stat[0] |
|
164 |
finally: |
|
165 |
os.close(console) |
|
166 |
||
2482
by Evan Dandrea
* Properly drop privileges in ubiquity-dm. Previous attempts were |
167 |
def drop_privileges(self): |
2580
by Evan Dandrea
* bin/ubiquity-dm: Set groups in drop_privileges. |
168 |
os.setgroups(self.groups) |
2482
by Evan Dandrea
* Properly drop privileges in ubiquity-dm. Previous attempts were |
169 |
os.setgid(self.gid) |
6233.4.1
by Shih-Yuan Lee (FourDollars)
Set effective uid and gid when dropping privileges. |
170 |
os.setegid(self.gid) |
2482
by Evan Dandrea
* Properly drop privileges in ubiquity-dm. Previous attempts were |
171 |
os.setuid(self.uid) |
6233.4.1
by Shih-Yuan Lee (FourDollars)
Set effective uid and gid when dropping privileges. |
172 |
os.seteuid(self.uid) |
2482
by Evan Dandrea
* Properly drop privileges in ubiquity-dm. Previous attempts were |
173 |
|
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
174 |
def server_preexec(self): |
175 |
signal.signal(signal.SIGUSR1, signal.SIG_IGN) |
|
176 |
||
5522.2.3
by Kent Baxley
put the actual fixed-up file in place :) |
177 |
def run_hooks(self, hookdir): |
178 |
if os.path.isdir(hookdir): |
|
5562
by Colin Watson
Make all Python code pass pep8(1), and add a test to enforce this. |
179 |
# Exclude hooks containing '.', so that *.dpkg-* et al are avoided.
|
5522.2.5
by Kent Baxley
Make final cleanups per Colin. |
180 |
hooks = [entry for entry in os.listdir(hookdir) |
181 |
if '.' not in entry] |
|
5522.2.3
by Kent Baxley
put the actual fixed-up file in place :) |
182 |
for hookentry in hooks: |
183 |
hook = os.path.join(hookdir, hookentry) |
|
6104.1.2
by Aurélien Gâteau
Improve logging support |
184 |
subprocess.call( |
185 |
hook, stdout=logfile, stderr=logfile, |
|
186 |
preexec_fn=self.drop_privileges) |
|
5562
by Colin Watson
Make all Python code pass pep8(1), and add a test to enforce this. |
187 |
|
6002.1.1
by Dmitrijs Ledkovs
* Add dependencies on python3-pam. |
188 |
def pam_open_session(self): |
189 |
self.auth.start('su') |
|
190 |
self.auth.set_item(PAM.PAM_USER, self.username) |
|
191 |
self.auth.set_item(PAM.PAM_CONV, _pam_conv) |
|
192 |
self.auth.putenv('XDG_SESSION_CLASS=greeter') |
|
193 |
self.auth.putenv('XDG_SEAT=seat0') |
|
6002.1.2
by Dmitrijs Ledkovs
Refactor & do not hard-code vt # |
194 |
# at the time pam_open_session is called self.vt is the
|
195 |
# correct vt: either the one originally passed as cmd line
|
|
196 |
# arg or as determined by active_vt()
|
|
197 |
#
|
|
198 |
# self.vt is of the form str("vt10")
|
|
199 |
self.auth.putenv('XDG_VTNR=%s' % self.vt[2:]) |
|
6002.1.1
by Dmitrijs Ledkovs
* Add dependencies on python3-pam. |
200 |
self.auth.authenticate() |
201 |
self.auth.open_session() |
|
202 |
os.environ.update( |
|
203 |
[i.split('=', 1) for i in self.auth.getenvlist()]) |
|
204 |
||
205 |
def pam_close_session(self): |
|
206 |
if self.auth: |
|
207 |
self.auth.close_session() |
|
208 |
self.auth = None |
|
209 |
||
3858
by Evan Dandrea
Move the greeter functionality into ubiquity itself, still |
210 |
def run(self, *program): |
5562
by Colin Watson
Make all Python code pass pep8(1), and add a test to enforce this. |
211 |
# Extract the program basename to see if we are in oem-config or
|
212 |
# ubiquity.
|
|
5522.2.3
by Kent Baxley
put the actual fixed-up file in place :) |
213 |
program_basename = os.path.basename(program[0]) |
5562
by Colin Watson
Make all Python code pass pep8(1), and add a test to enforce this. |
214 |
|
5390.1.2
by Stéphane Graber
Get ubiquity-dm to spawn a new dconf-service |
215 |
extras = [] |
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
216 |
null = open('/dev/null', 'w') |
6104.1.2
by Aurélien Gâteau
Improve logging support |
217 |
log('starting') |
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
218 |
|
219 |
signal.signal(signal.SIGUSR1, self.sigusr1_handler) |
|
220 |
signal.signal(signal.SIGTTIN, signal.SIG_IGN) |
|
221 |
signal.signal(signal.SIGTTOU, signal.SIG_IGN) |
|
2529
by Mario Limonciello
allow changes to X command for different frontends in ubiquity-dm |
222 |
|
3621.1.1
by Colin Watson
Handle transitioning away from plymouth in ubiquity-dm. |
223 |
servercommand = ['X', '-br', '-ac', '-noreset', '-nolisten', 'tcp'] |
224 |
||
6104.1.2
by Aurélien Gâteau
Improve logging support |
225 |
log('plymouth') |
3621.1.1
by Colin Watson
Handle transitioning away from plymouth in ubiquity-dm. |
226 |
try: |
227 |
plymouth_running = subprocess.call(['plymouth', '--ping']) == 0 |
|
228 |
except OSError: |
|
229 |
plymouth_running = False |
|
230 |
if plymouth_running: |
|
231 |
subprocess.call(['plymouth', 'deactivate']) |
|
3937
by Colin Watson
Quit plymouth if it doesn't have an active VT, rather than trying to |
232 |
if subprocess.call(['plymouth', '--has-active-vt']) == 0: |
233 |
self.vt = 'vt%d' % self.active_vt() |
|
5538
by Colin Watson
ubiquity-dm: Use "-background none" rather than no-longer-supported |
234 |
servercommand.extend(['-background', 'none']) |
3937
by Colin Watson
Quit plymouth if it doesn't have an active VT, rather than trying to |
235 |
else: |
236 |
subprocess.call(['plymouth', 'quit']) |
|
237 |
plymouth_running = False |
|
3621.1.1
by Colin Watson
Handle transitioning away from plymouth in ubiquity-dm. |
238 |
|
239 |
servercommand.extend([self.vt, self.display]) |
|
2529
by Mario Limonciello
allow changes to X command for different frontends in ubiquity-dm |
240 |
|
6104.1.2
by Aurélien Gâteau
Improve logging support |
241 |
log('start X {}'.format(servercommand)) |
5207
by Mario Limonciello
Have two separate failsafe attempts for 'fbdev' and 'vesa'. It's |
242 |
for attempt in ('main', 'fbdev', 'vesa'): |
3756
by Colin Watson
Automatically fall back to vesa if normal X startup fails. This is a |
243 |
command = list(servercommand) |
4143
by Mario Limonciello
Add a new template ubiquity/force_failsafe_graphics intended to force |
244 |
if attempt == 'main' and self.force_failsafe: |
245 |
continue
|
|
5207
by Mario Limonciello
Have two separate failsafe attempts for 'fbdev' and 'vesa'. It's |
246 |
elif attempt != 'main': |
3756
by Colin Watson
Automatically fall back to vesa if normal X startup fails. This is a |
247 |
# TODO cjwatson 2010-02-11: This is a bodge. The
|
248 |
# duplication is nasty, but fortunately bullet-proof X
|
|
249 |
# actually turns out not to be very complicated nowadays.
|
|
250 |
# Most of the complexity is in the fallback session, which I
|
|
251 |
# haven't attempted to integrate here, so you won't get
|
|
252 |
# things like interactive reconfiguration. I believe Evan
|
|
253 |
# is working on doing that, but is blocked on a couple of
|
|
254 |
# Upstart bugs; once all that's resolved, we should back
|
|
255 |
# this out.
|
|
5207
by Mario Limonciello
Have two separate failsafe attempts for 'fbdev' and 'vesa'. It's |
256 |
if attempt == 'fbdev' and not os.path.exists('/dev/fb0'): |
257 |
continue
|
|
3756
by Colin Watson
Automatically fall back to vesa if normal X startup fails. This is a |
258 |
xorg_conf_failsafe = '/etc/X11/xorg.conf.failsafe' |
259 |
command.extend(['-config', xorg_conf_failsafe]) |
|
5207
by Mario Limonciello
Have two separate failsafe attempts for 'fbdev' and 'vesa'. It's |
260 |
command.extend(['-logfile', '/var/log/Xorg.%s.log' % attempt]) |
3756
by Colin Watson
Automatically fall back to vesa if normal X startup fails. This is a |
261 |
|
5427
by Colin Watson
Fix a slew of file handle leaks, including making much more liberal |
262 |
with open(xorg_conf_failsafe, 'w') as xorg_conf_failsafe_file: |
263 |
print('''\ |
|
3756
by Colin Watson
Automatically fall back to vesa if normal X startup fails. This is a |
264 |
Section "Device"
|
5562
by Colin Watson
Make all Python code pass pep8(1), and add a test to enforce this. |
265 |
\tIdentifier "Configured Video Device" |
266 |
\tDriver "%s" |
|
3756
by Colin Watson
Automatically fall back to vesa if normal X startup fails. This is a |
267 |
EndSection
|
268 |
||
269 |
Section "Monitor"
|
|
5562
by Colin Watson
Make all Python code pass pep8(1), and add a test to enforce this. |
270 |
\tIdentifier "Configured Monitor" |
3756
by Colin Watson
Automatically fall back to vesa if normal X startup fails. This is a |
271 |
EndSection
|
272 |
||
273 |
Section "Screen"
|
|
5562
by Colin Watson
Make all Python code pass pep8(1), and add a test to enforce this. |
274 |
\tIdentifier "Default Screen" |
275 |
\tMonitor "Configured Monitor" |
|
276 |
\tDevice "Configured Video Device" |
|
3756
by Colin Watson
Automatically fall back to vesa if normal X startup fails. This is a |
277 |
EndSection
|
5120.2.12
by Colin Watson
merge trunk |
278 |
''' % attempt, file=xorg_conf_failsafe_file) |
3756
by Colin Watson
Automatically fall back to vesa if normal X startup fails. This is a |
279 |
|
3890
by Colin Watson
try to keep to 80 columns a bit more |
280 |
server = subprocess.Popen( |
281 |
command, stdin=null, stdout=logfile, stderr=logfile, |
|
282 |
preexec_fn=self.server_preexec) |
|
3756
by Colin Watson
Automatically fall back to vesa if normal X startup fails. This is a |
283 |
|
284 |
# Really we should select on a pipe or something, but it's not
|
|
285 |
# worth the effort for now.
|
|
286 |
try: |
|
287 |
timeout = 60 |
|
288 |
while not self.server_started: |
|
289 |
status = server.poll() |
|
290 |
if type(status) is int and status != 0: |
|
291 |
if plymouth_running: |
|
292 |
subprocess.call(['plymouth', 'quit']) |
|
4456
by Evan Dandrea
PEP-8, deprecated exception style and has_key. |
293 |
raise XStartupError('X server exited with return code ' |
294 |
+ str(status)) |
|
3756
by Colin Watson
Automatically fall back to vesa if normal X startup fails. This is a |
295 |
if timeout == 0: |
296 |
if plymouth_running: |
|
297 |
subprocess.call(['plymouth', 'quit']) |
|
4456
by Evan Dandrea
PEP-8, deprecated exception style and has_key. |
298 |
raise XStartupError('X server failed to start after 60' |
299 |
' seconds') |
|
3756
by Colin Watson
Automatically fall back to vesa if normal X startup fails. This is a |
300 |
time.sleep(1) |
301 |
timeout -= 1 |
|
302 |
if plymouth_running: |
|
303 |
subprocess.call(['plymouth', 'quit', '--retain-splash']) |
|
304 |
except XStartupError: |
|
5207
by Mario Limonciello
Have two separate failsafe attempts for 'fbdev' and 'vesa'. It's |
305 |
if attempt == 'vesa': |
3756
by Colin Watson
Automatically fall back to vesa if normal X startup fails. This is a |
306 |
raise
|
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
307 |
|
3952
by Colin Watson
Don't fall through to the failsafe X server if the main X server |
308 |
if self.server_started: |
309 |
break
|
|
310 |
||
6104.1.2
by Aurélien Gâteau
Improve logging support |
311 |
log('set vars') |
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
312 |
os.environ['DISPLAY'] = self.display |
2494
by Evan Dandrea
* Minor changes to ubiquity-dm from suggestions by Colin Watson. |
313 |
os.environ['HOME'] = self.homedir |
3573.1.58
by Evan Dandrea
Set SUDO_UID and SUDO_GID in ubiquity-dm so ubiquity knows what user |
314 |
# Give ubiquity a UID and GID that it can drop privileges to.
|
5972
by Dmitrijs Ledkovs
Properly drop privileges with pkexec by deriving UID/GID/username from |
315 |
os.environ['PKEXEC_UID'] = str(self.uid) |
5562
by Colin Watson
Make all Python code pass pep8(1), and add a test to enforce this. |
316 |
os.environ['GVFS_DISABLE_FUSE'] = '1' |
5830
by Dmitrijs Ledkovs
* Migrate remaining gconf settings to gsettings in ubiquity-dm. |
317 |
# Overlay scrollbars are now a gtk module
|
318 |
os.environ['GTK_MODULES'] = 'overlay-scrollbar' |
|
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
319 |
|
6104.1.2
by Aurélien Gâteau
Improve logging support |
320 |
log('pam_open_session') |
6002.1.1
by Dmitrijs Ledkovs
* Add dependencies on python3-pam. |
321 |
self.pam_open_session() |
322 |
||
5522.2.2
by Kent Baxley
fixed up ubiquity-dm per Colin. Also got rid of static directory entries. |
323 |
# run simple, custom scripts during install time
|
5522.2.3
by Kent Baxley
put the actual fixed-up file in place :) |
324 |
if program_basename == 'ubiquity': |
6104.1.2
by Aurélien Gâteau
Improve logging support |
325 |
log('dm-scripts') |
5522.2.5
by Kent Baxley
Make final cleanups per Colin. |
326 |
self.run_hooks('/usr/lib/ubiquity/dm-scripts/install') |
5522.2.1
by Kent Baxley
Add the ability to run simple, custom scripts in ubiquity-dm (LP: #1017580) |
327 |
|
5522.2.2
by Kent Baxley
fixed up ubiquity-dm per Colin. Also got rid of static directory entries. |
328 |
# run simple, custom scripts during oem-config
|
5522.2.3
by Kent Baxley
put the actual fixed-up file in place :) |
329 |
if program_basename == 'oem-config-wrapper': |
6104.1.2
by Aurélien Gâteau
Improve logging support |
330 |
log('oem dm-scripts') |
5522.2.5
by Kent Baxley
Make final cleanups per Colin. |
331 |
self.run_hooks('/usr/lib/ubiquity/dm-scripts/oem') |
4325
by Evan Dandrea
Properly start a ConsoleKit session (LP: #631538). |
332 |
|
2835
by Colin Watson
Start dbus and (in the case of the GTK frontend) gconfd in only-ubiquity |
333 |
# Session bus, apparently needed by most interfaces now
|
334 |
if ('DBUS_SESSION_BUS_ADDRESS' not in os.environ and |
|
5770
by Colin Watson
Huge pile of minor changes to make ubiquity compatible with pep8 1.3. |
335 |
osextras.find_on_path('dbus-launch')): |
6104.1.2
by Aurélien Gâteau
Improve logging support |
336 |
log('dbus') |
2835
by Colin Watson
Start dbus and (in the case of the GTK frontend) gconfd in only-ubiquity |
337 |
dbus_subp = subprocess.Popen( |
338 |
['dbus-launch', '--exit-with-session'], |
|
339 |
stdin=null, stdout=subprocess.PIPE, stderr=logfile, |
|
5418
by Colin Watson
As a general rule, open subprocesses with universal_newlines=True when |
340 |
preexec_fn=self.drop_privileges, universal_newlines=True) |
2835
by Colin Watson
Start dbus and (in the case of the GTK frontend) gconfd in only-ubiquity |
341 |
for line in dbus_subp.stdout: |
342 |
try: |
|
343 |
name, value = line.rstrip('\n').split('=', 1) |
|
344 |
os.environ[name] = value |
|
345 |
except ValueError: |
|
346 |
pass
|
|
3880
by Colin Watson
ubiquity-dm: Close stdout from dbus-launch. |
347 |
dbus_subp.stdout.close() |
2835
by Colin Watson
Start dbus and (in the case of the GTK frontend) gconfd in only-ubiquity |
348 |
dbus_subp.wait() |
349 |
||
5390.1.2
by Stéphane Graber
Get ubiquity-dm to spawn a new dconf-service |
350 |
# dconf writer
|
351 |
if os.path.exists("/usr/lib/dconf/dconf-service"): |
|
6104.1.2
by Aurélien Gâteau
Improve logging support |
352 |
log('dconf-service') |
5390.1.2
by Stéphane Graber
Get ubiquity-dm to spawn a new dconf-service |
353 |
extras.append(subprocess.Popen( |
354 |
['/usr/lib/dconf/dconf-service'], |
|
355 |
stdin=null, stdout=logfile, stderr=logfile, |
|
356 |
preexec_fn=self.drop_privileges)) |
|
357 |
||
6043
by Dmitrijs Ledkovs
Well read proc/cmdline only once |
358 |
# Accessibility infrastructure
|
359 |
proc_cmdline = [] |
|
360 |
with open('/proc/cmdline', 'r') as fp: |
|
361 |
proc_cmdline = fp.readline().split() |
|
362 |
||
6104.1.2
by Aurélien Gâteau
Improve logging support |
363 |
log('start frontend {}'.format(self.frontend)) |
3682.1.26
by Mario Limonciello
Drop mythbuntu_ui and all references to it. The (former) Mythbuntu |
364 |
if self.frontend == 'gtk_ui': |
5814
by Dmitrijs Ledkovs
If available, Use gnome-settings-daemon to set the wallpaper, instead |
365 |
# Set a desktop wallpaper.
|
6043
by Dmitrijs Ledkovs
Well read proc/cmdline only once |
366 |
visual_a11y = 'access=v' in proc_cmdline |
5814
by Dmitrijs Ledkovs
If available, Use gnome-settings-daemon to set the wallpaper, instead |
367 |
|
5830
by Dmitrijs Ledkovs
* Migrate remaining gconf settings to gsettings in ubiquity-dm. |
368 |
background_image = None |
369 |
for background in ( |
|
6001.1.1
by Howard Chan
Fix the new Ubuntu Studio wallpaper backdrop for ubiquity. (LP: #1229651) |
370 |
'/usr/share/xfce4/backdrops/ubuntustudio-1310.png', |
5998
by Stéphane Graber
Change default wallpaper for Xubuntu. |
371 |
'/usr/share/xfce4/backdrops/xubuntu-wallpaper.png', |
5845
by Dmitrijs Ledkovs
lubuntu is too long, an uglyish fix for pep8. |
372 |
'/usr/share/lubuntu/wallpapers/'
|
6044
by Dmitrijs Ledkovs
Set wallpaper for 'feh' only, for others just assume gsettings schemes |
373 |
'lubuntu-default-wallpaper.png'): |
5830
by Dmitrijs Ledkovs
* Migrate remaining gconf settings to gsettings in ubiquity-dm. |
374 |
exists = os.access(background, os.R_OK) |
375 |
if exists: |
|
376 |
background_image = background |
|
377 |
break
|
|
378 |
||
379 |
accessibility = False |
|
380 |
if gsettings._gsettings_exists(): |
|
381 |
accessibility = gsettings.get( |
|
382 |
'org.gnome.desktop.interface', 'toolkit-accessibility', |
|
383 |
self.username) |
|
5017
by Stéphane Graber
Update ubiquity-dm to set gsettings keys instead of gconf |
384 |
|
385 |
# Set gsettings keys
|
|
6243.1.4
by Ubuntu MATE Developers
Refactored based on feedback. |
386 |
gsettings_keys = [ |
6259
by Mathieu Trudel-Lapierre
Fix indentations for gsettings keys added by previous commit. |
387 |
('org.gnome.desktop.lockdown', 'disable-lock-screen', |
388 |
'true'), |
|
389 |
('org.gnome.desktop.lockdown', 'disable-user-switching', |
|
390 |
'true'), |
|
391 |
('org.gnome.settings-daemon.plugins.background', 'active', |
|
392 |
'true'), |
|
393 |
('org.gnome.desktop.background', 'draw-background', |
|
394 |
'true'), |
|
395 |
('org.gnome.desktop.background', 'show-desktop-icons', |
|
396 |
'false'), |
|
397 |
('org.gnome.metacity', 'compositing-manager', |
|
398 |
'true'), |
|
399 |
('org.gnome.desktop.wm.preferences', 'num-workspaces', |
|
400 |
'1'), |
|
401 |
]
|
|
6243.1.4
by Ubuntu MATE Developers
Refactored based on feedback. |
402 |
|
403 |
# Setting a wallpaper image, or solid color.
|
|
404 |
if visual_a11y: |
|
405 |
gsettings_keys.append( |
|
406 |
('org.gnome.desktop.background', 'picture-options', |
|
407 |
'none')) |
|
408 |
gsettings_keys.append( |
|
409 |
('org.gnome.desktop.background', 'picture-uri', |
|
6259
by Mathieu Trudel-Lapierre
Fix indentations for gsettings keys added by previous commit. |
410 |
"''")) |
6243.1.4
by Ubuntu MATE Developers
Refactored based on feedback. |
411 |
|
6195
by Dimitri John Ledkov
Added marco (MATE window manager) support to ubiquity-dm. |
412 |
if osextras.find_on_path('marco'): |
6243.1.2
by Ubuntu MATE Developers
Minor refactor. Properly fixed MATE support. Tested. |
413 |
gsettings_keys = [ |
414 |
('org.mate.lockdown', 'disable-lock-screen', |
|
6242
by Dimitri John Ledkov
pep8 |
415 |
'true'), |
6243.1.2
by Ubuntu MATE Developers
Minor refactor. Properly fixed MATE support. Tested. |
416 |
('org.mate.lockdown', 'disable-user-switching', |
6242
by Dimitri John Ledkov
pep8 |
417 |
'true'), |
418 |
('org.mate.SettingsDaemon.plugins.background', |
|
419 |
'active', 'true'), |
|
6243.1.2
by Ubuntu MATE Developers
Minor refactor. Properly fixed MATE support. Tested. |
420 |
('org.mate.background', 'draw-background', |
6242
by Dimitri John Ledkov
pep8 |
421 |
'true'), |
6243.1.2
by Ubuntu MATE Developers
Minor refactor. Properly fixed MATE support. Tested. |
422 |
('org.mate.background', 'show-desktop-icons', |
6242
by Dimitri John Ledkov
pep8 |
423 |
'false'), |
6233.3.1
by Martin Wimpress
Correct compositing for Marco. Add Ubuntu MATE background to Ubiquity. |
424 |
('org.mate.Marco.general', 'compositing-manager', |
6243.1.1
by Ubuntu MATE Developers
Fixes lp: #1408219 |
425 |
'true'), |
6233.3.2
by Martin Wimpress
Make use of mate-settings-daemon. |
426 |
('org.mate.Marco.general', 'num-workspaces', |
6243.1.2
by Ubuntu MATE Developers
Minor refactor. Properly fixed MATE support. Tested. |
427 |
'1'), |
428 |
]
|
|
429 |
||
430 |
# Setting a wallpaper image, or solid color.
|
|
431 |
if visual_a11y: |
|
432 |
gsettings_keys.append( |
|
433 |
('org.mate.background', 'picture-options', |
|
434 |
'none')) |
|
435 |
gsettings_keys.append( |
|
436 |
('org.mate.background', 'picture-filename', |
|
6259
by Mathieu Trudel-Lapierre
Fix indentations for gsettings keys added by previous commit. |
437 |
"''")) |
6243.1.2
by Ubuntu MATE Developers
Minor refactor. Properly fixed MATE support. Tested. |
438 |
|
439 |
if osextras.find_on_path('gnome-shell'): |
|
440 |
gsettings_keys.append( |
|
441 |
('org.gnome.settings-daemon.plugins.background', |
|
442 |
'active', 'false')) |
|
443 |
gsettings_keys.remove( |
|
444 |
('org.gnome.desktop.wm.preferences', 'num-workspaces', |
|
6242
by Dimitri John Ledkov
pep8 |
445 |
'1')) |
6195
by Dimitri John Ledkov
Added marco (MATE window manager) support to ubiquity-dm. |
446 |
|
5989.1.2
by Tim Lunn
* disable g-s-d background plugin for Ubuntu GNOME |
447 |
for gs_schema, gs_key, gs_value in gsettings_keys: |
448 |
subprocess.call( |
|
449 |
['gsettings', 'set', gs_schema, gs_key, gs_value], |
|
450 |
stdin=null, stdout=logfile, stderr=logfile, |
|
451 |
preexec_fn=self.drop_privileges) |
|
452 |
||
6118
by Dimitri John Ledkov
Launch unity-settings-daemon if available. |
453 |
usd = '/usr/lib/unity-settings-daemon/unity-settings-daemon' |
5830
by Dmitrijs Ledkovs
* Migrate remaining gconf settings to gsettings in ubiquity-dm. |
454 |
gsd = '/usr/lib/gnome-settings-daemon/gnome-settings-daemon' |
6233.3.2
by Martin Wimpress
Make use of mate-settings-daemon. |
455 |
msd = '/usr/bin/mate-settings-daemon' |
456 |
||
6118
by Dimitri John Ledkov
Launch unity-settings-daemon if available. |
457 |
if osextras.find_on_path(usd): |
458 |
extras.append(subprocess.Popen( |
|
459 |
[usd], stdin=null, stdout=logfile, stderr=logfile, |
|
460 |
preexec_fn=self.drop_privileges)) |
|
461 |
||
462 |
elif osextras.find_on_path(gsd): |
|
5831
by Dmitrijs Ledkovs
Fix up, check before executing g-s-d. |
463 |
extras.append(subprocess.Popen( |
464 |
[gsd], stdin=null, stdout=logfile, stderr=logfile, |
|
465 |
preexec_fn=self.drop_privileges)) |
|
5830
by Dmitrijs Ledkovs
* Migrate remaining gconf settings to gsettings in ubiquity-dm. |
466 |
|
6233.3.2
by Martin Wimpress
Make use of mate-settings-daemon. |
467 |
elif osextras.find_on_path(msd): |
468 |
extras.append(subprocess.Popen( |
|
469 |
[msd], stdin=null, stdout=logfile, stderr=logfile, |
|
470 |
preexec_fn=self.drop_privileges)) |
|
471 |
||
5840
by Dmitrijs Ledkovs
Use feh to draw the wallpaper on Lubuntu when using ubiquity-dm. |
472 |
elif background_image and osextras.find_on_path('feh'): |
473 |
subprocess.call( |
|
474 |
['feh', '--bg-fill', background_image], |
|
475 |
stdin=null, stdout=logfile, stderr=logfile, |
|
476 |
preexec_fn=self.drop_privileges) |
|
477 |
||
6042
by Dmitrijs Ledkovs
Don't read proc_cmdline twice (LP: #1213748) |
478 |
if (accessibility or 'maybe-ubiquity' in proc_cmdline or |
479 |
'only-ubiquity' in proc_cmdline or |
|
480 |
program_basename == 'oem-config-wrapper'): |
|
481 |
launcher = '/usr/lib/at-spi2-core/at-spi-bus-launcher' |
|
482 |
if os.path.exists(launcher): |
|
483 |
extras.append(subprocess.Popen( |
|
484 |
[launcher, '--launch-immediately'], |
|
485 |
stdin=null, stdout=logfile, stderr=logfile, |
|
486 |
preexec_fn=self.drop_privileges)) |
|
487 |
os.environ['GTK_MODULES'] += os.pathsep + 'gail' |
|
2664
by Luke Yelavich
* bin/ubiquity-dm: |
488 |
|
5978.1.2
by Tim Lunn
* Use gnome-shell as wm in ubiquity-dm on Ubuntu GNOME (LP: #1214732) |
489 |
if osextras.find_on_path('gnome-shell'): |
490 |
wm_cmd = ['gnome-shell', '--sm-disable', '--mode=ubiquity'] |
|
6194.1.2
by Martin Wimpress
Added marco (MATE window manager) support to ubiquity-dm. |
491 |
elif osextras.find_on_path('marco'): |
492 |
wm_cmd = ['marco', '--sm-disable'] |
|
5978.1.2
by Tim Lunn
* Use gnome-shell as wm in ubiquity-dm on Ubuntu GNOME (LP: #1214732) |
493 |
elif osextras.find_on_path('metacity'): |
4090
by Evan Dandrea
Start the window manager via ck-launch-session so pulseaudio is |
494 |
wm_cmd = ['metacity', '--sm-disable'] |
2514
by Colin Watson
* In ubiquity-dm, fall back to xfwm4 if metacity fails (unifying gtk_ui |
495 |
elif osextras.find_on_path('xfwm4'): |
6254.1.1
by Unit 193
* Start all Xfce components with --sm-client-disable. |
496 |
wm_cmd = ['xfwm4', '--compositor=off', '--sm-client-disable'] |
2679
by Colin Watson
Add ubiquity-dm implementation for matchbox-window-manager (thanks, |
497 |
elif osextras.find_on_path('matchbox-window-manager'): |
4090
by Evan Dandrea
Start the window manager via ck-launch-session so pulseaudio is |
498 |
wm_cmd = ['matchbox-window-manager'] |
4435.1.1
by Julien Lavergne
* debian/ubiquity.ubiquity.upstart: |
499 |
elif osextras.find_on_path('openbox-lubuntu'): |
500 |
wm_cmd = ['openbox-lubuntu'] |
|
5198
by Colin Watson
ubiquity-dm: Try openbox after openbox-lubuntu (LP: #888107). |
501 |
elif osextras.find_on_path('openbox'): |
502 |
wm_cmd = ['openbox'] |
|
5777.1.1
by Dmitrijs Ledkovs
Add basic support for compiz window manager. |
503 |
elif osextras.find_on_path('compiz'): |
5814
by Dmitrijs Ledkovs
If available, Use gnome-settings-daemon to set the wallpaper, instead |
504 |
wm_cmd = ['compiz', '--sm-disable', 'decor', 'resize', 'place', |
505 |
'move'] |
|
2514
by Colin Watson
* In ubiquity-dm, fall back to xfwm4 if metacity fails (unifying gtk_ui |
506 |
else: |
5770
by Colin Watson
Huge pile of minor changes to make ubiquity compatible with pep8 1.3. |
507 |
raise MissingProgramError( |
508 |
'No window manager found (tried '
|
|
6194.1.2
by Martin Wimpress
Added marco (MATE window manager) support to ubiquity-dm. |
509 |
'marco, metacity, xfwm4, matchbox-window-manager, '
|
5777.1.1
by Dmitrijs Ledkovs
Add basic support for compiz window manager. |
510 |
'openbox-lubuntu, openbox, compiz)') |
511 |
||
5770
by Colin Watson
Huge pile of minor changes to make ubiquity compatible with pep8 1.3. |
512 |
wm = subprocess.Popen( |
513 |
wm_cmd, stdin=null, stdout=logfile, stderr=logfile, |
|
4512
by Evan Dandrea
Fix accessibility support in the installer session. |
514 |
preexec_fn=self.drop_privileges) |
2514
by Colin Watson
* In ubiquity-dm, fall back to xfwm4 if metacity fails (unifying gtk_ui |
515 |
|
5518
by Colin Watson
Remove hardcoded paths to xfsettingsd and various accessibility tools. |
516 |
if osextras.find_on_path('xfsettingsd'): |
4198
by Mario Limonciello
If available, run xfsettingsd in ubiquity only mode. |
517 |
extras.append(subprocess.Popen( |
6254.1.1
by Unit 193
* Start all Xfce components with --sm-client-disable. |
518 |
['xprop', '-root', '-format', '_NET_NUMBER_OF_DESKTOPS', |
519 |
'32c', '-set', '_NET_NUMBER_OF_DESKTOPS', '1'], |
|
520 |
stdin=null, stdout=logfile, stderr=logfile, |
|
521 |
preexec_fn=self.drop_privileges)) |
|
522 |
extras.append(subprocess.Popen( |
|
523 |
['xfsettingsd', '--sm-client-disable'], |
|
524 |
stdin=null, stdout=logfile, stderr=logfile, |
|
525 |
preexec_fn=self.drop_privileges)) |
|
4198
by Mario Limonciello
If available, run xfsettingsd in ubiquity only mode. |
526 |
|
4435.1.1
by Julien Lavergne
* debian/ubiquity.ubiquity.upstart: |
527 |
if osextras.find_on_path('lxsession'): |
5830
by Dmitrijs Ledkovs
* Migrate remaining gconf settings to gsettings in ubiquity-dm. |
528 |
extras.append(subprocess.Popen( |
5562
by Colin Watson
Make all Python code pass pep8(1), and add a test to enforce this. |
529 |
['lxsession', '-s', 'Lubuntu', '-e', 'LXDE', '-a'], |
4435.1.1
by Julien Lavergne
* debian/ubiquity.ubiquity.upstart: |
530 |
stdin=null, stdout=logfile, stderr=logfile, |
5830
by Dmitrijs Ledkovs
* Migrate remaining gconf settings to gsettings in ubiquity-dm. |
531 |
preexec_fn=self.drop_privileges)) |
4435.1.1
by Julien Lavergne
* debian/ubiquity.ubiquity.upstart: |
532 |
|
6233.2.1
by Unit 193
Enable the ubiquity panel in xfwm4 now since it is functional. |
533 |
if os.path.exists('/usr/lib/ubiquity/panel'): |
5978.1.2
by Tim Lunn
* Use gnome-shell as wm in ubiquity-dm on Ubuntu GNOME (LP: #1214732) |
534 |
if ("openbox-lubuntu" not in wm_cmd and |
535 |
"openbox" not in wm_cmd and |
|
536 |
"gnome-shell" not in wm_cmd): |
|
6105
by Dimitri John Ledkov
Fix loading indicators in ubiquity-dm. |
537 |
multiarchdir = os.path.split( |
538 |
sysconfig.get_config_var('multiarchsubdir'))[-1] |
|
6167
by Colin Watson
Add future location of indicator-keyboard-service, tolerating missing |
539 |
indicators = list(filter(os.path.isfile, [ |
6105
by Dimitri John Ledkov
Fix loading indicators in ubiquity-dm. |
540 |
os.path.join('/usr/lib', multiarchdir, i) for i in ( |
6138
by Colin Watson
break long line |
541 |
'indicator-application/'
|
542 |
'indicator-application-service', |
|
6105
by Dimitri John Ledkov
Fix loading indicators in ubiquity-dm. |
543 |
'indicator-session/indicator-session-service', |
544 |
'indicator-sound/indicator-sound-service', |
|
545 |
'indicator-bluetooth/indicator-bluetooth-service', |
|
6167
by Colin Watson
Add future location of indicator-keyboard-service, tolerating missing |
546 |
'indicator-keyboard/indicator-keyboard-service', |
6105
by Dimitri John Ledkov
Fix loading indicators in ubiquity-dm. |
547 |
'indicator-keyboard-service', |
6170
by Dimitri John Ledkov
Add power indicator to the list of indicators launched under install |
548 |
'indicator-power/indicator-power-service', |
6167
by Colin Watson
Add future location of indicator-keyboard-service, tolerating missing |
549 |
)]))
|
4653.1.3
by Julien Lavergne
[ Julien Lavergne ] |
550 |
extras.append(subprocess.Popen( |
551 |
['/usr/lib/ubiquity/panel'], |
|
552 |
stdin=null, stdout=logfile, stderr=logfile, |
|
553 |
preexec_fn=self.drop_privileges)) |
|
6105
by Dimitri John Ledkov
Fix loading indicators in ubiquity-dm. |
554 |
for indicator in indicators: |
555 |
extras.append(subprocess.Popen( |
|
556 |
[indicator], |
|
557 |
stdin=null, stdout=logfile, stderr=logfile, |
|
558 |
preexec_fn=self.drop_privileges)) |
|
4123.1.41
by Evan Dandrea
Actually run the panel in the installer session. |
559 |
|
5982
by Dmitrijs Ledkovs
Fix pep8 |
560 |
if (osextras.find_on_path('nm-applet') and |
561 |
"gnome-shell" not in wm_cmd): |
|
4302
by Evan Dandrea
Run nm-applet in the ubiquity GTK session. |
562 |
extras.append(subprocess.Popen( |
563 |
['nm-applet'], |
|
564 |
stdin=null, stdout=logfile, stderr=logfile, |
|
4512
by Evan Dandrea
Fix accessibility support in the installer session. |
565 |
preexec_fn=self.drop_privileges)) |
5214
by Stéphane Graber
Get ubiquity-dm to spawn ibus-daemon if available. |
566 |
|
567 |
if osextras.find_on_path('ibus-daemon'): |
|
568 |
extras.append(subprocess.Popen( |
|
569 |
['ibus-daemon'], |
|
570 |
stdin=null, stdout=logfile, stderr=logfile, |
|
571 |
preexec_fn=self.drop_privileges)) |
|
572 |
||
5245
by Stéphane Graber
Start bluetooth-applet from ubiquity-dm |
573 |
# Simply start bluetooth-applet, ubiquity-bluetooth-agent will
|
574 |
# override it from casper to make sure it also covers the regular
|
|
575 |
# live session
|
|
576 |
if osextras.find_on_path('bluetooth-applet'): |
|
577 |
extras.append(subprocess.Popen( |
|
578 |
['bluetooth-applet'], |
|
579 |
stdin=null, stdout=logfile, stderr=logfile, |
|
580 |
preexec_fn=self.drop_privileges)) |
|
581 |
||
2664
by Luke Yelavich
* bin/ubiquity-dm: |
582 |
# Accessibility tools
|
5562
by Colin Watson
Make all Python code pass pep8(1), and add a test to enforce this. |
583 |
if accessibility: |
6043
by Dmitrijs Ledkovs
Well read proc/cmdline only once |
584 |
# FIXME: launch onboard, when touch screen detected
|
585 |
if 'access=m2' in proc_cmdline: |
|
586 |
if osextras.find_on_path('onboard'): |
|
587 |
extras.append(subprocess.Popen( |
|
588 |
['onboard'], |
|
589 |
stdin=null, stdout=logfile, stderr=logfile, |
|
590 |
preexec_fn=self.drop_privileges)) |
|
591 |
else: |
|
592 |
if osextras.find_on_path('orca'): |
|
593 |
time.sleep(15) |
|
594 |
extras.append(subprocess.Popen( |
|
595 |
['orca'], |
|
596 |
stdin=null, stdout=logfile, stderr=logfile, |
|
597 |
preexec_fn=self.drop_privileges)) |
|
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
598 |
elif self.frontend == 'kde_ui': |
6194
by Jonathan Riddell
fix pep8 whitespace fussyness |
599 |
if 'access=v1' not in proc_cmdline: |
6104.1.4
by Aurélien Gâteau
Bring back default wallpaper behind Ubiquity window |
600 |
log('paint background') |
6280
by Jonathan Riddell
keep pep8 happy |
601 |
path = \ |
602 |
'/usr/share/wallpapers/Next/contents/images/2560x1600.png'
|
|
6104.1.4
by Aurélien Gâteau
Bring back default wallpaper behind Ubiquity window |
603 |
extras.append(subprocess.Popen( |
604 |
['ubiquity-qtsetbg', path], |
|
605 |
stdin=null, stdout=logfile, stderr=logfile, |
|
606 |
preexec_fn=self.drop_privileges)) |
|
3975
by Evan Dandrea
Set a wallpaper and cursor for the KDE frontend when in only- |
607 |
|
6104.1.3
by Aurélien Gâteau
Hide all KWin buttons but the maximize/restore button |
608 |
log("add_ubiquity_kdedir") |
609 |
add_ubiquity_kdedir() |
|
6104.1.2
by Aurélien Gâteau
Improve logging support |
610 |
log('start kwin') |
6198.1.1
by Rohan Garg
Make sure ubiquity-dm works on Plasma 5 KWin |
611 |
if osextras.find_on_path('kwin'): |
6200
by Colin Watson
Tidy up whitespace. |
612 |
wm_cmd = ['kwin'] |
6198.1.1
by Rohan Garg
Make sure ubiquity-dm works on Plasma 5 KWin |
613 |
elif osextras.find_on_path('kwin_x11'): |
6200
by Colin Watson
Tidy up whitespace. |
614 |
wm_cmd = ['kwin_x11'] |
5770
by Colin Watson
Huge pile of minor changes to make ubiquity compatible with pep8 1.3. |
615 |
wm = subprocess.Popen( |
6198.1.1
by Rohan Garg
Make sure ubiquity-dm works on Plasma 5 KWin |
616 |
wm_cmd, stdin=null, stdout=logfile, stderr=logfile, |
3890
by Colin Watson
try to keep to 80 columns a bit more |
617 |
preexec_fn=self.drop_privileges) |
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
618 |
|
6104.1.2
by Aurélien Gâteau
Improve logging support |
619 |
log('start greeter') |
5562
by Colin Watson
Make all Python code pass pep8(1), and add a test to enforce this. |
620 |
greeter = subprocess.Popen( |
621 |
program, stdin=null, stdout=logfile, stderr=logfile) |
|
3858
by Evan Dandrea
Move the greeter functionality into ubiquity itself, still |
622 |
ret = greeter.wait() |
6104.1.2
by Aurélien Gâteau
Improve logging support |
623 |
log('greeter exited with code {}'.format(ret)) |
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
624 |
|
4057
by Evan Dandrea
Let the user know why we're starting a desktop session or rebooting |
625 |
reboot = False |
626 |
if ret != 0: |
|
627 |
db = DebconfCommunicator('ubiquity', cloexec=True) |
|
628 |
try: |
|
4060
by Evan Dandrea
Call ubiquity/failure_command if we crash in only ubiquity mode. |
629 |
error_cmd = db.get('ubiquity/failure_command') |
630 |
if error_cmd: |
|
631 |
subprocess.call(['sh', '-c', error_cmd]) |
|
632 |
except debconf.DebconfError: |
|
633 |
pass
|
|
4914
by Colin Watson
remove trailing whitespace |
634 |
|
4115
by Evan Dandrea
Don't reboot on failure if we say we're not going to. |
635 |
reboot = False |
4060
by Evan Dandrea
Call ubiquity/failure_command if we crash in only ubiquity mode. |
636 |
try: |
4115
by Evan Dandrea
Don't reboot on failure if we say we're not going to. |
637 |
if '--automatic' in program: |
638 |
reboot = db.get('ubiquity/reboot_on_failure') == 'true' |
|
4057
by Evan Dandrea
Let the user know why we're starting a desktop session or rebooting |
639 |
except debconf.DebconfError: |
4115
by Evan Dandrea
Don't reboot on failure if we say we're not going to. |
640 |
pass
|
4914
by Colin Watson
remove trailing whitespace |
641 |
|
4115
by Evan Dandrea
Don't reboot on failure if we say we're not going to. |
642 |
if reboot: |
4057
by Evan Dandrea
Let the user know why we're starting a desktop session or rebooting |
643 |
question = 'ubiquity/install_failed_reboot' |
644 |
else: |
|
645 |
question = 'ubiquity/install_failed' |
|
646 |
title = '' |
|
647 |
message = '' |
|
648 |
try: |
|
5441
by Colin Watson
Replace all calls to unicode() with calls to six.text_type() or |
649 |
title = utf8(db.metaget(question, 'description'), |
650 |
errors='replace') |
|
651 |
message = utf8(db.metaget(question, 'extended_description'), |
|
652 |
errors='replace') |
|
4057
by Evan Dandrea
Let the user know why we're starting a desktop session or rebooting |
653 |
except debconf.DebconfError: |
654 |
pass
|
|
4625
by Colin Watson
Shut down the debconf-communicator instance started in DM.run. This |
655 |
db.shutdown() |
4057
by Evan Dandrea
Let the user know why we're starting a desktop session or rebooting |
656 |
|
657 |
if title and message: |
|
658 |
if self.frontend == 'gtk_ui': |
|
659 |
cmd = ['zenity', '--error', '--title=%s' % title, |
|
660 |
'--text=%s' % message] |
|
661 |
subprocess.call(cmd) |
|
662 |
elif self.frontend == 'kde_ui': |
|
663 |
cmd = ['kdialog', '--title=%s' % title, |
|
664 |
'--msgbox=%s' % message] |
|
665 |
subprocess.call(cmd) |
|
666 |
else: |
|
667 |
# Not ideal, but if we cannot let the user know what's
|
|
668 |
# going on, it's best to drop them into a desktop and let
|
|
669 |
# them figure it out.
|
|
670 |
reboot = False |
|
671 |
||
6044
by Dmitrijs Ledkovs
Set wallpaper for 'feh' only, for others just assume gsettings schemes |
672 |
# Revert gnome-settings to default, for dropping to desktop
|
6090
by Jonathan Riddell
[ Harald Sitter ] |
673 |
if self.frontend == 'gtk_ui' and gsettings._gsettings_exists(): |
6044
by Dmitrijs Ledkovs
Set wallpaper for 'feh' only, for others just assume gsettings schemes |
674 |
for gs_schema, gs_key, gs_value in gsettings_keys: |
675 |
subprocess.call( |
|
676 |
['gsettings', 'reset', gs_schema, gs_key], |
|
677 |
stdin=null, stdout=logfile, stderr=logfile, |
|
678 |
preexec_fn=self.drop_privileges) |
|
679 |
||
3443
by Colin Watson
Stop ubiquity-dm crashing if a process it's trying to kill doesn't exist |
680 |
def kill_if_exists(pid, signum): |
681 |
try: |
|
682 |
os.kill(pid, signum) |
|
5120.2.2
by Colin Watson
Use "except Exception as e" syntax rather than the old-style "except |
683 |
except OSError as e: |
3443
by Colin Watson
Stop ubiquity-dm crashing if a process it's trying to kill doesn't exist |
684 |
if e.errno != errno.ESRCH: |
685 |
raise
|
|
686 |
||
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
687 |
def sigalrm_handler(signum, frame): |
3443
by Colin Watson
Stop ubiquity-dm crashing if a process it's trying to kill doesn't exist |
688 |
kill_if_exists(wm.pid, signal.SIGKILL) |
2209
by Colin Watson
run gnome-settings-daemon so that we use the normal theme |
689 |
for extra in extras: |
3443
by Colin Watson
Stop ubiquity-dm crashing if a process it's trying to kill doesn't exist |
690 |
kill_if_exists(extra.pid, signal.SIGKILL) |
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
691 |
|
3443
by Colin Watson
Stop ubiquity-dm crashing if a process it's trying to kill doesn't exist |
692 |
kill_if_exists(wm.pid, signal.SIGTERM) |
2209
by Colin Watson
run gnome-settings-daemon so that we use the normal theme |
693 |
for extra in extras: |
3443
by Colin Watson
Stop ubiquity-dm crashing if a process it's trying to kill doesn't exist |
694 |
kill_if_exists(extra.pid, signal.SIGTERM) |
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
695 |
signal.signal(signal.SIGALRM, sigalrm_handler) |
5562
by Colin Watson
Make all Python code pass pep8(1), and add a test to enforce this. |
696 |
signal.alarm(1) # low patience with WMs failing to exit on demand |
2209
by Colin Watson
run gnome-settings-daemon so that we use the normal theme |
697 |
processes = set(extras) |
698 |
processes.add(wm) |
|
699 |
while processes: |
|
700 |
done = set() |
|
701 |
for process in processes: |
|
702 |
try: |
|
703 |
process.wait() |
|
704 |
done.add(process) |
|
5120.2.2
by Colin Watson
Use "except Exception as e" syntax rather than the old-style "except |
705 |
except OSError as e: |
2209
by Colin Watson
run gnome-settings-daemon so that we use the normal theme |
706 |
if e.errno == errno.EINTR: |
707 |
continue
|
|
708 |
raise
|
|
709 |
processes -= done |
|
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
710 |
signal.alarm(0) |
5038
by Stéphane Graber
Clear the console just before killing X in ubiquity-dm, this should give us a blank screen while waiting for lightdm to start. |
711 |
|
5040
by Stéphane Graber
Update comment in ubiquity-dm (s/upstart messages/boot-time messages/g) |
712 |
# Clear the console so we don't see boot-time messages on switch
|
5043
by Stéphane Graber
Don't fail if we can't open the tty |
713 |
try: |
5427
by Colin Watson
Fix a slew of file handle leaks, including making much more liberal |
714 |
with open('/dev/tty' + self.vt[2:], 'r+') as vthandle: |
715 |
subprocess.call(['clear'], stdin=vthandle, stdout=vthandle) |
|
5043
by Stéphane Graber
Don't fail if we can't open the tty |
716 |
except IOError: |
717 |
pass
|
|
5038
by Stéphane Graber
Clear the console just before killing X in ubiquity-dm, this should give us a blank screen while waiting for lightdm to start. |
718 |
|
3443
by Colin Watson
Stop ubiquity-dm crashing if a process it's trying to kill doesn't exist |
719 |
kill_if_exists(server.pid, signal.SIGTERM) |
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
720 |
server.wait() |
721 |
||
5427
by Colin Watson
Fix a slew of file handle leaks, including making much more liberal |
722 |
null.close() |
723 |
||
4057
by Evan Dandrea
Let the user know why we're starting a desktop session or rebooting |
724 |
if reboot: |
725 |
subprocess.Popen(['reboot']) |
|
2206
by Colin Watson
* If 'automatic-ubiquity' is on the kernel command line, start Ubiquity in |
726 |
if ret is not None and ret >= 0: |
727 |
return ret |
|
728 |
else: |
|
729 |
return 1 |
|
730 |
||
5562
by Colin Watson
Make all Python code pass pep8(1), and add a test to enforce this. |
731 |
|
6104.1.2
by Aurélien Gâteau
Improve logging support |
732 |
def run(vt, display, username): |
733 |
try: |
|
734 |
dm = DM(vt, display, username) |
|
735 |
except XStartupError: |
|
736 |
log("XStartupError") |
|
737 |
return 1 |
|
738 |
ret = dm.run(*sys.argv[4:]) |
|
739 |
if ret == 0: |
|
740 |
log("set_locale") |
|
741 |
set_locale() |
|
742 |
dm.pam_close_session() |
|
743 |
return ret |
|
744 |
||
745 |
||
746 |
def main(): |
|
747 |
global logfile |
|
748 |
||
749 |
if len(sys.argv) < 4: |
|
750 |
sys.stderr.write('Usage: %s <vt[1-N]> <:[0-N]> <username> <program> ' |
|
751 |
'[<arguments>]\n' % sys.argv[0]) |
|
752 |
return 1 |
|
753 |
vt, display, username = sys.argv[1:4] |
|
754 |
||
6112
by Jonathan Riddell
Fix ubiquity-dm to create logfile directory before opening logfile |
755 |
try: |
756 |
os.makedirs('/var/log/installer') |
|
757 |
except OSError as e: |
|
758 |
# be happy if someone already created the path
|
|
759 |
if e.errno != errno.EEXIST: |
|
760 |
raise
|
|
6104.1.2
by Aurélien Gâteau
Improve logging support |
761 |
logfile = open('/var/log/installer/dm', 'w') |
762 |
try: |
|
763 |
ret = run(vt, display, username) |
|
764 |
log('Exiting with code {}'.format(ret)) |
|
765 |
except Exception: |
|
766 |
log('Failed with an exception:') |
|
767 |
log(traceback.format_exc()) |
|
768 |
return 1 |
|
769 |
||
770 |
if __name__ == '__main__': |
|
771 |
sys.exit(main()) |