[pkg-fso-commits] [nodm] 01/02: Add systemd support, via NMU to unstable (debian/0.12-1.1).

Mike Gabriel sunweaver at debian.org
Mon Jan 23 16:26:52 UTC 2017


This is an automated email from the git hooks/post-receive script.

sunweaver pushed a commit to branch master
in repository nodm.

commit 590ea3ae82d120d35d166d8ab53e3d45abd7dfe4
Author: Simon McVittie <smcv at debian.org>
Date:   Mon Jan 23 13:12:41 2017 +0100

    Add systemd support, via NMU to unstable (debian/0.12-1.1).
    
    Conflicts (resolved by Mike Gabriel):
    	debian/changelog
---
 Makefile.am           | 13 +++++++-
 debian/changelog      |  8 +++++
 debian/copyright      | 15 ++++++++++
 debian/nodm.config    | 36 ++++++++++++++++++++++
 debian/nodm.init      |  2 +-
 debian/nodm.postinst  | 41 ++++++++++++++++++++++++-
 debian/nodm.prerm     | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++
 debian/nodm.templates | 20 +++++++++++++
 debian/rules          |  5 ++++
 nodm.service.in       | 10 +++++++
 10 files changed, 230 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 28709f9..299020f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -64,9 +64,12 @@ test_internals_SOURCES = $(testlibsources)	\
 EXTRA_DIST = test_nodm		\
              nodm-man-extras	\
              autogen.sh		\
+             nodm.service.in	\
              $(NULL)
 
-CLEANFILES = nodm.8
+CLEANFILES = $(man_MANS) \
+             $(systemdsystemunit_DATA) \
+             $(NULL)
 
 DISTCLEANFILES = Makefile.in   \
                  aclocal.m4    \
@@ -74,3 +77,11 @@ DISTCLEANFILES = Makefile.in   \
                  config/*      \
                  configure     \
                  $(NULL)
+
+systemdsystemunitdir = $(prefix)/lib/systemd/system
+systemdsystemunit_DATA = nodm.service
+
+nodm.service: nodm.service.in
+	sed \
+		-e 's![@]sbindir[@]!${sbindir}!g' \
+		< $< > $@
diff --git a/debian/changelog b/debian/changelog
index 656f9b8..04d139b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,6 +12,14 @@ nodm (0.12-2) UNRELEASED; urgency=medium
 
  -- Mike Gabriel <sunweaver at debian.org>  Thu, 24 Mar 2016 14:43:36 +0100
 
+nodm (0.12-1.1) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Apply patches from Simon McVittie to add a native systemd service
+    file (Closes: #796203).
+
+ -- Arto Jantunen <viiru at debian.org>  Wed, 18 Jan 2017 17:29:22 +0200
+
 nodm (0.12-1) unstable; urgency=low
 
   [ Enrico Zini ]
diff --git a/debian/copyright b/debian/copyright
index c3be889..577d7d8 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -63,6 +63,17 @@ Copyright: 2008, Joachim Breitner <nomeata at debian.org>
            2016, Mike Gabriel <sunweaver at debian.org>
 License: GPL-2+
 
+Files:
+ debian/nodm.config
+ debian/nodm.postinst
+ debian/nodm.prerm
+Copyright:
+ 2000-2001, Branden Robinson
+ 2008, Joachim Breitner <nomeata at debian.org>
+ 2009-2011, Enrico Zini <enrico at debian.org>
+ 2016, Mike Gabriel <sunweaver at debian.org>
+License: GPL-2
+
 License: GPL-2+
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
@@ -81,3 +92,7 @@ License: GPL-2+
  On Debian systems, the full text of the GNU General Public
  License version 2 can be found in the file
  `/usr/share/common-licenses/GPL-2'.
+
+License: GPL-2
+ Licensed under the GNU General Public License, version 2.  See the file
+ /usr/share/common-licenses/GPL-2 or <http://www.gnu.org/copyleft/gpl.txt>.
diff --git a/debian/nodm.config b/debian/nodm.config
index 68fc680..40af76b 100644
--- a/debian/nodm.config
+++ b/debian/nodm.config
@@ -1,9 +1,45 @@
 #!/bin/sh
 
+# Partially based on gdm3.config, © 2000-2001 Branden Robinson.
+# Licensed under the GNU General Public License, version 2.  See the file
+# /usr/share/common-licenses/GPL-2 or <http://www.gnu.org/copyleft/gpl.txt>.
+
+
 set -e
 
 . /usr/share/debconf/confmodule
 
+THIS_PACKAGE=nodm
+DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager
+
+# set default display manager
+
+db_get shared/default-x-display-manager
+OLD_DEFAULT="$RET"
+
+db_metaget shared/default-x-display-manager owners
+OWNERS="$RET"
+db_metaget shared/default-x-display-manager choices
+CHOICES="$RET"
+
+if [ "$OWNERS" != "$CHOICES" ]; then
+  db_subst shared/default-x-display-manager choices $OWNERS
+  db_fset shared/default-x-display-manager seen false
+fi
+
+db_input high shared/default-x-display-manager || true
+db_go
+
+# using this display manager?
+db_get shared/default-x-display-manager
+CURRENT_DEFAULT="$RET"
+# set a flag to indicate to postinst that we need to update from debconf
+if [ "$OLD_DEFAULT" != "$CURRENT_DEFAULT" ]; then
+  DEFAULT_DISPLAY_MANAGER_DIR=$(dirname $DEFAULT_DISPLAY_MANAGER_FILE)
+  test -e $DEFAULT_DISPLAY_MANAGER_DIR || mkdir -p $DEFAULT_DISPLAY_MANAGER_DIR
+  touch $DEFAULT_DISPLAY_MANAGER_FILE.debconf-update
+fi
+
 if [ -s /etc/default/nodm ] ; then
 	. /etc/default/nodm
 
diff --git a/debian/nodm.init b/debian/nodm.init
index 48cc28a..6ab9738 100644
--- a/debian/nodm.init
+++ b/debian/nodm.init
@@ -1,7 +1,7 @@
 #!/bin/sh
 ### BEGIN INIT INFO
 # Provides:       nodm
-# Should-Start:   console-screen kbd hal bluetooth
+# Should-Start:   bluetooth
 # Required-Start: $remote_fs
 # Required-Stop:
 # Default-Start:  2 3 4 5
diff --git a/debian/nodm.postinst b/debian/nodm.postinst
index b209bce..9216c13 100644
--- a/debian/nodm.postinst
+++ b/debian/nodm.postinst
@@ -1,10 +1,49 @@
 #! /bin/sh
-# postinst script for nodm
+# postinst script for nodm, partially based on gdm3.postinst
 
 set -e
 
+THIS_PACKAGE=nodm
+DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager
+
 . /usr/share/debconf/confmodule
 
+# debconf is not a registry, so we only fiddle with the default file if
+# the configure script requested an update
+if [ -e $DEFAULT_DISPLAY_MANAGER_FILE.debconf-update ]; then
+  rm -f $DEFAULT_DISPLAY_MANAGER_FILE.debconf-update
+  if db_get shared/default-x-display-manager; then
+    # workaround debconf passthru bug (#379198)
+    if [ -z "$RET" ]; then
+      RET="$THIS_PACKAGE"
+    fi
+    if [ "$THIS_PACKAGE" != "$RET" ]; then
+      echo "Please be sure to run \"dpkg --configure $RET\"."
+    fi
+    if db_get "$RET"/daemon_name; then
+      echo "$RET" > $DEFAULT_DISPLAY_MANAGER_FILE
+    fi
+  fi
+fi
+
+DEFAULT_SERVICE=/etc/systemd/system/display-manager.service
+# set default-display-manager systemd service link according to our config
+if [ "$1" = configure ] && [ -d /etc/systemd/system/ ]; then
+  if [ -e "$DEFAULT_DISPLAY_MANAGER_FILE" ]; then
+    SERVICE=/lib/systemd/system/$(basename $(cat "$DEFAULT_DISPLAY_MANAGER_FILE")).service
+    if [ -h "$DEFAULT_SERVICE" ] && [ $(readlink "$DEFAULT_SERVICE") = /dev/null ]; then
+      echo "Display manager service is masked" >&2
+    elif [ -e "$SERVICE" ]; then
+      ln -sf "$SERVICE" "$DEFAULT_SERVICE"
+    else
+      echo "WARNING: $SERVICE is the selected default display manager but does not exist" >&2
+      rm -f "$DEFAULT_SERVICE"
+    fi
+  else
+    rm -f "$DEFAULT_SERVICE"
+  fi
+fi
+
 if [ "$1" = "configure" ] ; then
 	if [ -n "$2" ] && dpkg --compare-versions "$2" lt "0.2"; then
 		# Before version 0.2, nodm was only used on the OpenMoko.  To
diff --git a/debian/nodm.prerm b/debian/nodm.prerm
new file mode 100644
index 0000000..f9aa470
--- /dev/null
+++ b/debian/nodm.prerm
@@ -0,0 +1,83 @@
+#!/bin/bash
+# Debian nodm package pre-removal script
+#
+# Based on gdm3.prerm:
+# © 2001 Branden Robinson
+#
+# Licensed under the GNU General Public License, version 2.  See the file
+# /usr/share/common-licenses/GPL-2 or <http://www.gnu.org/copyleft/gpl.txt>.
+# Acknowlegements to Stephen Early, Mark Eichin, and Manoj Srivastava.
+
+set -e
+
+THIS_PACKAGE=nodm
+DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager
+
+if [ "$1" = "remove" -o "$1" = "deconfigure" ]; then
+  if [ -e /usr/share/debconf/confmodule ]; then
+    . /usr/share/debconf/confmodule
+    # disown this question
+    db_unregister shared/default-x-display-manager || true
+    # does the question still exist?
+    if db_get shared/default-x-display-manager; then
+      db_metaget shared/default-x-display-manager owners
+      db_subst shared/default-x-display-manager choices "$RET"
+      db_get shared/default-x-display-manager
+      # are we removing the currently selected display manager?
+      if [ "$THIS_PACKAGE" = "$RET" ]; then
+        if [ -e "$DEFAULT_DISPLAY_MANAGER_FILE" ]; then
+          db_get "$RET"/daemon_name
+          if [ "$(cat $DEFAULT_DISPLAY_MANAGER_FILE)" = "$RET" ]; then
+            rm "$DEFAULT_DISPLAY_MANAGER_FILE"
+          fi
+        fi
+        # ask the user to choose a new default
+        db_fset shared/default-x-display-manager seen false
+        db_input critical shared/default-x-display-manager || true
+        db_go
+        # if the display manager file doesn't exist, write it with the path
+        # to the new default display manager
+        if [ ! -e $DEFAULT_DISPLAY_MANAGER_FILE ]; then
+          db_get shared/default-x-display-manager
+          echo "Please be sure to run \"dpkg-reconfigure $RET\"."
+          db_get "$RET"/daemon_name
+          echo "$RET" > "$DEFAULT_DISPLAY_MANAGER_FILE"
+        fi
+      fi
+    fi
+  fi
+
+  DEFAULT_SERVICE=/etc/systemd/system/display-manager.service
+  # set default-display-manager systemd service link according to our config
+  if [ -e "$DEFAULT_DISPLAY_MANAGER_FILE" ]; then
+    SERVICE=/lib/systemd/system/$(basename $(cat "$DEFAULT_DISPLAY_MANAGER_FILE")).service
+    if [ -h "$DEFAULT_SERVICE" ] && [ $(readlink "$DEFAULT_SERVICE") = /dev/null ]; then
+      echo "Display manager service is masked" >&2
+    elif [ -e "$SERVICE" ]; then
+      ln -sf "$SERVICE" "$DEFAULT_SERVICE"
+    else
+      echo "WARNING: $SERVICE is the selected default display manager but does not exist" >&2
+      rm -f "$DEFAULT_SERVICE"
+    fi
+  else
+    rm -f "$DEFAULT_SERVICE"
+  fi
+fi
+
+if [ "$1" = "remove" ]; then
+  if [ -x /etc/init.d/nodm ]; then
+    nostop=
+    for hostname in "" "localhost" "$(hostname)" "$(hostname -f)"; do
+      if echo $DISPLAY | grep -q "^$hostname:0.*"; then
+        nostop=yes
+      fi
+    done
+    if [ -z $nostop ]; then
+      invoke-rc.d nodm stop
+    fi
+  fi
+fi
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/nodm.templates b/debian/nodm.templates
index 5d1223a..fd4b79b 100644
--- a/debian/nodm.templates
+++ b/debian/nodm.templates
@@ -72,3 +72,23 @@ Default: /etc/X11/Xsession
 _Description: X session to use:
  Please choose the name of the X session script to use with nodm.
 
+Template: nodm/daemon_name
+Type: string
+Default: /usr/sbin/nodm
+Description: for internal use only
+
+Template: shared/default-x-display-manager
+Type: select
+Choices: ${choices}
+_Description: Default display manager:
+ A display manager is a program that provides graphical login capabilities for
+ the X Window System.
+ .
+ Only one display manager can manage a given X server, but multiple display
+ manager packages are installed. Please select which display manager should
+ run by default.
+ .
+ Multiple display managers can run simultaneously if they are configured to
+ manage different servers; to achieve this, configure the display managers
+ accordingly, edit each of their init scripts in /etc/init.d, and disable the
+ check for a default display manager.
diff --git a/debian/rules b/debian/rules
index 01dbed9..62a74da 100755
--- a/debian/rules
+++ b/debian/rules
@@ -12,6 +12,11 @@ override_dh_auto_configure:
 	NOCONFIGURE=1 ./autogen.sh
 	dh_auto_configure $(DHFLAGS)
 
+override_dh_auto_install:
+	dh_auto_install -- systemdsystemunitdir=/lib/systemd/system
+	echo "# Debian-specific change until all display managers participate in /etc/X11/default-display-manager" >> debian/nodm/lib/systemd/system/nodm.service
+	echo "ExecStartPre=/bin/sh -c '[ \"\$$(cat /etc/X11/default-display-manager 2>/dev/null)\" = \"/usr/sbin/nodm\" ]'" >> debian/nodm/lib/systemd/system/nodm.service
+
 override_dh_auto_test:
 	#make check
 
diff --git a/nodm.service.in b/nodm.service.in
new file mode 100644
index 0000000..638f919
--- /dev/null
+++ b/nodm.service.in
@@ -0,0 +1,10 @@
+[Unit]
+Description=Display manager for automatic session logins
+Documentation=man:nodm(8)
+After=systemd-user-sessions.service
+
+[Service]
+EnvironmentFile=-/etc/default/nodm
+ExecStartPre=/usr/bin/test ${NODM_ENABLED} != no -a ${NODM_ENABLED} != false
+ExecStart=@sbindir@/nodm $NODM_OPTIONS
+Restart=always

-- 
Alioth's hooks/post-receive on /srv/git.debian.org/git/pkg-fso/nodm.git



More information about the pkg-fso-commits mailing list