#948 %{_unitdir} directory ownership
Opened 2 months ago by ppisar. Modified 2 months ago

I find unclear whether a package that installs a unit file into %{_unitdir} path should run-require systemd. Technically the package or some of its dependencies must own the directory.

But various documentation either implicitly discourages from run-requiring systemd https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_dependencies_on_the_systemd_package

The %systemd_requires macro is a shortcut to require systemd for the %pre, %post, and %postun scriptlets. Note that those dependencies are not required for the %systemd_{post,preun,postun_with_restart,user_post,user_preun} macros listed above.

or does not mention it all https://docs.fedoraproject.org/en-US/packaging-guidelines/Systemd/#_packaging.

Nowadays unit files are reloaded and services restarted by systemd file triggers. Also container people do not like systemd in a container. That's maybe the reason why the guidelines do not explicitly state "run-require systemd package".

If we really do no want to run-require systemd, we should amend https://docs.fedoraproject.org/en-US/packaging-guidelines/Systemd/#_files_section to hint packagers not to forget on owning the directory. But the problem is that owning %{_unitdir} directory is not enough as we need also to own the parent directory:

root@fedora-32:~ # rpm -qf /usr/lib/systemd/system
systemd-244.1-2.fc32.x86_64
root@fedora-32:~ # rpm -qf /usr/lib/systemd
systemd-244.1-2.fc32.x86_64
root@fedora-32:~ # rpm -qf /usr/lib
filesystem-3.14-2.fc32.x86_64

I think systemd-rpm-macros could provide a new macro that packagers would past into a %files section to own the directories properly. Like this:

%files
%{_unitdirs}
%{_unitdir}/%{name}.service


Login to comment on this ticket.

Metadata