Add debconf question for display-manager, based on gdm3

This commit is contained in:
Jeremy Soller 2024-02-05 15:44:38 -07:00
parent 912bd61da0
commit 9947473cb4
No known key found for this signature in database
GPG key ID: D02FD439211AF56F
6 changed files with 180 additions and 2 deletions

1
debian/control vendored
View file

@ -17,4 +17,5 @@ Homepage: https://github.com/pop-os/cosmic-greeter
Package: cosmic-greeter
Architecture: amd64 arm64
Depends: cage, greetd, ${misc:Depends}, ${shlibs:Depends}
Provides: x-display-manager
Description: Cosmic Greeter

43
debian/cosmic-greeter.config vendored Normal file
View file

@ -0,0 +1,43 @@
#!/bin/sh
# Debian cosmic-greeter package configuration script
# Copyright 2000-2001 Branden Robinson.
# Licensed under the GNU General Public License, version 2. See the file
# /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.
set -e
# source debconf library
. /usr/share/debconf/confmodule
THIS_PACKAGE=cosmic-greeter
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
exit 0

49
debian/cosmic-greeter.postinst vendored Normal file
View file

@ -0,0 +1,49 @@
#!/bin/sh
set -e
. /usr/share/debconf/confmodule
THIS_PACKAGE=cosmic-greeter
DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager
# 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
# debconf hangs if cosmic-greeter gets started below without this
db_stop || true
#DEBHELPER#

64
debian/cosmic-greeter.prerm vendored Normal file
View file

@ -0,0 +1,64 @@
#!/bin/bash
# Debian gdm package pre-removal script
# Copyright 2001 Branden Robinson.
# Licensed under the GNU General Public License, version 2. See the file
# /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.
# Acknowlegements to Stephen Early, Mark Eichin, and Manoj Srivastava.
set -e
THIS_PACKAGE=cosmic-greeter
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
#DEBHELPER#

View file

@ -16,5 +16,6 @@ RestartSec=1
StartLimitBurst=5
StartLimitInterval=30
[Install]
Alias=display-manager.service
# Managed by debconf
#[Install]
#Alias=display-manager.service

20
debian/cosmic-greeter.templates vendored Normal file
View file

@ -0,0 +1,20 @@
Template: cosmic-greeter/daemon_name
Type: string
Default: /usr/bin/cosmic-greeter
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.