Accepting request 556888 from home:fbui:branches:Base:System

- Move macros.systemd in /usr/lib/rpm
  The file is not supposed to be customized by the user.

- Make %systemd_add_pre() more similar to %systemd_add_post()

- Make sure to apply presets if packages start shipping units during upgrades (bsc#1071543)

OBS-URL: https://build.opensuse.org/request/show/556888
OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd-rpm-macros?expand=0&rev=25
This commit is contained in:
Franck Bui 2017-12-15 09:52:31 +00:00 committed by Git OBS Bridge
parent ffe1e7b5fe
commit d3d7919f6b
3 changed files with 58 additions and 21 deletions

View File

@ -88,13 +88,14 @@ else \
done \
for service in %{?*} ; do \
sysv_service="${service%%.*}" \
if [ ! -e "/var/lib/systemd/migrated/$sysv_service" ]; then \
services_to_migrate="$services_to_migrate $sysv_service" \
if [ -e /var/lib/systemd/migrated/$sysv_service ]; then \
continue \
fi \
if [ ! -x /usr/sbin/systemd-sysv-convert ]; then \
continue \
fi \
/usr/sbin/systemd-sysv-convert --save $sysv_service || : \
done \
if [ -n "$services_to_migrate" -a -x /usr/sbin/systemd-sysv-convert ]; then \
/usr/sbin/systemd-sysv-convert --save $services_to_migrate || : \
fi \
fi \
%{nil}
@ -102,21 +103,11 @@ fi \
%service_add_post() \
test -n "$FIRST_ARG" || FIRST_ARG="$1" \
[ -d /var/lib/systemd/migrated ] || mkdir -p /var/lib/systemd/migrated || : \
for service in %{?*} ; do \
sysv_service="${service%%.*}" \
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 [ "$YAST_IS_RUNNING" != "instsys" -a -x /usr/bin/systemctl ]; then \
/usr/bin/systemctl daemon-reload || : \
fi \
if [ -n "$services_to_migrate" ]; then \
if [ -x /usr/sbin/systemd-sysv-convert ]; then \
/usr/sbin/systemd-sysv-convert --apply $services_to_migrate || : \
fi \
elif [ "$FIRST_ARG" -eq 1 ]; then \
if [ "$FIRST_ARG" -eq 1 ]; then \
if [ -x /usr/bin/systemctl ]; then \
/usr/bin/systemctl preset %{?*} || : \
fi \
@ -131,6 +122,17 @@ elif [ "$FIRST_ARG" -gt 1 ]; then \
fi \
/usr/bin/systemctl preset "$service" || : \
done \
for service in %{?*} ; do \
sysv_service=${service%%.*} \
if [ -e /var/lib/systemd/migrated/$sysv_service ]; then \
continue \
fi \
if [ ! -x /usr/sbin/systemd-sysv-convert ]; then \
continue \
fi \
/usr/sbin/systemd-sysv-convert --apply $sysv_service || : \
touch /var/lib/systemd/migrated/$sysv_service || : \
done \
fi \
%{nil}

View File

@ -1,3 +1,39 @@
-------------------------------------------------------------------
Thu Dec 14 08:39:15 UTC 2017 - fbui@suse.com
- Move macros.systemd in /usr/lib/rpm
The file is not supposed to be customized by the user.
-------------------------------------------------------------------
Wed Dec 13 17:14:25 UTC 2017 - fbui@suse.com
- Make %systemd_add_pre() more similar to %systemd_add_post()
The main advantage is that we pass only one argument to
systemd-sysv-convert script. The later can now be improved/rewritten
to handle only one argument and return a useful exit status.
-------------------------------------------------------------------
Wed Dec 13 16:42:56 UTC 2017 - fbui@suse.com
- Make sure to apply presets if packages start shipping units during upgrades (bsc#1071543)
If a package started shipping units during upgrade only sysv
migration was done. However if the package didn't ship any sysv
scripts before no presets were applied.
Now during upgrades, preset are always applied (still only during
the first time the units are installed) then followed by the sysv
migration machinery.
The downside of this is that migrated services can have symlinks in
both runlevel.target.wants/ (created by the sysv migration) and in
the directory specified by the [Install] sections (created by
"systemctl preset")...
The whole thing should be rewritten.
-------------------------------------------------------------------
Fri Dec 1 10:47:29 UTC 2017 - fbui@suse.com

View File

@ -39,9 +39,8 @@ services files. This package provides these macros.
%build
%install
mkdir -p %{buildroot}%{_sysconfdir}/rpm
install -m644 %{S:0} %{buildroot}%{_sysconfdir}/rpm
UNITDIR="`cat %{S:0} | sed -n 's|.*_unitdir[[:blank:]]*||p'`"
install -Dm644 %{S:0} %{buildroot}%{_rpmconfigdir}/macros.d/macros.systemd
UNITDIR="$(sed -n 's/.*_unitdir[[:blank:]]*//p' %{S:0})"
for i in $UNITDIR `dirname $UNITDIR`; do
mkdir -p %{buildroot}$i
echo $i >> unitdir
@ -49,6 +48,6 @@ done
%files -f unitdir
%defattr(-,root,root)
%config %{_sysconfdir}/rpm/macros.systemd
%{_rpmconfigdir}/macros.d/macros.systemd
%changelog