#!/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."

# Automatically added by dh_installdeb/13.24.2
dpkg-maintscript-helper rm_conffile /etc/lightdm/lightdm.conf.d/autologin.conf -- "$@"
dpkg-maintscript-helper rm_conffile /etc/X11/Xsession.d/50default_editor -- "$@"
dpkg-maintscript-helper rm_conffile /etc/privleap/conf.d/usability-misc.conf -- "$@"
dpkg-maintscript-helper rm_conffile /etc/sudoers.d/upgrade-passwordless -- "$@"
# End automatically added section


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
