#!/bin/bash

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

set -x
set -o errexit
set -o nounset
set -o pipefail
set -o errtrace

true "INFO: Currently running script: ${BASH_SOURCE[0]} $*"

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

cd "$MYDIR"
cd ..
cd help-steps

dist_build_source_run="true"

source pre
source variables

main() {
   shopt -s nullglob
   shopt -s dotglob

   ## Use -x to delete files listed in .gitignore.
   ## Make sure packages/uwt/libindp.so is deleted.
   git clean -d --force --force -x

   for derivative_name_item in $derivative_name_list ; do
      for item in "$source_code_folder_dist/packages/$derivative_name_item/"*; do
         if [ ! -d "$item" ]; then
            true "INFO: Not a folder: $item"
            continue
         fi
         cd "$item"
         ## Use git rather than "make deb-cleanup" for better security.
         git clean -d --force --force -x
      done
   done
}

main "$@"
