From 31ee367e9779c871df96e63e065c0b221831ed73 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 4 Aug 2018 21:06:19 -0400 Subject: [PATCH] debian: stop using symlinks to save space on *-dev packages Using symlinks to save space on duplicate copies of the /usr/share/doc/*/changelog.Debian.gz is a bit of a mess, since when the foo-dev package is removed, the files in /usr/share/doc/libfoo/* get removed, which means the copyright file gets removed. So stop doing this altogether, and set up maintainer scripts to clean up the mess so that the symlinks are removed when the packages get upgraded. Addresses-Debian-Bug: #905195 Signed-off-by: Theodore Ts'o --- debian/comerr-dev.postinst | 30 ++++++++++++++++++++++++++++++ debian/comerr-dev.postrm | 36 ++++++++++++++++++++++++++++++++++++ debian/comerr-dev.preinst | 31 +++++++++++++++++++++++++++++++ debian/e2fslibs-dev.postinst | 26 ++++++++++++++++++++++++++ debian/e2fslibs-dev.postrm | 32 ++++++++++++++++++++++++++++++++ debian/e2fslibs-dev.preinst | 27 +++++++++++++++++++++++++++ debian/rules | 3 --- debian/ss-dev.postinst | 26 ++++++++++++++++++++++++++ debian/ss-dev.postrm | 32 ++++++++++++++++++++++++++++++++ debian/ss-dev.preinst | 27 +++++++++++++++++++++++++++ 10 files changed, 267 insertions(+), 3 deletions(-) create mode 100644 debian/comerr-dev.postinst create mode 100644 debian/comerr-dev.postrm create mode 100644 debian/comerr-dev.preinst create mode 100644 debian/e2fslibs-dev.postinst create mode 100644 debian/e2fslibs-dev.postrm create mode 100644 debian/e2fslibs-dev.preinst create mode 100644 debian/ss-dev.postinst create mode 100644 debian/ss-dev.postrm create mode 100644 debian/ss-dev.preinst diff --git a/debian/comerr-dev.postinst b/debian/comerr-dev.postinst new file mode 100644 index 0000000..aae743a --- /dev/null +++ b/debian/comerr-dev.postinst @@ -0,0 +1,30 @@ +#!/bin/sh + +# Abort on error. +set -e + +symlink_match() +{ + local SYMLINK="$1" + local SYMLINK_TARGET="$2" + + [ "$(readlink "$SYMLINK")" = "$SYMLINK_TARGET" ] || \ + [ "$(readlink -f "$SYMLINK")" = "$SYMLINK_TARGET" ] +} + +SYMLINK=/usr/share/doc/comerr-dev +SYMLINK_TARGET=libcomerr2 +SYMLINK_TARGET2=libcom-err2 + +if [ "$1" = "configure" ] && [ -h "${SYMLINK}.dpkg-backup" ] +then + if symlink_match "${SYMLINK}.dpkg-backup" "$SYMLINK_TARGET" || + symlink_match "${SYMLINK}.dpkg-backup" "$SYMLINK_TARGET2" + then + rm -f "${SYMLINK}.dpkg-backup" + fi +fi + +#DEBHELPER# + +exit 0 diff --git a/debian/comerr-dev.postrm b/debian/comerr-dev.postrm new file mode 100644 index 0000000..8f9e679 --- /dev/null +++ b/debian/comerr-dev.postrm @@ -0,0 +1,36 @@ +#!/bin/sh + +# Abort on error. +set -e + +symlink_match() +{ + local SYMLINK="$1" + local SYMLINK_TARGET="$2" + + [ "$(readlink "$SYMLINK")" = "$SYMLINK_TARGET" ] || \ + [ "$(readlink -f "$SYMLINK")" = "$SYMLINK_TARGET" ] +} + +SYMLINK=/usr/share/doc/comerr-dev +SYMLINK_TARGET=libcomerr2 +SYMLINK_TARGET2=libcom-err2 + +if [ "$1" = "purge" ] && [ -h "${SYMLINK}.dpkg-backup" ] +then + rm -f "${SYMLINK}.dpkg-backup" +fi +if [ "$1" = "abort-install" -o "$1" = "abort-upgrade" ] && + [ -n "$2" ] && [ ! -e "$SYMLINK" ] && [ -h "${SYMLINK}.dpkg-backup" ] +then + if symlink_match "${SYMLINK}.dpkg-backup" "$SYMLINK_TARGET" || + symlink_match "${SYMLINK}.dpkg-backup" "$SYMLINK_TARGET2" + then + echo "Restoring backup of $SYMLINK ..." + mv "${SYMLINK}.dpkg-backup" "$SYMLINK" + fi +fi + +#DEBHELPER# + +exit 0 diff --git a/debian/comerr-dev.preinst b/debian/comerr-dev.preinst new file mode 100644 index 0000000..5d8090a --- /dev/null +++ b/debian/comerr-dev.preinst @@ -0,0 +1,31 @@ +#!/bin/sh + +# Abort on error. +set -e + +symlink_match() +{ + local SYMLINK="$1" + local SYMLINK_TARGET="$2" + + [ "$(readlink "$SYMLINK")" = "$SYMLINK_TARGET" ] || \ + [ "$(readlink -f "$SYMLINK")" = "$SYMLINK_TARGET" ] +} + +SYMLINK=/usr/share/doc/comerr-dev +SYMLINK_TARGET=libcomerr2 +SYMLINK_TARGET2=libcom-err2 + +if [ "$1" = "install" -o "$1" = "upgrade" ] && + [ -n "$2" ] && [ -h "$SYMLINK" ] +then + if symlink_match "$SYMLINK" "$SYMLINK_TARGET" || + symlink_match "$SYMLINK" "$SYMLINK_TARGET2" + then + mv -f "$SYMLINK" "${SYMLINK}.dpkg-backup" + fi +fi + +#DEBHELPER# + +exit 0 diff --git a/debian/e2fslibs-dev.postinst b/debian/e2fslibs-dev.postinst new file mode 100644 index 0000000..def6673 --- /dev/null +++ b/debian/e2fslibs-dev.postinst @@ -0,0 +1,26 @@ +#!/bin/sh + +# Abort on error. +set -e + +symlink_match() +{ + local SYMLINK="$1" + local SYMLINK_TARGET="$2" + + [ "$(readlink "$SYMLINK")" = "$SYMLINK_TARGET" ] || \ + [ "$(readlink -f "$SYMLINK")" = "$SYMLINK_TARGET" ] +} + +SYMLINK=/usr/share/doc/e2fslibs-dev +SYMLINK_TARGET=e2fslibs + +if [ "$1" = "configure" ] && [ -h "${SYMLINK}.dpkg-backup" ] && + symlink_match "${SYMLINK}.dpkg-backup" "$SYMLINK_TARGET" +then + rm -f "${SYMLINK}.dpkg-backup" +fi + +#DEBHELPER# + +exit 0 diff --git a/debian/e2fslibs-dev.postrm b/debian/e2fslibs-dev.postrm new file mode 100644 index 0000000..54841af --- /dev/null +++ b/debian/e2fslibs-dev.postrm @@ -0,0 +1,32 @@ +#!/bin/sh + +# Abort on error. +set -e + +symlink_match() +{ + local SYMLINK="$1" + local SYMLINK_TARGET="$2" + + [ "$(readlink "$SYMLINK")" = "$SYMLINK_TARGET" ] || \ + [ "$(readlink -f "$SYMLINK")" = "$SYMLINK_TARGET" ] +} + +SYMLINK=/usr/share/doc/e2fslibs-dev +SYMLINK_TARGET=e2fslibs + +if [ "$1" = "purge" ] && [ -h "${SYMLINK}.dpkg-backup" ] +then + rm -f "${SYMLINK}.dpkg-backup" +fi +if [ "$1" = "abort-install" -o "$1" = "abort-upgrade" ] && + [ -n "$2" ] && [ ! -e "$SYMLINK" ] && [ -h "${SYMLINK}.dpkg-backup" ] && + symlink_match "${SYMLINK}.dpkg-backup" "$SYMLINK_TARGET" +then + echo "Restoring backup of $SYMLINK ..." + mv "${SYMLINK}.dpkg-backup" "$SYMLINK" +fi + +#DEBHELPER# + +exit 0 diff --git a/debian/e2fslibs-dev.preinst b/debian/e2fslibs-dev.preinst new file mode 100644 index 0000000..b3f9a4b --- /dev/null +++ b/debian/e2fslibs-dev.preinst @@ -0,0 +1,27 @@ +#!/bin/sh + +# Abort on error. +set -e + +symlink_match() +{ + local SYMLINK="$1" + local SYMLINK_TARGET="$2" + + [ "$(readlink "$SYMLINK")" = "$SYMLINK_TARGET" ] || \ + [ "$(readlink -f "$SYMLINK")" = "$SYMLINK_TARGET" ] +} + +SYMLINK=/usr/share/doc/e2fslibs-dev +SYMLINK_TARGET=e2fslibs + +if [ "$1" = "install" -o "$1" = "upgrade" ] && + [ -n "$2" ] && [ -h "$SYMLINK" ] && + symlink_match "$SYMLINK" "$SYMLINK_TARGET" +then + mv -f "$SYMLINK" "${SYMLINK}.dpkg-backup" +fi + +#DEBHELPER# + +exit 0 diff --git a/debian/rules b/debian/rules index b6df023..5449f2b 100755 --- a/debian/rules +++ b/debian/rules @@ -377,15 +377,12 @@ binary-arch: install $(INSTALL_UDEB) mkdir -p ${debdir}/libss${SS_SOVERSION}/usr/share/doc/libss${SS_SOVERSION} mkdir -p ${debdir}/ss-dev/usr/share/doc - ln -sf libss${SS_SOVERSION} ${debdir}/ss-dev/usr/share/doc/ss-dev mkdir -p ${debdir}/libcom-err${COMERR_SOVERSION}/usr/share/doc/libcom-err${COMERR_SOVERSION} mkdir -p ${debdir}/comerr-dev/usr/share/doc - ln -sf libcom-err${COMERR_SOVERSION} ${debdir}/comerr-dev/usr/share/doc/comerr-dev mkdir -p ${debdir}/libext2fs2/usr/share/doc/libext2fs mkdir -p ${debdir}/libext2fs-dev/usr/share/doc - ln -sf libext2fs2 ${debdir}/libext2fs-dev/usr/share/doc/libext2fs-dev dh_installdocs -a -Ne2fsprogs-udeb diff --git a/debian/ss-dev.postinst b/debian/ss-dev.postinst new file mode 100644 index 0000000..bf49c9d --- /dev/null +++ b/debian/ss-dev.postinst @@ -0,0 +1,26 @@ +#!/bin/sh + +# Abort on error. +set -e + +symlink_match() +{ + local SYMLINK="$1" + local SYMLINK_TARGET="$2" + + [ "$(readlink "$SYMLINK")" = "$SYMLINK_TARGET" ] || \ + [ "$(readlink -f "$SYMLINK")" = "$SYMLINK_TARGET" ] +} + +SYMLINK=/usr/share/doc/ss-dev +SYMLINK_TARGET=libss2 + +if [ "$1" = "configure" ] && [ -h "${SYMLINK}.dpkg-backup" ] && + symlink_match "${SYMLINK}.dpkg-backup" "$SYMLINK_TARGET" +then + rm -f "${SYMLINK}.dpkg-backup" +fi + +#DEBHELPER# + +exit 0 diff --git a/debian/ss-dev.postrm b/debian/ss-dev.postrm new file mode 100644 index 0000000..c625aae --- /dev/null +++ b/debian/ss-dev.postrm @@ -0,0 +1,32 @@ +#!/bin/sh + +# Abort on error. +set -e + +symlink_match() +{ + local SYMLINK="$1" + local SYMLINK_TARGET="$2" + + [ "$(readlink "$SYMLINK")" = "$SYMLINK_TARGET" ] || \ + [ "$(readlink -f "$SYMLINK")" = "$SYMLINK_TARGET" ] +} + +SYMLINK=/usr/share/doc/ss-dev +SYMLINK_TARGET=libss2 + +if [ "$1" = "purge" ] && [ -h "${SYMLINK}.dpkg-backup" ] +then + rm -f "${SYMLINK}.dpkg-backup" +fi +if [ "$1" = "abort-install" -o "$1" = "abort-upgrade" ] && + [ -n "$2" ] && [ ! -e "$SYMLINK" ] && [ -h "${SYMLINK}.dpkg-backup" ] && + symlink_match "${SYMLINK}.dpkg-backup" "$SYMLINK_TARGET" +then + echo "Restoring backup of $SYMLINK ..." + mv "${SYMLINK}.dpkg-backup" "$SYMLINK" +fi + +#DEBHELPER# + +exit 0 diff --git a/debian/ss-dev.preinst b/debian/ss-dev.preinst new file mode 100644 index 0000000..8da566e --- /dev/null +++ b/debian/ss-dev.preinst @@ -0,0 +1,27 @@ +#!/bin/bash + +# Abort on error. +set -e + +symlink_match() +{ + local SYMLINK="$1" + local SYMLINK_TARGET="$2" + + [ "$(readlink "$SYMLINK")" = "$SYMLINK_TARGET" ] || \ + [ "$(readlink -f "$SYMLINK")" = "$SYMLINK_TARGET" ] +} + +SYMLINK=/usr/share/doc/ss-dev +SYMLINK_TARGET=libss2 + +if [ "$1" = "install" -o "$1" = "upgrade" ] && + [ -n "$2" ] && [ -h "$SYMLINK" ] && + symlink_match "$SYMLINK" "$SYMLINK_TARGET" +then + mv -f "$SYMLINK" "${SYMLINK}.dpkg-backup" +fi + +#DEBHELPER# + +exit 0 -- 1.8.3.1