From Fedora Project Wiki
(link to the guidelines now that the draft has been approved)
 
Line 1: Line 1:
When updating from a systemV to a systemd package, we "start-over fresh" with default start and stop policy from the package, not what the user had previously configured.  systemd provides a tool, <code>systemd-sysv-convert --apply</code>, to help do this conversion if the user wants after the package is updated.
{{admon/note|This page used to contain a draft packaging guidelines which has now been approved.}}


Scriptlets:
You can now find the current content at the following pages:
 
* [[Packaging:ScriptletSnippets#Systemd|Scriptlet snippets for systemd-enabled services]]
== Start over fresh ==
* [[Packaging:SysVInitScript#Initscripts_in_addition_to_systemd_unit_files|Scriptlets snippets for sysv initscripts in a subpackage]]
<pre>
 
# This is actually needed for the %triggerun script but Requires(triggerun)
# is not valid.  We can use %post because this particular %triggerun script
# should fire just after this package is installed.
Requires(post): systemd-sysv
 
### A sysv => systemd migration contains all of the same scriptlets as a
### systemd package.  These are additional scriptlets
 
# Note: the NEVR in trigger scripts should all be the version in
# which the package switched to systemd unit files and the comparision
# should be less than.  Using <= the last version with the sysV script won't
# work for several reasons:
# 1) disttag is different between Fedora releases
# 2) An update in an old Fedora release may create a newer NEVR
#    Note that this means an update in an older Fedora release must be NEVR
#    lower than this.  Freezing the version and release of the old package and
#    using a number after the disttag is one way to do this.  Example:
#       httpd-1.0-1%{?dist} => httpd-1.0-1%{?dist}.1
 
%triggerun -- httpd < 1.0-2
# Save the current service runlevel info
# User must manually run systemd-sysv-convert --apply httpd
# to migrate them to systemd targets
/usr/bin/systemd-sysv-convert --save httpd
 
# If the package is allowed to autostart:
/bin/systemctl enable apache-httpd.service >/dev/null 2>&1
 
# Run these because the SysV package being removed won't do them
/sbin/chkconfig --del httpd >/dev/null 2>&1 || :
/bin/systemctl try-restart apache-httpd.service >/dev/null 2>&1 || :
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
 
</pre>
 
{{admon/question||Be sure to test that the try-restart in the trigger restarts the daemon if it was running in a former sysv package and also does not enable a daemon if it wasn't running.  For other test cases, see my notes on the many variants that we have to test here: https://fedoraproject.org/wiki/User:Toshio/Testing_systemd}}
 
== Subpackage with sysv initscripts ==
<pre>
# If we're shipping sysvinit scripts
%triggerpostun -n httpd-sysvinit -- httpd < 1.0-2
/sbin/chkconfig --add httpd >/dev/null 2>&1 || :
</pre>

Latest revision as of 03:05, 21 June 2011

Note.png
This page used to contain a draft packaging guidelines which has now been approved.

You can now find the current content at the following pages: