[opensuse-packaging] ANNOUNCE: systemd service packaging
Hi everyone, I just finished merging the migration macros into the "main" systemd macros, so here is the final result for macros (see file attached). Usage would be like this (it will be hard to put macros in the wrong section ;) : Add : %systemd_requires and if you are compiling your package for old distributions : %if 0%{suse_version} <= 1140 %define systemd_requires %{nil} %endif for scripts : %post %service_add_pre demo.service demo1.service %post %service_add_post demo.service demo1.service %preun %service_del_preun demo.service demo1.service %postun %service_del_postun demo.service demo1.servoce Please note those macros are "systemd preset" aware (this was discussed on this mailing list in july) : you don't need to enable a service in % post : if it is specified in the default preset policy as "enabled by default", it will be handled automatically. These defaults will be in systemd-default-presets package (not yet created, probably tomorrow). -- Frederic Crozat <fcrozat@suse.com> SUSE # RPM macros for packages installing systemd unit files # ### # # When a package install systemd unit files, it should use the following macros: # # add %systemd_requires in the specfile # # %post # %service_add_pre demo.service demo1.service # # %post # %service_add_post demo.service demo1.service # # %preun # %service_del_preun demo.service # # %postun # %service_del_postun demo.service # ### # This is for /bin/systemctl %systemd_requires \ Requires(pre): systemd \ Requires(post): systemd \ Requires(preun): systemd \ Requires(postun): systemd \ %_unitdir /lib/systemd/system %service_add_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 \ sysv_service=`echo $service | sed -e 's/\\.[a-z]*//g'` \ touch "/var/lib/systemd/migrated/$sysv_service" \ done \ else \ for service in %{?*} ; do \ sysv_service=`echo $service | sed -e 's/\\.[a-z]*//g'` \ if [ ! -e "/var/lib/systemd/migrated/$sysv_service" ]; then \ services_to_migrate="$services_to_migrate $sysv_service" \ fi \ done \ if [ -n "$services_to_migrate" ]; then \ /usr/sbin/systemd-sysv-convert --save $services_to_migrate >/dev/null 2>&1 || : \ fi \ fi \ %{nil} # On install, tell systemd to reload its unit files %service_add_post() \ test -n "$FIRST_ARG" || FIRST_ARG=$1 \ for service in %{?*} ; do \ sysv_service=`echo $service | sed -e 's/\\.[a-z]*//g'` \ if [ ! -e "/var/lib/systemd/migrated/$sysv_service" ]; then \ services_to_migrate="$services_to_migrate $sysv_service" \ touch "/var/lib/systemd/migrated/$sysv_service" \ fi \ done \ if [ -n "$services_to_migrate" ]; then \ /usr/sbin/systemd-sysv-convert --apply $services_to_migrate >/dev/null 2>&1 || : \ fi \ /bin/systemctl daemon-reload >/dev/null 2>&1 || : \ /bin/systemctl preset %{?*} >/dev/null 2>&1 || : \ %{nil} # On uninstall, disable and stop services %service_del_preun() \ test -n "$FIRST_ARG" || FIRST_ARG=$1 \ if [ $FIRST_ARG -eq 0 ]; then \ # Package removal, not upgrade \ /bin/systemctl --no-reload disable %{?*} > /dev/null 2>&1 || : \ /bin/systemctl stop %{?*} > /dev/null 2>&1 || : \ fi \ %{nil} # On uninstall, tell systemd to reload its unit files %service_del_postun() \ test -n "$FIRST_ARG" || FIRST_ARG=$1 \ if [ $FIRST_ARG -ge 1 ]; then \ # Package upgrade, not uninstall \ /bin/systemctl try-restart %{?*} >/dev/null 2>&1 || : \ else # package uninstall \ for service in %{?*} ; do \ sysv_service=`echo $service | sed -e 's/\\.[a-z]*//g'` \ rm -f "/var/lib/systemd/migrated/$sysv_service" 2> /dev/null \ done \ /bin/systemctl daemon-reload >/dev/null 2>&1 || : \ fi \ %{nil}
Hi, Le lundi 26 septembre 2011, à 17:35 +0200, Frederic Crozat a écrit :
Hi everyone,
I just finished merging the migration macros into the "main" systemd macros, so here is the final result for macros (see file attached).
Usage would be like this (it will be hard to put macros in the wrong section ;) :
Add : %systemd_requires
and if you are compiling your package for old distributions : %if 0%{suse_version} <= 1140 %define systemd_requires %{nil} %endif
for scripts : %post %service_add_pre demo.service demo1.service
I guess you mean %pre ;-)
%post %service_add_post demo.service demo1.service
%preun %service_del_preun demo.service demo1.service
%postun %service_del_postun demo.service demo1.servoce
Please note those macros are "systemd preset" aware (this was discussed on this mailing list in july) : you don't need to enable a service in % post : if it is specified in the default preset policy as "enabled by default", it will be handled automatically.
These defaults will be in systemd-default-presets package (not yet created, probably tomorrow).
I suggest to call the package systemd-branding-openSUSE, since it'll be the default configuration for openSUSE, and openSUSE derivatives might want to change this easily without tweaking our packages. Cheers, Vincent -- Les gens heureux ne sont pas pressés. -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
Le lundi 26 septembre 2011 à 17:58 +0200, Vincent Untz a écrit :
Hi,
Le lundi 26 septembre 2011, à 17:35 +0200, Frederic Crozat a écrit :
Hi everyone,
I just finished merging the migration macros into the "main" systemd macros, so here is the final result for macros (see file attached).
Usage would be like this (it will be hard to put macros in the wrong section ;) :
Add : %systemd_requires
and if you are compiling your package for old distributions : %if 0%{suse_version} <= 1140 %define systemd_requires %{nil} %endif
for scripts : %post %service_add_pre demo.service demo1.service
I guess you mean %pre ;-)
Yes, fixed..
%post %service_add_post demo.service demo1.service
%preun %service_del_preun demo.service demo1.service
%postun %service_del_postun demo.service demo1.servoce
Please note those macros are "systemd preset" aware (this was discussed on this mailing list in july) : you don't need to enable a service in % post : if it is specified in the default preset policy as "enabled by default", it will be handled automatically.
These defaults will be in systemd-default-presets package (not yet created, probably tomorrow).
I suggest to call the package systemd-branding-openSUSE, since it'll be the default configuration for openSUSE, and openSUSE derivatives might want to change this easily without tweaking our packages.
Except it is not "branding" but presets (like polkit-default-privs). But I'm using "Supplements" so we don't want to enforce "this" particular package.. -- Frederic Crozat <fcrozat@suse.com> SUSE -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
Le lundi 26 septembre 2011, à 18:17 +0200, Frederic Crozat a écrit :
Le lundi 26 septembre 2011 à 17:58 +0200, Vincent Untz a écrit :
Le lundi 26 septembre 2011, à 17:35 +0200, Frederic Crozat a écrit :
These defaults will be in systemd-default-presets package (not yet created, probably tomorrow).
I suggest to call the package systemd-branding-openSUSE, since it'll be the default configuration for openSUSE, and openSUSE derivatives might want to change this easily without tweaking our packages.
Except it is not "branding" but presets (like polkit-default-privs).
Right, but using the branding mechanism to define default configuration is a nice way to do that kind of thing. My point is really that it makes life easier for derivatives. Cheers, Vincent -- Les gens heureux ne sont pas pressés. -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
On Monday 2011-09-26 17:35, Frederic Crozat wrote:
%service_add_pre() \ test -n "$FIRST_ARG" || FIRST_ARG=$1 \ # disable migration if initial install under systemd \ if [ $FIRST_ARG -eq 1 ]; then \
Why not just directly use $1 in the test?
for service in %{?*} ; do \ sysv_service=`echo $service | sed -e 's/\\.[a-z]*//g'` \
What is it that is being stripped here? \.[a-z]* looks like it can wreak havoc all over the string. I guess something like this goes faster: sysv_service="$service"; sysv_service="${service%.service}"; sysv_service="${service%.unit}"; if not, $service should at least be quoted. -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
Le lundi 26 septembre 2011 à 18:52 +0200, Jan Engelhardt a écrit :
On Monday 2011-09-26 17:35, Frederic Crozat wrote:
%service_add_pre() \ test -n "$FIRST_ARG" || FIRST_ARG=$1 \ # disable migration if initial install under systemd \ if [ $FIRST_ARG -eq 1 ]; then \
Why not just directly use $1 in the test?
Because I use similar techniques which are already used in % restart_on_update and other SUSE macros.
for service in %{?*} ; do \ sysv_service=`echo $service | sed -e 's/\\.[a-z]*//g'` \
What is it that is being stripped here? \.[a-z]* looks like it can wreak havoc all over the string. I guess something like this goes faster:
sysv_service="$service"; sysv_service="${service%.service}"; sysv_service="${service%.unit}";
Except I don't want to list all possible extensions units might have.
if not, $service should at least be quoted.
Not sure I'm following you here.. PS: no need to CC me.. -- Frederic Crozat <fcrozat@suse.com> SUSE -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
On Monday 2011-09-26 19:03, Frederic Crozat wrote:
sysv_service=`echo $service | sed -e 's/\\.[a-z]*//g'` \
What is it that is being stripped here? \.[a-z]* looks like it can wreak havoc all over the string. I guess something like this goes faster:
sysv_service="$service"; sysv_service="${service%.service}"; sysv_service="${service%.unit}";
Except I don't want to list all possible extensions units might have.
Well it does not just strip extensions, it strips everything after a dot: java1.6start.service Well, might just as well do "${x%.*}";
if not, $service should at least be quoted.
Not sure I'm following you here..
- sysv_service=`echo $service | sed -e 's/\\.[a-z]*//g'` \ + sysv_service=$(echo "$service" | sed -e 's/\\.[a-z]*//g') \
PS: no need to CC me..
standard MUA procedure for lists. -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
Le lundi 26 septembre 2011 à 19:21 +0200, Jan Engelhardt a écrit :
On Monday 2011-09-26 19:03, Frederic Crozat wrote:
sysv_service=`echo $service | sed -e 's/\\.[a-z]*//g'` \
What is it that is being stripped here? \.[a-z]* looks like it can wreak havoc all over the string. I guess something like this goes faster:
sysv_service="$service"; sysv_service="${service%.service}"; sysv_service="${service%.unit}";
Except I don't want to list all possible extensions units might have.
Well it does not just strip extensions, it strips everything after a dot: java1.6start.service
Well, might just as well do "${x%.*}";
Thanks, I'll do that.
if not, $service should at least be quoted.
Not sure I'm following you here..
- sysv_service=`echo $service | sed -e 's/\\.[a-z]*//g'` \ + sysv_service=$(echo "$service" | sed -e 's/\\.[a-z]*//g') \
Ok, with above change, this is no longer needed. -- Frederic Crozat <fcrozat@suse.com> SUSE -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
On Mon, 26 Sep 2011 19:03, Frederic Crozat <fcrozat@...> wrote:
Le lundi 26 septembre 2011 à 18:52 +0200, Jan Engelhardt a écrit :
On Monday 2011-09-26 17:35, Frederic Crozat wrote: <snip>
for service in %{?*} ; do \ sysv_service=`echo $service | sed -e 's/\\.[a-z]*//g'` \
What is it that is being stripped here? \.[a-z]* looks like it can wreak havoc all over the string. I guess something like this goes faster:
sysv_service="$service"; sysv_service="${service%.service}"; sysv_service="${service%.unit}";
Except I don't want to list all possible extensions units might have.
if not, $service should at least be quoted.
Not sure I'm following you here..
Hmm, I'm not a regex-guru, but think about adding a '$' sysv_service=`echo $service | sed -e 's/\\.[a-z]*$//g'` to make sure only the end of the string is cut. If you make this (the scripts) a extra package, a added "-branding" would be wrong, maybe a systemd-presets-<DISTRO> ? openSUSE would be systemd-presets-openSUSE and systemd-presets-SLE, RedHat could add systemd-presets-fedora and systemd-presets-RHEL, Ubuntu would be systemd-presets-ubuntu and so on. That way the real presets / defaults (default service on /off), and the distro diverse handling scripts could be handled in a transparent and easy to manage way (future updates, changes, ...) Just my 2 ct, and yes a cul-de-sac / blind alley in maintainance is ugly, let think and talk with the other distro's for a common nameing scheme beforehand. Cheers, Yamaban.
Le lundi 26 septembre 2011 à 19:21 +0200, Yamaban a écrit :
On Mon, 26 Sep 2011 19:03, Frederic Crozat <fcrozat@...> wrote:
Le lundi 26 septembre 2011 à 18:52 +0200, Jan Engelhardt a écrit :
On Monday 2011-09-26 17:35, Frederic Crozat wrote: <snip>
for service in %{?*} ; do \ sysv_service=`echo $service | sed -e 's/\\.[a-z]*//g'` \
What is it that is being stripped here? \.[a-z]* looks like it can wreak havoc all over the string. I guess something like this goes faster:
sysv_service="$service"; sysv_service="${service%.service}"; sysv_service="${service%.unit}";
Except I don't want to list all possible extensions units might have.
if not, $service should at least be quoted.
Not sure I'm following you here..
Hmm, I'm not a regex-guru, but think about adding a '$' sysv_service=`echo $service | sed -e 's/\\.[a-z]*$//g'` to make sure only the end of the string is cut.
If you make this (the scripts) a extra package, a added "-branding" would be wrong, maybe a systemd-presets-<DISTRO> ? openSUSE would be systemd-presets-openSUSE and systemd-presets-SLE, RedHat could add systemd-presets-fedora and systemd-presets-RHEL, Ubuntu would be systemd-presets-ubuntu and so on.
After discussing with Vincent on IRC, I'll switch the presets package to "systemd-presets-branding-openSUSE" to follow the branding scheme we use in the distro. -- Frederic Crozat <fcrozat@suse.com> SUSE -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
Am Dienstag, 27. September 2011 schrieb Frederic Crozat:
After discussing with Vincent on IRC, I'll switch the presets package to "systemd-presets-branding-openSUSE" to follow the branding scheme we use in the distro.
What kind of branding do you want to put in there? I thought this is about policies? Greetings, Stephan -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
Le mardi 27 septembre 2011 à 10:22 +0200, Stephan Kulow a écrit :
Am Dienstag, 27. September 2011 schrieb Frederic Crozat:
After discussing with Vincent on IRC, I'll switch the presets package to "systemd-presets-branding-openSUSE" to follow the branding scheme we use in the distro.
What kind of branding do you want to put in there? I thought this is about policies?
just the name ;) I've been told it would be better to follow "*-branding-openSUSE", so distro derivatives would "find" what we need to change more easily.. Right now, the default presets is : enable acpid.service enable NetworkManager.service disable * -- Frederic Crozat <fcrozat@suse.com> SUSE -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
On 09/26/2011 05:35 PM, Frederic Crozat wrote:
Add : %systemd_requires
and if you are compiling your package for old distributions : %if 0%{suse_version} <= 1140 %define systemd_requires %{nil} %endif
I guess %{?systemd_requires} works as well and sorts the problem with all distributions not having the macro defined, not just openSUSE 11.4 and older. -- Best Regards / S pozdravom, Pavol RUSNAK SUSE LINUX, s.r.o openSUSE Boosters Team Lihovarska 1060/12 PGP 0xA6917144 19000 Praha 9 prusnak[at]opensuse.org Czech Republic -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
Le mardi 27 septembre 2011 à 12:41 +0200, Pavol Rusnak a écrit :
On 09/26/2011 05:35 PM, Frederic Crozat wrote:
Add : %systemd_requires
and if you are compiling your package for old distributions : %if 0%{suse_version} <= 1140 %define systemd_requires %{nil} %endif
I guess %{?systemd_requires} works as well and sorts the problem with all distributions not having the macro defined, not just openSUSE 11.4 and older.
Indeed. Thanks, RPM master ;) -- Frederic Crozat <fcrozat@suse.com> SUSE -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
participants (6)
-
Frederic Crozat
-
Jan Engelhardt
-
Pavol Rusnak
-
Stephan Kulow
-
Vincent Untz
-
Yamaban