[PATCHv2] macros: Add macro to automatically install any systemd sysusers files

Message ID 20230402165524.3814-1-stefan.schantl@ipfire.org
State New
Headers
Series [PATCHv2] macros: Add macro to automatically install any systemd sysusers files |

Commit Message

Stefan Schantl April 2, 2023, 4:55 p.m. UTC
  This macros works very similar than the tmpfiles one but handles
sysusers files.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 macros/build.macro   | 1 +
 macros/systemd.macro | 9 +++++++++
 2 files changed, 10 insertions(+)
  

Patch

diff --git a/macros/build.macro b/macros/build.macro
index 4eedd6a9..c19430a4 100644
--- a/macros/build.macro
+++ b/macros/build.macro
@@ -12,6 +12,7 @@  end
 def MACRO_INSTALL_FILES
 	%{MACRO_INSTALL_DEFAULT_FILES}
 	%{MACRO_INSTALL_SYSTEMD_FILES}
+	%{MACRO_INSTALL_SYSTEMD_SYSUSERS}
 	%{MACRO_INSTALL_SYSTEMD_TMPFILES}
 	%{MACRO_INSTALL_PAM_FILES}
 end
diff --git a/macros/systemd.macro b/macros/systemd.macro
index 085fabbd..7a40cff6 100644
--- a/macros/systemd.macro
+++ b/macros/systemd.macro
@@ -16,3 +16,12 @@  MACRO_INSTALL_SYSTEMD_TMPFILES
 	done
 	unset file
 end
+
+MACRO_INSTALL_SYSTEMD_SYSUSERS
+	for file in %{DIR_SOURCE}/*.sysusers; do
+		[ -e "${file}" ] || continue
+		mkdir -pv %{BUILDROOT}/%{sysusersdir}
+		install -v -m 0644 ${file} %{BUILDROOT}/%{sysusersdir}/$(basename ${file%*.sysusers}).conf
+	done
+	unset file
+end