#!/bin/bash

## Copyright (C) 2012 - 2023 ENCRYPTED SUPPORT LP <adrelanos@whonix.org>
## Copyright (C) 2018 Algernon
## See the file COPYING for copying conditions.

set -x
set -e

true "INFO: Currently running script: $BASH_SOURCE $@"

MYDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

source "$MYDIR/pre"
source "$MYDIR/colors"
source "$MYDIR/variables"

main() {
   $SUDO_TO_ROOT rm --force "$dist_sources_list_temp_initial_deb_sources_list"
   $SUDO_TO_ROOT rm --force "$CHROOT_FOLDER/$dist_sources_list_temp_build_folder/build_sources.list"
   $SUDO_TO_ROOT rm --force "$CHROOT_FOLDER/$dist_sources_list_temp_build_folder/qubes-builder.list"

   ## apt_target_key_derivative exists only when using:
   ## build_remote_derivative_pkgs=true / --remote-derivative-packages true
   if [ ! "$apt_target_key_derivative" = "" ]; then
      $SUDO_TO_ROOT rm --force "$CHROOT_FOLDER/$apt_target_key_derivative"
   fi

   ## "$CHROOT_FOLDER/$DEB_INSTALL_FOLDER" gets unmounted in help-steps/unchroot script.
}

main "$@"
