diff options
Diffstat (limited to 'debian/zutils.preinst')
-rwxr-xr-x | debian/zutils.preinst | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/debian/zutils.preinst b/debian/zutils.preinst new file mode 100755 index 0000000..3fa0faf --- /dev/null +++ b/debian/zutils.preinst @@ -0,0 +1,59 @@ +#!/bin/sh + +set -e + +# DEP17 M18: Duplicate diversion in aliased location /bin. + +case "${1}" in + install) + for FILE in zcat zcmp zdiff zegrep zfgrep zgrep + do + dpkg-divert --package zutils --quiet --add --rename --divert "/usr/bin/${FILE}.gzip" "/usr/bin/${FILE}" + dpkg-divert --package zutils --quiet --add --rename --divert "/bin/${FILE}.gzip.usr-is-merged" "/bin/${FILE}" + 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 + # gzip.preinst duplicated the diversion for us + 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}" + elif [ "${TRUENAME}" != "/usr/bin/${FILE}.gzip" ] + 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 + fi + done + ;; + abort-upgrade) + + ;; + + *) + echo "preinst called with unknown argument \`${1}'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 |