[Mageia-dev] Adding tmpfiles.d support to packages (was: Re: rpmlint)

Colin Guthrie mageia at colin.guthr.ie
Thu Nov 22 11:20:21 CET 2012

'Twas brillig, and Remco Rijnders at 22/11/12 08:17 did gyre and gimble:
> On Wed, Nov 21, 2012 at 11:43:24PM +0000, Colin wrote in
> <50AD671C.2060409 at colin.guthr.ie>:
>> So I've added a few tests to rpmlint for stuff previously discussed.
>> I'm aware of lots of packages that will fail but will try and fix them
>> over the weekend.
>> If anyone wants to help with the "known-to-break" list, please fix up
>> the following packages to add tmpfiles support rather than shipping the
>> actual files/folders:
> Colin,
> You'll probably be tired of repeating yourself over and over, but do you
> have a few pointers (maybe on the packaging wiki?), what to change and
> where? Is it a general approach for all packages, if so perhaps point to
> a commit on SVN having the needed changes for a package?

I should write up a wiki page, but here is the details:

1. Add a file like: %{name}-tmpfiles.conf to the SOURCES tree containing:

 D /run/my-package 0710 my-user my-group -

(this will create a folder call /run/my-package owned by
my-user:my-group in /run. You should likely use /run or /run/lock
directly rather than /var/run or /var/lock which are just symlinks to that).

You can also create files, links, named pipes etc. too. See "man
tmpfiles.d" for full syntax.

2. Add the source to the SPEC:
 SourceN:        %{name}-tmpfiles.conf

3. Install the tmpfile snippet:

 # create tmpfiles directory
 install -d -m0755 %{buildroot}%{_prefix}/lib/tmpfiles.d
 install -m0644 %{SOURCEN}

Make sure it's included in the %files section too:

4. Add Requires:
 Requires(post): systemd

5. Add/add to %post:

 systemd-tmpfiles --create %{name}.conf

(note, passing in the file basename here is very important! Don't just
run "systemd-tmpfiles --create" as it has unexpected consequences!)

That's about it.

We could go around %ghosting the files created, but to be perfectly
honest, I don't think it's worth the effort. Files in /run should be
considered generally volatile and they should all be pretty self
explanatory generally IMO.




Colin Guthrie

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/

More information about the Mageia-dev mailing list