From: Stefan Schantl Date: Sat, 1 Apr 2023 08:20:34 +0000 (+0200) Subject: macros: Add macro to apply sysusers based users/groups inside the jail X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fsystemd-sysusers;p=people%2Fstevee%2Fpakfire.git macros: Add macro to apply sysusers based users/groups inside the jail This macro can be called inside a build file and easily allows to apply any kind of users/groups specified in a sysusers file. Signed-off-by: Stefan Schantl --- diff --git a/macros/build.macro b/macros/build.macro index c19430a4..e80301ac 100644 --- a/macros/build.macro +++ b/macros/build.macro @@ -243,6 +243,8 @@ build # Install %{make_install} + %{MACRO_APPLY_SYSTEMD_SYSUSERS} + # Run custom commands %{install_cmds} end diff --git a/macros/systemd.macro b/macros/systemd.macro index 7a40cff6..e8a66ee3 100644 --- a/macros/systemd.macro +++ b/macros/systemd.macro @@ -1,3 +1,20 @@ +build + export APPLY_SYSUSERS_FILE= + + MACRO_APPLY_SYSTEMD_SYSUSERS + if [ -n "$APPLY_SYSUSERS_FILE" ] && [ -x "$(command -v systemd-sysusers)" ]; then + mkdir -pv %{sysusersdir} + + for file in ${APPLY_SYSUSERS_FILE}; do + [ -e "${file}" ] || continue + cat ${file} | \ + systemd-sysusers --replace=%{sysusersdir}/$(basename ${file%*.*}).conf - + done + unset file + fi + end +end + MACRO_INSTALL_SYSTEMD_FILES for file in %{DIR_SOURCE}/systemd/*; do [ -e "${file}" ] || continue