chiark / gitweb /
scanner: rename variables, use os.path.relpath
[fdroidserver.git] / jenkins-build-makebuildserver
1 #!/bin/bash
2
3 if [ `dirname $0` != "." ]; then
4     echo "only run this script like ./`basename $0`"
5     exit
6 fi
7
8 if [ -z $WORKSPACE ]; then
9     WORKSPACE=`pwd`
10 fi
11
12 # make sure that no VirtualBox processes are left running
13 cleanup_all() {
14     set +e
15     echo "$(date -u) - cleanup in progress..."
16     ps auxww | grep -e VBox -e qemu
17     virsh --connect qemu:///system list --all
18     ls -hl /var/lib/libvirt/images
19     cd $WORKSPACE/buildserver
20     vagrant halt
21     sleep 5
22     killall VBoxHeadless
23     sleep 5
24     killall -9 VBoxHeadless
25     echo "$(date -u) - cleanup done."
26 }
27 trap cleanup_all INT TERM EXIT
28
29 set -e
30 set -x
31
32 # make sure we have the vagrant box image cached
33 test -e ~/.cache/fdroidserver || mkdir -p ~/.cache/fdroidserver
34 cd ~/.cache/fdroidserver
35 wget --tries=1 --timeout=5 --continue https://f-droid.org/jessie64.box || true
36 echo "de3e3c4a9c13e8c015e30edeea0f583b195d1ee8ff9ad4814e933bbfb560200f  jessie64.box" > jessie64.box.sha256
37 sha256sum -c jessie64.box.sha256
38
39 # redirect homes to be in the git repo, so they'll get cleaned and reset
40 export XDG_CONFIG_HOME=$WORKSPACE
41 export VBOX_USER_HOME=$WORKSPACE/VirtualBox
42 mkdir $VBOX_USER_HOME
43 if which VBoxManage; then
44     VBoxManage setproperty machinefolder $WORKSPACE/virtualbox.d
45     VBoxManage setproperty logginglevel debug
46 fi
47 export VAGRANT_HOME=$WORKSPACE/vagrant.d
48 mkdir $VAGRANT_HOME
49
50 cd $WORKSPACE
51 echo "debian_mirror = 'https://deb.debian.org/debian/'" > $WORKSPACE/makebuildserver.config.py
52 echo "boot_timeout = 1200" >> $WORKSPACE/makebuildserver.config.py
53 echo "apt_package_cache = True" >> $WORKSPACE/makebuildserver.config.py
54 echo "copy_caches_from_host = True" >> $WORKSPACE/makebuildserver.config.py
55 ./makebuildserver -vv --clean
56
57 if [ -z "`vagrant box list | egrep '^buildserver\s+\((libvirt|virtualbox), [0-9]+\)$'`" ]; then
58     vagrant box list
59     echo "ERROR: buildserver box does not exist!"
60     exit 1
61 fi
62
63 # this can be handled in the jenkins job, or here:
64 if [ -e fdroiddata ]; then
65     cd fdroiddata
66     while ! git fetch; do sleep 1; done
67     git remote update -p
68     git checkout master
69     git reset --hard origin/master
70     git clean -fdx
71     cd ..
72 else
73     git clone --depth 1 https://gitlab.com/fdroid/fdroiddata.git fdroiddata
74 fi
75
76 cd fdroiddata
77
78 if [ -z $ANDROID_HOME ]; then
79     if [ -e ~/.android/bashrc ]; then
80         . ~/.android/bashrc
81     else
82         echo "ANDROID_HOME must be set!"
83         exit 1
84     fi
85 fi
86
87 ../fdroid init --verbose
88 export GNUPGHOME=$WORKSPACE/tests/gnupghome
89 echo "gpghome = '$GNUPGHOME'" >> config.py
90 echo "gpgkey = 'CE71F7FB'" >> config.py
91 echo "build_server_always = True" >> config.py
92
93 # if it can't build fdroid, then its really broken
94 ../fdroid build --verbose --stop --latest org.fdroid.fdroid
95 # Gradle, JNI, preassemble
96 ../fdroid build --verbose --stop org.adaway:55
97 # Uses verification
98 ../fdroid build --verbose --stop info.guardianproject.checkey:101
99 # building old versions should still work
100 ../fdroid build --verbose --stop org.fdroid.fdroid:96150
101 # test OTA update ZIP build and publish
102 ../fdroid build --verbose --stop org.fdroid.fdroid.privileged.ota:2030
103
104 # publish process when building and signing are on separate machines
105 test -d repo || mkdir repo
106 test -d archive || mkdir archive
107 # copy everything over to run on SIGN machine
108 ../fdroid publish --verbose
109 ../fdroid gpgsign --verbose
110 # copy everything over to run on BUILD machine
111 ../fdroid update --verbose --nosign
112 # copy everything over to run on SIGN machine
113 ../fdroid signindex --verbose
114
115 ../fdroid rewritemeta --verbose
116 git --no-pager diff