d/libgtk-3-0t64.preinst: Remove libgtk-3-0 postrm to avoid file loss

During the migration from libgtk-3-0 to libgtk-3-0t64, the package
that is responsible for "owning" /usr/lib/*/gtk-3.0/3.0.0/immodules.cache
changed from libgtk-3-0 to libgtk-3-0t64. Because dpkg does not have an
equivalent of RPM's %ghost files, the ownership of this file is managed
by social convention rather than by the package management system.

Unfortunately, libgtk-3-0's postrm as shipped in Debian releases from
2010 to the present is not aware of the possibility that another binary
package might need to take over responsibility for this file, and so
will remove it during purge (and in fact also during upgrades) in
accordance with the requirement that the package must not leave unowned
files behind. This causes input methods to be non-functional in GTK apps
until the next time the gtk-query-immodules-3.0 trigger happens to be run.

To disarm the problematic maintainer script, delete it during the new
package's preinst, similar to what was done for GLib in response
to #1065022.

A subsequent commit will improve the postrm so that if we find that we
need to migrate from libgtk-3-0t64 to libgtk-3-0xyz at some point in
the future, similar efforts will not be needed.

Closes: #1065494
This commit is contained in:
Simon McVittie 2024-03-06 10:48:10 +00:00
parent f338b27188
commit 1c4fb7e79a

37
debian/libgtk-3-0t64.preinst vendored Normal file
View File

@ -0,0 +1,37 @@
#!/bin/sh
# Copyright 2024 Simon McVittie
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
# Clean up libgtk-3-0:*.postrm, so that when libgtk-3-0 is purged, it
# will not delete non-dpkg-managed files that have been taken over by
# libgtk-3-0t64, such as
# /usr/lib/#DEB_HOST_MULTIARCH#/gtk-3.0/3.0.0/immodules.cache
# See https://bugs.debian.org/1065494, https://bugs.debian.org/1065170.
# TODO: When, if ever, can we safely remove this?
case "$1" in
(install|upgrade)
# Do this cleanup on upgrade from any version older than the one that
# introduced this change.
#
# We also need to do this cleanup on new installations of
# libgtk-3-0t64 (because any new installation might be replacing
# libgtk-3-0) so treat an empty version as being arbitrarily old.
if dpkg --compare-versions "${2:-}" lt "3.24.41-2"
then
if old_postrm=$(dpkg-query --control-path "libgtk-3-0:#DEB_HOST_ARCH#" postrm 2>/dev/null) \
&& [ -n "$old_postrm" ] \
&& [ -e "$old_postrm" ]
then
echo "libgtk-3-0t64.preinst: Removing $old_postrm to avoid" \
"loss of /usr/lib/#DEB_HOST_MULTIARCH#/gtk-3.0/3.0.0/immodules.cache..."
rm -f -v "$old_postrm"
fi
fi
;;
esac
#DEBHELPER#
# vim:set sw=4 sts=4 et: