#!/bin/bash
set -e

script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source "$script_dir/functions"

cd ~/"$SIGNING_PROJECTNAME-$tbb_version"

test -n "${YUBIPASS:-}" || read -s -p "Authenticode (yubihsm) password:" YUBIPASS
echo

cwd=$(pwd)
for i in `find . -name "*.exe" -print`
do
  echo "Signing $i"
  sudo -u signing-win -- "$wrappers_dir/sign-exe" \
                 "$YUBIPASS" \
                 "$cwd/$i"
  cp /home/signing-win/last-signed-file.exe "$cwd/$i"
done

unset YUBIPASS
