#!/bin/sh set -e # DEP17 M18: Duplicate diversion in aliased location /bin. die() { printf '%s, cannot proceed\n' "$*" 1>&2 exit 1 } case "${1}" in install) # Situations considered: # * bookworm or earlier gzip is fully installed. # -> No diversions, /bin/${FILE} # * trixie or later gzip is unpacked. # -> No diversions, /usr/bin/${FILE} # * trixie or later gzip has been unpacked while bookworm's # zutils was installed, but zutils has since been removed. # -> /usr/bin/FILE -> /usr/bin/FILE.usr-is-merged # * trixie or later gzip is fully installed. # -> No diversions, /usr/bin/${FILE} # # We cannot run between gzip.preinst and gzip unpack. GZIP_VERSION=$(dpkg-query -f '${Version}' -W gzip) GZIP_PREFIX=/usr dpkg --compare-versions "$GZIP_VERSION" lt 1.12-1.1~ && GZIP_PREFIX= for FILE in zcat zcmp zdiff zegrep zfgrep zgrep do TRUENAME=$(dpkg-divert --truename "/usr/bin/${FILE}") if [ "${TRUENAME}" = "/usr/bin/${FILE}.usr-is-merged" ] then dpkg-divert --package zutils --quiet --remove --no-rename --divert "${TRUENAME}" "/usr/bin/${FILE}" elif [ "${TRUENAME}" != "/usr/bin/${FILE}" ] then die "unexpected diversion of /usr/bin/${FILE} to ${TRUENAME}" fi # We cannot --rename, because it'll rename any existing # file without checking whether the file is owned or # not. Correctly compute the required rename depending # on the gzip version. dpkg-divert --package zutils --quiet --add --no-rename --divert "/usr/bin/${FILE}.gzip" "/usr/bin/${FILE}" dpkg-divert --package zutils --quiet --add --no-rename --divert "/bin/${FILE}.gzip.usr-is-merged" "/bin/${FILE}" mv "${DPKG_ROOT:-}${TRUENAME}" "${DPKG_ROOT:-}${GZIP_PREFIX}/bin/${FILE}.gzip${GZIP_PREFIX:+.usr-is-merged}" dpkg-divert --package zutils --quiet --add --rename --divert /usr/share/man/man1/${FILE}.gzip.1.gz /usr/share/man/man1/${FILE}.1.gz done ;; upgrade) for FILE in zcat zcmp zdiff zegrep zfgrep zgrep do TRUENAME=$(dpkg-divert --truename "/usr/bin/${FILE}") if [ "${TRUENAME}" = "/usr/bin/${FILE}.usr-is-merged" ] then # This branch should be dead code. The # diversion indicates that trixie's gzip has # been unpacked, but trixie's gzip also # conflicts with zutils (<< trixie), so either # we're not installing or we are upgrading from # trixie. if ! [ -e "${DPKG_ROOT}${TRUENAME}" ] then die "diverted file ${TRUENAME} does not exist" fi dpkg-divert --package zutils --quiet --remove --no-rename --divert "/usr/bin/${FILE}.usr-is-merged" "/usr/bin/${FILE}" dpkg-divert --package zutils --quiet --remove --no-rename "/bin/${FILE}" dpkg-divert --package zutils --quiet --add --no-rename --divert "/usr/bin/${FILE}.gzip" "/usr/bin/${FILE}" dpkg-divert --package zutils --quiet --add --no-rename --divert "/bin/${FILE}.gzip.usr-is-merged" "/bin/${FILE}" mv "${DPKG_ROOT}${TRUENAME}" "${DPKG_ROOT}/usr/bin/${FILE}.gzip" elif [ "${TRUENAME}" = "/usr/bin/${FILE}" ] then dpkg-divert --package zutils --quiet --add --no-rename --divert "/usr/bin/${FILE}.gzip" "/usr/bin/${FILE}" TRUENAME=$(dpkg-divert --truename "/bin/${FILE}") if [ "${TRUENAME}" != "/bin/${FILE}.gzip.usr-is-merged" ] then dpkg-divert --package zutils --quiet --remove --no-rename "/bin/${FILE}" dpkg-divert --package zutils --quiet --add --no-rename --divert "/bin/${FILE}.gzip.usr-is-merged" "/bin/${FILE}" if [ -e "${DPKG_ROOT}${TRUENAME}" ] || [ -h "${DPKG_ROOT}${TRUENAME}" ] then mv "${DPKG_ROOT}${TRUENAME}" "${DPKG_ROOT}/bin/${FILE}.gzip.usr-is-merged" fi fi elif [ "${TRUENAME}" != "/usr/bin/${FILE}.gzip" ] then die "unexpected diversion of /usr/bin/${FILE} to ${TRUENAME}" fi done ;; abort-upgrade) ;; *) echo "preinst called with unknown argument \`${1}'" >&2 exit 1 ;; esac # Automatically added by dh_installdeb/13.24.2 dpkg-maintscript-helper rm_conffile /etc/zutilsrc 1.12-3\~ -- "$@" # End automatically added section exit 0