#! /bin/sh # Debian Policy ยง10.4 says /bin/sh has a superset of POSIX functionality # shellcheck disable=SC3043 set -e clean_up_giomodule_cache () { local multiarch="x86_64-linux-gnu" local modules="/usr/lib/${multiarch}/gio/modules" local iter if ! [ -d "$modules" ]; then return 0 fi # Don't remove giomodule.cache if libglib2.0-0t64 has been replaced # by some other ABI variant of essentially the same library # (for example libglib2.0-0xyz), if that ever happens, to # avoid causing an equivalent of . # # This implementation is based on the assumption that any GLib # version that still uses ${libdir}/gio/modules/giomodule.cache # will also continue to ship ${libdir}/glib-2.0. if [ -d "/usr/lib/${multiarch}/glib-2.0" ]; then return 0 fi # As an additional safety-catch, don't remove giomodule.cache if # there is at least one module that should have been listed in it. for iter in "$modules"/*.so; do if [ -e "$iter" ]; then echo "$0: not removing $modules/giomodule.cache because $iter still exists" >&2 return 0 fi done rm -f "$modules/giomodule.cache" rmdir -p --ignore-fail-on-non-empty "$modules" } clean_up_gsettings_schemas () { local schemas="/usr/share/glib-2.0/schemas" local iter if ! [ -d "$schemas" ]; then return 0 fi # Similarly, instead of using $DPKG_MAINTSCRIPT_PACKAGE_REFCOUNT, only # remove gschemas.compiled if GLib has completely gone away - not just # libglib2.0-0 and libglib2.0-0t64, but any possible future ABI variant # like libglib2.0-0xyz. # # This implementation is based on the assumption that any GLib # version that still uses ${datadir}/glib-2.0/schemas # will also continue to ship ${libdir}/glib-2.0. for iter in /usr/lib/*/glib-2.0; do if [ -e "$iter" ]; then return 0 fi done # As an additional safety-catch, don't remove gschemas.compiled if # there is at least one schema that should have been listed in it. for iter in "$schemas"/*.xml; do if [ -e "$iter" ]; then echo "$0: not removing $schemas/gschemas.compiled because $iter still exists" >&2 return 0 fi done rm -f "$schemas/gschemas.compiled" rmdir -p --ignore-fail-on-non-empty "$schemas" } case "$1" in (purge) clean_up_giomodule_cache clean_up_gsettings_schemas ;; esac # vim:set sw=4 sts=4 et: