From 81c82ef343353dd37af33a7c9570e61a6a22121a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 11 Jun 2024 00:21:35 +0200 Subject: [PATCH] [displaymanager] Look for variant gdm config files FIXES #2335 --- src/modules/displaymanager/main.py | 26 +++++++++++++++---- .../displaymanager/tests/CMakeTests.txt | 2 +- .../displaymanager/tests/test-dm-gdm.py | 19 ++++++++++++++ 3 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 src/modules/displaymanager/tests/test-dm-gdm.py diff --git a/src/modules/displaymanager/main.py b/src/modules/displaymanager/main.py index 217cd56b0..6ca279e18 100644 --- a/src/modules/displaymanager/main.py +++ b/src/modules/displaymanager/main.py @@ -376,14 +376,30 @@ class DMgdm(DisplayManager): GDM exists with different executable names, so search for one of them and use it. """ - for executable, config in ( + candidates = ( ( "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) sbin_path = "{!s}/usr/sbin/{!s}".format(self.root_mount_point, executable) - if os.path.exists(bin_path) or os.path.exists(sbin_path): - # Keep the found-executable name around for later + return os.path.exists(bin_path) or os.path.exists(sbin_path) + + 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.config = config return True diff --git a/src/modules/displaymanager/tests/CMakeTests.txt b/src/modules/displaymanager/tests/CMakeTests.txt index 70e3d580d..22195f281 100644 --- a/src/modules/displaymanager/tests/CMakeTests.txt +++ b/src/modules/displaymanager/tests/CMakeTests.txt @@ -4,7 +4,7 @@ # We have tests to load (some) of the DMs specifically, to test their # configuration code. Those tests conventionally live in Python # files here in the tests/ directory. Add them. -foreach(_dmname greetd sddm) +foreach(_dmname greetd sddm gdm) add_test( NAME configure-displaymanager-${_dmname} COMMAND env PYTHONPATH=.: python3 ${CMAKE_CURRENT_LIST_DIR}/test-dm-${_dmname}.py diff --git a/src/modules/displaymanager/tests/test-dm-gdm.py b/src/modules/displaymanager/tests/test-dm-gdm.py new file mode 100644 index 000000000..778bb8fbb --- /dev/null +++ b/src/modules/displaymanager/tests/test-dm-gdm.py @@ -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)