`+PERM+` are the permissions (in the 4-digit octal format) to apply to the directory when it is created.
Properly labelling the created directories is done automatically by the tmpfiles.d mechanism but would have to be manually done by the init script.
`+/run/NAME+` is the filesystem path to create.
Since the init script is run by root, before the daemon drops privileges, why not create the directories there?
`+-+` specifies that aging should not be applied to the contents of the directory. Aging is a mechanism for automated cleanup of files that were not used for a specified length of time. This is mostly useful for directories such as /tmp and is seldom used by packages. Feel free to use aging if it is appropriate for your directory.
The format of the line is as follows:
There are multiple ways to try creating the directories but most suffer some disadvantage that tmpfiles.d addresses:
This code would need to be implemented in every init script packaged. Using tmpfiles.d we can cut down on the number of places we have to put code like this.
# This may not be needed if the upstream's install script creates the directories
# Make sure permissions are correct
install -d -m 0755 %{buildroot}/run/%{name}/
tmpfiles.d configuration
# tmpfiles.d configuration for the /run directory
Source1: %{name}-tmpfiles.conf
`+%{_tmpfilesdir}+` expands to `+%{_prefix}/lib/tmpfiles.d+` which is the location that the package's default tmpfile creation scripts should install into. `+%{_tmpfilesdir}/%{name}.conf+` is *not* marked as a `+%config+` file because it is not supposed to be edited by administrators. Administrators can override the package's `+%{name}.conf+` by placing an identically named file in `+/etc/tmpfiles.d/+`, but this should very rarely be needed.
tmpfiles.d is a service for managing temporary files and runtime directories for daemons. In this guideline we mainly concentrate on how it is used to populate `+/run+` and `+/run/lock+`. Since `+/run+` is a `+tmpfs+` filesystem, it and its contents must be recreated on every reboot. For files intended to be created there, this should normally not pose any problems. However, directories will often need to be created ahead of time. This is best done using the tmpfiles.d mechanism.
`+USER+` is the name of the owner of the directory.
Why not create the directories with XXXXXX instead?