Merge branch 'master' of https://github.com/calamares/calamares into development

This commit is contained in:
Philip Müller 2018-08-22 10:28:04 +02:00
commit 83c397620c
5 changed files with 495 additions and 344 deletions

19
CHANGES
View File

@ -5,11 +5,16 @@ website will have to do for older versions.
= 3.2.2 (unreleased) =
This release contains contributions from (alphabetically by first name):
- Andrius Štikonas
- artoo@cromnix.org
- Caio Carvalho
- Philip Müller
- Simon Quigley
- Walter Lapchynski
== Core ==
* Contributions from the following people (alphabetically by first name):
- artoo@cromnix.org
- Caio Carvalho
* Example configurations are **no longer installed** by default.
The default setting for *INSTALL_CONFIG* has changed. Distributions
are strongly encouraged to write their own configuration files and
@ -45,6 +50,14 @@ website will have to do for older versions.
a bad configuration). The configuration is a little more flexible
because a service (or target) name can be used on its own with
sensible defaults.
* The displaymanager module has been entirely revamped. A long-standing
bug which ignored the settings for default desktop has been fixed
(thanks to Walter Lapchynski). Translations have been added to the
error messages. Each DM now has an implementation class for doing
all the configuration steps it needs. This groups the code needed for
a specific DM (and presumably, per-distro) in one place.
Distro's are **strongly advised** to re-test their DM configuration
and installation with the revamped code.
**3.2.1** (2018-06-25)

View File

@ -3,13 +3,14 @@
# Travis CI script for use on every-commit:
# - build and install Calamares
#
test -n "$BUILDDIR" || exit 1
test -n "$SRCDIR" || exit 1
test -n "$BUILDDIR" || { echo "! \$BUILDDIR not set" ; exit 1 ; }
test -n "$SRCDIR" || { echo "! \$SRCDIR not set" ; exit 1 ; }
test -d $BUILDDIR || exit 1
test -d $SRCDIR || exit 1
test -f $SRCDIR/CMakeLists.txt || exit 1
test -d $BUILDDIR || { echo "! $BUILDDIR not a directory" ; exit 1 ; }
test -d $SRCDIR || { echo "! $SRCDIR not a directory" ; exit 1 ; }
test -f $SRCDIR/CMakeLists.txt || { echo "! Missing $SRCDIR/CMakeLists.txt" ; exit 1 ; }
cd $BUILDDIR || exit 1
echo "# cmake $CMAKE_ARGS $SRCDIR"
cmake $CMAKE_ARGS $SRCDIR && make -j2 && make install DESTDIR=/build/INSTALL_ROOT

View File

@ -3,13 +3,13 @@
# Travis CI script for weekly (cron) use:
# - use the coverity tool to build and and upload results
#
test -n "$COVERITY_SCAN_TOKEN" || exit 1
test -n "$BUILDDIR" || exit 1
test -n "$SRCDIR" || exit 1
test -n "$COVERITY_SCAN_TOKEN" || { echo "! Missing Coverity token" ; exit 1 ; }
test -n "$BUILDDIR" || { echo "! \$BUILDDIR not set" ; exit 1 ; }
test -n "$SRCDIR" || { echo "! \$SRCDIR not set" ; exit 1 ; }
test -d $BUILDDIR || exit 1
test -d $SRCDIR || exit 1
test -f $SRCDIR/CMakeLists.txt || exit 1
test -d $BUILDDIR || { echo "! $BUILDDIR not a directory" ; exit 1 ; }
test -d $SRCDIR || { echo "! $SRCDIR not a directory" ; exit 1 ; }
test -f $SRCDIR/CMakeLists.txt || { echo "! Missing $SRCDIR/CMakeLists.txt" ; exit 1 ; }
cd $BUILDDIR || exit 1
@ -20,7 +20,7 @@ mkdir "$BUILDDIR/coveritytool"
tar xvf coverity_tool.tar.gz -C "$BUILDDIR/coveritytool" --strip-components 2
export PATH="$BUILDDIR/coveritytool/bin:$PATH"
echo "# cmake -DCMAKE_BUILD_TYPE=Debug $CMAKE_ARGS $SRCDIR"
cmake -DCMAKE_BUILD_TYPE=Debug $CMAKE_ARGS $SRCDIR || exit 1
cov-build --dir cov-int make -j2

View File

@ -8,11 +8,11 @@
# intensive than the coverity add-on, but works on master.
#
D=`dirname "$0"`
test -d "$D" || exit 1
test -x "$D/travis-continuous.sh" || exit 1
test -x "$D/travis-coverity.sh" || exit 1
test -d "$D" || { echo "! No directory $D" ; exit 1 ; }
test -x "$D/travis-continuous.sh" || { echo "! Missing -continuous" ; exit 1 ; }
test -x "$D/travis-coverity.sh" || { echo "! Missing -coverity" ; exit 1 ; }
test -f "$D/travis-common.sh" && . "$D/travis-config.sh"
test -f "$D/travis-config.sh" && . "$D/travis-config.sh"
if test "$TRAVIS_EVENT_TYPE" = "cron" ; then
exec "$D/travis-coverity.sh"

View File

@ -23,16 +23,43 @@
# You should have received a copy of the GNU General Public License
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
import abc
import os
import collections
import re
import libcalamares
import configparser
from libcalamares.utils import gettext_path, gettext_languages
import gettext
_translation = gettext.translation("calamares-python",
localedir=gettext_path(),
languages=gettext_languages(),
fallback=True)
_ = _translation.gettext
_n = _translation.ngettext
class DesktopEnvironment:
"""
Desktop Environment -- some utility functions for a desktop
environment (e.g. finding out if it is installed). This
is independent of the *Display Manager*, which is what
we're configuring in this module.
"""
def __init__(self, exec, desktop):
self.executable = exec
self.desktop_file = desktop
def find_desktop_environment(self, root_mount_point):
"""
Check if this environment is installed in the
target system at @p root_mount_point.
"""
return (
os.path.exists("{!s}{!s}".format(root_mount_point, self.executable)) and
os.path.exists("{!s}/usr/share/xsessions/{!s}.desktop".format(root_mount_point, self.desktop_file))
)
DesktopEnvironment = collections.namedtuple(
'DesktopEnvironment', ['executable', 'desktop_file']
)
desktop_environments = [
DesktopEnvironment('/usr/bin/startkde', 'plasma'), # KDE Plasma 5
@ -67,54 +94,80 @@ def find_desktop_environment(root_mount_point):
:return:
"""
for desktop_environment in desktop_environments:
if (os.path.exists("{!s}{!s}".format(
root_mount_point, desktop_environment.executable
)
) and os.path.exists(
"{!s}/usr/share/xsessions/{!s}.desktop".format(
root_mount_point, desktop_environment.desktop_file
)
)):
if desktop_environment.find_desktop_environment(root_mount_point):
return desktop_environment
return None
def have_dm(dm_name, root_mount_point):
class DisplayManager(metaclass=abc.ABCMeta):
"""
Checks if display manager is properly installed.
Display Manager -- a base class for DM configuration.
"""
name = None
executable = None
:param dm_name:
:param root_mount_point:
:return:
"""
bin_path = "{!s}/usr/bin/{!s}".format(root_mount_point, dm_name)
sbin_path = "{!s}/usr/sbin/{!s}".format(root_mount_point, dm_name)
return (os.path.exists(bin_path)
def __init__(self, root_mount_point):
self.root_mount_point = root_mount_point
def have_dm(self):
"""
Is this DM installed in the target system?
The default implementation checks for `executable`
in the target system.
"""
if self.executable is None:
return True
bin_path = "{!s}/usr/bin/{!s}".format(self.root_mount_point, self.executable)
sbin_path = "{!s}/usr/sbin/{!s}".format(self.root_mount_point, self.executable)
return (
os.path.exists(bin_path)
or os.path.exists(sbin_path)
)
# The four abstract methods below are called in the order listed here.
# They must all be implemented by subclasses, but not all of them
# actually do something for all DMs.
def set_autologin(username,
displaymanager,
default_desktop_environment,
root_mount_point):
"""
Enables automatic login for the installed desktop managers.
@abc.abstractmethod
def basic_setup(self):
"""
Do basic setup (e.g. users, groups, directory creation) for this DM.
"""
# Some implementations do nothing
:param username:
:param displaymanager: str
The displaymanager for which to configure autologin.
:param default_desktop_environment:
:param root_mount_point:
"""
do_autologin = True
@abc.abstractmethod
def desktop_environment_setup(self, desktop_environment):
"""
Configure the given @p desktop_environment as the default one, in
the configuration files for this DM.
"""
# Many implementations do nothing
if username is None:
do_autologin = False
@abc.abstractmethod
def greeter_setup(self):
"""
Additional setup for the greeter.
"""
# Most implementations do nothing
if "mdm" == displaymanager:
@abc.abstractmethod
def set_autologin(self, username, do_autologin, default_desktop_environment):
"""
Configure the DM inside the given @p root_mount_point with
autologin (if @p do_autologin is True) for the given @p username.
If the DM supports it, set the default DE to @p default_desktop_environment
as well.
"""
class DMmdm(DisplayManager):
name = "mdm"
executable = "mdm"
def set_autologin(self, username, do_autologin, default_desktop_environment):
# Systems with MDM as Desktop Manager
mdm_conf_path = os.path.join(root_mount_point, "etc/mdm/custom.conf")
mdm_conf_path = os.path.join(self.root_mount_point, "etc/mdm/custom.conf")
if os.path.exists(mdm_conf_path):
with open(mdm_conf_path, 'r') as mdm_conf:
@ -149,9 +202,58 @@ def set_autologin(username,
else:
mdm_conf.write('AutomaticLoginEnable=False\n')
if "gdm" == displaymanager:
def basic_setup(self):
if libcalamares.utils.target_env_call(
['getent', 'group', 'mdm']
) != 0:
libcalamares.utils.target_env_call(
['groupadd', '-g', '128', 'mdm']
)
if libcalamares.utils.target_env_call(
['getent', 'passwd', 'mdm']
) != 0:
libcalamares.utils.target_env_call(
['useradd',
'-c', '"Linux Mint Display Manager"',
'-u', '128',
'-g', 'mdm',
'-d', '/var/lib/mdm',
'-s', '/usr/bin/nologin',
'mdm'
]
)
libcalamares.utils.target_env_call(
['passwd', '-l', 'mdm']
)
libcalamares.utils.target_env_call(
['chown', 'root:mdm', '/var/lib/mdm']
)
libcalamares.utils.target_env_call(
['chmod', '1770', '/var/lib/mdm']
)
def desktop_environment_setup(self, default_desktop_environment):
os.system(
"sed -i \"s|default.desktop|{!s}.desktop|g\" "
"{!s}/etc/mdm/custom.conf".format(
default_desktop_environment.desktop_file,
self.root_mount_point
)
)
def greeter_setup(self):
pass
class DMgdm(DisplayManager):
name = "gdm"
executable = "gdm"
def set_autologin(self, username, do_autologin, default_desktop_environment):
# Systems with GDM as Desktop Manager
gdm_conf_path = os.path.join(root_mount_point, "etc/gdm/custom.conf")
gdm_conf_path = os.path.join(self.root_mount_point, "etc/gdm/custom.conf")
if os.path.exists(gdm_conf_path):
with open(gdm_conf_path, 'r') as gdm_conf:
@ -185,7 +287,7 @@ def set_autologin(username,
if (do_autologin):
accountservice_dir = "{!s}/var/lib/AccountsService/users".format(
root_mount_point
self.root_mount_point
)
userfile_path = "{!s}/{!s}".format(accountservice_dir, username)
if os.path.exists(accountservice_dir):
@ -198,10 +300,51 @@ def set_autologin(username,
userfile.write("Icon=\n")
if "kdm" == displaymanager:
def basic_setup(self):
if libcalamares.utils.target_env_call(
['getent', 'group', 'gdm']
) != 0:
libcalamares.utils.target_env_call(
['groupadd', '-g', '120', 'gdm']
)
if libcalamares.utils.target_env_call(
['getent', 'passwd', 'gdm']
) != 0:
libcalamares.utils.target_env_call(
['useradd',
'-c', '"Gnome Display Manager"',
'-u', '120',
'-g', 'gdm',
'-d', '/var/lib/gdm',
'-s', '/usr/bin/nologin',
'gdm'
]
)
libcalamares.utils.target_env_call(
['passwd', '-l', 'gdm']
)
libcalamares.utils.target_env_call(
['chown', '-R', 'gdm:gdm', '/var/lib/gdm']
)
def desktop_environment_setup(self, desktop_environment):
pass
def greeter_setup(self):
pass
class DMkdm(DisplayManager):
name = "kdm"
executable = "kdm"
def set_autologin(self, username, do_autologin, default_desktop_environment):
# Systems with KDM as Desktop Manager
kdm_conf_path = os.path.join(
root_mount_point, "usr/share/config/kdm/kdmrc"
self.root_mount_point, "usr/share/config/kdm/kdmrc"
)
# Check which path is in use: SUSE does something else.
# Also double-check the default setting. Pick the first
@ -210,7 +353,7 @@ def set_autologin(username,
"usr/share/config/kdm/kdmrc",
"usr/share/kde4/config/kdm/kdmrc",
):
p = os.path.join(root_mount_point, candidate_kdmrc)
p = os.path.join(self.root_mount_point, candidate_kdmrc)
if os.path.exists(p):
kdm_conf_path = p
break
@ -234,13 +377,51 @@ def set_autologin(username,
kdm_conf.write(line)
else:
return (
"Cannot write KDM configuration file",
"KDM config file {!s} does not exist".format(kdm_conf_path)
_("Cannot write KDM configuration file"),
_("KDM config file {!s} does not exist").format(kdm_conf_path)
)
if "lxdm" == displaymanager:
def basic_setup(self):
if libcalamares.utils.target_env_call(
['getent', 'group', 'kdm']
) != 0:
libcalamares.utils.target_env_call(
['groupadd', '-g', '135', 'kdm']
)
if libcalamares.utils.target_env_call(
['getent', 'passwd', 'kdm']
) != 0:
libcalamares.utils.target_env_call(
['useradd',
'-u', '135',
'-g', 'kdm',
'-d', '/var/lib/kdm',
'-s', '/bin/false',
'-r',
'-M',
'kdm'
]
)
libcalamares.utils.target_env_call(
['chown', '-R', '135:135', 'var/lib/kdm']
)
def desktop_environment_setup(self, desktop_environment):
pass
def greeter_setup(self):
pass
class DMlxdm(DisplayManager):
name = "lxdm"
executable = "lxdm"
def set_autologin(self, username, do_autologin, default_desktop_environment):
# Systems with LXDM as Desktop Manager
lxdm_conf_path = os.path.join(root_mount_point, "etc/lxdm/lxdm.conf")
lxdm_conf_path = os.path.join(self.root_mount_point, "etc/lxdm/lxdm.conf")
text = []
if os.path.exists(lxdm_conf_path):
@ -258,17 +439,52 @@ def set_autologin(username,
lxdm_conf.write(line)
else:
return (
"Cannot write LXDM configuration file",
"LXDM config file {!s} does not exist".format(lxdm_conf_path)
_("Cannot write LXDM configuration file"),
_("LXDM config file {!s} does not exist").format(lxdm_conf_path)
)
if "lightdm" == displaymanager:
def basic_setup(self):
if libcalamares.utils.target_env_call(
['getent', 'group', 'lxdm']
) != 0:
libcalamares.utils.target_env_call(
['groupadd', '--system', 'lxdm']
)
libcalamares.utils.target_env_call(
['chgrp', '-R', 'lxdm', '/var/lib/lxdm']
)
libcalamares.utils.target_env_call(
['chgrp', 'lxdm', '/etc/lxdm/lxdm.conf']
)
libcalamares.utils.target_env_call(
['chmod', '+r', '/etc/lxdm/lxdm.conf']
)
def desktop_environment_setup(self, default_desktop_environment):
os.system(
"sed -i -e \"s|^.*session=.*|session={!s}|\" "
"{!s}/etc/lxdm/lxdm.conf".format(
default_desktop_environment.executable,
self.root_mount_point
)
)
def greeter_setup(self):
pass
class DMlightdm(DisplayManager):
name = "lightdm"
executable = "lightdm"
def set_autologin(self, username, do_autologin, default_desktop_environment):
# Systems with LightDM as Desktop Manager
# Ideally, we should use configparser for the ini conf file,
# but we just do a simple text replacement for now, as it
# worksforme(tm)
lightdm_conf_path = os.path.join(
root_mount_point, "etc/lightdm/lightdm.conf"
self.root_mount_point, "etc/lightdm/lightdm.conf"
)
text = []
@ -298,15 +514,93 @@ def set_autologin(username,
"#autologin-user=\n")
except FileNotFoundError:
return (
"Cannot write LightDM configuration file",
"LightDM config file {!s} does not exist".format(
lightdm_conf_path
)
_("Cannot write LightDM configuration file"),
_("LightDM config file {!s} does not exist").format(lightdm_conf_path)
)
if "slim" == displaymanager:
def basic_setup(self):
libcalamares.utils.target_env_call(
['mkdir', '-p', '/run/lightdm']
)
if libcalamares.utils.target_env_call(
['getent', 'group', 'lightdm']
) != 0:
libcalamares.utils.target_env_call(
['groupadd', '-g', '620', 'lightdm']
)
if libcalamares.utils.target_env_call(
['getent', 'passwd', 'lightdm']
) != 0:
libcalamares.utils.target_env_call(
['useradd', '-c',
'"LightDM Display Manager"',
'-u', '620',
'-g', 'lightdm',
'-d', '/var/run/lightdm',
'-s', '/usr/bin/nologin',
'lightdm'
]
)
libcalamares.utils.target_env_call(['passwd', '-l', 'lightdm'])
libcalamares.utils.target_env_call(['chown', '-R', 'lightdm:lightdm', '/run/lightdm'])
libcalamares.utils.target_env_call(['chmod', '+r' '/etc/lightdm/lightdm.conf'])
def desktop_environment_setup(self, default_desktop_environment):
os.system(
"sed -i -e \"s/^.*user-session=.*/user-session={!s}/\" "
"{!s}".format(
default_desktop_environment.desktop_file,
lightdm_conf_path
)
)
def greeter_setup(self):
lightdm_conf_path = os.path.join(
self.root_mount_point, "etc/lightdm/lightdm.conf"
)
# configure lightdm-greeter
greeter_path = os.path.join(
self.root_mount_point, "usr/share/xgreeters"
)
if (os.path.exists(greeter_path)):
# configure first found lightdm-greeter
for entry in os.listdir(greeter_path):
if entry.endswith('.desktop'):
greeter = entry.split('.')[0]
libcalamares.utils.debug(
"found greeter {!s}".format(greeter)
)
os.system(
"sed -i -e \"s/^.*greeter-session=.*"
"/greeter-session={!s}/\" {!s}".format(
greeter,
lightdm_conf_path
)
)
libcalamares.utils.debug(
"{!s} configured as greeter.".format(greeter)
)
break
else:
return (
_("Cannot configure LightDM"),
_("No LightDM greeter installed.")
)
class DMslim(DisplayManager):
name = "slim"
executable = "slim"
def set_autologin(self, username, do_autologin, default_desktop_environment):
# Systems with Slim as Desktop Manager
slim_conf_path = os.path.join(root_mount_point, "etc/slim.conf")
slim_conf_path = os.path.join(self.root_mount_point, "etc/slim.conf")
text = []
if os.path.exists(slim_conf_path):
@ -327,13 +621,28 @@ def set_autologin(username,
slim_conf.write(line)
else:
return (
"Cannot write SLIM configuration file",
"SLIM config file {!s} does not exist".format(slim_conf_path)
_("Cannot write SLIM configuration file"),
_("SLIM config file {!s} does not exist").format(slim_conf_path)
)
if "sddm" == displaymanager:
def basic_setup(self):
pass
def desktop_environment_setup(self, desktop_environment):
pass
def greeter_setup(self):
pass
class DMsddm(DisplayManager):
name = "sddm"
executable = "sddm"
def set_autologin(self, username, do_autologin, default_desktop_environment):
# Systems with Sddm as Desktop Manager
sddm_conf_path = os.path.join(root_mount_point, "etc/sddm.conf")
sddm_conf_path = os.path.join(self.root_mount_point, "etc/sddm.conf")
sddm_config = configparser.ConfigParser(strict=False)
# Make everything case sensitive
@ -360,7 +669,22 @@ def set_autologin(username,
with open(sddm_conf_path, 'w') as sddm_config_file:
sddm_config.write(sddm_config_file, space_around_delimiters=False)
if "sysconfig" == displaymanager:
def basic_setup(self):
pass
def desktop_environment_setup(self, desktop_environment):
pass
def greeter_setup(self):
pass
class DMsysconfig(DisplayManager):
name = "sysconfig"
executable = None
def set_autologin(self, username, do_autologin, default_desktop_environment):
dmauto = "DISPLAYMANAGER_AUTOLOGIN"
os.system(
@ -368,11 +692,28 @@ def set_autologin(username,
"{!s}/etc/sysconfig/displaymanager".format(
dmauto, dmauto,
username if do_autologin else "",
root_mount_point
self.root_mount_point
)
)
return None
def basic_setup(self):
pass
def desktop_environment_setup(self, desktop_environment):
pass
def greeter_setup(self):
pass
# Collect all the subclasses of DisplayManager defined above,
# and index them based on the name property of each class.
display_managers = [
(c.name, c)
for c in globals().values()
if type(c) is abc.ABCMeta and issubclass(c, DisplayManager) and c.name
]
def run():
@ -386,6 +727,7 @@ def run():
If a displaymanager is in the list but not installed, a debugging message
is printed and the entry ignored.
"""
# Get configuration settings for display managers
displaymanagers = None
if "displaymanagers" in libcalamares.job.configuration:
displaymanagers = libcalamares.job.configuration["displaymanagers"]
@ -393,16 +735,46 @@ def run():
if libcalamares.globalstorage.contains("displayManagers"):
displaymanagers = libcalamares.globalstorage.value("displayManagers")
if displaymanagers is None:
if not displaymanagers:
return (
"No display managers selected for the displaymanager module.",
"The displaymanagers list is empty or undefined in both"
"globalstorage and displaymanager.conf."
_("No display managers selected for the displaymanager module."),
_("The displaymanagers list is empty or undefined in both"
"globalstorage and displaymanager.conf.")
)
username = libcalamares.globalstorage.value("autologinUser")
# Get instances that are actually installed
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
dm_impl = []
dm_names = displaymanagers[:]
if ("sysconfigSetup" in libcalamares.job.configuration
and libcalamares.job.configuration["sysconfigSetup"]):
dm_names.append("sysconfig")
for dm in dm_names:
# Find the implementation class
dm_instance = None
impl = [ cls for name, cls in display_managers if name == dm ]
if len(impl) == 1:
dm_instance = impl[0](root_mount_point)
if dm_instance.have_dm():
dm_impl.append(dm_instance)
else:
dm_instance = None
else:
libcalamares.utils.debug("{!s} has {!d} implementation classes.".format(dm).format(len(impl)))
if dm_instance is None:
libcalamares.utils.debug("{!s} selected but not installed".format(dm))
if dm in displaymanagers:
displaymanagers.remove(dm)
if not dm_impl:
return (
_("No display managers selected for the displaymanager module."),
_("The list is empty after checking for installed display managers.")
)
# Pick up remaining settings
if "defaultDesktopEnvironment" in libcalamares.job.configuration:
entry = libcalamares.job.configuration["defaultDesktopEnvironment"]
default_desktop_environment = DesktopEnvironment(
@ -418,269 +790,34 @@ def run():
else:
enable_basic_setup = False
# Setup slim
if "slim" in displaymanagers:
if not have_dm("slim", root_mount_point):
libcalamares.utils.debug("slim selected but not installed")
displaymanagers.remove("slim")
# Setup sddm
if "sddm" in displaymanagers:
if not have_dm("sddm", root_mount_point):
libcalamares.utils.debug("sddm selected but not installed")
displaymanagers.remove("sddm")
# setup lightdm
if "lightdm" in displaymanagers:
if have_dm("lightdm", root_mount_point):
lightdm_conf_path = os.path.join(
root_mount_point, "etc/lightdm/lightdm.conf"
)
if enable_basic_setup:
libcalamares.utils.target_env_call(
['mkdir', '-p', '/run/lightdm']
)
if libcalamares.utils.target_env_call(
['getent', 'group', 'lightdm']
) != 0:
libcalamares.utils.target_env_call(
['groupadd', '-g', '620', 'lightdm']
)
if libcalamares.utils.target_env_call(
['getent', 'passwd', 'lightdm']
) != 0:
libcalamares.utils.target_env_call(
['useradd', '-c',
'"LightDM Display Manager"',
'-u', '620',
'-g', 'lightdm',
'-d', '/var/run/lightdm',
'-s', '/usr/bin/nologin',
'lightdm'
]
)
libcalamares.utils.target_env_call('passwd', '-l', 'lightdm')
libcalamares.utils.target_env_call(
['chown', '-R', 'lightdm:lightdm', '/run/lightdm']
)
libcalamares.utils.target_env_call(
['chmod', '+r' '/etc/lightdm/lightdm.conf']
)
if default_desktop_environment is not None:
os.system(
"sed -i -e \"s/^.*user-session=.*/user-session={!s}/\" "
"{!s}".format(
default_desktop_environment.desktop_file,
lightdm_conf_path
)
)
# configure lightdm-greeter
greeter_path = os.path.join(
root_mount_point, "usr/share/xgreeters"
)
if (os.path.exists(greeter_path)):
# configure first found lightdm-greeter
for entry in os.listdir(greeter_path):
if entry.endswith('.desktop'):
greeter = entry.split('.')[0]
libcalamares.utils.debug(
"found greeter {!s}".format(greeter)
)
os.system(
"sed -i -e \"s/^.*greeter-session=.*"
"/greeter-session={!s}/\" {!s}".format(
greeter,
lightdm_conf_path
)
)
libcalamares.utils.debug(
"{!s} configured as greeter.".format(greeter)
)
break
else:
return ("No lightdm greeter installed.")
else:
libcalamares.utils.debug("lightdm selected but not installed")
displaymanagers.remove("lightdm")
# Setup gdm
if "gdm" in displaymanagers:
if have_dm("gdm", root_mount_point):
if enable_basic_setup:
if libcalamares.utils.target_env_call(
['getent', 'group', 'gdm']
) != 0:
libcalamares.utils.target_env_call(
['groupadd', '-g', '120', 'gdm']
)
if libcalamares.utils.target_env_call(
['getent', 'passwd', 'gdm']
) != 0:
libcalamares.utils.target_env_call(
['useradd',
'-c', '"Gnome Display Manager"',
'-u', '120',
'-g', 'gdm',
'-d', '/var/lib/gdm',
'-s', '/usr/bin/nologin',
'gdm'
]
)
libcalamares.utils.target_env_call(
['passwd', '-l', 'gdm']
)
libcalamares.utils.target_env_call(
['chown', '-R', 'gdm:gdm', '/var/lib/gdm']
)
else:
libcalamares.utils.debug("gdm selected but not installed")
displaymanagers.remove("gdm")
# Setup mdm
if "mdm" in displaymanagers:
if have_dm("mdm", root_mount_point):
if enable_basic_setup:
if libcalamares.utils.target_env_call(
['getent', 'group', 'mdm']
) != 0:
libcalamares.utils.target_env_call(
['groupadd', '-g', '128', 'mdm']
)
if libcalamares.utils.target_env_call(
['getent', 'passwd', 'mdm']
) != 0:
libcalamares.utils.target_env_call(
['useradd',
'-c', '"Linux Mint Display Manager"',
'-u', '128',
'-g', 'mdm',
'-d', '/var/lib/mdm',
'-s', '/usr/bin/nologin',
'mdm'
]
)
libcalamares.utils.target_env_call(
['passwd', '-l', 'mdm']
)
libcalamares.utils.target_env_call(
['chown', 'root:mdm', '/var/lib/mdm']
)
libcalamares.utils.target_env_call(
['chmod', '1770', '/var/lib/mdm']
)
if default_desktop_environment is not None:
os.system(
"sed -i \"s|default.desktop|{!s}.desktop|g\" "
"{!s}/etc/mdm/custom.conf".format(
default_desktop_environment.desktop_file,
root_mount_point
)
)
else:
libcalamares.utils.debug("mdm selected but not installed")
displaymanagers.remove("mdm")
# Setup lxdm
if "lxdm" in displaymanagers:
if have_dm("lxdm", root_mount_point):
if enable_basic_setup:
if libcalamares.utils.target_env_call(
['getent', 'group', 'lxdm']
) != 0:
libcalamares.utils.target_env_call(
['groupadd', '--system', 'lxdm']
)
libcalamares.utils.target_env_call(
['chgrp', '-R', 'lxdm', '/var/lib/lxdm']
)
libcalamares.utils.target_env_call(
['chgrp', 'lxdm', '/etc/lxdm/lxdm.conf']
)
libcalamares.utils.target_env_call(
['chmod', '+r', '/etc/lxdm/lxdm.conf']
)
if default_desktop_environment is not None:
os.system(
"sed -i -e \"s|^.*session=.*|session={!s}|\" "
"{!s}/etc/lxdm/lxdm.conf".format(
default_desktop_environment.executable,
root_mount_point
)
)
else:
libcalamares.utils.debug("lxdm selected but not installed")
displaymanagers.remove("lxdm")
# Setup kdm
if "kdm" in displaymanagers:
if have_dm("kdm", root_mount_point):
if enable_basic_setup:
if libcalamares.utils.target_env_call(
['getent', 'group', 'kdm']
) != 0:
libcalamares.utils.target_env_call(
['groupadd', '-g', '135', 'kdm']
)
if libcalamares.utils.target_env_call(
['getent', 'passwd', 'kdm']
) != 0:
libcalamares.utils.target_env_call(
['useradd',
'-u', '135',
'-g', 'kdm',
'-d', '/var/lib/kdm',
'-s', '/bin/false',
'-r',
'-M',
'kdm'
]
)
libcalamares.utils.target_env_call(
['chown', '-R', '135:135', 'var/lib/kdm']
)
else:
libcalamares.utils.debug("kdm selected but not installed")
displaymanagers.remove("kdm")
username = libcalamares.globalstorage.value("autologinUser")
if username is not None:
libcalamares.utils.debug(
"Setting up autologin for user {!s}.".format(username)
)
do_autologin = True
libcalamares.utils.debug("Setting up autologin for user {!s}.".format(username))
else:
do_autologin = False
libcalamares.utils.debug("Unsetting autologin.")
libcalamares.globalstorage.insert("displayManagers", displaymanagers)
# Do the actual configuration and collect messages
dm_setup_message = []
for dm in displaymanagers:
dm_message = set_autologin(
username, dm,
default_desktop_environment,
root_mount_point
)
for dm in dm_impl:
dm_message = None
if enable_basic_setup:
dm_message = dm.basic_setup()
if default_desktop_environment is not None and dm_message is None:
dm_message = dm.desktop_environment_setup(default_desktop_environment)
if dm_message is None:
dm_message = dm.greeter_setup()
if dm_message is None:
dm_message = dm.set_autologin(username, do_autologin, default_desktop_environment)
if dm_message is not None:
dm_setup_message.append("{!s}: {!s}".format(*dm_message))
if ("sysconfigSetup" in libcalamares.job.configuration
and libcalamares.job.configuration["sysconfigSetup"]):
set_autologin(username, "sysconfig", None, root_mount_point)
if dm_setup_message:
return ("Display manager configuration was incomplete",
"\n".join(dm_setup_message))
return (
_("Display manager configuration was incomplete"),
"\n".join(dm_setup_message)
)