| 1 | rootdir=$(pwd -P)
|
| 2 |
|
| 3 | distclean () {
|
| 4 | echo "Removing traces of previous builds from $rootdir"
|
| 5 | local allpkgs=$(find $rootdir -maxdepth 3 -name APKBUILD -print | sed -e 's/\/APKBUILD//g' | sort)
|
| 6 | for p in $allpkgs ; do
|
| 7 | cd $p
|
| 8 | pwd
|
| 9 | abuild clean 2>&1
|
| 10 | abuild cleanoldpkg 2>&1
|
| 11 | abuild cleanpkg 2>&1
|
| 12 | abuild cleancache 2>&1
|
| 13 | done
|
| 14 | }
|
| 15 |
|
| 16 | build () {
|
| 17 | local pkgs
|
| 18 | local maintainer
|
| 19 | local pkgno
|
| 20 | local failed
|
| 21 | pkgs=$($rootdir/aport.lua deplist $rootdir $1)
|
| 22 | pktcnt=$(echo $pkgs | wc -w)
|
| 23 | pkgno=0
|
| 24 | failed=0
|
| 25 | for p in $pkgs ; do
|
| 26 | pkgno=$(expr "$pkgno" + 1)
|
| 27 | echo "Building $p ($pkgno of $pktcnt in $1 - $failed failed)"
|
| 28 | cd $rootdir/$1/$p
|
| 29 | if [ -n "$debug" ] ; then
|
| 30 | apk info | sort > $rootdir/packages.$1.$pkgno.$p.before
|
| 31 | fi
|
| 32 | abuild -rm > $rootdir/$1_$p.txt 2>&1
|
| 33 | if [ "$?" = "0" ] ; then
|
| 34 | if [ -z "$debug" ] ; then
|
| 35 | rm $rootdir/$1_$p.txt
|
| 36 | fi
|
| 37 | else
|
| 38 | echo "Package $1/$p failed to build (output in $rootdir/$1_$p.txt)"
|
| 39 | if [ -n "$mail" ] ; then
|
| 40 | maintainer=$(grep Maintainer APKBUILD | cut -d " " -f 3-)
|
| 41 | if [ -n "$maintainer" ] ; then
|
| 42 | recipients="$maintainer -cc [email protected]"
|
| 43 | else
|
| 44 | recipients="[email protected]"
|
| 45 | fi
|
| 46 | if [ -n "$mail" ] ; then
|
| 47 | echo "Package $1/$p failed to build. Build output is attached" | \
|
| 48 | email -s "NOT SPAM $p build report" -a $rootdir/$1_$p.txt \
|
| 49 | -n AlpineBuildBot -f [email protected] $recipients
|
| 50 | fi
|
| 51 | fi
|
| 52 | failed=$(expr "$failed" + 1)
|
| 53 | fi
|
| 54 | if [ -n "$debug" ] ; then
|
| 55 | apk info | sort > $rootdir/packages.$1.$pkgno.$p.after
|
| 56 | fi
|
| 57 | done
|
| 58 | cd $rootdir
|
| 59 | }
|
| 60 |
|
| 61 | touch START_OF_BUILD.txt
|
| 62 |
|
| 63 | unset clean
|
| 64 | unset mail
|
| 65 | while getopts "cmd" opt; do
|
| 66 | case $opt in
|
| 67 | 'c') clean="--clean";;
|
| 68 | 'm') mail="--mail";;
|
| 69 | 'd') debug="--debug";;
|
| 70 | esac
|
| 71 | done
|
| 72 |
|
| 73 | if [ -n "$clean" ] ; then
|
| 74 | echo "Invoked with 'clean' option. This will take a while ..."
|
| 75 | tmp=$(distclean)
|
| 76 | echo "Done"
|
| 77 | fi
|
| 78 |
|
| 79 | echo "Refresh aports tree"
|
| 80 | git pull
|
| 81 |
|
| 82 | |
| 83 | |
| 84 | |
| 85 |
|
| 86 | for s in main testing unstable ; do
|
| 87 | echo "Building packages in $s"
|
| 88 | build $s
|
| 89 | done
|
| 90 |
|
| 91 | touch END_OF_BUILD.txt
|
| 92 |
|
| 93 | echo "Done"
|
| 94 |
|