File deepin-session.spec of Package deepin-session

#
# spec file for package deepin-session
#
# Copyright (c) 2024 SUSE LLC
# Copyright (c) 2024 Hillwood Yang <hillwood@opensuse.org>
#
# 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/
#

%define  _name  dde-session

Name:           deepin-session
Version:        2.0.10
Release:        0
Summary:        Deepin Session
License:        GPL-3.0+
Group:          System/GUI/Other
URL:            https://github.com/linuxdeepin/dde-session
Source:         https://github.com/linuxdeepin/dde-session/archive/%{version}/%{_name}-%{version}.tar.gz
# PATCH-FIX-OPENSUSE backport-for-deepin-kwin-5.patch hillwood@opensuse.org - Use deepin-kwin5
Patch0:         backport-for-deepin-kwin-5.patch
# PATCH-FIX-UPSTREAN fix-QString-6_10.patch hillwood@opensuse.org - Adapt QString::arg usage for Qt 6.10
# https://github.com/linuxdeepin/dde-session/pull/174
Patch1:         fix-QString-6_10.patch 
# PATCH-FIX-OPENSUSE servicename.patch hillwood@opensuse.org - servicename is invalid in stable release
# Patch1:         servicename.patch
BuildRequires:  pkgconfig(dtk6core)
BuildRequires:  pkgconfig(libsystemd)
BuildRequires:  pkgconfig(libsecret-1)
BuildRequires:  pkgconfig(gsettings-qt)
BuildRequires:  pkgconfig(glib-2.0)
BuildRequires:  pkgconfig(gio-2.0)
BuildRequires:  pkgconfig(xcursor)
BuildRequires:  pkgconfig(xfixes)
BuildRequires:  pkgconfig(x11)
BuildRequires:  pkgconfig(Qt6Core)
BuildRequires:  pkgconfig(Qt6Concurrent)
BuildRequires:  pkgconfig(Qt6DBus)
BuildRequires:  pkgconfig(Qt6Network)
BuildRequires:  pkgconfig(Qt6Xml)
BuildRequires:  dtk6core
BuildRequires:  systemd-rpm-macros
Requires(post): update-alternatives
Requires:       %{name}-core = %{version}
Requires:       jq
%{?systemd_ordering}

%description
The dde-session is used for launching DDE components systemd service project.
This project refers to a part of GNOME session documents and files.

%package core
Summary:        Minimal version of the GNOME Session Manager
Group:          System/GUI/Other
Requires:       dbus-1-x11

%description core
This package contains a minimal version of deepin-session, that can be
used for specific cases. The deepin-session package is needed for a fully
functional Deepin desktop.

%prep
%autosetup -p1 -n %{_name}-%{version}

%build
%cmake
%cmake_build

%install
%cmake_install

mkdir -p %{buildroot}%{_sysconfdir}/alternatives
touch %{buildroot}%{_sysconfdir}/alternatives/default-xsession.desktop
ln -s %{_sysconfdir}/alternatives/default-xsession.desktop %{buildroot}%{_datadir}/xsessions/default.desktop
#%ifnarch s390 s390x
#touch %{buildroot}%{_sysconfdir}/alternatives/default-waylandsession.desktop
#ln -s %{_sysconfdir}/alternatives/default-waylandsession.desktop %{buildroot}%{_datadir}/wayland-sessions/default.desktop
#%endif

chmod +x %{buildroot}%{_sysconfdir}/X11/Xsession.d/00deepin-dde-env
chmod +x %{buildroot}%{_sysconfdir}/X11/Xsession.d/97deepin-keyring-wb

%post
%{_sbindir}/update-alternatives --install %{_datadir}/xsessions/default.desktop \
  default-xsession.desktop %{_datadir}/xsessions/deepin.desktop 20

%postun
if [ ! -f %{_datadir}/xsessions/deepin.desktop ]; then
    %{_sbindir}/update-alternatives --remove default-xsession.desktop  \
      %{_datadir}/xsessions/deepin.desktop
fi

#%ifnarch s390 s390x
#%post wayland
#%{_sbindir}/update-alternatives --install %{_datadir}/wayland-sessions/default.desktop \
#  default-waylandsession.desktop %{_datadir}/wayland-sessions/dde-wayland.desktop 20

#%postun wayland
#[ -f %{_datadir}/wayland-sessions/dde-wayland.desktop ] || %{_sbindir}/update-alternatives \
#  --remove default-waylandsession.desktop %{_datadir}/wayland-sessions/dde-wayland.desktop
#%endif

%pre core
%systemd_user_pre dde-desktop.service
%systemd_user_pre dde-display.service
%systemd_user_pre dde-dock.service
%systemd_user_pre dde-keyring-checker.service
%systemd_user_pre dde-lock.service
%systemd_user_pre dde-login-reminder.service
%systemd_user_pre dde-osd.service
%systemd_user_pre dde-polkit-agent.service
%systemd_user_pre dde-session-exit-task.service
%systemd_user_pre dde-session-manager.service
%systemd_user_pre dde-session-shutdown.service
%systemd_user_pre dde-session@wayland.service
%systemd_user_pre dde-session@x11.service
%systemd_user_pre dde-version-checker.service
%systemd_user_pre dde-xsettings-checker.service

%post core
%systemd_user_post dde-desktop.service
%systemd_user_post dde-display.service
%systemd_user_post dde-dock.service
%systemd_user_post dde-keyring-checker.service
%systemd_user_post dde-lock.service
%systemd_user_post dde-login-reminder.service
%systemd_user_post dde-osd.service
%systemd_user_post dde-polkit-agent.service
%systemd_user_post dde-session-exit-task.service
%systemd_user_post dde-session-manager.service
%systemd_user_post dde-session-shutdown.service
%systemd_user_post dde-session@wayland.service
%systemd_user_post dde-session@x11.service
%systemd_user_post dde-version-checker.service
%systemd_user_post dde-xsettings-checker.service

%preun core
%systemd_user_preun dde-desktop.service
%systemd_user_preun dde-display.service
%systemd_user_preun dde-dock.service
%systemd_user_preun dde-keyring-checker.service
%systemd_user_preun dde-lock.service
%systemd_user_preun dde-login-reminder.service
%systemd_user_preun dde-osd.service
%systemd_user_preun dde-polkit-agent.service
%systemd_user_preun dde-session-exit-task.service
%systemd_user_preun dde-session-manager.service
%systemd_user_preun dde-session-shutdown.service
%systemd_user_preun dde-session@wayland.service
%systemd_user_preun dde-session@x11.service
%systemd_user_preun dde-version-checker.service
%systemd_user_preun dde-xsettings-checker.service

%postun core
%systemd_user_postun dde-desktop.service
%systemd_user_postun dde-display.service
%systemd_user_postun dde-dock.service
%systemd_user_postun dde-keyring-checker.service
%systemd_user_postun dde-lock.service
%systemd_user_postun dde-login-reminder.service
%systemd_user_postun dde-osd.service
%systemd_user_postun dde-polkit-agent.service
%systemd_user_postun dde-session-exit-task.service
%systemd_user_postun dde-session-manager.service
%systemd_user_postun dde-session-shutdown.service
%systemd_user_postun dde-session@wayland.service
%systemd_user_postun dde-session@x11.service
%systemd_user_postun dde-version-checker.service
%systemd_user_postun dde-xsettings-checker.service

%files
%doc README.md README.zh_CN.md
%license LICENSE
%{_libexecdir}/dde-session-ctl
%{_datadir}/dbus-1/services/org.deepin.dde.Session1.service
#%{_datadir}/xsessions/dde-x11.desktop
%{_datadir}/xsessions/default.desktop
%{_datadir}/xsessions/deepin.desktop
%ghost %{_sysconfdir}/alternatives/default-xsession.desktop
%ghost %{_sysconfdir}/alternatives/default.desktop
%config %{_sysconfdir}/profile.d/deepin-xdg-dir.sh
%dir %{_sysconfdir}/X11/Xsession.d
%config %{_sysconfdir}/X11/Xsession.d/00deepin-dde-env
%config %{_sysconfdir}/X11/Xsession.d/01deepin-profile
%config %{_sysconfdir}/X11/Xsession.d/97deepin-keyring-wb

#%ifnarch s390 s390x
#%files wayland
#%dir %{_datadir}/wayland-sessions
#%{_datadir}/wayland-sessions/dde-wayland.desktop
#%{_datadir}/wayland-sessions/default.desktop
#%ghost %{_sysconfdir}/alternatives/default-waylandsession.desktop
#%endif

%files core
%doc README.md README.zh_CN.md
%license LICENSE
%{_bindir}/dde-*
%{_userunitdir}/dde-*

%changelog
openSUSE Build Service is sponsored by