#!/bin/sh # postrm script for apt-ostree # # This script is executed after the package is removed. # It handles post-removal cleanup tasks such as removing # configuration files, cleaning up temporary files, and # updating system caches. set -e # Package name PACKAGE="apt-ostree" # Configuration directories CONFIG_DIR="/etc/apt-ostree" DATA_DIR="/var/lib/apt-ostree" LOG_DIR="/var/log/apt-ostree" case "$1" in remove) echo "Post-removal cleanup for $PACKAGE..." # Remove configuration files if [ -d "$CONFIG_DIR" ]; then echo "Removing configuration directory: $CONFIG_DIR" rm -rf "$CONFIG_DIR" fi # Remove data directory if [ -d "$DATA_DIR" ]; then echo "Removing data directory: $DATA_DIR" rm -rf "$DATA_DIR" fi # Remove log directory if [ -d "$LOG_DIR" ]; then echo "Removing log directory: $LOG_DIR" rm -rf "$LOG_DIR" fi # Remove log rotation configuration if [ -f "/etc/logrotate.d/apt-ostree" ]; then echo "Removing log rotation configuration" rm -f "/etc/logrotate.d/apt-ostree" fi # Remove shell completion files if [ -f "/usr/share/bash-completion/completions/apt-ostree" ]; then echo "Removing bash completion file" rm -f "/usr/share/bash-completion/completions/apt-ostree" fi if [ -f "/usr/share/zsh/vendor-completions/_apt-ostree" ]; then echo "Removing zsh completion file" rm -f "/usr/share/zsh/vendor-completions/_apt-ostree" fi # Update shell completion caches if command -v update-bash-completion >/dev/null 2>&1; then update-bash-completion apt-ostree || true fi # Update man page database if command -v mandb >/dev/null 2>&1; then mandb -q || true fi echo "$PACKAGE post-removal cleanup completed" ;; purge) echo "Post-purge cleanup for $PACKAGE..." # Remove all remaining files and directories if [ -d "$CONFIG_DIR" ]; then echo "Removing configuration directory: $CONFIG_DIR" rm -rf "$CONFIG_DIR" fi if [ -d "$DATA_DIR" ]; then echo "Removing data directory: $DATA_DIR" rm -rf "$DATA_DIR" fi if [ -d "$LOG_DIR" ]; then echo "Removing log directory: $LOG_DIR" rm -rf "$LOG_DIR" fi # Remove any remaining configuration files if [ -f "/etc/logrotate.d/apt-ostree" ]; then echo "Removing log rotation configuration" rm -f "/etc/logrotate.d/apt-ostree" fi # Remove shell completion files if [ -f "/usr/share/bash-completion/completions/apt-ostree" ]; then echo "Removing bash completion file" rm -f "/usr/share/bash-completion/completions/apt-ostree" fi if [ -f "/usr/share/zsh/vendor-completions/_apt-ostree" ]; then echo "Removing zsh completion file" rm -f "/usr/share/zsh/vendor-completions/_apt-ostree" fi # Update shell completion caches if command -v update-bash-completion >/dev/null 2>&1; then update-bash-completion apt-ostree || true fi # Update man page database if command -v mandb >/dev/null 2>&1; then mandb -q || true fi echo "$PACKAGE post-purge cleanup completed" ;; upgrade|failed-upgrade|abort-install|abort-upgrade|abort-remove|abort-deconfigure) echo "Post-operation cleanup for $PACKAGE..." # Nothing special needed for these operations ;; *) echo "postrm called with unknown argument \`$1'" >&2 exit 1 ;; esac # Exit successfully exit 0