Accepting request 263015 from Printing
use %posttrans in cups RPM to clean up systemd units (boo#904215) (forwarded request 263014 from jsmeix) OBS-URL: https://build.opensuse.org/request/show/263015 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/cups?expand=0&rev=124
This commit is contained in:
commit
415b45c089
19
cups.changes
19
cups.changes
@ -1,3 +1,22 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Nov 25 16:13:50 CET 2014 - jsmeix@suse.de
|
||||
|
||||
- Refresh and/or clean up the systemd units that belong to CUPS
|
||||
(cups.service cups.socket cups.path) via RPM posttrans scriplet
|
||||
in a generic way via "systemctl --force reenable" (bnc#904215).
|
||||
An enabled systemd unit may need a refresh via
|
||||
"systemctl --force reenable" after updating a package when
|
||||
the new package had installed a changed systemd unit file.
|
||||
A disabled systemd unit also may need a refresh via
|
||||
"systemctl --force reenable" but then it is again disabled.
|
||||
A systemd unit may become obsolete by updating a package when
|
||||
the new package does no longer provide a unit file. In this
|
||||
case "systemctl --force reenable" removes the unit.
|
||||
In any case currently running services are not stopped even
|
||||
when the new package does no longer provide the unit file
|
||||
because a RPM package update must not automatically disrupt
|
||||
(stop or restart) running services.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Nov 4 13:26:04 CET 2014 - jsmeix@suse.de
|
||||
|
||||
|
73
cups.spec
73
cups.spec
@ -603,25 +603,6 @@ sed -i -e 's|/var/lock|/run/lock|g' %{buildroot}/etc/init.d/cups
|
||||
# an explicit "exit 1" must be use to enforce package install/upgrade/erase failure where needed
|
||||
# see the "Shared_libraries" section in http://en.opensuse.org/openSUSE:Packaging_scriptlet_snippets
|
||||
%if 0%{?have_systemd}
|
||||
# Cleaning up obsolete systemd units cups.path and cups.socket is only needed up to openSUSE 13.1
|
||||
# because cups.path and cups.socket are only provided from openSUSE 12.2 up to openSUSE 13.1
|
||||
# see bnc#857372 starting at https://bugzilla.novell.com/show_bug.cgi?id=857372#c61
|
||||
%if 0%{?suse_version} <= 1310
|
||||
# Begin clean up obsolete systemd units cups.path and cups.socket
|
||||
# Stop and disable systemd units that have been provided by a previous package version but are no longer provided by this package.
|
||||
# Do this in any case because YaST only supprts cups.service but not cups.socket or cups.path
|
||||
# see https://bugzilla.novell.com/show_bug.cgi?id=857372#c120
|
||||
# and if cups.socket or cups.path would be actuve YaST would mess up the systemd setup for CUPS
|
||||
# see https://bugzilla.novell.com/show_bug.cgi?id=857372#c115
|
||||
# which is one more reason that cups.socket and cups.path are completely disabled and removed
|
||||
# see https://bugzilla.novell.com/show_bug.cgi?id=857372#c61
|
||||
for u in cups.path cups.socket
|
||||
do # (without "|| :" build fails with "Failed to get D-Bus connection: No connection to service manager. preinstall script ... failed"):
|
||||
systemctl --quiet stop $u || :
|
||||
systemctl --quiet disable $u || :
|
||||
done
|
||||
# End clean up obsolete systemd units cups.path and cups.socket
|
||||
%endif
|
||||
# Begin service_add_pre cups.service
|
||||
%service_add_pre cups.service
|
||||
# End service_add_pre cups.service
|
||||
@ -641,14 +622,6 @@ exit 0
|
||||
# Begin service_add_post cups.service
|
||||
%service_add_post cups.service
|
||||
# End service_add_post cups.service
|
||||
# Begin refresh systemd unit cups.service
|
||||
# Be on the safe side and enforce systemd to use the cups.service file in this package
|
||||
# ("reenable" does not implicitly stop a running cupsd which is exactly correct here):
|
||||
if systemctl --quiet is-enabled cups.service
|
||||
then # (without "|| :" build fails with "Failed to get D-Bus connection: No connection to service manager. postinstall script ... failed"):
|
||||
systemctl --quiet reenable cups.service || :
|
||||
fi
|
||||
# End refresh systemd unit cups.service
|
||||
%else
|
||||
# Begin fillup_and_insserv -ny cups cups
|
||||
%{fillup_and_insserv -ny cups cups}
|
||||
@ -689,6 +662,52 @@ exit 0
|
||||
%endif
|
||||
exit 0
|
||||
|
||||
%posttrans
|
||||
# Use a real bash script with an explicit "exit 0" at the end to be by default fail safe
|
||||
# an explicit "exit 1" must be use to enforce package install/upgrade/erase failure where needed
|
||||
# see the "Shared_libraries" section in http://en.opensuse.org/openSUSE:Packaging_scriptlet_snippets
|
||||
%if 0%{?have_systemd}
|
||||
# Begin refresh systemd units and clean up possibly obsolete systemd units
|
||||
# The following is a generic way how to refresh and/or clean up systemd units.
|
||||
# A systemd unit may need a refresh after updating a package when the new package
|
||||
# had installed a changed systemd unit file for an enabled systemd unit.
|
||||
# A systemd unit may become obsolete by updating a package (see bnc#904215).
|
||||
# A systemd unit is considered to have become obsolete when the systemd
|
||||
# symlink /etc/systemd/system/.../unit_name -> /path/to/unit_file is broken.
|
||||
# When during package update the new package does no longer provide a unit file
|
||||
# then the systemd symlink becomes broken after the files of the old package
|
||||
# had been actually removed by RPM.
|
||||
# According to /usr/share/doc/packages/rpm/manual/triggers and according
|
||||
# to https://en.opensuse.org/openSUSE:Packaging_scriptlet_snippets#Scriptlet_Ordering
|
||||
# and http://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Scriptlet_Ordering
|
||||
# from the new package only "posttrans of new package" is run after "removal of old package"
|
||||
# so that the new package must do the clean up as RPM posttrans scriptlet.
|
||||
for u in cups.service cups.socket cups.path
|
||||
do if systemctl --quiet is-enabled $u 2>/dev/null
|
||||
then # Refresh still valid enabled systemd units and clean up possibly obsoleted systemd units:
|
||||
# Enforce systemd to use the current unit file which is usually the unit file of the new package
|
||||
# but also in case of custom units (that use other unit files) a "reenable" won't hurt because
|
||||
# "reenable" does not implicitly stop a running service which is "the right thing" because
|
||||
# a RPM package installation must not automatically disrupt (restart) a running service.
|
||||
# Using "--force reenable" is essential to clean up possibly conflicting/broken symlinks.
|
||||
# (without "|| :" build fails with "Failed to get D-Bus connection: No connection to service manager. posttrans script ... failed"):
|
||||
systemctl --quiet --force reenable $u 2>/dev/null || :
|
||||
else # Refresh still valid disabled systemd units and clean up possibly obsoleted systemd units:
|
||||
# First using "--force reenable" is essential to clean up possibly conflicting/broken symlinks
|
||||
# because there is no "--force disable" that would clean up possibly conflicting/broken symlinks
|
||||
# see https://bugzilla.opensuse.org/show_bug.cgi?id=904215#c34
|
||||
# so that first the unit has a clean state and then it is set back to disabled (as it was before).
|
||||
# If a disabled systemd unit has become obsoleted, "systemctl --force reenable" will clean it up
|
||||
# which means the unit gets removed and the subsequent "systemctl disable" will do nothing.
|
||||
# (without "|| :" build fails with "Failed to get D-Bus connection: No connection to service manager. posttrans script ... failed"):
|
||||
systemctl --quiet --force reenable $u 2>/dev/null || :
|
||||
systemctl --quiet disable $u 2>/dev/null || :
|
||||
fi
|
||||
done
|
||||
# End refresh systemd units and clean up possibly obsolete systemd units
|
||||
%endif
|
||||
exit 0
|
||||
|
||||
%post libs
|
||||
# Use a real bash script with an explicit "exit 0" at the end to be by default fail safe
|
||||
# an explicit "exit 1" must be use to enforce package install/upgrade/erase failure where needed
|
||||
|
Loading…
x
Reference in New Issue
Block a user