[gnome-initial-setup/wip/benzea/systemd-user] Add systemd user instance support



commit bf965a668781763583914c37acf81473dcb3ac30
Author: Benjamin Berg <bberg redhat com>
Date:   Tue Apr 23 14:31:26 2019 +0200

    Add systemd user instance support
    
    This ports GNOME initial setup to start all services using the systemd
    user instance rather than relying on the gnome-session internal
    management.

 data/gnome-initial-setup-copy-worker.desktop.in.in |  1 +
 data/gnome-initial-setup-copy-worker.service.in    | 15 +++++++++++
 data/gnome-initial-setup-first-login.desktop.in.in |  1 +
 data/gnome-initial-setup-first-login.service.in    | 16 ++++++++++++
 data/gnome-initial-setup.service.in                | 16 ++++++++++++
 data/gnome-welcome-tour.desktop.in.in              |  1 +
 data/gnome-welcome-tour.service.in                 | 15 +++++++++++
 data/meson.build                                   | 29 +++++++++++++++++++++-
 meson.build                                        | 12 +++++++++
 meson_options.txt                                  |  6 +++++
 10 files changed, 111 insertions(+), 1 deletion(-)
---
diff --git a/data/gnome-initial-setup-copy-worker.desktop.in.in 
b/data/gnome-initial-setup-copy-worker.desktop.in.in
index d1ebb66..8f259f9 100644
--- a/data/gnome-initial-setup-copy-worker.desktop.in.in
+++ b/data/gnome-initial-setup-copy-worker.desktop.in.in
@@ -7,3 +7,4 @@ NoDisplay=true
 X-GNOME-AutoRestart=false
 X-GNOME-Autostart-Phase=EarlyInitialization
 AutostartCondition=unless-exists gnome-initial-setup-done
+@systemd_hidden@
diff --git a/data/gnome-initial-setup-copy-worker.service.in b/data/gnome-initial-setup-copy-worker.service.in
new file mode 100644
index 0000000..df43c39
--- /dev/null
+++ b/data/gnome-initial-setup-copy-worker.service.in
@@ -0,0 +1,15 @@
+[Unit]
+Description=GNOME Initial Setup Copy Worker
+
+# Make sure we run really early
+Before=gnome-session-pre.target graphical-session-pre.target
+
+ConditionPathExists=!%E/gnome-initial-setup-done
+
+[Service]
+Type=simple
+ExecStart=@libexecdir@/gnome-initial-setup-copy-worker
+Restart=no
+
+[Install]
+WantedBy=gnome-session.target
diff --git a/data/gnome-initial-setup-first-login.desktop.in.in 
b/data/gnome-initial-setup-first-login.desktop.in.in
index 8445e03..a244d5b 100644
--- a/data/gnome-initial-setup-first-login.desktop.in.in
+++ b/data/gnome-initial-setup-first-login.desktop.in.in
@@ -14,3 +14,4 @@ X-GNOME-Bugzilla-Bugzilla=GNOME
 X-GNOME-Bugzilla-Product=gnome-initial-setup
 X-GNOME-Bugzilla-Component=general
 X-GNOME-Bugzilla-Version=unknown
+@systemd_hidden@
diff --git a/data/gnome-initial-setup-first-login.service.in b/data/gnome-initial-setup-first-login.service.in
new file mode 100644
index 0000000..74067e8
--- /dev/null
+++ b/data/gnome-initial-setup-first-login.service.in
@@ -0,0 +1,16 @@
+[Unit]
+Description=GNOME Initial Setup
+
+BindsTo=gnome-session.target
+After=gnome-session.target
+
+Conflicts=gnome-session@gnome-initial-setup.target
+ConditionPathExists=!%E/gnome-initial-setup-done
+
+[Service]
+Type=simple
+ExecStart=@libexecdir@/gnome-initial-setup --existing-user
+Restart=no
+
+[Install]
+WantedBy=gnome-session.target
diff --git a/data/gnome-initial-setup.service.in b/data/gnome-initial-setup.service.in
new file mode 100644
index 0000000..ea91d69
--- /dev/null
+++ b/data/gnome-initial-setup.service.in
@@ -0,0 +1,16 @@
+[Unit]
+Description=GNOME Initial Setup
+RefuseManualStart=true
+RefuseManualStop=true
+
+BindsTo=gnome-session.target
+After=gnome-session.target
+
+[Service]
+Type=simple
+ExecStart=@libexecdir@/gnome-initial-setup
+ExecStopPost=-@libexecdir@/gnome-session-ctl --shutdown
+Restart=no
+
+[Install]
+WantedBy=gnome-session@gnome-initial-setup.target
diff --git a/data/gnome-welcome-tour.desktop.in.in b/data/gnome-welcome-tour.desktop.in.in
index 22e4536..47bc48a 100644
--- a/data/gnome-welcome-tour.desktop.in.in
+++ b/data/gnome-welcome-tour.desktop.in.in
@@ -5,3 +5,4 @@ Exec=@LIBEXECDIR@/gnome-welcome-tour
 AutostartCondition=if-exists run-welcome-tour
 OnlyShowIn=GNOME;
 NoDisplay=true
+@systemd_hidden@
diff --git a/data/gnome-welcome-tour.service.in b/data/gnome-welcome-tour.service.in
new file mode 100644
index 0000000..2315540
--- /dev/null
+++ b/data/gnome-welcome-tour.service.in
@@ -0,0 +1,15 @@
+[Unit]
+Description=GNOME Welcome Tour
+
+BindsTo=gnome-session.target
+After=gnome-session.target
+
+ConditionPathExists=%E/run-welcome-tour
+
+[Service]
+Type=simple
+ExecStart=@libexecdir@/gnome-welcome-tour
+Restart=no
+
+[Install]
+WantedBy=gnome-session.target
diff --git a/data/meson.build b/data/meson.build
index 817d8ef..aa7c245 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -5,7 +5,12 @@ autostart_files = [
 ]
 
 desktop_conf = configuration_data()
-desktop_conf.set('LIBEXECDIR', join_paths(prefix, get_option('libexecdir')))
+desktop_conf.set('LIBEXECDIR', libexec_dir)
+if enable_systemd
+  desktop_conf.set('systemd_hidden', 'X-GNOME-Autostart-systemd=true')
+else
+  desktop_conf.set('systemd_hidden', )
+endif
 
 foreach desktop_file: autostart_files
     i18n.merge_file(
@@ -37,6 +42,28 @@ i18n.merge_file(
     type: 'desktop'
 )
 
+if enable_systemd
+    unitconf = configuration_data()
+    unitconf.set('libexecdir', libexec_dir)
+
+    unit_files = [
+        'gnome-initial-setup.service',
+        'gnome-initial-setup-first-login.service',
+        'gnome-initial-setup-copy-worker.service',
+        'gnome-welcome-tour.service'
+    ]
+
+    foreach unit: unit_files
+        configure_file(
+            input: unit + '.in',
+            output: unit,
+            configuration: unitconf,
+            install_dir: systemd_userunitdir
+        )
+    endforeach
+endif
+
+
 rules_dir = join_paths(data_dir, 'polkit-1', 'rules.d')
 install_data('20-gnome-initial-setup.rules', install_dir: rules_dir)
 
diff --git a/meson.build b/meson.build
index 7b41505..e9be6d9 100644
--- a/meson.build
+++ b/meson.build
@@ -30,6 +30,18 @@ conf.set_quoted('PKGDATADIR', pkgdata_dir)
 conf.set('ENABLE_REGION_PAGE', get_option('region-page'))
 conf.set('SECRET_API_SUBJECT_TO_CHANGE', true)
 
+enable_systemd = get_option('systemd')
+if enable_systemd
+    systemd_dep = dependency('systemd', required: false)
+    assert(systemd_dep.found(), 'Systemd support explicitly required, but systemd not found')
+
+    # XXX: Once https://github.com/systemd/systemd/issues/9595 is fixed and we can
+    # depend on this version, replace with something like:
+    #  systemduserunitdir = systemd_dep.get_pkgconfig_variable('systemduserunitdir')
+    # and uncomment systemd_dep below
+    systemd_userunitdir = join_paths(prefix, 'lib', 'systemd', 'user')
+endif
+
 # Needed for the 'account' page
 cheese_dep = dependency ('cheese',
                          version: '>= 3.3.5',
diff --git a/meson_options.txt b/meson_options.txt
index 7502725..fc01864 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -26,3 +26,9 @@ option('ibus',
        type: 'feature',
        value: 'auto'
 )
+
+option('systemd',
+  type: 'boolean',
+  value: true,
+  description: 'Enable systemd integration'
+)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]