# no failures
set -e
-CMD=echo
+CMD=
+#echo
family=$1
dist=$2
dscfile=$4
dscfilef=$(readlink -f $dscfile)
-dscfilebase=${dscfilef%%.dsc}
+dscfilef_base=${dscfilef%%.dsc}
pkg=${dscfile%_*}
#? TODO -- should be a parameter as well?
-testdir=$PWD/$pkg-$arch.test-bdepends
+testdir=${dscfilef_base}_$arch.testrdepends.$family-$dist
+secdir=${dscfilef_base}_$arch.testrdepends.$family-$dist.secure
bindir=$testdir/bin
debdir=$testdir/debs
srcdir=$testdir/srcs
echo "I: Building the new package for $pkg"
-mkdir -p $debdir $srcdir $bindir
+mkdir -p $debdir $srcdir $bindir $secdir
$CMD nd_build $family $dist $arch $dscfile --buildresult=$debdir
+echo "I: Initiating the repository"
cd $debdir
dpkg-scanpackages . >| Packages
+apt-ftparchive release . >| Release
+
+gpgargs="--no-default-keyring --secret-keyring $secdir/keyring.sec --keyring $secdir/keyring.pub"
+if [ ! -e $secdir/keyring.sec ]; then
+ # Generate a key to sign the Release file
+ cat >| $secdir/keyring.gen <<EOF
+ %echo Generating a standard key
+ Key-Type: DSA
+ Key-Length: 1024
+ Subkey-Type: ELG-E
+ Subkey-Length: 1024
+ Name-Real: NeuroDebian Tester
+ Name-Comment: Temporary key
+ Name-Email: team@neuro.debian.net
+ Expire-Date: 0
+ Passphrase: salty salt
+ %pubring $secdir/keyring.pub
+ %secring $secdir/keyring.sec
+ # Do a commit here, so that we can later print "done" :-)
+ %commit
+ %echo done
+EOF
+
+ gpg --batch --gen-key $secdir/keyring.gen
+ gpg $gpgargs --list-secret-keys
+fi
+
+echo "I: signing Release file"
+gpg $gpgargs --list-secret-keys
+gpg --yes -abs -u "NeuroDebian Tester" \
+ $gpgargs --passphrase "salty salt" \
+ -o Release.gpg Release
+pubkey=$(gpg $gpgargs -a --export -u "NeuroDebian Tester")
+
+# All binary packages produced
+pkgs=$(awk '/^Package:/{print $2;}' Packages)
cd - > /dev/null
-echo "I: Fetching all bdepends for $pkg in $family $dist under $arch"
+echo "I: Fetching all bdepends for $pkgs in $family $dist under $arch"
# need first to provide the necessary scripts out there
cp -p $(dirname $0)/nd_fetch_bdepends $bindir
-$CMD nd_execute $family $dist $arch --bindmounts $testdir $bindir/nd_fetch_bdepends $pkg $srcdir
+$CMD nd_execute $family $dist $arch --bindmounts $testdir $bindir/nd_fetch_bdepends $dist $srcdir $pkgs
echo "I: preparing the hook"
cat << EOF >| $bindir/D00add_custom_repo
echo 'deb file://$debdir ./' >| /etc/apt/sources.list.d/custom.list
-apt-get update
+echo "$pubkey" | apt-key add -
+apt-get update || /bin/bash < /dev/tty > /dev/tty 2> /dev/tty
EOF
chmod a+x $bindir/D00add_custom_repo
echo "I: Going throught the packages and testing the builds"
cd $srcdir
-summary_file=${dscfilebase}_$arch.$family-$dist.test-rdeps
+summary_file=${testdir}.summary
echo -e "\nTesting builds against $dscfile" >> $summary_file
-for dsc in *dipy*.dsc; do
+for dsc in *.dsc; do
echo " I: Building $dsc with native versions"
src=${dsc%%_*}
dscbase=${dsc%%.dsc}
--hookdir=$bindir --bindmount=$testdir \
&& new=ok || new="FAILED $newbuildsdir/${dscbase}_$arch.build"
mv ${dscbase}_$arch.build $newbuildsdir
- printf '%-20s\t%5s\t%5s\n' $dsc "$old" "$new" >> $summary_file
+ printf '%-40s\t%5s\t%5s\n' $dsc "$old" "$new" >> $summary_file
done