#!/bin/bash

## Copyright (C) 2012 - 2023 ENCRYPTED SUPPORT LP <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

[[ -v derivative_maker_main_source_code ]] || derivative_maker_main_source_code=~/derivative-maker

pushd "$derivative_maker_main_source_code"

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

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