#!/bin/sh set -e log_debug() { echo "Debug: piuparts exception for package $PIUPARTS_OBJECTS" } case ${PIUPARTS_OBJECTS%%=*} in TARBALL) # skip while creating the tarball exit 0 ;; esac # clear out /usr/share/doc # but keep the directories (and symlinks) as well as the copyright files cat << EOF > /etc/dpkg/dpkg.cfg.d/piuparts-path-exclude path-exclude=/usr/share/doc/*/* path-include=/usr/share/doc/*/copyright EOF # switching init systems forth and back will clean out /usr/share/doc # reinstalling the affected packages beforehand makes the files disappear # before the snapshot of the reference system is created CANDIDATES="systemd systemd-sysv sysv-rc" CANDIDATES=$(dpkg-query -W $CANDIDATES | awk '{ if ($2) { print $1 } }') if [ -n "$CANDIDATES" ]; then echo "Reinstalling $(echo $CANDIDATES)..." # workaround apt bug #770291 - do it one by one, not all at once for package in $CANDIDATES do apt-get -u --reinstall install $package done fi case ${PIUPARTS_OBJECTS%%=*} in localepurge) case ${PIUPARTS_DISTRIBUTION} in lenny*|squeeze*) ;; *) # reinstall packages that will be reinstalled after purge # to not record their /usr/share/doc content that is about to disappear log_debug EXTRA="" apt-get -u --reinstall --fix-missing install $(dpkg -S LC_MESSAGES 'man/??/man' | cut -d: -f1 | tr ', ' '\n' | sort -u) $EXTRA ;; esac ;; esac