Mailinglist Archive: opensuse-packaging (171 mails)

< Previous Next >
Re: [opensuse-packaging] Packaging policy for systemd .unit file - Proposal - Amended - migration
Le lundi 04 juillet 2011 à 14:17 +0200, Frederic Crozat a écrit :
Here is new version of the proposal I sent to systemd-devel some minutes
ago.

The big change is dropping %service_add_enabled : systemd folks doesn't
want to hardcode policy for a service as part of packagings and would
prefer some separate files to handle that (see
http://lists.freedesktop.org/archives/systemd-devel/2011-June/002755.html and
http://lists.freedesktop.org/archives/systemd-devel/2011-July/002801.html ).
Until this happens, I suggest we use "/bin/systemctl enable foobar.service
/dev/null 2>&1 || :" in specfiles.

Other changess :
-%service_* macros are expecting full unit name (sshd.service,
foobar.socket)
-%service_* macros accept several units files as parameters

(the various macros could be modified by distro if they also want to
support sysvinit service with the same macro, but it is outside the
scope of this initial proposal)

And here is a change, for handling sysvinit to systemd migration,
without relying on triggers :
- we use fedora systemd-sysv-convert script (which will be in systemd
package)
- %systemd_requires now contains, in addition : Requires(pre): systemd
- \
Requires(pre): systemd \
Requires(post): systemd \
Requires(preun): systemd \
Requires(postun): systemd \
- %service_migrate_to_systemd macro is replaced by :
%service_migrate_to_systemd_pre() \
test -n "$FIRST_ARG" || FIRST_ARG=$1 \
# disable migration if initial install under systemd \
if [ $FIRST_ARG -eq 1 ]; then \
for service in %{?*} ; do \
touch "/var/lib/systemd/migrated/$service" \
done \
else \
for service in %{?*} ; do \
if [ ! -e "/var/lib/systemd/migrated/$service" ]; then \
services_to_migrate="$services_to_migrate $service" \
fi \
done \
if [ -n "$services_to_migrate" ]; then \
/usr/sbin/systemd-sysv-convert --save $services_to_migrate
/dev/null 2>&1 || : \
fi \
fi

%service_migrate_to_systemd_post() \
for service in %{?*} ; do \
if [ ! -e "/var/lib/systemd/migrated/$service" ]; then \
services_to_migrate="$services_to_migrate $service" \
touch "/var/lib/systemd/migrated/$service" \
fi \
done \
if [ -n "$services_to_migrate" ]; then \
/usr/sbin/systemd-sysv-convert --apply $services_to_migrate >/dev/null
2>&1 || : \
/bin/systemctl daemon-reload >/dev/null 2>&1 || : \
fi


%service_migrate_to_systemd_postun() \
test -n "$FIRST_ARG" || FIRST_ARG=$1 \
if [ $FIRST_ARG -eq 0 ]; then \
for service in %{?*} ; do \
rm -f "/var/lib/systemd/migrated/$service" 2> /dev/null \
done \
fi

And usage is like this :
%pre
%service_migrate_to_systemd_pre foobar

%post
%service_migrate_to_systemd_post foobar
%service_add foobar.service

%preun
%service_del_preun foobar.service

%postun
%service_migrate_to_systemd_postun foobar
%service_del_postun foobar.service

Comments welcome (you can use package home:fcrozat:systemd:systemd which
contains the changes).
--
Frederic Crozat <fcrozat@xxxxxxxx>
SUSE

--
To unsubscribe, e-mail: opensuse-packaging+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-packaging+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups