[displaymanager] Look for variant gdm config files

FIXES #2335
This commit is contained in:
Adriaan de Groot 2024-06-11 00:21:35 +02:00
parent ad28ae08b6
commit 81c82ef343
3 changed files with 41 additions and 6 deletions

View File

@ -376,14 +376,30 @@ class DMgdm(DisplayManager):
GDM exists with different executable names, so search GDM exists with different executable names, so search
for one of them and use it. for one of them and use it.
""" """
for executable, config in ( candidates = (
( "gdm", "etc/gdm/custom.conf" ), ( "gdm", "etc/gdm/custom.conf" ),
( "gdm3", "etc/gdm3/daemon.conf" ) ( "gdm3", "etc/gdm3/daemon.conf" ),
): ( "gdm3", "etc/gdm3/custom.conf" ),
)
def have_executable(executable : str):
bin_path = "{!s}/usr/bin/{!s}".format(self.root_mount_point, executable) bin_path = "{!s}/usr/bin/{!s}".format(self.root_mount_point, executable)
sbin_path = "{!s}/usr/sbin/{!s}".format(self.root_mount_point, executable) sbin_path = "{!s}/usr/sbin/{!s}".format(self.root_mount_point, executable)
if os.path.exists(bin_path) or os.path.exists(sbin_path): return os.path.exists(bin_path) or os.path.exists(sbin_path)
# Keep the found-executable name around for later
def have_config(config : str):
config_path = "{!s}/{!s}".format(self.root_mount_point, config)
return os.path.exists(config_path)
# Look for an existing configuration file as a hint, then
# keep the found-executable name and config around for later.
for executable, config in candidates:
if have_config(config) and have_executable(executable):
self.executable = executable
self.config = config
return True
for executable, config in candidates:
if have_executable(executable):
self.executable = executable self.executable = executable
self.config = config self.config = config
return True return True

View File

@ -4,7 +4,7 @@
# We have tests to load (some) of the DMs specifically, to test their # We have tests to load (some) of the DMs specifically, to test their
# configuration code. Those tests conventionally live in Python # configuration code. Those tests conventionally live in Python
# files here in the tests/ directory. Add them. # files here in the tests/ directory. Add them.
foreach(_dmname greetd sddm) foreach(_dmname greetd sddm gdm)
add_test( add_test(
NAME configure-displaymanager-${_dmname} NAME configure-displaymanager-${_dmname}
COMMAND env PYTHONPATH=.: python3 ${CMAKE_CURRENT_LIST_DIR}/test-dm-${_dmname}.py COMMAND env PYTHONPATH=.: python3 ${CMAKE_CURRENT_LIST_DIR}/test-dm-${_dmname}.py

View File

@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0
#
# Calamares Boilerplate
import libcalamares
libcalamares.globalstorage = libcalamares.GlobalStorage(None)
libcalamares.globalstorage.insert("testing", True)
# Module prep-work
from src.modules.displaymanager import main
default_desktop_environment = main.DesktopEnvironment("startplasma-x11", "kde-plasma.desktop")
# Specific DM test
d = main.DMgdm("/tmp")
d.have_dm()
d.set_autologin("d", True, default_desktop_environment)
# .. and again (this time checks load/save)
d.set_autologin("d", True, default_desktop_environment)
d.set_autologin("d", True, default_desktop_environment)