Merge lp:~mterry/unity8/systemd into lp:unity8

Proposed by Michael Terry
Status: Work in progress
Proposed branch: lp:~mterry/unity8/systemd
Merge into: lp:unity8
Diff against target: 432 lines (+98/-150)
17 files modified
data/unity8-dash.conf (+0/-25)
data/unity8-dash.service (+15/-0)
data/unity8-filewatcher.conf (+0/-13)
data/unity8-session (+46/-0)
data/unity8.conf (+0/-82)
data/unity8.service (+15/-0)
debian/control (+4/-1)
debian/rules (+1/-1)
debian/unity8.install (+3/-3)
plugins/Unity/Launcher/dbusinterface.cpp (+2/-0)
plugins/Unity/Session/dbusunitysessionservice.cpp (+5/-11)
tests/plugins/Unity/Session/CMakeLists.txt (+1/-0)
tests/plugins/Unity/Session/LogindServer.cpp (+0/-5)
tests/plugins/Unity/Session/LogindServer.h (+0/-1)
tests/plugins/Unity/Session/interfaces.xml (+0/-4)
tests/plugins/Unity/Session/server.cpp (+1/-1)
tests/plugins/Unity/Session/sessionbackendtest.cpp (+5/-3)
To merge this branch: bzr merge lp:~mterry/unity8/systemd
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+321557@code.launchpad.net

Commit message

WIP

To post a comment you must log in.
lp:~mterry/unity8/systemd updated
2894. By Michael Terry

Fix up some packaging bits

2895. By Michael Terry

Add missing service file

Unmerged revisions

2895. By Michael Terry

Add missing service file

2894. By Michael Terry

Fix up some packaging bits

2893. By Michael Terry

Fix trapping of STOP

2892. By Michael Terry

First (unfinished) pass at systemd unit for unity8

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file 'data/unity8-dash.conf'
2--- data/unity8-dash.conf 2016-10-07 17:22:21 +0000
3+++ data/unity8-dash.conf 1970-01-01 00:00:00 +0000
4@@ -1,25 +0,0 @@
5-description "Unity Shell v8 Dash"
6-author "Michael Zanetti <michael.zanetti@canonical.com>"
7-
8-emits scope-ui-starting
9-
10-start on started unity8
11-stop on stopping unity8
12-
13-kill timeout 120
14-
15-# Focused app is 100 so we want to be less likely to get
16-# killed than the focused app but more than Unity8
17-
18-oom score 50
19-
20-respawn
21-respawn limit unlimited
22-
23-env APP_ID=unity8-dash
24-
25-pre-start script
26- initctl emit scope-ui-starting
27-end script
28-
29-exec ${BINARY:-unity8-dash} $ARGS --desktop_file_hint=unity8-dash.desktop
30
31=== added file 'data/unity8-dash.service'
32--- data/unity8-dash.service 1970-01-01 00:00:00 +0000
33+++ data/unity8-dash.service 2017-04-03 17:54:55 +0000
34@@ -0,0 +1,15 @@
35+[Unit]
36+Description=Unity Shell v8 Dash
37+PartOf=graphical-session.target
38+BindsTo=unity8.service
39+After=unity8.service
40+
41+[Service]
42+ExecStart=/usr/bin/unity8-dash --desktop_file_hint=unity8-dash
43+Restart=always
44+TimeoutStartSec=120
45+Environment=APP_ID=unity8-dash
46+
47+# Focused app is 100 so we want to be less likely to get
48+# killed than the focused app but more than Unity8
49+OOMScoreAdjust=50
50
51=== removed file 'data/unity8-filewatcher.conf'
52--- data/unity8-filewatcher.conf 2016-10-07 17:22:21 +0000
53+++ data/unity8-filewatcher.conf 1970-01-01 00:00:00 +0000
54@@ -1,13 +0,0 @@
55-description "File system watcher for unity8"
56-author "Michael Zanetti <michael.zanetti@canonical.com>"
57-
58-# This method of updating the launcher will not work in our new snappy world,
59-# neither for snaps installed in the system nor if we are running inside a snap.
60-# Plus it hardcodes the phablet user... To be replaced once bug 1630997 is
61-# fixed in ubuntu-app-launch.
62-
63-# Workaround for bug 1360208. ~ and * in one expression doesn't work currently
64-start on (file FILE=/home/phablet/.local/share/applications/*.desktop) or (file FILE=/usr/share/applications/*.desktop)
65-
66-exec dbus-send --type=method_call --dest=com.canonical.Unity.Launcher /com/canonical/Unity/Launcher com.canonical.Unity.Launcher.Refresh
67-
68
69=== added file 'data/unity8-session'
70--- data/unity8-session 1970-01-01 00:00:00 +0000
71+++ data/unity8-session 2017-04-03 17:54:55 +0000
72@@ -0,0 +1,46 @@
73+#!/bin/sh
74+# -*- Mode: sh; indent-tabs-mode: nil; tab-width: 2 -*-
75+
76+# Ensure the shell always gets unthrottled touch events, so that applications
77+# who want full speed low-latency input can get it (LP: #1497105) and so that
78+# apps can use QML touch compression safely (the QML touch compression
79+# algorithm does not support nesting well - LP: #1486341, LP: #1556763 - so
80+# must be fed by the raw input event stream from Unity8).
81+export QML_NO_TOUCH_COMPRESSION=1
82+
83+export MIR_SERVER_PROMPT_FILE=1
84+
85+# Hard code socket path because our snappy apparmor profile
86+# only lets us put the socket in one place. And consumers expect it there.
87+# (XDG_RUNTIME_DIR isn't typical under snappy)
88+export MIR_SERVER_FILE=/run/user/$(id -u)/mir_socket
89+
90+rm -f "$MIR_SERVER_FILE"
91+rm -f "${MIR_SERVER_FILE}_trusted"
92+
93+if [ "$XDG_SESSION_DESKTOP" = "ubuntu-touch" ]; then
94+ # On Ubuntu Touch, we currently use a trick where we auto-login the
95+ # user without a LightDM greeter at all. In this case, we want to
96+ # start with the lockscreen visible. Once we switch to using a
97+ # proper greeter for the first login, we can remove this code path.
98+ MODE=full-greeter
99+else
100+ MODE=full-shell
101+fi
102+
103+dbus-update-activation-environment --systemd MIR_SOCKET=$MIR_SERVER_FILE
104+
105+# Tell unity-mir to raise SIGSTOP after we start, which we use to tell
106+# systemd when we are done starting up.
107+export UNITY_MIR_EMITS_SIGSTOP=1
108+
109+${BINARY:-unity8} --mode=$MODE "$@" &
110+child=$!
111+
112+# Wait for SIGSTOP in child
113+while [ $(ps --no-headers -o state $child) != "T" ]; do
114+ sleep 0.1
115+done
116+
117+kill -CONT $child
118+exit 0
119
120=== removed file 'data/unity8.conf'
121--- data/unity8.conf 2017-02-08 15:46:18 +0000
122+++ data/unity8.conf 1970-01-01 00:00:00 +0000
123@@ -1,82 +0,0 @@
124-description "Unity Shell v8"
125-author "Ricardo Mendoza <ricmm@ubuntu.com>"
126-
127-emits indicator-services-start
128-
129-start on ((xsession SESSION=ubuntu-touch) or (xsession SESSION=unity8-mir) or (xsession SESSION=unity8)) and started dbus
130-stop on desktop-end
131-
132-kill timeout 120
133-
134-#
135-# Ensure the shell always gets unthrottled touch events, so that applications
136-# who want full speed low-latency input can get it (LP: #1497105) and so that
137-# apps can use QML touch compression safely (the QML touch compression
138-# algorithm does not support nesting well - LP: #1486341, LP: #1556763 - so
139-# must be fed by the raw input event stream from Unity8).
140-#
141-env QML_NO_TOUCH_COMPRESSION=1
142-
143-respawn
144-expect stop
145-
146-# FIXME Create an autopilot test that makes sure start+stop and restart
147-# work fine at least 2 times
148-
149-pre-start script
150- # Tell unity-mir to raise SIGSTOP after we start
151- initctl set-env UNITY_MIR_EMITS_SIGSTOP=1
152-
153- # Save original value of MIR_SOCKET so that we can restore it when stopped,
154- # as we modify the variable for future jobs, including ourself.
155- initctl set-env UNITY_MIR_SOCKET=$MIR_SOCKET
156-
157- # Decide where we are going to put our own socket file
158- if [ -n "$SNAP" ]; then
159- # In snappy, we want to hard code our path because our apparmor profile
160- # only lets us put the socket in one place. And consumers expect it
161- # there.
162- MIR_SERVER_FILE=/run/user/$(id -u)/mir_socket
163- else
164- MIR_SERVER_FILE=$XDG_RUNTIME_DIR/mir_socket
165- fi
166- initctl set-env MIR_SERVER_FILE=$MIR_SERVER_FILE
167-
168- # Point all future jobs in this session to our Mir socket instead of
169- # unity-system-compositor's socket.
170- initctl set-env --global MIR_SOCKET=$MIR_SERVER_FILE
171- gdbus call --session --dest org.freedesktop.DBus --object-path /org/freedesktop/DBus --method org.freedesktop.DBus.UpdateActivationEnvironment "@a{ss} {'MIR_SOCKET': '$MIR_SERVER_FILE'}"
172-
173- # Remove the normal and trusted sockets if still there
174- if [ -S "$MIR_SERVER_FILE" ]; then
175- rm "$MIR_SERVER_FILE"
176- fi
177-
178- if [ -S "${MIR_SERVER_FILE}_trusted" ]; then
179- rm "${MIR_SERVER_FILE}_trusted"
180- fi
181-
182- initctl set-env --global MIR_SERVER_PROMPT_FILE=1
183-
184- if [ "$XDG_SESSION_DESKTOP" = "ubuntu-touch" ]; then
185- # On Ubuntu Touch, we currently use a trick where we auto-login the
186- # user without a LightDM greeter at all. In this case, we want to
187- # start with the lockscreen visible. Once we switch to using a
188- # proper greeter for the first login, we can remove this code path.
189- initctl set-env MODE=full-greeter
190- else
191- initctl set-env MODE=full-shell
192- fi
193-end script
194-
195-exec ${BINARY:-unity8} --mode=$MODE $ARGS
196-
197-post-start script
198- initctl emit --no-wait indicator-services-start
199-end script
200-
201-post-stop script
202- initctl set-env --global MIR_SOCKET=$UNITY_MIR_SOCKET
203- initctl unset-env --global MIR_SERVER_PROMPT_FILE
204- initctl emit application-end
205-end script
206
207=== added file 'data/unity8.service'
208--- data/unity8.service 1970-01-01 00:00:00 +0000
209+++ data/unity8.service 2017-04-03 17:54:55 +0000
210@@ -0,0 +1,15 @@
211+[Unit]
212+Description=Unity Shell v8
213+PartOf=graphical-session.target
214+Requires=dbus.socket
215+After=dbus.socket
216+Before=indicators.target
217+Wants=unity8-dash.service
218+Wants=indicators.target
219+
220+[Service]
221+Type=forking
222+ExecStart=/usr/bin/unity8-session
223+ExecStopPost=/usr/bin/dbus-update-activation-environment --systemd MIR_SOCKET=
224+Restart=on-failure
225+TimeoutStartSec=120
226
227=== modified file 'debian/control'
228--- debian/control 2017-03-20 10:19:11 +0000
229+++ debian/control 2017-04-03 17:54:55 +0000
230@@ -6,6 +6,7 @@
231 dbus-test-runner,
232 debhelper (>= 9),
233 dh-apparmor,
234+ dh-systemd,
235 doxyqml,
236 # To allow cross-compiling to work, we also must append :native
237 # to g++ so we don't try to run arm g++
238@@ -71,6 +72,7 @@
239 qtdeclarative5-private-dev (>= 5.6),
240 qtdeclarative5-ubuntu-content1,
241 qtdeclarative5-ubuntu-settings-components (>= 0.11),
242+ systemd,
243 ttf-ubuntu-font-family,
244 xvfb,
245 Standards-Version: 3.9.4
246@@ -120,7 +122,8 @@
247 Package: unity8
248 Architecture: any
249 Provides: indicator-renderer,
250-Depends: dmz-cursor-theme,
251+Depends: dbus,
252+ dmz-cursor-theme,
253 gsettings-desktop-schemas,
254 libcap2-bin,
255 libglib2.0-bin,
256
257=== modified file 'debian/rules'
258--- debian/rules 2017-01-18 00:25:13 +0000
259+++ debian/rules 2017-04-03 17:54:55 +0000
260@@ -9,7 +9,7 @@
261 export NO_PNG_PKG_MANGLE=1
262
263 %:
264- dh $@ --parallel --fail-missing --with python3
265+ dh $@ --parallel --fail-missing --with python3,systemd
266
267 override_dh_auto_configure:
268 # Debian defines CMAKE_INSTALL_LOCALSTATEDIR as /usr/var, which is wrong.
269
270=== modified file 'debian/unity8.install'
271--- debian/unity8.install 2016-10-04 16:21:38 +0000
272+++ debian/unity8.install 2017-04-03 17:54:55 +0000
273@@ -1,8 +1,8 @@
274 debian/usr.bin.unity8-dash etc/apparmor.d
275 var/lib/unity8/version
276-data/unity8-dash.conf usr/share/upstart/sessions/
277-data/unity8-filewatcher.conf usr/share/upstart/sessions/
278-data/unity8.conf usr/share/upstart/sessions/
279+data/unity8.service usr/lib/systemd/user
280+data/unity8-dash.service usr/lib/systemd/user
281+data/unity8-session usr/bin
282 data/devices.conf etc/ubuntu/
283 usr/bin/unity8
284 usr/bin/unity8-dash
285
286=== modified file 'plugins/Unity/Launcher/dbusinterface.cpp'
287--- plugins/Unity/Launcher/dbusinterface.cpp 2015-11-20 15:01:39 +0000
288+++ plugins/Unity/Launcher/dbusinterface.cpp 2017-04-03 17:54:55 +0000
289@@ -39,6 +39,8 @@
290 QString nodes;
291
292 // Add Refresh to introspect
293+ // TODO: Confirm this is still used anywhere and remove if not.
294+ // It used to be used in an upstart job when desktop fles changed.
295 nodes = QStringLiteral("<interface name=\"com.canonical.Unity.Launcher\">"
296 "<method name=\"Refresh\"/>"
297 "</interface>");
298
299=== modified file 'plugins/Unity/Session/dbusunitysessionservice.cpp'
300--- plugins/Unity/Session/dbusunitysessionservice.cpp 2017-03-21 10:51:38 +0000
301+++ plugins/Unity/Session/dbusunitysessionservice.cpp 2017-04-03 17:54:55 +0000
302@@ -36,6 +36,7 @@
303
304 #define LOGIN1_SERVICE QStringLiteral("org.freedesktop.login1")
305 #define LOGIN1_PATH QStringLiteral("/org/freedesktop/login1")
306+#define LOGIN1_SESSION_ROOT QStringLiteral("/org/freedesktop/login1/session/")
307 #define LOGIN1_IFACE QStringLiteral("org.freedesktop.login1.Manager")
308 #define LOGIN1_SESSION_IFACE QStringLiteral("org.freedesktop.login1.Session")
309
310@@ -58,16 +59,9 @@
311
312 void init()
313 {
314- // get our logind session path
315- QDBusMessage msg = QDBusMessage::createMethodCall(LOGIN1_SERVICE,
316- LOGIN1_PATH,
317- LOGIN1_IFACE,
318- QStringLiteral("GetSessionByPID"));
319- msg << (quint32) getpid();
320-
321- QDBusReply<QDBusObjectPath> reply = QDBusConnection::SM_BUSNAME().call(msg);
322- if (reply.isValid()) {
323- logindSessionPath = reply.value().path();
324+ QString sessionID = QString::fromLocal8Bit(qgetenv("XDG_SESSION_ID"));
325+ if (!sessionID.isEmpty()) {
326+ logindSessionPath = LOGIN1_SESSION_ROOT + sessionID;
327
328 // start watching the Active property
329 QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, logindSessionPath, QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("PropertiesChanged"),
330@@ -79,7 +73,7 @@
331 QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, LOGIN1_PATH, LOGIN1_IFACE, QStringLiteral("PrepareForSleep"),
332 this, SLOT(onResuming(bool)));
333 } else {
334- qWarning() << "Failed to get logind session path" << reply.error().message();
335+ qWarning() << "Failed to get logind session: XDG_SESSION_ID is not set";
336 }
337 }
338
339
340=== modified file 'tests/plugins/Unity/Session/CMakeLists.txt'
341--- tests/plugins/Unity/Session/CMakeLists.txt 2017-03-14 18:51:23 +0000
342+++ tests/plugins/Unity/Session/CMakeLists.txt 2017-04-03 17:54:55 +0000
343@@ -60,6 +60,7 @@
344
345 add_unity8_unittest(SessionBackend dbus-test-runner
346 ENVIRONMENT LD_PRELOAD=$<TARGET_FILE:SessionBackendTestPreload>
347+ XDG_SESSION_ID=testing
348 XDG_SESSION_PATH=/session
349 ARG_PREFIX "--parameter"
350 ARGS
351
352=== modified file 'tests/plugins/Unity/Session/LogindServer.cpp'
353--- tests/plugins/Unity/Session/LogindServer.cpp 2017-03-15 21:31:32 +0000
354+++ tests/plugins/Unity/Session/LogindServer.cpp 2017-04-03 17:54:55 +0000
355@@ -22,11 +22,6 @@
356 {
357 }
358
359-QDBusObjectPath LogindServer::GetSessionByPID(quint32)
360-{
361- return QDBusObjectPath("/logindsession");
362-}
363-
364 void LogindServer::Reboot(bool interactive)
365 {
366 Q_EMIT RebootCalled(interactive);
367
368=== modified file 'tests/plugins/Unity/Session/LogindServer.h'
369--- tests/plugins/Unity/Session/LogindServer.h 2017-03-15 21:31:32 +0000
370+++ tests/plugins/Unity/Session/LogindServer.h 2017-04-03 17:54:55 +0000
371@@ -30,7 +30,6 @@
372 explicit LogindServer(QObject *parent = nullptr);
373
374 public Q_SLOTS:
375- QDBusObjectPath GetSessionByPID(quint32 pid);
376 void Reboot(bool interactive);
377 void PowerOff(bool interactive);
378
379
380=== modified file 'tests/plugins/Unity/Session/interfaces.xml'
381--- tests/plugins/Unity/Session/interfaces.xml 2017-03-15 21:31:32 +0000
382+++ tests/plugins/Unity/Session/interfaces.xml 2017-04-03 17:54:55 +0000
383@@ -3,10 +3,6 @@
384 <method name="Lock" />
385 </interface>
386 <interface name="org.freedesktop.login1.Manager">
387- <method name="GetSessionByPID">
388- <arg name="pid" type="u" direction="in" />
389- <arg name="session" type="o" direction="out" />
390- </method>
391 <method name="Reboot">
392 <arg name="interactive" type="b" direction="in" />
393 </method>
394
395=== modified file 'tests/plugins/Unity/Session/server.cpp'
396--- tests/plugins/Unity/Session/server.cpp 2016-06-21 14:23:49 +0000
397+++ tests/plugins/Unity/Session/server.cpp 2017-04-03 17:54:55 +0000
398@@ -37,7 +37,7 @@
399 auto connection = QDBusConnection::sessionBus();
400 if (!connection.registerObject("/org/freedesktop/login1", logind))
401 return 1;
402- if (!connection.registerObject("/logindsession", logind))
403+ if (!connection.registerObject("/org/freedesktop/login1/session/testing", logind))
404 return 1;
405 if (!connection.registerService("org.freedesktop.login1"))
406 return 1;
407
408=== modified file 'tests/plugins/Unity/Session/sessionbackendtest.cpp'
409--- tests/plugins/Unity/Session/sessionbackendtest.cpp 2017-03-21 10:51:38 +0000
410+++ tests/plugins/Unity/Session/sessionbackendtest.cpp 2017-04-03 17:54:55 +0000
411@@ -103,8 +103,8 @@
412 QCoreApplication::processEvents(); // to let the services register on DBus
413
414 QDBusInterface login1Interface("org.freedesktop.login1",
415- "/logindsession",
416- "org.freedesktop.login1.Manager");
417+ "/org/freedesktop/login1/session/testing",
418+ "org.freedesktop.login1.Manager");
419 QSignalSpy spy(&login1Interface, signal.toUtf8().data());
420
421 QDBusInterface dbusGnomeSessionWrapper("org.gnome.SessionManager",
422@@ -225,7 +225,9 @@
423 DBusUnitySessionService dbusUnitySessionService;
424 QCoreApplication::processEvents(); // to let the service register on DBus
425
426- QDBusInterface iface("org.freedesktop.login1", "/logindsession", "org.freedesktop.login1.Session");
427+ QDBusInterface iface("org.freedesktop.login1",
428+ "/org/freedesktop/login1/session/testing",
429+ "org.freedesktop.login1.Session");
430 QVERIFY(iface.isValid());
431
432 QSignalSpy spy(&dbusUnitySessionService, SIGNAL(Unlocked()));

Subscribers

People subscribed via source and target branches