#!/bin/bash

## Copyright (C) 2012 - 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: BEGIN: $DPKG_MAINTSCRIPT_PACKAGE $DPKG_MAINTSCRIPT_NAME $@
#####################################################################
"

## legacy
#if test -f /etc/apt/sources.list.d/whonix.list ; then
#   if ! test -f /etc/apt/sources.list.d/derivative.list ; then
#      mv --verbose /etc/apt/sources.list.d/whonix.list /etc/apt/sources.list.d/derivative.list
#   fi
#fi

## legacy
#rm --verbose --force /etc/apt/trusted.gpg.d/whonix.gpg
#rm --verbose --force /etc/apt/trusted.gpg.d/derivative.gpg
#rm --verbose --force /etc/apt/trusted.gpg.d/derivative.asc
#
#file_name="/etc/apt/sources.list.d/derivative.list"

## legacy
#if test -f "$file_name" ; then
#   ## Do not try to upgrade http to https as this would fail for onions.
#
#   search="deb tor+http"
#   replace="deb [signed-by=/usr/share/keyrings/derivative.asc] tor+http"
#   str_replace "$search" "$replace" "$file_name" >/dev/null || true
#   search="deb http"
#   replace="deb [signed-by=/usr/share/keyrings/derivative.asc] http"
#   str_replace "$search" "$replace" "$file_name" >/dev/null || true
#
#   search="deb-src tor+http"
#   replace="deb-src [signed-by=/usr/share/keyrings/derivative.asc] tor+http"
#   str_replace "$search" "$replace" "$file_name" >/dev/null || true
#   search="deb-src http"
#   replace="deb-src [signed-by=/usr/share/keyrings/derivative.asc] http"
#   str_replace "$search" "$replace" "$file_name" >/dev/null || 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
