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

## Build Script Upgrade Build Machine
## defaults to: upgrade build machine
## When not turned off below, it will run apt-get update and
## apt-get dist-upgrade before in build step "prepare build machine".
## as well.
if [ "${dist_build_upgrade_build_machine:-}" = "" ]; then
   export dist_build_upgrade_build_machine="0"
fi

## Build Script Unattended Package Install
## default to: do not install packages unattended
## Sets dpkg option --force-confold while upgrading.
## When not turned off below, it will not install packages without configuration
## questions.
## Debian frontend is set to noninteractive while running the upgrade
## as well.
if [ "${dist_build_unattended_pkg_install:-}" = "" ]; then
   export dist_build_unattended_pkg_install="1"
fi

if [ ! "${dist_build_unattended_pkg_install:-}" = "1" ]; then
   ## Always keep old configuration file. Do not prompt to install new config files.
   apt_unattended_opts="--option Dpkg::Options=--force-confold"
else
   apt_unattended_opts=""
fi

## Export so cowbuilder chroot scripts inherit it via 'sudo --preserve-env';
## without it, unguarded '$apt_unattended_opts' references trip 'set -o nounset'.
export apt_unattended_opts
