On Mon, Nov 29, 2010 at 12:21:08PM -0500, Paul Wouters wrote:
On Wed, 24 Nov 2010, Toshio Kuratomi wrote:
>>> And when are the files and dirs created? Only when the system is
>>> booted?
>>
>> Yes.
>>
>>> But then after installing an package that requires files to be created
>>> by tmpfiles.d the system needs to be rebooted before it can be used. Or
>>> will rpm call something that parses the appropriate tmpfiles.d file when
>>> the package is installed / updated?
>>
>> Hmm, it has been suggested that we should make it possible to create
>> these dirs in the .spec files by invoking the systemd-tmpfiles tool
>> directly from the scriptlets. I guess we should add a nice interface for
>> that. In the meantime it should be sufficient to simply place th right
>> "mkdir -p -m ..." in the scriptlet. Of course it would be desirable
if
>> we have a single place where the dirs to create are encoded.
>>
> A question I'd have when looking over a proposed packaging guideline would
> be: why %ghost the directories? Why not include the directories as normal
> but add the tmpfiles.d step in addition?
So with all of this, as a package maintainer, I will have to make sure the
dirs exist in the init scripts anyway. In which case one can wonder why
bothering with tmpfiles.d files (or %ghost). Just to cleanup a volatile directory in
case a package is uninstalled after start?
There's a few different things we'd like to achieve:
* after a reboot, the application is able to startup and write to a directory
in /var/run and/or /var/lock.
* The sysadmin would like to be able to see who owns the directories and
lock files in /var/run and/or /var/lock so rpm -qf /var/run/foo/ should
tell them that.
corner cases:
* After installation but before reboot, the application is able to startup
and write to a directory in /var/run and/or /var/lock
* After removal but before reboot, the directories that aren't needed are
cleaned up from /var/run and /var/lock
The first of these corner cases is much more important than the second of
them.
So with all this, we know a few things:
1) The rpm metadata has to carry information about the directories (and
should for files as well) inside of /var/run and /var/lock. To me we should
just put the directories in per normal and %ghost any files (which is what
we should be doing already but probably aren't always).
2) The act of installing the rpm should create the necessary directories.
Alternately, the program (or as you say, the init script) can create the
necessary directories. Note that I don't believe that systemd gives you the
flexibility to do that sort of thing (there's no "script" in its init
stuff)
so you'd need a wrapper script for the program itself or write a patch to
the program itself to achieve this where the program doesn't create the
directory already and if we don't do this from within the rpm payload.
3) We have to use tmpfiles.d to create the directories on reboot.
Of these, only %ghosting of files (not directories) is only about cleaning
up the directories. The rest can cause the service to fail to startup.
-Toshio