openSUSE:Systemd packaging guidelines

Ga naar: navigatie, zoeken
Systemd gebruiken - Systemd-status - Systemd beheren - Richtlijnen voor het maken van pakketten met systemd
Dit artikel beschrijft richtlijnen voor het maken van pakketten met gerbruik van de systemd-services

RPM macros

Dit artikel is nog maar gedeeltelijk vertaald. Als u mee wilt helpen met vertalen lees dan Wiki vertalen naar het Nederlands.

Starting with openSUSE 12.1, several RPM macros must be used to package systemd services files

Build Requirement

You should add :

%if 0%{?suse_version} >= 1210
BuildRequires: systemd
%endif

as Build Requires.

Requires

Add

%{?systemd_requires}

to ensure the needed dependencies are added to your package

Service files

Service files should always be installed in %_unitdir (ie /lib/systemd/system) and never in /etc/systemd/system (so they can be overriden by users without conflicting with packaging).

Register services in install scripts

add the following macros to your scripts :

if foo.service bar.service are two systemd services you are installing :

%pre
%service_add_pre foo.service bar.service

%post
%service_add_post foo.service bar.service

%preun
%service_del_preun foo.service bar.service

%postun
%service_del_postun foo.service bar.service

If your package is also providing sysv initscripts, those macros will handle sysv initscripts migration transparently (as long as initscripts and systemd services have similar names)

If your package is supposed to build for openSUSE older than 12.1, you should use condition test for those macros.

Enabling service

By default, services are not enabled when package is installed. If you want your service to be enabled by default, you should do a submit request (with OBS) on systemd-presets-branding-openSUSE package, modifying default-openSUSE.preset file by adding :

enable your_service_name.service