chiark / gitweb /
build: log vcs tools version on every build attempt
[fdroidserver.git] / jenkins-setup-build-environment
1 #!/bin/bash
2 #
3 # runs here:
4 # https://jenkins.debian.net/job/reproducible_setup_fdroid_build_environment
5
6 if [ `dirname $0` != "." ]; then
7     echo "only run this script like ./`basename $0`"
8     exit
9 fi
10
11 if [ -z $WORKSPACE ]; then
12     WORKSPACE=`pwd`
13 fi
14
15 # make sure that no VirtualBox processes are left running
16 cleanup_all() {
17     set +e
18     echo "$(date -u) - cleanup in progress..."
19     ps auxww | grep -e VBox -e qemu
20     virsh --connect qemu:///system list --all
21     ls -hl /var/lib/libvirt/images
22     cd $WORKSPACE/buildserver
23     vagrant halt
24     sleep 5
25     killall VBoxHeadless
26     sleep 5
27     killall -9 VBoxHeadless
28     echo "$(date -u) - cleanup done."
29 }
30 trap cleanup_all INT TERM EXIT
31
32 set -e
33 set -x
34
35 # make sure we have the vagrant box image cached
36 test -e ~/.cache/fdroidserver || mkdir -p ~/.cache/fdroidserver
37 cd ~/.cache/fdroidserver
38 wget --tries=1 --timeout=5 --continue https://f-droid.org/jessie64.box || true
39 echo "de3e3c4a9c13e8c015e30edeea0f583b195d1ee8ff9ad4814e933bbfb560200f  jessie64.box" > jessie64.box.sha256
40 sha256sum -c jessie64.box.sha256
41
42 # redirect homes to be in the git repo, so they'll get cleaned and reset
43 export XDG_CONFIG_HOME=$WORKSPACE
44 export VBOX_USER_HOME=$WORKSPACE/VirtualBox
45 mkdir $VBOX_USER_HOME
46 if which VBoxManage; then
47     VBoxManage setproperty machinefolder $WORKSPACE/virtualbox.d
48     VBoxManage setproperty logginglevel debug
49 fi
50 export VAGRANT_HOME=$WORKSPACE/vagrant.d
51 mkdir $VAGRANT_HOME
52
53 cd $WORKSPACE
54 echo "debian_mirror = 'https://deb.debian.org/debian/'" > $WORKSPACE/makebuildserver.config.py
55 echo "boot_timeout = 1200" >> $WORKSPACE/makebuildserver.config.py
56 echo "apt_package_cache = True" >> $WORKSPACE/makebuildserver.config.py
57 echo "copy_caches_from_host = True" >> $WORKSPACE/makebuildserver.config.py
58 echo "memory = 6144" >> $WORKSPACE/makebuildserver.config.py
59 echo "cpus = 2" >> $WORKSPACE/makebuildserver.config.py
60 ./makebuildserver -vv --clean
61
62 if [ -z "`vagrant box list | egrep '^buildserver\s+\((libvirt|virtualbox), [0-9]+\)$'`" ]; then
63     vagrant box list
64     echo "ERROR: buildserver box does not exist!"
65     exit 1
66 fi
67
68 # this can be handled in the jenkins job, or here:
69 if [ -e fdroiddata ]; then
70     cd fdroiddata
71     while ! git fetch origin --tags --prune; do sleep 10; done
72     git remote update -p
73     git checkout master
74     git reset --hard origin/master
75     git clean -fdx
76     cd ..
77 else
78     git clone --depth 1 https://gitlab.com/fdroid/fdroiddata.git fdroiddata
79 fi
80
81 cd fdroiddata
82 echo "build_server_always = True" > config.py
83
84 if [ -z $ANDROID_HOME ]; then
85     if [ -e ~/.android/bashrc ]; then
86         . ~/.android/bashrc
87     else
88         echo "ANDROID_HOME must be set!"
89         exit 1
90     fi
91 fi
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 # building old versions should still work
98 ../fdroid build --verbose --stop org.fdroid.fdroid:96150
99 # test OTA update ZIP build and publish
100 ../fdroid build --verbose --stop org.fdroid.fdroid.privileged.ota:2070