Backport patches to install systemd units to fix initialization races

- Fix minor spec formatting inconsistencies

Resolves: RHEL-79119

Signed-off-by: Neal Gompa <ngompa@centosproject.org>
This commit is contained in:
Neal Gompa 2025-02-17 08:14:42 -05:00
parent fdf3cf79cc
commit 92e70edf1d
3 changed files with 144 additions and 9 deletions

View File

@ -0,0 +1,57 @@
From 2a63d3f0ffb76135790bb1168a3270a599904380 Mon Sep 17 00:00:00 2001
From: David Redondo <kde@david-redondo.de>
Date: Tue, 20 Sep 2022 10:37:51 +0200
Subject: [PATCH 1/2] Add a systemd service to run xdg-user-dirs-update
Recently GNOME and Plasma have been embracing systemd for handling
their session startup. To enable autostart integration with this
systemd includes systemd-xdg-autostart-generator which creates units
from autostart desktop files. xdg-user-dirs installs such a desktop
file (xdg-user-dirs.desktop). However because this file contains
X-GNOME-Autostart-Phase=Initialization systemd will skip it since
it assumes it will be handles by GNOME itself. This a problem for
Plasma and other desktop environments that do not handle this
themselves, assuming that systemd takes care about autostart
xdg-user-dirs-update will not be run.
See https://github.com/systemd/systemd/issues/18791
We can provide a systemd service file to make sure xdg-user-dirs-update
is run during session startup. This ensures that the relevant
directories of the user exist on login and during startup as
specifying to be run before graphical-session-pre.target
means that it runs sufficiently early in the startup process while
using the generator would result in 'After=graphical-session.target'.
---
xdg-user-dirs.desktop | 1 +
xdg-user-dirs.service | 11 +++++++++++
2 files changed, 12 insertions(+)
create mode 100644 xdg-user-dirs.service
diff --git a/xdg-user-dirs.desktop b/xdg-user-dirs.desktop
index 6b969d4..b14a973 100644
--- a/xdg-user-dirs.desktop
+++ b/xdg-user-dirs.desktop
@@ -8,3 +8,4 @@ NoDisplay=true
X-GNOME-Autostart-Phase=Initialization
X-KDE-autostart-phase=1
+X-systemd-skip=true
diff --git a/xdg-user-dirs.service b/xdg-user-dirs.service
new file mode 100644
index 0000000..6795045
--- /dev/null
+++ b/xdg-user-dirs.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=User folders update
+Documentation=man:xdg-user-dirs-update(1)
+Before=graphical-session-pre.target
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/xdg-user-dirs-update
+
+[Install]
+WantedBy=graphical-session-pre.target
--
2.48.1

View File

@ -0,0 +1,51 @@
From 1512365de068446f8b5e14163601dd71e34e8bc1 Mon Sep 17 00:00:00 2001
From: David Redondo <kde@david-redondo.de>
Date: Thu, 9 Feb 2023 11:57:37 +0100
Subject: [PATCH 2/2] Install systemd service file
---
Makefile.am | 4 +++-
configure.ac | 5 +++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am
index f649564..81d9976 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,7 +14,7 @@ INCLUDES = \
$(NULL)
EXTRA_DIST= config.rpath translate.c autogen.sh \
- user-dirs.conf user-dirs.defaults xdg-user-dir xdg-user-dirs.desktop
+ user-dirs.conf user-dirs.defaults xdg-user-dir xdg-user-dirs.desktop xdg-user-dirs.service
xdgdir=$(sysconfdir)/xdg
xdg_DATA=user-dirs.conf user-dirs.defaults
@@ -22,6 +22,8 @@ xdg_DATA=user-dirs.conf user-dirs.defaults
xdgautostartdir=$(xdgdir)/autostart
xdgautostart_DATA = xdg-user-dirs.desktop
+systemduserunit_DATA = xdg-user-dirs.service
+
libraries = $(LIBINTL)
bin_PROGRAMS = \
diff --git a/configure.ac b/configure.ac
index 2cce082..dc389db 100644
--- a/configure.ac
+++ b/configure.ac
@@ -77,6 +77,11 @@ if test x$enable_documentation = xyes; then
fi
AM_CONDITIONAL(BUILD_DOCUMENTATION, test x$enable_documentation = xyes)
+PKG_CHECK_EXISTS([systemd],
+ [systemduserunitdir=$($PKG_CONFIG --variable=systemduserunitdir systemd)],
+ [systemduserunitdir='${prefix}/lib/systemd/user'])
+AC_SUBST(systemduserunitdir)
+
AC_OUTPUT([ po/Makefile.in
Makefile
man/Makefile
--
2.48.1

View File

@ -3,29 +3,40 @@
Name: xdg-user-dirs
Version: 0.18
Release: 6%{?dist}
Release: 7%{?dist}
Summary: Handles user special directories
License: GPL-2.0-or-later AND MIT
URL: https://freedesktop.org/wiki/Software/xdg-user-dirs
Source0: https://user-dirs.freedesktop.org/releases/%{name}-%{version}.tar.gz
BuildRequires: make
BuildRequires: gcc
BuildRequires: gettext
BuildRequires: docbook-style-xsl
BuildRequires: libxslt
Requires: %{_sysconfdir}/xdg/autostart
# Backports from upstream
Patch0001: 0001-Add-a-systemd-service-to-run-xdg-user-dirs-update.patch
Patch0002: 0002-Install-systemd-service-file.patch
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: make
BuildRequires: gcc
BuildRequires: gettext-devel
BuildRequires: git-core
BuildRequires: docbook-style-xsl
BuildRequires: libxslt
BuildRequires: systemd-rpm-macros
Requires: %{_sysconfdir}/xdg/autostart
%description
Contains xdg-user-dirs-update that updates folders in a users
homedirectory based on the defaults configured by the administrator.
%prep
%setup -q
%autosetup -S git_am
%conf
autoreconf -fiv
%configure
%build
%configure
%make_build
%install
@ -34,6 +45,16 @@ homedirectory based on the defaults configured by the administrator.
%find_lang %name
%post
%systemd_user_post xdg-user-dirs.service
%preun
%systemd_user_preun xdg-user-dirs.service
%postun
%systemd_user_postun_with_reload xdg-user-dirs.service
%files -f %{name}.lang
%license COPYING
%doc NEWS AUTHORS README
@ -43,9 +64,15 @@ homedirectory based on the defaults configured by the administrator.
%{_sysconfdir}/xdg/autostart/*
%{_mandir}/man1/*
%{_mandir}/man5/*
%{_userunitdir}/xdg-user-dirs.service
%changelog
* Mon Feb 17 2025 Neal Gompa <ngompa@centosproject.org> - 0.18-7
- Backport patches to install systemd units to fix initialization races
Resolves: RHEL-79119
- Fix minor spec formatting inconsistencies
* Tue Oct 29 2024 Troy Dawson <tdawson@redhat.com> - 0.18-6
- Bump release for October 2024 mass rebuild:
Resolves: RHEL-64018