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-Tag: 0.9.29~202 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6c7b281781261c6ec7610b692a9b5ba099b5088;p=pakfire.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 Signed-off-by: Michael Tremer --- diff --git a/macros/build.macro b/macros/build.macro index c19430a42..e80301ac2 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 7a40cff64..e8a66ee30 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