]> git.donarmstrong.com Git - neurodebian.git/blob - tools/nd_build_testrdepends
BF: move -u in nd_build down so we get sensible help
[neurodebian.git] / tools / nd_build_testrdepends
1 #!/bin/bash
2
3 # no undefined
4 set -u
5 # no failures
6 set -e
7
8 CMD=
9 #echo
10
11 family=$1
12 dist=$2
13 arch=$3      # limit to 1 for now
14
15 dscfile=$4
16 dscfilef=$(readlink -f $dscfile)
17 dscfilef_base=${dscfilef%%.dsc}
18
19 pkg=${dscfile%_*}
20
21 #? TODO -- should be a parameter as well?
22
23 testdir=${dscfilef_base}_$arch.testrdepends.$family-$dist
24 secdir=${dscfilef_base}_$arch.testrdepends.$family-$dist.secure
25 bindir=$testdir/bin
26 debdir=$testdir/debs
27 srcdir=$testdir/srcs
28 oldbuildsdir=$srcdir/old
29 newbuildsdir=$srcdir/new
30
31 echo "I: Building the new package for $pkg"
32
33 mkdir -p $debdir $srcdir $bindir $secdir
34 $CMD nd_build $family $dist $arch $dscfile --buildresult=$debdir
35
36 echo "I: Initiating the repository"
37 cd $debdir
38 dpkg-scanpackages . >| Packages
39 apt-ftparchive release . >| Release
40
41 gpgargs="--no-default-keyring --secret-keyring $secdir/keyring.sec --keyring $secdir/keyring.pub"
42 if [ ! -e $secdir/keyring.sec ]; then
43         # Generate a key to sign the Release file
44         cat >| $secdir/keyring.gen <<EOF
45              %echo Generating a standard key
46              Key-Type: DSA
47              Key-Length: 1024
48              Subkey-Type: ELG-E
49              Subkey-Length: 1024
50              Name-Real: NeuroDebian Tester
51              Name-Comment: Temporary key
52              Name-Email: team@neuro.debian.net
53              Expire-Date: 0
54              Passphrase: salty salt
55              %pubring $secdir/keyring.pub
56              %secring $secdir/keyring.sec
57              # Do a commit here, so that we can later print "done" :-)
58              %commit
59              %echo done
60 EOF
61
62         gpg --batch --gen-key $secdir/keyring.gen
63         gpg $gpgargs --list-secret-keys
64 fi
65
66 echo "I: signing Release file"
67 gpg $gpgargs --list-secret-keys
68 gpg --yes -abs -u "NeuroDebian Tester" \
69     $gpgargs --passphrase "salty salt" \
70     -o Release.gpg Release
71 pubkey=$(gpg $gpgargs -a --export -u "NeuroDebian Tester")
72
73 # All binary packages produced
74 pkgs=$(awk '/^Package:/{print $2;}' Packages)
75 cd - > /dev/null
76
77 echo "I: Fetching all bdepends for $pkgs in $family $dist under $arch"
78 # need first to provide the necessary scripts out there
79 cp -p $(dirname $0)/nd_fetch_bdepends $bindir
80 $CMD nd_execute $family $dist $arch --bindmounts $testdir $bindir/nd_fetch_bdepends $srcdir $pkgs
81
82 echo "I: preparing the hook"
83 cat << EOF >| $bindir/D00add_custom_repo
84 echo 'deb file://$debdir ./' >| /etc/apt/sources.list.d/custom.list
85 echo "$pubkey" | apt-key add -
86 apt-get update || /bin/bash < /dev/tty > /dev/tty 2> /dev/tty
87 EOF
88 chmod a+x $bindir/D00add_custom_repo
89
90 echo "I: Going throught the packages and testing the builds"
91 cd $srcdir
92 summary_file=${testdir}.summary
93 echo -e "\nTesting builds against $dscfile" >> $summary_file
94 for dsc in *.dsc; do
95         echo " I: Building $dsc with native versions"
96         src=${dsc%%_*}
97         dscbase=${dsc%%.dsc}
98         nd_build $family $dist $arch $dsc --buildresult=$oldbuildsdir \
99                 && old=ok || old=FAILED
100         mv ${dscbase}_$arch.build $oldbuildsdir
101         echo " I: Building $dsc with new versions"
102         nd_build $family $dist $arch $dsc --buildresult=$newbuildsdir \
103                 --hookdir=$bindir --bindmount=$testdir \
104                 && new=ok || new="FAILED $newbuildsdir/${dscbase}_$arch.build"
105         mv ${dscbase}_$arch.build $newbuildsdir
106         printf '%-40s\t%5s\t%5s\n' $dsc "$old" "$new" >> $summary_file
107 done