[opensuse-packaging] Packaging policy for systemd .unit file
Hi all,
as part of systemd integration in openSUSE, Michal suggested we might
want to create our own openSUSE policy for packaging systemd .unit file,
similar to Fedora policy
http://fedoraproject.org/wiki/Packaging:Systemd , moreover the
scriptlets part :
http://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Systemd
However, I'm not sure we should directly add those direct call to
systemctl in %post but instead, use some macros, similar to the one we
have for sysvinit and / or update those macros to be systemd compliant :
%stop_on_removal / %insserv_force_if_yast / %{fillup_only} / %
restart_on_update / etc..
Opinions ?
--
Frederic Crozat
Hey, Le mercredi 15 juin 2011, à 18:57 +0200, Frederic Crozat a écrit :
However, I'm not sure we should directly add those direct call to systemctl in %post but instead, use some macros, similar to the one we have for sysvinit and / or update those macros to be systemd compliant : %stop_on_removal / %insserv_force_if_yast / %{fillup_only} / % restart_on_update / etc..
+1 for macros. I don't think it's worth trying to update the macros; adding new ones should work well enough -- especially as there's a new file to package anyway, so people will notice there's something to do. 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
Vincent Untz wrote:
Hey,
Le mercredi 15 juin 2011, à 18:57 +0200, Frederic Crozat a écrit :
However, I'm not sure we should directly add those direct call to systemctl in %post but instead, use some macros, similar to the one we have for sysvinit and / or update those macros to be systemd compliant : %stop_on_removal / %insserv_force_if_yast / %{fillup_only} / % restart_on_update / etc..
+1 for macros. I don't think it's worth trying to update the macros; adding new ones should work well enough -- especially as there's a new file to package anyway, so people will notice there's something to do.
systemd unit files are usually named the same as the init scripts though. So adding some code that transparently handles both the init script and systemd files should be no problem. Note that there already %service_add, %service_del_preun and %service_del_postun. So you can use those instead of %fillup_and_insserv&co to make the .spec file look more modern :-) cu Ludwig -- (o_ Ludwig Nussel //\ V_/_ http://www.suse.de/ SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
On 16/06/11 09:28, Vincent Untz wrote:
Le mercredi 15 juin 2011, à 18:57 +0200, Frederic Crozat a écrit :
However, I'm not sure we should directly add those direct call to systemctl in %post but instead, use some macros, similar to the one we have for sysvinit and / or update those macros to be systemd compliant : %stop_on_removal / %insserv_force_if_yast / %{fillup_only} / % restart_on_update / etc..
+1 for macros. I don't think it's worth trying to update the macros; adding new ones should work well enough -- especially as there's a new file to package anyway, so people will notice there's something to do.
Please, this is an opportunity to unify services packaging across all RPM distros. Please, don't screw up by introducing any new SUSE specific macros. We can talk with Fedora and Mageia at least to come up with one solution that is OK with everyone and has the highest chance of being adopted in upstream RPM. -- 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
On Thursday, June 16, 2011 11:51:29 AM Pavol Rusnak wrote:
On 16/06/11 09:28, Vincent Untz wrote:
Le mercredi 15 juin 2011, à 18:57 +0200, Frederic Crozat a écrit :
However, I'm not sure we should directly add those direct call to systemctl in %post but instead, use some macros, similar to the one we have for sysvinit and / or update those macros to be systemd compliant : %stop_on_removal / %insserv_force_if_yast / %{fillup_only} / % restart_on_update / etc..
+1 for macros. I don't think it's worth trying to update the macros; adding new ones should work well enough -- especially as there's a new file to package anyway, so people will notice there's something to do.
Please, this is an opportunity to unify services packaging across all RPM distros. Please, don't screw up by introducing any new SUSE specific macros. We can talk with Fedora and Mageia at least to come up with one solution that is OK with everyone and has the highest chance of being adopted in upstream RPM.
I agree. So, let's discuss on the systemd mailing list and propose something there - or what's the best way? Andreas -- Andreas Jaeger, Program Manager openSUSE aj@{novell.com,suse.com,opensuse.org} Twitter/Identica: jaegerandi SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
Le jeudi 16 juin 2011 à 13:48 +0200, Andreas Jaeger a écrit :
On Thursday, June 16, 2011 11:51:29 AM Pavol Rusnak wrote:
On 16/06/11 09:28, Vincent Untz wrote:
Le mercredi 15 juin 2011, à 18:57 +0200, Frederic Crozat a écrit :
However, I'm not sure we should directly add those direct call to systemctl in %post but instead, use some macros, similar to the one we have for sysvinit and / or update those macros to be systemd compliant : %stop_on_removal / %insserv_force_if_yast / %{fillup_only} / % restart_on_update / etc..
+1 for macros. I don't think it's worth trying to update the macros; adding new ones should work well enough -- especially as there's a new file to package anyway, so people will notice there's something to do.
Please, this is an opportunity to unify services packaging across all RPM distros. Please, don't screw up by introducing any new SUSE specific macros. We can talk with Fedora and Mageia at least to come up with one solution that is OK with everyone and has the highest chance of being adopted in upstream RPM.
I agree.
So, let's discuss on the systemd mailing list and propose something there - or what's the best way?
I sent a RFC on systemd-devel mailing list yesterday, we'll see how
people react.
--
Frederic Crozat
Le vendredi 17 juin 2011 à 10:38 +0200, Frederic Crozat a écrit :
Le jeudi 16 juin 2011 à 13:48 +0200, Andreas Jaeger a écrit :
On Thursday, June 16, 2011 11:51:29 AM Pavol Rusnak wrote:
On 16/06/11 09:28, Vincent Untz wrote:
Le mercredi 15 juin 2011, à 18:57 +0200, Frederic Crozat a écrit :
However, I'm not sure we should directly add those direct call to systemctl in %post but instead, use some macros, similar to the one we have for sysvinit and / or update those macros to be systemd compliant : %stop_on_removal / %insserv_force_if_yast / %{fillup_only} / % restart_on_update / etc..
+1 for macros. I don't think it's worth trying to update the macros; adding new ones should work well enough -- especially as there's a new file to package anyway, so people will notice there's something to do.
Please, this is an opportunity to unify services packaging across all RPM distros. Please, don't screw up by introducing any new SUSE specific macros. We can talk with Fedora and Mageia at least to come up with one solution that is OK with everyone and has the highest chance of being adopted in upstream RPM.
I agree.
So, let's discuss on the systemd mailing list and propose something there - or what's the best way?
I sent a RFC on systemd-devel mailing list yesterday, we'll see how people react.
Reaction was positive.
Here is a proposal I plan to submit upstream if it is fine with people
here. I've reused Michael Schröder proposal from FOSDEM 2006, adapted to
systemd.
For openSUSE, we could modify slightly this proposal to call %
fillup_and_insserv / %stop_on_removal / %restart_on_update when package
hasn't migrated to systemd (I didn't add this part to systemd proposal,
since it is distro specific) and would keep compat for current users of
service_add / service_del_preun / service_del_post
(proposed at fosdem 2006)
%service_add()
if [ "$1" -eq 1 ] ; then
# Initial installation
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi
%service_add_enabled()
if [ "$1" -eq 1 ] ; then
# Initial installation
/bin/systemctl enable %{1}.service >/dev/null 2>&1 || :
fi
%service_del_preun()
if [ "$1" -eq 0 ] ; then
# Package removal, not upgrade
/bin/systemctl --no-reload disable %{1}.service > /dev/null 2>&1 || :
/bin/systemctl stop %{1}.service > /dev/null 2>&1 || :
fi
%service_del_postun()
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
if [ "$1" -ge 1 ] ; then
# Package upgrade, not uninstall
/bin/systemctl try-restart %{1}.service >/dev/null 2>&1 || :
fi
Comments welcome
--
Frederic Crozat
On 06/16/2011 11:51 AM, Pavol Rusnak wrote:
On 16/06/11 09:28, Vincent Untz wrote:
Le mercredi 15 juin 2011, à 18:57 +0200, Frederic Crozat a écrit :
However, I'm not sure we should directly add those direct call to systemctl in %post but instead, use some macros, similar to the one we have for sysvinit and / or update those macros to be systemd compliant : %stop_on_removal / %insserv_force_if_yast / %{fillup_only} / % restart_on_update / etc..
+1 for macros. I don't think it's worth trying to update the macros; adding new ones should work well enough -- especially as there's a new file to package anyway, so people will notice there's something to do.
Please, this is an opportunity to unify services packaging across all RPM distros. Please, don't screw up by introducing any new SUSE specific macros. We can talk with Fedora and Mageia at least to come up with one solution that is OK with everyone and has the highest chance of being adopted in upstream RPM.
I could not agree more and certainly, I'll ping the Mageia folks if needed. I know one of their core maintainers well, so contact me off-list or via IRC when needed. Cheers, Peter -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
On Monday, June 20, 2011 15:56:37 Frederic Crozat wrote:
Le vendredi 17 juin 2011 à 10:38 +0200, Frederic Crozat a écrit :
Le jeudi 16 juin 2011 à 13:48 +0200, Andreas Jaeger a écrit :
On Thursday, June 16, 2011 11:51:29 AM Pavol Rusnak wrote:
On 16/06/11 09:28, Vincent Untz wrote:
Le mercredi 15 juin 2011, à 18:57 +0200, Frederic Crozat a écrit :
However, I'm not sure we should directly add those direct call to systemctl in %post but instead, use some macros, similar to the one we have for sysvinit and / or update those macros to be systemd compliant : %stop_on_removal / %insserv_force_if_yast / %{fillup_only} / % restart_on_update / etc..
+1 for macros. I don't think it's worth trying to update the macros; adding new ones should work well enough -- especially as there's a new file to package anyway, so people will notice there's something to do.
Please, this is an opportunity to unify services packaging across all RPM distros. Please, don't screw up by introducing any new SUSE specific macros. We can talk with Fedora and Mageia at least to come up with one solution that is OK with everyone and has the highest chance of being adopted in upstream RPM.
I agree.
So, let's discuss on the systemd mailing list and propose something there - or what's the best way?
I sent a RFC on systemd-devel mailing list yesterday, we'll see how people react.
Reaction was positive.
Here is a proposal I plan to submit upstream if it is fine with people here. I've reused Michael Schröder proposal from FOSDEM 2006, adapted to systemd.
For openSUSE, we could modify slightly this proposal to call % fillup_and_insserv / %stop_on_removal / %restart_on_update when package hasn't migrated to systemd (I didn't add this part to systemd proposal, since it is distro specific) and would keep compat for current users of service_add / service_del_preun / service_del_post
(proposed at fosdem 2006) %service_add() if [ "$1" -eq 1 ] ; then # Initial installation /bin/systemctl daemon-reload >/dev/null 2>&1 || : fi
%service_add_enabled() if [ "$1" -eq 1 ] ; then # Initial installation /bin/systemctl enable %{1}.service >/dev/null 2>&1 || : fi
%service_del_preun() if [ "$1" -eq 0 ] ; then # Package removal, not upgrade /bin/systemctl --no-reload disable %{1}.service > /dev/null 2>&1 || : /bin/systemctl stop %{1}.service > /dev/null 2>&1 || : fi
%service_del_postun() /bin/systemctl daemon-reload >/dev/null 2>&1 || : if [ "$1" -ge 1 ] ; then # Package upgrade, not uninstall /bin/systemctl try-restart %{1}.service >/dev/null 2>&1 || : fi
Comments welcome
Let's add some examples. Please check whether the following is right for service demo.service: # XXX: systemd-units is the name on Fedora, should we use the same? # This is for /bin/systemctl Requires(post): systemd-units Requires(preun): systemd-units Requires(postun): systemd-units %post %service_add demo.service # Alternative: %service_add_enabled demo.service %preun %service_del_preun demo.service %postun %service_del_postun demo.service What I'm missing is the way to update so that the service is only enabled if it was enabled before. Fedora has something like the following in their files: # Package with native systemd unit file is installed for the first time %triggerun -- ypbind < 3:1.32-9 if /sbin/chkconfig --level 3 ypbind ; then /bin/systemctl --no-reload enable ypbind.service >/dev/null 2>&1 || : fi Andreas -- Andreas Jaeger, Program Manager openSUSE aj@{novell.com,suse.com,opensuse.org} Twitter/Identica: jaegerandi SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
On Mon, 20 Jun 2011 15:56, Frederic Crozat
Le vendredi 17 juin 2011 à 10:38 +0200, Frederic Crozat a écrit :
Le jeudi 16 juin 2011 à 13:48 +0200, Andreas Jaeger a écrit :
On Thursday, June 16, 2011 11:51:29 AM Pavol Rusnak wrote:
On 16/06/11 09:28, Vincent Untz wrote:
Le mercredi 15 juin 2011, à 18:57 +0200, Frederic Crozat a écrit :
However, I'm not sure we should directly add those direct call to systemctl in %post but instead, use some macros, similar to the one we have for sysvinit and / or update those macros to be systemd compliant : %stop_on_removal / %insserv_force_if_yast / %{fillup_only} / % restart_on_update / etc..
+1 for macros. I don't think it's worth trying to update the macros; adding new ones should work well enough -- especially as there's a new file to package anyway, so people will notice there's something to do.
Please, this is an opportunity to unify services packaging across all RPM distros. Please, don't screw up by introducing any new SUSE specific macros. We can talk with Fedora and Mageia at least to come up with one solution that is OK with everyone and has the highest chance of being adopted in upstream RPM.
I agree.
So, let's discuss on the systemd mailing list and propose something there - or what's the best way?
I sent a RFC on systemd-devel mailing list yesterday, we'll see how people react.
Reaction was positive.
Here is a proposal I plan to submit upstream if it is fine with people here. I've reused Michael Schröder proposal from FOSDEM 2006, adapted to systemd.
For openSUSE, we could modify slightly this proposal to call % fillup_and_insserv / %stop_on_removal / %restart_on_update when package hasn't migrated to systemd (I didn't add this part to systemd proposal, since it is distro specific) and would keep compat for current users of service_add / service_del_preun / service_del_post
(proposed at fosdem 2006) %service_add() if [ "$1" -eq 1 ] ; then # Initial installation /bin/systemctl daemon-reload >/dev/null 2>&1 || : fi
%service_add_enabled() if [ "$1" -eq 1 ] ; then # Initial installation /bin/systemctl enable %{1}.service >/dev/null 2>&1 || : fi
%service_del_preun() if [ "$1" -eq 0 ] ; then # Package removal, not upgrade /bin/systemctl --no-reload disable %{1}.service > /dev/null 2>&1 || : /bin/systemctl stop %{1}.service > /dev/null 2>&1 || : fi
%service_del_postun() /bin/systemctl daemon-reload >/dev/null 2>&1 || : if [ "$1" -ge 1 ] ; then # Package upgrade, not uninstall /bin/systemctl try-restart %{1}.service >/dev/null 2>&1 || : fi
Comments welcome
Added Idea esp. for Distros which use their own macros: Would it be possible to provide these macros system/distro independent? As smallest common denominator? The individual distros could implement / modify their special marcos around these basics. This would make distro-independent source-rpm possible, or at least bring them a step nearer. Another step that could be possible to go now would be a database/wiki with the distro-dependent differences. Maybe even a "MASTER"-template spec-file which included all the main rpm consumers in conditional statements? --- Well, a dev can dream, or not? Yamaban.
Le lundi 20 juin 2011 à 16:13 +0200, Andreas Jaeger a écrit :
Let's add some examples. Please check whether the following is right for service demo.service:
# XXX: systemd-units is the name on Fedora, should we use the same? # This is for /bin/systemctl Requires(post): systemd-units Requires(preun): systemd-units Requires(postun): systemd-units
I'm ok with this part, but we must split systemd on openSUSE to be like Fedora one (I don't have objection).
%post %service_add demo.service # Alternative: %service_add_enabled demo.service
%preun %service_del_preun demo.service
%postun %service_del_postun demo.service
What I'm missing is the way to update so that the service is only enabled if it was enabled before. Fedora has something like the following in their files:
# Package with native systemd unit file is installed for the first time %triggerun -- ypbind < 3:1.32-9 if /sbin/chkconfig --level 3 ypbind ; then /bin/systemctl --no-reload enable ypbind.service >/dev/null 2>&1 || : fi
Hmm, this part might be a too distro specific to be macro-ified :
- it depends on runlevel (which might be different in distro or not
relevant at all)
- it depends on tool to handle sysvinit (we could call chkconfig but
even this might not be on all distro or in the same path)
another possibility could be to add a optional macro (this one is
untested ;)
%service_migrate_to_systemd(l)
{-l:LEVEL="-l $1 ; shift }
if /sbin/chkconfig $LEVEL %{1} ; then
/bin/systemctl --no-reload enable %{1}.service >/dev/null 2>&1 || :
fi
usage :
%triggerun -- ypbind < 3:1.32-9
%service_migration_to_systemd -l 3 ypbind
--
Frederic Crozat
Frederic Crozat wrote:
[...] Here is a proposal I plan to submit upstream if it is fine with people here. I've reused Michael Schröder proposal from FOSDEM 2006, adapted to systemd.
For openSUSE, we could modify slightly this proposal to call % fillup_and_insserv / %stop_on_removal / %restart_on_update when package hasn't migrated to systemd (I didn't add this part to systemd proposal, since it is distro specific) and would keep compat for current users of service_add / service_del_preun / service_del_post
(proposed at fosdem 2006) %service_add() if [ "$1" -eq 1 ] ; then # Initial installation /bin/systemctl daemon-reload >/dev/null 2>&1 || : fi
%service_add_enabled() if [ "$1" -eq 1 ] ; then # Initial installation /bin/systemctl enable %{1}.service >/dev/null 2>&1 || : fi
There are some packages that directly package the symlink in e.g. multi-user.target.wants. I suppose that shouldn't be done in favor of the macro then? I think it would be better if the "default enable flag" was an actual entry in the config file though. That would allow to easily check whether an existing system has all mandatory services enabled and to reset it to the default state if needed. Also, being able to parse an ini file rather than some script language makes an rpmlint check easier and more reliable :-) What about packages that have both .service and .socket? Prefer .socket? cu Ludwig -- (o_ Ludwig Nussel //\ V_/_ http://www.suse.de/ SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
On Monday, June 20, 2011 17:05:06 Frederic Crozat wrote:
Le lundi 20 juin 2011 à 16:13 +0200, Andreas Jaeger a écrit :
Let's add some examples. Please check whether the following is right for service demo.service:
# XXX: systemd-units is the name on Fedora, should we use the same? # This is for /bin/systemctl Requires(post): systemd-units Requires(preun): systemd-units Requires(postun): systemd-units
I'm ok with this part, but we must split systemd on openSUSE to be like Fedora one (I don't have objection).
%post %service_add demo.service # Alternative: %service_add_enabled demo.service
%preun %service_del_preun demo.service
%postun %service_del_postun demo.service
What I'm missing is the way to update so that the service is only enabled if it was enabled before. Fedora has something like the following in their files:
# Package with native systemd unit file is installed for the first time %triggerun -- ypbind < 3:1.32-9 if /sbin/chkconfig --level 3 ypbind ; then
/bin/systemctl --no-reload enable ypbind.service >/dev/null 2>&1 || : fi
Hmm, this part might be a too distro specific to be macro-ified : - it depends on runlevel (which might be different in distro or not relevant at all) - it depends on tool to handle sysvinit (we could call chkconfig but even this might not be on all distro or in the same path)
We need a solution for SUSE for this ;) - and the version number for sure is distro specific.
another possibility could be to add a optional macro (this one is untested ;)
%service_migrate_to_systemd(l) {-l:LEVEL="-l $1 ; shift } if /sbin/chkconfig $LEVEL %{1} ; then /bin/systemctl --no-reload enable %{1}.service >/dev/null 2>&1 || : fi
usage : %triggerun -- ypbind < 3:1.32-9 %service_migration_to_systemd -l 3 ypbind
Fine with me as well, Andreas -- Andreas Jaeger, Program Manager openSUSE aj@{novell.com,suse.com,opensuse.org} Twitter/Identica: jaegerandi SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
Le lundi 20 juin 2011 à 17:07 +0200, Ludwig Nussel a écrit :
Frederic Crozat wrote:
[...] Here is a proposal I plan to submit upstream if it is fine with people here. I've reused Michael Schröder proposal from FOSDEM 2006, adapted to systemd.
For openSUSE, we could modify slightly this proposal to call % fillup_and_insserv / %stop_on_removal / %restart_on_update when package hasn't migrated to systemd (I didn't add this part to systemd proposal, since it is distro specific) and would keep compat for current users of service_add / service_del_preun / service_del_post
(proposed at fosdem 2006) %service_add() if [ "$1" -eq 1 ] ; then # Initial installation /bin/systemctl daemon-reload >/dev/null 2>&1 || : fi
%service_add_enabled() if [ "$1" -eq 1 ] ; then # Initial installation /bin/systemctl enable %{1}.service >/dev/null 2>&1 || : fi
There are some packages that directly package the symlink in e.g. multi-user.target.wants. I suppose that shouldn't be done in favor of the macro then?
Good question. I guess this should be discussed with upstream folks.
I think it would be better if the "default enable flag" was an actual entry in the config file though. That would allow to easily check whether an existing system has all mandatory services enabled and to reset it to the default state if needed.
Also, being able to parse an ini file rather than some script language makes an rpmlint check easier and more reliable :-)
Unfortunately, that isn't part of the syntax choosen by systemd and it wouldn't mix very well with the /lib vs /etc override which is quite handy IMO ;)
What about packages that have both .service and .socket? Prefer .socket?
Good question again. We also have the issue for .target / .device
and .swap
Maybe we should restrict service_* macro to .service files and add
similar macros for sockets. Or handle both.. Probably worth discussing
with upstream.
--
Frederic Crozat
Le lundi 20 juin 2011 à 17:35 +0200, Frederic Crozat a écrit :
Le lundi 20 juin 2011 à 17:07 +0200, Ludwig Nussel a écrit :
Frederic Crozat wrote:
[...] Here is a proposal I plan to submit upstream if it is fine with people here. I've reused Michael Schröder proposal from FOSDEM 2006, adapted to systemd.
For openSUSE, we could modify slightly this proposal to call % fillup_and_insserv / %stop_on_removal / %restart_on_update when package hasn't migrated to systemd (I didn't add this part to systemd proposal, since it is distro specific) and would keep compat for current users of service_add / service_del_preun / service_del_post
(proposed at fosdem 2006) %service_add() if [ "$1" -eq 1 ] ; then # Initial installation /bin/systemctl daemon-reload >/dev/null 2>&1 || : fi
%service_add_enabled() if [ "$1" -eq 1 ] ; then # Initial installation /bin/systemctl enable %{1}.service >/dev/null 2>&1 || : fi
There are some packages that directly package the symlink in e.g. multi-user.target.wants. I suppose that shouldn't be done in favor of the macro then?
Good question. I guess this should be discussed with upstream folks.
I can see one big issue, mostly in migration :
systemctl enable (or disable) only works if systemd is running. So, if
you are installing a package which tries to enable a .service and if
systemd isn't running (old init or upgrade for 11.4), systemctl won't do
anything :(
--
Frederic Crozat
Frederic Crozat wrote:
Le lundi 20 juin 2011 à 17:35 +0200, Frederic Crozat a écrit :
Le lundi 20 juin 2011 à 17:07 +0200, Ludwig Nussel a écrit :
Frederic Crozat wrote:
[...] Here is a proposal I plan to submit upstream if it is fine with people here. I've reused Michael Schröder proposal from FOSDEM 2006, adapted to systemd.
For openSUSE, we could modify slightly this proposal to call % fillup_and_insserv / %stop_on_removal / %restart_on_update when package hasn't migrated to systemd (I didn't add this part to systemd proposal, since it is distro specific) and would keep compat for current users of service_add / service_del_preun / service_del_post
(proposed at fosdem 2006) %service_add() if [ "$1" -eq 1 ] ; then # Initial installation /bin/systemctl daemon-reload >/dev/null 2>&1 || : fi
%service_add_enabled() if [ "$1" -eq 1 ] ; then # Initial installation /bin/systemctl enable %{1}.service >/dev/null 2>&1 || : fi
There are some packages that directly package the symlink in e.g. multi-user.target.wants. I suppose that shouldn't be done in favor of the macro then?
Good question. I guess this should be discussed with upstream folks.
I can see one big issue, mostly in migration : systemctl enable (or disable) only works if systemd is running. So, if you are installing a package which tries to enable a .service and if systemd isn't running (old init or upgrade for 11.4), systemctl won't do anything :(
"systemctl enable" could simply be replaced with a "ln -s" call I suppose. OTOH the package could just as well simply include the symlink in %files then. cu Ludwig -- (o_ Ludwig Nussel //\ V_/_ http://www.suse.de/ SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
Hello, on Montag, 20. Juni 2011, Andreas Jaeger wrote:
On Monday, June 20, 2011 15:56:37 Frederic Crozat wrote:
For openSUSE, we could modify slightly this proposal to call % fillup_and_insserv / %stop_on_removal / %restart_on_update when package hasn't migrated to systemd (I didn't add this part to systemd proposal, since it is distro specific) and would keep compat for current users of service_add / service_del_preun / service_del_post
I assume there are more distributions that haven't migrated to systemd completely - why not make these calls (optional) part of the proposal?
Let's add some examples. Please check whether the following is right for service demo.service:
# XXX: systemd-units is the name on Fedora, should we use the same? # This is for /bin/systemctl Requires(post): systemd-units Requires(preun): systemd-units Requires(postun): systemd-units
This is crying for a %systemd_requires macro ;-) (if possible, it should be defined in a base package so that we don't need an additional "BuildRequires" to have the macro available - perl-macros / %{perl_requires} can serve as bad example regarding this detail)
What I'm missing is the way to update so that the service is only enabled if it was enabled before. Fedora has something like the following in their files:
# Package with native systemd unit file is installed for the first time %triggerun -- ypbind < 3:1.32-9 if /sbin/chkconfig --level 3 ypbind ; then /bin/systemctl --no-reload enable ypbind.service >/dev/null 2>&1 || : fi
This should also be a macro. Frederic: Especially the fact that there _are_ different runlevels and tools to handle sysvinit is a good reason to have a macro, even if every distro might have to write their own macro The important point is to have a %service_migrate_to_systemd macro that you can use in the specfile for all distributions and that does the job. In other words: specfile writers should not need to know/care about the technical details behind the macro. Regards, Christian Boltz -- Fragen Sie im Zweifel sofort nach dem Absenden telefonisch beim Empfänger nach, ob Ihre E-Mail angekommen ist. Bei Schwierigkeiten wenden Sie sich bitte grundsätzlich nie an den eigenen Administrator. Es ist stets das gegnerische Mailsystem schuld. [Peer Heinlein in postfixbuch-users] -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
Hello, on Montag, 20. Juni 2011, Frederic Crozat wrote:
I can see one big issue, mostly in migration : systemctl enable (or disable) only works if systemd is running. So, if you are installing a package which tries to enable a .service and if systemd isn't running (old init or upgrade for 11.4), systemctl won't do anything :(
I don't know the details and the reason for this behaviour, but to me it sounds like a bug. Therefore I'd say: open a bugreport ;-) BTW, related question: Did anyone test upgrades by booting YaST from the installation DVD? Does systemctl honor --root? Regards, Christian Boltz -- My concern is that Flash seems to be closer to Swiss cheese than anything else. [Vahis in evergreen] -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
Am Dienstag, 21. Juni 2011 schrieb Christian Boltz:
This is crying for a %systemd_requires macro ;-) (if possible, it should be defined in a base package so that we don't need an additional "BuildRequires" to have the macro available - perl-macros / %{perl_requires} can serve as bad example regarding this detail)
perl-macros is only for backports. Greetings, Stephan -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
Le mardi 21 juin 2011 à 13:47 +0200, Christian Boltz a écrit :
Hello,
on Montag, 20. Juni 2011, Frederic Crozat wrote:
I can see one big issue, mostly in migration : systemctl enable (or disable) only works if systemd is running. So, if you are installing a package which tries to enable a .service and if systemd isn't running (old init or upgrade for 11.4), systemctl won't do anything :(
I don't know the details and the reason for this behaviour, but to me it sounds like a bug.
Therefore I'd say: open a bugreport ;-)
Not sure it is worth it : systemctl is a "basic" wrapper which talks with systemd over dbus, where everything is handled. So, it is "logic" for systemctl to not be able to enable / disable services if systemd isn't running.
BTW, related question: Did anyone test upgrades by booting YaST from the installation DVD? Does systemctl honor --root?
I don't think it will, since systemctl is a wrapper.
--
Frederic Crozat
Le lundi 20 juin 2011 à 18:47 +0200, Frederic Crozat a écrit :
Le lundi 20 juin 2011 à 17:35 +0200, Frederic Crozat a écrit :
Le lundi 20 juin 2011 à 17:07 +0200, Ludwig Nussel a écrit :
Frederic Crozat wrote:
[...] Here is a proposal I plan to submit upstream if it is fine with people here. I've reused Michael Schröder proposal from FOSDEM 2006, adapted to systemd.
For openSUSE, we could modify slightly this proposal to call % fillup_and_insserv / %stop_on_removal / %restart_on_update when package hasn't migrated to systemd (I didn't add this part to systemd proposal, since it is distro specific) and would keep compat for current users of service_add / service_del_preun / service_del_post
(proposed at fosdem 2006) %service_add() if [ "$1" -eq 1 ] ; then # Initial installation /bin/systemctl daemon-reload >/dev/null 2>&1 || : fi
%service_add_enabled() if [ "$1" -eq 1 ] ; then # Initial installation /bin/systemctl enable %{1}.service >/dev/null 2>&1 || : fi
There are some packages that directly package the symlink in e.g. multi-user.target.wants. I suppose that shouldn't be done in favor of the macro then?
Good question. I guess this should be discussed with upstream folks.
I can see one big issue, mostly in migration : systemctl enable (or disable) only works if systemd is running. So, if you are installing a package which tries to enable a .service and if systemd isn't running (old init or upgrade for 11.4), systemctl won't do anything :(
I retract that statement :
I've checked systemctl code : "enable" and "disable" do NOT require bus
connection to systemd. Moreover, if systemctl is running in a chroot, it
won't do anything too. (and after tests, I confirm it works as
expected ;)
So, we can keep systemctl enable / disable in the macro (and it seems
more "clean" than using ln -s, since it is an implementation detail).
--
Frederic Crozat
Le mardi 21 juin 2011 à 13:42 +0200, Christian Boltz a écrit :
Hello,
on Montag, 20. Juni 2011, Andreas Jaeger wrote:
On Monday, June 20, 2011 15:56:37 Frederic Crozat wrote:
For openSUSE, we could modify slightly this proposal to call % fillup_and_insserv / %stop_on_removal / %restart_on_update when package hasn't migrated to systemd (I didn't add this part to systemd proposal, since it is distro specific) and would keep compat for current users of service_add / service_del_preun / service_del_post
I assume there are more distributions that haven't migrated to systemd completely - why not make these calls (optional) part of the proposal?
Well, I would expect each "distro adapted" macros to land in rpm-build (or a package pulled by rpm-build) as we don't really to handle all the other distros macros into our own distro. What I could do is some <insert your custom distro service handling macro here> template in the proposal.
Let's add some examples. Please check whether the following is right for service demo.service:
# XXX: systemd-units is the name on Fedora, should we use the same? # This is for /bin/systemctl Requires(post): systemd-units Requires(preun): systemd-units Requires(postun): systemd-units
This is crying for a %systemd_requires macro ;-) (if possible, it should be defined in a base package so that we don't need an additional "BuildRequires" to have the macro available - perl-macros / %{perl_requires} can serve as bad example regarding this detail)
Indeed ;) %systemd_requires Requires(post): systemd-units \ Requires(preun): systemd-units \ Requires(postun): systemd-units (the content of this macro could be distro specific, if other rpm distro don't want to use systemd-units as package name for the one containing systemctl
What I'm missing is the way to update so that the service is only enabled if it was enabled before. Fedora has something like the following in their files:
# Package with native systemd unit file is installed for the first time %triggerun -- ypbind < 3:1.32-9 if /sbin/chkconfig --level 3 ypbind ; then /bin/systemctl --no-reload enable ypbind.service >/dev/null 2>&1 || : fi
This should also be a macro.
Frederic: Especially the fact that there _are_ different runlevels and tools to handle sysvinit is a good reason to have a macro, even if every distro might have to write their own macro
The important point is to have a %service_migrate_to_systemd macro that you can use in the specfile for all distributions and that does the job. In other words: specfile writers should not need to know/care about the technical details behind the macro.
Already answered in reply to AJ ;)
I'll post a new draft here tomorrow, trying to include all the feedback
received.
--
Frederic Crozat
Hello, on Dienstag, 21. Juni 2011, Frederic Crozat wrote:
Le mardi 21 juin 2011 à 13:42 +0200, Christian Boltz a écrit :
This is crying for a %systemd_requires macro ;-)
Indeed ;)
%systemd_requires Requires(post): systemd-units \ Requires(preun): systemd-units \ Requires(postun): systemd-units
(the content of this macro could be distro specific, if other rpm distro don't want to use systemd-units as package name for the one containing systemctl
Is there a special reason why you tend to make it different again? ;-) All distributions should just standardize on a common package name (or Provides:) for systemctl and then use one common macro. I'd propose "Provides: systemd-systemctl" or just "Provides: systemctl". Regards, Christian Boltz -- Du kannst dir einen Kernel so geschwaetzig eingestellt kompilieren, dass die HDD kaum noch mit dem loggen hinterherkommt (was wiederum Bugs im HDD-Treiber ausloesen koennte ;)) [David Haller in suse-linux] -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
Le mardi 21 juin 2011 à 23:36 +0200, Christian Boltz a écrit :
Hello,
on Dienstag, 21. Juni 2011, Frederic Crozat wrote:
Le mardi 21 juin 2011 à 13:42 +0200, Christian Boltz a écrit :
This is crying for a %systemd_requires macro ;-)
Indeed ;)
%systemd_requires Requires(post): systemd-units \ Requires(preun): systemd-units \ Requires(postun): systemd-units
(the content of this macro could be distro specific, if other rpm distro don't want to use systemd-units as package name for the one containing systemctl
Is there a special reason why you tend to make it different again? ;-)
Because it already exists on Fedora and not only contains systemctl but
also add default .units :
http://pkgs.fedoraproject.org/gitweb/?p=systemd.git;a=blob;f=systemd.spec;h=...
--
Frederic Crozat
Christian Boltz wrote:
on Montag, 20. Juni 2011, Andreas Jaeger wrote:
# XXX: systemd-units is the name on Fedora, should we use the same? # This is for /bin/systemctl Requires(post): systemd-units Requires(preun): systemd-units Requires(postun): systemd-units
This is crying for a %systemd_requires macro ;-)
Can't this be solved by the automatic dependency generators of rpm 4.9 so packages don't have to care at all? cu Ludwig -- (o_ Ludwig Nussel //\ V_/_ http://www.suse.de/ SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
On 06/22/2011 10:17 AM, Ludwig Nussel wrote:
Christian Boltz wrote:
on Montag, 20. Juni 2011, Andreas Jaeger wrote:
# XXX: systemd-units is the name on Fedora, should we use the same? # This is for /bin/systemctl Requires(post): systemd-units Requires(preun): systemd-units Requires(postun): systemd-units
This is crying for a %systemd_requires macro ;-)
Can't this be solved by the automatic dependency generators of rpm 4.9 so packages don't have to care at all?
Is there an example for this? Packages that install *.info files and such could also use some automatic help which would reduce spec file noise. Regards. -- Ismail Dönmez - openSUSE Booster SUSE LINUX Products GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
Le mercredi 22 juin 2011 à 10:17 +0200, Ludwig Nussel a écrit :
Christian Boltz wrote:
on Montag, 20. Juni 2011, Andreas Jaeger wrote:
# XXX: systemd-units is the name on Fedora, should we use the same? # This is for /bin/systemctl Requires(post): systemd-units Requires(preun): systemd-units Requires(postun): systemd-units
This is crying for a %systemd_requires macro ;-)
Can't this be solved by the automatic dependency generators of rpm 4.9 so packages don't have to care at all?
I'd say it is an implementation detail and I'd prefer to avoid a hard
dependency on rpm 4.9 in the proposal (but if we can use rpm 4.9 feature
to handle %systemd_requires, why not ;)
--
Frederic Crozat
Le mardi 21 juin 2011 à 13:47 +0200, Christian Boltz a écrit :
BTW, related question: Did anyone test upgrades by booting YaST from the installation DVD? Does systemctl honor --root?
systemctl doesn't yet honor --root (I've just asked upstream) but there
is no opposition to add support for it (patch welcome ;)
--
Frederic Crozat
Le lundi 20 juin 2011 à 16:19 +0200, Yamaban a écrit :
On Mon, 20 Jun 2011 15:56, Frederic Crozat
wrote: Le vendredi 17 juin 2011 à 10:38 +0200, Frederic Crozat a écrit :
Le jeudi 16 juin 2011 à 13:48 +0200, Andreas Jaeger a écrit :
On Thursday, June 16, 2011 11:51:29 AM Pavol Rusnak wrote:
On 16/06/11 09:28, Vincent Untz wrote:
Le mercredi 15 juin 2011, à 18:57 +0200, Frederic Crozat a écrit : > However, I'm not sure we should directly add those direct call to > systemctl in %post but instead, use some macros, similar to the one we > have for sysvinit and / or update those macros to be systemd compliant : > %stop_on_removal / %insserv_force_if_yast / %{fillup_only} / % > restart_on_update / etc..
+1 for macros. I don't think it's worth trying to update the macros; adding new ones should work well enough -- especially as there's a new file to package anyway, so people will notice there's something to do.
Please, this is an opportunity to unify services packaging across all RPM distros. Please, don't screw up by introducing any new SUSE specific macros. We can talk with Fedora and Mageia at least to come up with one solution that is OK with everyone and has the highest chance of being adopted in upstream RPM.
I agree.
So, let's discuss on the systemd mailing list and propose something there - or what's the best way?
I sent a RFC on systemd-devel mailing list yesterday, we'll see how people react.
Reaction was positive.
Here is a proposal I plan to submit upstream if it is fine with people here. I've reused Michael Schröder proposal from FOSDEM 2006, adapted to systemd.
For openSUSE, we could modify slightly this proposal to call % fillup_and_insserv / %stop_on_removal / %restart_on_update when package hasn't migrated to systemd (I didn't add this part to systemd proposal, since it is distro specific) and would keep compat for current users of service_add / service_del_preun / service_del_post
(proposed at fosdem 2006) %service_add() if [ "$1" -eq 1 ] ; then # Initial installation /bin/systemctl daemon-reload >/dev/null 2>&1 || : fi
%service_add_enabled() if [ "$1" -eq 1 ] ; then # Initial installation /bin/systemctl enable %{1}.service >/dev/null 2>&1 || : fi
%service_del_preun() if [ "$1" -eq 0 ] ; then # Package removal, not upgrade /bin/systemctl --no-reload disable %{1}.service > /dev/null 2>&1 || : /bin/systemctl stop %{1}.service > /dev/null 2>&1 || : fi
%service_del_postun() /bin/systemctl daemon-reload >/dev/null 2>&1 || : if [ "$1" -ge 1 ] ; then # Package upgrade, not uninstall /bin/systemctl try-restart %{1}.service >/dev/null 2>&1 || : fi
Comments welcome
Added Idea esp. for Distros which use their own macros: Would it be possible to provide these macros system/distro independent? As smallest common denominator?
The idea is to get those macro either shipped with systemd or in rpm
upstream.
--
Frederic Crozat
Le lundi 20 juin 2011 à 15:56 +0200, Frederic Crozat a écrit :
Le vendredi 17 juin 2011 à 10:38 +0200, Frederic Crozat a écrit :
Le jeudi 16 juin 2011 à 13:48 +0200, Andreas Jaeger a écrit :
On Thursday, June 16, 2011 11:51:29 AM Pavol Rusnak wrote:
On 16/06/11 09:28, Vincent Untz wrote:
Le mercredi 15 juin 2011, à 18:57 +0200, Frederic Crozat a écrit :
However, I'm not sure we should directly add those direct call to systemctl in %post but instead, use some macros, similar to the one we have for sysvinit and / or update those macros to be systemd compliant : %stop_on_removal / %insserv_force_if_yast / %{fillup_only} / % restart_on_update / etc..
+1 for macros. I don't think it's worth trying to update the macros; adding new ones should work well enough -- especially as there's a new file to package anyway, so people will notice there's something to do.
Please, this is an opportunity to unify services packaging across all RPM distros. Please, don't screw up by introducing any new SUSE specific macros. We can talk with Fedora and Mageia at least to come up with one solution that is OK with everyone and has the highest chance of being adopted in upstream RPM.
I agree.
So, let's discuss on the systemd mailing list and propose something there - or what's the best way?
I sent a RFC on systemd-devel mailing list yesterday, we'll see how people react.
Reaction was positive.
Here is a proposal I plan to submit upstream if it is fine with people here. I've reused Michael Schröder proposal from FOSDEM 2006, adapted to systemd.
Here is a new version of the proposal, based on our feedback :
(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)
%service_add()
if [ "$1" -eq 1 ] ; then
# Initial installation
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi
%service_add_enabled()
if [ "$1" -eq 1 ] ; then
# Initial installation
/bin/systemctl enable %{1}.service >/dev/null 2>&1 || :
fi
%service_del_preun()
if [ "$1" -eq 0 ] ; then
# Package removal, not upgrade
/bin/systemctl --no-reload disable %{1}.service > /dev/null 2>&1 || :
/bin/systemctl stop %{1}.service > /dev/null 2>&1 || :
fi
%service_del_postun()
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
if [ "$1" -ge 1 ] ; then
# Package upgrade, not uninstall
/bin/systemctl try-restart %{1}.service >/dev/null 2>&1 || :
fi
(this macro could refer to different package, if people don't agree on
systemd-units as packagename)
%define systemd_requires()
# This is for /bin/systemctl
Requires(post): systemd-units \
Requires(preun): systemd-units \
Requires(postun): systemd-units \
%service_migrate_to_systemd(l)
{-l:LEVEL="-l $1 ; shift }
if /sbin/chkconfig $LEVEL %{1} ; then
/bin/systemctl --no-reload enable %{1}.service >/dev/null 2>&1 || :
fi
usage :
%post
%service_add demo.service
# Alternative: %service_add_enabled demo.service
%preun
%service_del_preun demo.service
%postun
%service_del_postun demo.service
when migrating a package from sysvinit to systemd :
%triggerun -- package_name < version_where_switch_occured
%service_migration_to_systemd [ -l run_level ] service_name
-l
Hello, on Mittwoch, 22. Juni 2011, Frederic Crozat wrote:
Here is a new version of the proposal, based on our feedback : ... %service_add_enabled() if [ "$1" -eq 1 ] ; then # Initial installation /bin/systemctl enable %{1}.service >/dev/null 2>&1 || : fi ... usage :
%post %service_add demo.service
This looks buggy ;-) Your macros all contain %{1}.service - therefore calling them with *.service as parameter will double it. The question is what is better: a) remove the .service when calling the macro (that saves packagers some keystrokes) b) remove the .service in the macros (that makes them more flexible - IIRC systemd also supports things like *.socket etc.) You know systemd much better than I do, therefore I'll let the decision up to you. Regards, Christian Boltz --
Ich habe immer so Bißspuren in meiner Tastatur! Weiß jemand wieso? Ist Deine Maus hungrig? [> Bernd Brodesser und Hannes Vogelmann in suse-linux] -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
Le jeudi 23 juin 2011 à 19:21 +0200, Christian Boltz a écrit :
Hello,
on Mittwoch, 22. Juni 2011, Frederic Crozat wrote:
Here is a new version of the proposal, based on our feedback : ... %service_add_enabled() if [ "$1" -eq 1 ] ; then # Initial installation /bin/systemctl enable %{1}.service >/dev/null 2>&1 || : fi ... usage :
%post %service_add demo.service
This looks buggy ;-)
Your macros all contain %{1}.service - therefore calling them with *.service as parameter will double it.
The question is what is better: a) remove the .service when calling the macro (that saves packagers some keystrokes) b) remove the .service in the macros (that makes them more flexible - IIRC systemd also supports things like *.socket etc.)
You know systemd much better than I do, therefore I'll let the decision up to you.
Well, it depends if we want to also use those macros for handle sysvinit
initscripts.
I guess this will be discussed on systemd-devel.
I'll post the proposal today.
Thanks again everybody for your comments.
--
Frederic Crozat
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)
%service_add()
if [ "$1" -eq 1 ] ; then
# Initial installation
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi
%service_del_preun()
if [ "$1" -eq 0 ] ; then
# Package removal, not upgrade
/bin/systemctl --no-reload disable %{?*} > /dev/null 2>&1 || :
/bin/systemctl stop %{?*} > /dev/null 2>&1 || :
fi
%service_del_postun()
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
if [ "$1" -ge 1 ] ; then
# Package upgrade, not uninstall
/bin/systemctl try-restart %{1} >/dev/null 2>&1 || :
fi
(this macro could refer to different package, if people don't agree on
systemd-units as packagename)
%define systemd_requires()
# This is for /bin/systemctl
Requires(post): systemd-units \
Requires(preun): systemd-units \
Requires(postun): systemd-units \
%service_migrate_to_systemd(l)
{-l:LEVEL="-l $1 ; shift }
for service in %{?*} ; do \
if /sbin/chkconfig $LEVEL $service ; then
/bin/systemctl --no-reload enable `echo $service | sed -e
's/\.service//g'` >/dev/null 2>&1 || :
fi
usage :
%post
%service_add demo.service foobar.socket
%preun
%service_del_preun demo.service
%postun
%service_del_postun demo.service
when migrating a package from sysvinit to systemd :
%triggerun -- package_name < version_where_switch_occured
%service_migration_to_systemd [ -l run_level ] service_name.service
foobar.socket
-l
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
Frederic Crozat wrote:
And here is a change, for handling sysvinit to systemd migration, without relying on triggers : [...] 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).
What about integrating %service_migrate_to_systemd_post into %service_add and just do it automatically? Same for %service_migrate_to_systemd_postun. %service_migrate_to_systemd_pre could be renamed to a more generic %service_add_pre then which would allow us to hook in other things in the future if needed. cu Ludwig -- (o_ Ludwig Nussel //\ V_/_ http://www.suse.de/ SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
Le vendredi 26 août 2011 à 09:40 +0200, Ludwig Nussel a écrit :
Frederic Crozat wrote:
And here is a change, for handling sysvinit to systemd migration, without relying on triggers : [...] 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).
What about integrating %service_migrate_to_systemd_post into %service_add and just do it automatically? Same for %service_migrate_to_systemd_postun. %service_migrate_to_systemd_pre could be renamed to a more generic %service_add_pre then which would allow us to hook in other things in the future if needed.
Initially, the proposal was based on Fedora work, which was using
triggers (and we know it is not a very good idea).
However, if we "merge" the migration macros in the %service_add*, we
won't be able share this macro definition with upstream (which was the
goal initially), since distributions aren't handling migration the
same..
But apart from that, I don't have a strong objection against merging.
--
Frederic Crozat
participants (10)
-
Andreas Jaeger
-
Christian Boltz
-
Frederic Crozat
-
Ismail Doenmez
-
Ludwig Nussel
-
Pavol Rusnak
-
Peter Linnell
-
Stephan Kulow
-
Vincent Untz
-
Yamaban