]> git.donarmstrong.com Git - neurodebian.git/blob - tools/nd_build_testrdepends
Also for stats report which repo and which job number use our setup
[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: Updating target chroot $family $dist"
32 $CMD nd_updatedist $family $dist $arch
33
34 mkdir -p $debdir $srcdir $bindir $secdir
35
36 echo "I: Building the new package for $pkg"
37 $CMD nd_build $family $dist $arch $dscfile --buildresult=$debdir
38
39 echo "I: Initiating the repository"
40 cd $debdir
41 dpkg-scanpackages . >| Packages
42 apt-ftparchive release . >| Release
43
44 gpgargs="--no-default-keyring --secret-keyring $secdir/keyring.sec --keyring $secdir/keyring.pub"
45 if [ ! -e $secdir/keyring.sec ]; then
46         # Generate a key to sign the Release file
47         cat >| $secdir/keyring.gen <<EOF
48              %echo Generating a standard key
49              Key-Type: DSA
50              Key-Length: 1024
51              Subkey-Type: ELG-E
52              Subkey-Length: 1024
53              Name-Real: NeuroDebian Tester
54              Name-Comment: Temporary key
55              Name-Email: team@neuro.debian.net
56              Expire-Date: 0
57              Passphrase: salty salt
58              %pubring $secdir/keyring.pub
59              %secring $secdir/keyring.sec
60              # Do a commit here, so that we can later print "done" :-)
61              %commit
62              %echo done
63 EOF
64
65         gpg --batch --gen-key $secdir/keyring.gen
66         gpg $gpgargs --list-secret-keys
67 fi
68
69 echo "I: signing Release file"
70 gpg $gpgargs --list-secret-keys
71 gpg --yes -abs -u "NeuroDebian Tester" \
72     $gpgargs --passphrase "salty salt" \
73     -o Release.gpg Release
74 pubkey=$(gpg $gpgargs -a --export -u "NeuroDebian Tester")
75
76 # All binary packages produced
77 pkgs=$(awk '/^Package:/{print $2;}' Packages)
78 cd - > /dev/null
79
80 echo "I: Fetching all bdepends for $pkgs in $family $dist under $arch"
81 # need first to provide the necessary scripts out there
82 cp -p $(dirname $0)/nd_fetch_bdepends $bindir
83 $CMD nd_execute $family $dist $arch --bindmounts $testdir $bindir/nd_fetch_bdepends $dist $srcdir $pkgs
84
85 echo "I: preparing the hook"
86 cat << EOF >| $bindir/D00add_custom_repo
87 echo 'deb file://$debdir ./' >| /etc/apt/sources.list.d/custom.list
88 echo "$pubkey" | apt-key add -
89 apt-get update || /bin/bash < /dev/tty > /dev/tty 2> /dev/tty
90 EOF
91 chmod a+x $bindir/D00add_custom_repo
92
93 echo "I: Going throught the packages and testing the builds"
94 cd $srcdir
95 summary_file=${testdir}.summary
96 echo -e "\nTesting builds against $dscfile" >> $summary_file
97 for dsc in *.dsc; do
98         echo " I: Building $dsc with native versions"
99         src=${dsc%%_*}
100         dscbase=${dsc%%.dsc}
101         nd_build $family $dist $arch $dsc --buildresult=$oldbuildsdir \
102                 && old=ok || old=FAILED
103         mv ${dscbase}_$arch.build $oldbuildsdir
104         echo " I: Building $dsc with new versions"
105         nd_build $family $dist $arch $dsc --buildresult=$newbuildsdir \
106                 --hookdir=$bindir --bindmount=$testdir \
107                 && new=ok || new="FAILED $newbuildsdir/${dscbase}_$arch.build"
108         mv ${dscbase}_$arch.build $newbuildsdir
109         printf '%-40s\t%5s\t%5s\n' $dsc "$old" "$new" >> $summary_file
110 done