File plasma5-session.spec of Package plasma5-session

#
# spec file for package plasma5-session
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


Name:           plasma5-session
Version:        5.27.11
Release:        0
Summary:        KDE Plasma 5 X11 Session
License:        GPL-2.0-or-later
Group:          System/GUI/KDE
URL:            https://www.kde.org/
Source1:        plasma5.desktop
Source2:        COPYING
Source3:        plasmawayland.desktop
Source4:        plasmafullwayland.desktop
Source101:      kf5.sh
Source102:      startkf5
Source103:      startkf5-wayland
Source104:      zzz-kf5.sh
Source105:      99-kf5.sh
BuildRequires:  kf5-filesystem
Requires:       %{name}-envscript
Requires:       breeze >= %{version}
Requires:       breeze5-decoration >= %{version}
Requires:       khotkeys5 >= %{version}
Requires:       kwin5 >= %{version}
Requires:       libkscreen2-plugin >= %{version}
Requires:       plasma-nm5 >= %{version}
Requires:       plasma5-desktop >= %{version}
Requires:       plasma5-workspace >= %{version}
Requires:       polkit-kde-agent-5 >= %{version}
Requires:       powerdevil5 >= %{version}
Requires:       systemsettings5 >= %{version}
Requires(post): update-alternatives
Requires(postun): update-alternatives
Requires(pre):  %{_bindir}/cut
Requires(pre):  %{_bindir}/grep
Requires(pre):  %{_bindir}/sed
# needed for displaying the handbooks of KDE applications in a Plasma5 session (boo#980068)
Recommends:     khelpcenter5
BuildArch:      noarch

%description
This package contains the startup scripts necessary to start a KDE
Plasma 5 session with X11 from a display manager.

%package envscript
Summary:        Scripts to setup KF5 environment
Group:          System/GUI/KDE

%description envscript
This package contains scripts to set up the environment to be able
to run Plasma 5 or KF5 applications from /opt/kf5

%package wayland
Summary:        KDE Plasma 5 Wayland session
Group:          System/GUI/KDE
Requires:       kwayland-integration >= %{version}
Requires:       libqt5-qtwayland
Requires:       %{name} >= %{version}
Requires:       xf86-input-libinput
Requires:       xorg-x11-server-wayland

%description wayland
This package contains the startup scripts necessary to start a KDE
Plasma 5 session with Wayland from a display manager.

%prep

%build

%install
# Leap (upto 15.4 at least) has a different _libexecdir than Tumbleweed, so adjust path
sed -i "s!/usr/libexec/!%{_libexecdir}/!" %{SOURCE103}

install -m 0755 -d %{buildroot}%{_datadir}/xsessions/
mkdir -p %{buildroot}%{_kf5_bindir}
install -m 0755 %{SOURCE102} %{buildroot}%{_kf5_bindir}/startkf5
mkdir -p %{buildroot}%{_kf5_sharedir}/env/
install -m 0755 %{SOURCE101} %{buildroot}%{_kf5_sharedir}/env/kf5.sh
# create symlink in /usr/bin/
mkdir -p %{buildroot}%{_bindir}
ln -s %{_kf5_sharedir}/env/kf5.sh %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_sysconfdir}/profile.d/
install -m 0755 %{SOURCE104} %{buildroot}%{_sysconfdir}/profile.d/zzz-kf5.sh
%if 0%{?suse_version} >= 1500
mkdir -p %{buildroot}%{_systemd_user_env_generator_dir}
install -m 0755 %{SOURCE105} %{buildroot}%{_systemd_user_env_generator_dir}/99-kf5.sh
%endif
# Leap 42.1 doesn't have XWayland
%if 0%{?suse_version} > 1320
install -m 0755 %{SOURCE103} %{buildroot}%{_kf5_bindir}/startkf5-wayland
install -m 0755 -d %{buildroot}%{_datadir}/wayland-sessions/
%endif
# write version number into plasma5.desktop, this is displayed by KInfocenter as Plasma version
echo "X-KDE-PluginInfo-Version=%{version}" >> %{SOURCE1}
echo "X-KDE-PluginInfo-Version=%{version}" >> %{SOURCE3}
echo "X-KDE-PluginInfo-Version=%{version}" >> %{SOURCE4}
cp %{SOURCE1} %{buildroot}%{_datadir}/xsessions/
# Leap 42.1 doesn't have XWayland
%if 0%{?suse_version} > 1320
cp %{SOURCE3} %{buildroot}%{_datadir}/wayland-sessions/
#cp %{SOURCE4} %{buildroot}%{_datadir}/wayland-sessions/
%endif
install -D -m644 %{SOURCE2} %{buildroot}%{_datadir}/doc/packages/plasma5-session/COPYING
# Leap 42.1 doesn't have XWayland
%if 0%{?suse_version} > 1320
install -D -m644 %{SOURCE2} %{buildroot}%{_datadir}/doc/packages/plasma5-session-wayland/COPYING
%endif

%if 0%{?suse_version} > 1320
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
touch %{buildroot}%{_sysconfdir}/alternatives/default-xsession.desktop
ln -s %{_sysconfdir}/alternatives/default-xsession.desktop %{buildroot}%{_datadir}/xsessions/default.desktop
%endif

%post
# Reset the DEFAULT_WM value for KDE upgrade compatibility
if [ -f /etc/sysconfig/windowmanager ]; then
    OLD_DEFAULTWM=`grep "DEFAULT_WM" /etc/sysconfig/windowmanager | cut -d '=' -f 2 | cut -d '"' -f 2`
fi

if [ -f /var/adm/fillup-templates/sysconfig.windowmanager ]; then
    TEMPLATE_DEFAULTWM=`grep "DEFAULT_WM" /var/adm/fillup-templates/sysconfig.windowmanager | cut -d '=' -f 2 | cut -d '"' -f 2`
fi

# Check the old DEFAULT_WM and whether current DEFAULT_WM exists
if [ "$OLD_DEFAULTWM" = "startkde4" ] || [ "$OLD_DEFAULTWM" = "startkde" ] || [ "$OLD_DEFAULTWM" = "kde4" ]; then
    if [ -n "$TEMPLATE_DEFAULTWM" ] && [ "$OLD_DEFAULTWM" != "$TEMPLATE_DEFAULTWM" ]; then
        sed -i -e "s/^DEFAULT_WM=['\"]\?kde.*/DEFAULT_WM=\"${TEMPLATE_DEFAULTWM}\"/g" /etc/sysconfig/windowmanager
    fi
fi

%if 0%{?suse_version} > 1320
%{_sbindir}/update-alternatives --install %{_datadir}/xsessions/default.desktop \
  default-xsession.desktop %{_datadir}/xsessions/plasma5.desktop 25

%postun
[ -f %{_datadir}/xsessions/plasma5.desktop ] || %{_sbindir}/update-alternatives \
  --remove default-xsession.desktop %{_datadir}/xsessions/plasma5.desktop
%endif

%files
%defattr(-,root,root)
%{_datadir}/xsessions/plasma5.desktop
%if 0%{?suse_version} > 1320
%ghost %{_sysconfdir}/alternatives/default-xsession.desktop
%{_datadir}/xsessions/default.desktop
%endif
%dir %{_datadir}/doc/packages/plasma5-session
%{_datadir}/doc/packages/plasma5-session/COPYING
%{_kf5_bindir}/startkf5

%files envscript
%defattr(-,root,root)
%dir %{_kf5_sharedir}/env/
%{_bindir}/kf5.sh
%{_kf5_sharedir}/env/kf5.sh
%{_sysconfdir}/profile.d/zzz-kf5.sh
%if 0%{?suse_version} >= 1500
%dir %{_systemd_user_env_generator_dir}
%{_systemd_user_env_generator_dir}/99-kf5.sh
%endif

# Leap 42.1 doesn't have XWayland
%if 0%{?suse_version} > 1320
%files wayland
%{_datadir}/wayland-sessions/plasmawayland.desktop
#%{_datadir}/wayland-sessions/plasmafullwayland.desktop
%dir %{_datadir}/wayland-sessions/
%dir %{_datadir}/doc/packages/plasma5-session-wayland
%{_datadir}/doc/packages/plasma5-session-wayland/COPYING
%{_kf5_bindir}/startkf5-wayland
%endif

%changelog
openSUSE Build Service is sponsored by