#!/bin/bash

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

set -x
set -o pipefail

build_all_error_handler() {
   : echo "
${red}${bold}BASH_COMMAND${reset}: $BASH_COMMAND
${red}${bold}ERROR $BASH_SOURCE: | caller: $(caller)${reset}
"
   exit 1
}

trap "build_all_error_handler" ERR

## XXX: hardcoded path
[[ -v derivative_maker_main_source_code ]] || derivative_maker_main_source_code="$HOME/derivative-maker"

pushd "$derivative_maker_main_source_code"

./derivative-maker --flavor whonix-gateway-lxqt "$@"
./build-steps.d/*_convert-raw-to-vdi --flavor whonix-gateway-lxqt "$@"
./build-steps.d/*_create-vbox-vm --flavor whonix-gateway-lxqt "$@"
./build-steps.d/*_export-vbox-vm --flavor whonix-gateway-lxqt "$@"

./derivative-maker --flavor whonix-workstation-lxqt "$@"
./build-steps.d/*_convert-raw-to-vdi --flavor whonix-workstation-lxqt "$@"
./build-steps.d/*_create-vbox-vm --flavor whonix-workstation-lxqt "$@"
./build-steps.d/*_export-vbox-vm --flavor whonix-workstation-lxqt "$@"
