script_name=$(basename "${BASH_ARGV0:-$0}")

if echo "$script_name" | grep -q '\.dry-run$'; then
  DRY_RUN='--dry-run'
  script_name=$(echo "$script_name" | perl -pe 's/\.dry-run$//')
fi

if test -z "${SIGNING_PROJECTNAME+x}"; then
  echo "$script_name" | grep -q '\.' && \
    SIGNING_PROJECTNAME=$(echo "$script_name" | perl -pe 's/^[^\.]+\.//')
fi

test -n "${SIGNING_PROJECTNAME+x}" \
  || exit_error 'SIGNING_PROJECTNAME is not set'

test "$SIGNING_PROJECTNAME" = 'torbrowser' \
  || test "$SIGNING_PROJECTNAME" = 'basebrowser' \
  || test "$SIGNING_PROJECTNAME" = 'mullvadbrowser' \
  || exit_error "Unknown SIGNING_PROJECTNAME $SIGNING_PROJECTNAME"

export SIGNING_PROJECTNAME

rbm="$script_dir/../../rbm/rbm"

test -z "$no_generate_config" && generate_config
. "$script_dir/set-config.generated-config"
export no_generate_config=1

test "$tbb_version_type" = 'release' \
  || test "$tbb_version_type" = 'alpha' \
  || test "$tbb_version_type" = 'nightly' \
  || exit_error "Unknown tbb_version_type $tbb_version_type"

. "$script_dir/set-config.hosts"

signed_dir="$script_dir/../../$SIGNING_PROJECTNAME/$tbb_version_type/signed"
signed_version_dir="$signed_dir/$tbb_version"
macos_stapled_dir="$signed_dir/$tbb_version-macos-notarized+stapled-tar"
macos_signed_dir="$signed_dir/$tbb_version-macos-signed-dmg"
macos_rcodesign_signed_tar_dir="$signed_dir/$tbb_version-macos-rcodesign-signed-tar"

faketime_path=/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1

test -z "${NON_INTERACTIVE:-}" || rsync_progress="--progress"
rsync_options="-avH ${rsync_progress:-} ${DRY_RUN:-}"

tb_builders='bea boklm clairehurst dan henry jwilde ma1 morgan pierov'
wrappers_dir=/signing/tor-browser-build/tools/signing/wrappers
