#!/bin/bash

## Copyright (C) 2025 - 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

if [ -f /usr/libexec/helper-scripts/pre.bsh ]; then
   source /usr/libexec/helper-scripts/pre.bsh
fi

set -e

true "
#####################################################################
## INFO: START: $DPKG_MAINTSCRIPT_PACKAGE $DPKG_MAINTSCRIPT_NAME $@
#####################################################################
"

## config-package-dev displace migration from desktop-config-dist to usability-misc
##
## Using 'dpkg-divert' with '--rename' is not possible.
#+ dpkg-divert --rename --package desktop-config-dist --remove /etc/zsh/zshrc
#Removing 'diversion of /etc/zsh/zshrc to /etc/zsh/zshrc.dist-orig by desktop-config-dist'
#dpkg-divert: error: rename involves overwriting '/etc/zsh/zshrc' with
#  different file '/etc/zsh/zshrc.dist-orig', not allowed
#+ true
if [ "$(dpkg-divert --listpackage /etc/zsh/zshrc)" = "desktop-config-dist" ]; then
  unlink /etc/zsh/zshrc || true
  dpkg-divert --rename --package desktop-config-dist --remove /etc/zsh/zshrc || true
fi
if [ "$(dpkg-divert --listpackage /etc/zsh/zprofile)" = "desktop-config-dist" ]; then
  unlink /etc/zsh/zprofile || true
  dpkg-divert --rename --package desktop-config-dist --remove /etc/zsh/zprofile || true
fi

true "INFO: debhelper beginning here."

#DEBHELPER#

true "INFO: Done with debhelper."

true "
#####################################################################
## INFO: END  : $DPKG_MAINTSCRIPT_PACKAGE $DPKG_MAINTSCRIPT_NAME $@
#####################################################################
"

## Explicitly "exit 0", so eventually trapped errors can be ignored.
exit 0
