From f50b7324beffb5b39c9df62d2de8408d3b3fbd25 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 8 Mar 2024 18:55:26 +0100 Subject: Cosmetically harmonizing diversion handling in maintainer scripts for better readability. Signed-off-by: Daniel Baumann --- debian/zutils.postrm | 4 ++-- debian/zutils.preinst | 39 +++++++++++++++++++++++---------------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/debian/zutils.postrm b/debian/zutils.postrm index e9ad406..9a3c7c5 100755 --- a/debian/zutils.postrm +++ b/debian/zutils.postrm @@ -6,8 +6,8 @@ case "${1}" in remove) for FILE in zcat zcmp zdiff zegrep zfgrep zgrep do - dpkg-divert --package zutils --quiet --remove --rename --divert "/usr/bin/$FILE.gzip" "/usr/bin/$FILE" - dpkg-divert --package zutils --quiet --remove --rename --divert "/bin/$FILE.gzip.usr-is-merged" "/bin/$FILE" + dpkg-divert --package zutils --quiet --remove --rename --divert "/usr/bin/${FILE}.gzip" "/usr/bin/${FILE}" + dpkg-divert --package zutils --quiet --remove --rename --divert "/bin/${FILE}.gzip.usr-is-merged" "/bin/${FILE}" dpkg-divert --package zutils --quiet --remove --rename --divert /usr/share/man/man1/${FILE}.gzip.1.gz /usr/share/man/man1/${FILE}.1.gz done ;; diff --git a/debian/zutils.preinst b/debian/zutils.preinst index 4795b30..3fa0faf 100755 --- a/debian/zutils.preinst +++ b/debian/zutils.preinst @@ -8,8 +8,8 @@ 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/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 ;; @@ -17,21 +17,28 @@ case "${1}" in upgrade) for FILE in zcat zcmp zdiff zegrep zfgrep zgrep do - TRUENAME=$(dpkg-divert --truename "/usr/bin/$FILE") - if test "$TRUENAME" = "/usr/bin/$FILE.usr-is-merged"; then + 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 test "$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 test "$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 test -e "$DPKG_ROOT$TRUENAME" -o -h "$DPKG_ROOT$TRUENAME"; then - mv "$DPKG_ROOT$TRUENAME" "$DPKG_ROOT/bin/$FILE.gzip.usr-is-merged" + 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 -- cgit v1.2.3