#! /bin/sh # postrm script for sbuild # # see: dh_installdeb(1) set -e # summary of how this script can be called: # * `remove' # * `purge' # * `upgrade' # * `failed-upgrade' # * `abort-install' # * `abort-install' # * `abort-upgrade' # * `disappear' overwrit>r> # for details, see /usr/share/doc/packaging-manual/ PACKAGE="sbuild" # Remove a conffile which has been forgotten by dpkg # If the file does not exist, or is owned by any package, do not remove it. rm_conffile() { CONFFILE="$1" local delete; delete="false" if [ -f "$CONFFILE" ]; then local fpkg; fpkg="" local pkg; pkg="" if fpkg=$(dpkg -S "$CONFFILE" 2>/dev/null); then # Don't delete, but check which package it came from. pkg=$(echo $fpkg | sed -e 's/\(^[[:print:]][[:print:]]*\): .*$/\1/') if [ "$pkg" = "$PACKAGE" ]; then delete="true" fi else rm -f "$CONFFILE" delete="true" fi else delete="true" fi # Remove dpkg cruft if [ "$delete" = "true" ]; then rm -f "${CONFFILE}.dpkg-old" rm -f "${CONFFILE}.dpkg-new" rm -f "${CONFFILE}.dpkg-dist" fi } case "$1" in remove|upgrade|failed-upgrade|abort-install|abort-upgrade) ;; purge|disappear) # Lock sbuild account. usermod -L -e 1 sbuild || true rm_conffile "/etc/sbuild.conf" rm_conffile "/etc/sbuild.conf.local" rm_conffile "/etc/schroot/setup.d/50sbuild" # Don't remove /etc/sbuild/chroot recursively in case anyone # put the entire chroot under here; only remove symlinks. rm -f /etc/sbuild/chroot/* rmdir --ignore-fail-on-non-empty /etc/sbuild/chroot/ || true # Remove autogenerated files. rm -f /var/lib/sbuild/apt.conf* rm -f /var/lib/sbuild/apt-keys/* rm -f /var/lib/sbuild/avg-build-space rm -f /var/lib/sbuild/avg-build-times rm -f /var/lib/sbuild/source-dependencies-* rm -rf /var/lib/sbuild/srcdep-lock ;; *) echo "postrm called with unknown argument \`$1'" >&2 exit 0 ;; esac # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. #DEBHELPER# exit 0