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" = 'privacybrowser' \
  || exit_error "Unknown SIGNING_PROJECTNAME $SIGNING_PROJECTNAME"

test -z "${rbm_not_available+x}" && rbm="$script_dir/../../rbm/rbm"

. "$script_dir/set-config.tbb-version"
. "$script_dir/set-config.hosts"

bundle_locales="ALL"

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-stapled"
macos_signed_dir="$signed_dir/$tbb_version-macos-signed"

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='boklm dan henry ma1 pierov richard'
