#!/bin/bash
set -e
. tests/lib
. $troot/lib-import-chk

t-tstunt-parsechangelog

t-archive-none example
v=1.0-1

link_src_files () {
	mkdir $1
	cp $troot/pkg-srcs/${p}_* $1
	dscfn=$1/$dscleaf
}

combo () {
	case $bpdhow in
	none)	bpd=..				;;
	abs)	bpd=$tmp/$subdir/bpd		;;
	rel)	bpd=../bpd			;;
	*)	x-unknown-bpdhow $bpdhow	;;
	esac

	mkdir -p $bpd
	git config --local dgit.default.build-products-dir $bpd

	dscleaf=${p}_${v}.dsc
	dscfn=$troot/pkg-srcs/$dscleaf

	case $dschow in
	abs)					;;
	rel)	link_src_files ../copies	;;
	bpd)	link_src_files $bpd		;;
	*)	x-unknown-dschow $dschow	;;
	esac

	t-dgit import-dsc $dscfn +import
	git reset --hard import

	t-dch-commit -v$v.1 -m 'New version'
	t-dch-commit-r
	t-dgit build-source
}

for bpdhow in none rel abs; do
	for dschow in rel abs; do

		subdir=$bpdhow-$dschow
		mkdir $subdir
		cd $subdir

		mkdir $p
		cd $p

		git init
		combo
		cd ../..
	done
done
