[systemd-devel] System units packaging and rpmlint

Michael Scherer misc at zarb.org
Sat May 18 14:44:48 PDT 2013


Hi,

After the last discussion on fedora-devel about boot times[1], I have
been looking at the various units on my disk and if I could code
something in rpmlint ( tool to verify a rpm against a set of guidelines
) to have packagers follow some best practices.

So I have been writing various checks that emit Warning/Errors, and
would like to get some feedback on a few assumption I made when writing
the checks :

- pid file should be in /run, or in a subdirectory of /run
I have seen a few service who still use /var/run, but can I safely
assume that anything booting with systemd would have /run?
(and so warn if something is using /run for that) 

- unit file should be in %_unitdir, which is on /usr/lib for
distribution with merged /usr ( at least, on Fedora and Mageia )

So I planned to warn if the unit are directly in /lib, but I know there
is some distribution that didn't choose this path yet. So when /usr is
not merged, what is the canonical location ( ie, for Opensuse, Mandriva,
since they are both rpm based ) ?


- we should avoid as much as possible to use Type=forking when we can
avoid it. 

This one is likely the one that will be met with resistance from
packagers, so before adding it as warning, I would like to be sure that
I am not totally wrong.

A standard daemon will fork ( likely twice ) in the background,  do
various stuff and then write the pidfile on /run. 

By not going in the background, we can :
- avoid forking 1 or 2 times for nothing,
- avoid taking memory for /run, and avoid taking a inode

So that's should be a little bit better in most case, or do I miss
anything ?
( ie, something like "this is so negligible that we shouldn't care" )

If there is other good argument to add in the explanation of the error,
that would help to convince the users.


- if using Type=forking, it is better to use PIDFile, 
While systemd seems to support fine to guess the main pid, I think this
should be avoided when possible , according to
http://lists.freedesktop.org/archives/systemd-devel/2011-June/002690.html . 
So does it make sense to send a warning if there is a service that do
not use PIDFile and of type Forking ?

- some package install directly file in /usr/lib/systemd/system/*.wants
There is some special case ( like plymouth ), but usually, that
shouldn't be done directly in the package, but better done in %post, and
in /etc ?

IE, is this right to make a warning or a error when that occurs ?


I was also interested into checking the syntax of systemd file, but
since systemd is moving quite fast, I doubt to be able to keep a up to
date parser of unit/service/timer/snapshot files. And duplicating code
of systemd in python do not seems like a smart move. 

I didn't found any way to reuse systemd code, but I think that a tool
like desktop-file-validate would be quite useful for all distributions.


[1] http://lists.fedoraproject.org/pipermail/devel/2013-May/182697.html

-- 
Michael Scherer



More information about the systemd-devel mailing list