[1/2] macros: Add macro to automatically install all systemd sysusers files
Commit Message
This macros works very similar than the tmpfiles one but handles
sysusers files.
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
macros/systemd.macro | 10 ++++++++++
1 file changed, 10 insertions(+)
Comments
Hello Stefan,
> On 30 Mar 2023, at 07:52, Stefan Schantl <stefan.schantl@ipfire.org> wrote:
>
> This macros works very similar than the tmpfiles one but handles
> sysusers files.
>
> Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
> ---
> macros/systemd.macro | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/macros/systemd.macro b/macros/systemd.macro
> index 9dc74ff0..1453db95 100644
> --- a/macros/systemd.macro
> +++ b/macros/systemd.macro
> @@ -1,5 +1,6 @@
>
> SYSTEMD_TMPFILES_DIR = /usr/lib/tmpfiles.d
> +SYSTEMD_SYSUSERS_DIR = /usr/lib/sysusers.d
Is there a particular reason you are not using %{sysusersdir} here?
> MACRO_INSTALL_SYSTEMD_FILES
> for file in %{DIR_SOURCE}/systemd/*; do
> @@ -19,3 +20,12 @@ MACRO_INSTALL_SYSTEMD_TMPFILES
> done
> unset file
> end
> +
> +MACRO_INSTALL_SYSTEMD_SYSUSERS
> + for file in %{DIR_SOURCE}/*.sysusers; do
> + [ -e "${file}" ] || continue
> + mkdir -p %{BUILDROOT}/%{SYSTEMD_SYSUSERS_DIR}
> + cp -vf ${file} %{BUILDROOT}/%{SYSTEMD_SYSUSERS_DIR}/$(basename ${file%*.sysusers}).conf
> + done
> + unset file
> +end
Should the command not be “install” with a specific file mode set? Probably 0644?
> --
> 2.30.2
>
Hello Michael,
a big thanks for your feedback and thoughts.
> Hello Stefan,
>
> > On 30 Mar 2023, at 07:52, Stefan Schantl
> > <stefan.schantl@ipfire.org> wrote:
> >
> > This macros works very similar than the tmpfiles one but handles
> > sysusers files.
> >
> > Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
> > ---
> > macros/systemd.macro | 10 ++++++++++
> > 1 file changed, 10 insertions(+)
> >
> > diff --git a/macros/systemd.macro b/macros/systemd.macro
> > index 9dc74ff0..1453db95 100644
> > --- a/macros/systemd.macro
> > +++ b/macros/systemd.macro
> > @@ -1,5 +1,6 @@
> >
> > SYSTEMD_TMPFILES_DIR = /usr/lib/tmpfiles.d
> > +SYSTEMD_SYSUSERS_DIR = /usr/lib/sysusers.d
>
> Is there a particular reason you are not using %{sysusersdir} here?
I was not aware about, I can use this here. So yes you are absolutely
right in use %{sysusers} here again and avoid a dubble declaration of
the same stuff.
Thought one step ahead, then it would also good to use %{tmpfiles} ?
>
> > MACRO_INSTALL_SYSTEMD_FILES
> > for file in %{DIR_SOURCE}/systemd/*; do
> > @@ -19,3 +20,12 @@ MACRO_INSTALL_SYSTEMD_TMPFILES
> > done
> > unset file
> > end
> > +
> > +MACRO_INSTALL_SYSTEMD_SYSUSERS
> > + for file in %{DIR_SOURCE}/*.sysusers; do
> > + [ -e "${file}" ] || continue
> > + mkdir -p %{BUILDROOT}/%{SYSTEMD_SYSUSERS_DIR}
> > + cp -vf ${file} %{BUILDROOT}/%{SYSTEMD_SYSUSERS_DIR}/$(basename
> > ${file%*.sysusers}).conf
> > + done
> > + unset file
> > +end
>
> Should the command not be “install” with a specific file mode set?
> Probably 0644?
Yes, I'll switch that simple copy into an install command and specify
the correct permissions.
>
> > --
> > 2.30.2
> >
>
- Stefan
@@ -1,5 +1,6 @@
SYSTEMD_TMPFILES_DIR = /usr/lib/tmpfiles.d
+SYSTEMD_SYSUSERS_DIR = /usr/lib/sysusers.d
MACRO_INSTALL_SYSTEMD_FILES
for file in %{DIR_SOURCE}/systemd/*; do
@@ -19,3 +20,12 @@ MACRO_INSTALL_SYSTEMD_TMPFILES
done
unset file
end
+
+MACRO_INSTALL_SYSTEMD_SYSUSERS
+ for file in %{DIR_SOURCE}/*.sysusers; do
+ [ -e "${file}" ] || continue
+ mkdir -p %{BUILDROOT}/%{SYSTEMD_SYSUSERS_DIR}
+ cp -vf ${file} %{BUILDROOT}/%{SYSTEMD_SYSUSERS_DIR}/$(basename ${file%*.sysusers}).conf
+ done
+ unset file
+end