#!/usr/bin/env bash

# Ensure that default values are set, prefix_path should be set at this point so
# this is also a failsafe.
#TODO: update repository_url to "wayneeseguin/bdsm"
true \
  "${prefix_path:="/usr/local"}" \
  "${bin_path:="${prefix_path}/bin"}" \
  "${src_path:="${bdsm_path}/src"}" \
  "${md5_path:="${bdsm_path}/md5"}" \
  "${archives_path:="${bdsm_path}/archives"}" \
  "${archive_format:=tar.gz}" \
  "${package_name:=${extension}}" \
  "${repository_url:="git://github.com/wayneeseguin/bdsm"}"

true \
  "${extensions_url:=$(hash_file "$config_path/defaults" "extensions_url")}" \
  "${extensions_repository_url:=$(hash_file "$config_path/defaults" "extensions_repository_url")}" \
  ${remote:="origin"} \
  ${branch:="master"}

for config in "${bdsm_path}/extensions/core/config/defaults" "${bdsm_path}/extensions/core/config/defaults"
do
  if file_exists "$config"
  then
    true "${releases_url:=$(hash_file "${config}" "releases_url")}"
  fi
done

# Load the BDSM framework version.
bdsm_version

user="$USER"

extensions_src_path="${src_path}/extensions"

export prefix_path bin_path source_path
