2016-02-03 22:00:48 +01:00
|
|
|
#!/bin/bash
|
2017-11-08 09:40:10 +01:00
|
|
|
#
|
|
|
|
# runs here:
|
|
|
|
# https://jenkins.debian.net/job/reproducible_setup_fdroid_build_environment
|
2016-02-03 22:00:48 +01:00
|
|
|
|
|
|
|
if [ `dirname $0` != "." ]; then
|
|
|
|
echo "only run this script like ./`basename $0`"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z $WORKSPACE ]; then
|
|
|
|
WORKSPACE=`pwd`
|
|
|
|
fi
|
|
|
|
|
2018-09-24 12:15:46 +02:00
|
|
|
if [ -z $LC_ALL ] || [ $LC_ALL == "C.UTF-8" ] || [[ $LC_ALL != *.UTF-8 ]]; then
|
2018-10-17 17:17:16 +02:00
|
|
|
for var in `set | grep -Eo '^(LANG|LC_[A-Z]+)' | sort -u`; do
|
|
|
|
unset $var
|
|
|
|
done
|
2018-09-24 12:15:46 +02:00
|
|
|
export LC_ALL=en_US.UTF-8
|
2018-10-17 17:17:16 +02:00
|
|
|
echo "Forced locale to ${LC_ALL}:"
|
|
|
|
set | grep -E '^(LANG|LC_[A-Z]+)'
|
2018-09-24 12:15:46 +02:00
|
|
|
fi
|
|
|
|
|
2016-02-03 22:00:48 +01:00
|
|
|
# make sure that no VirtualBox processes are left running
|
|
|
|
cleanup_all() {
|
2016-09-15 14:38:36 +02:00
|
|
|
set +e
|
2016-02-03 22:00:48 +01:00
|
|
|
echo "$(date -u) - cleanup in progress..."
|
2016-09-15 14:38:36 +02:00
|
|
|
ps auxww | grep -e VBox -e qemu
|
2017-03-08 12:29:18 +01:00
|
|
|
virsh --connect qemu:///system list --all
|
|
|
|
ls -hl /var/lib/libvirt/images
|
2016-02-03 22:00:48 +01:00
|
|
|
cd $WORKSPACE/buildserver
|
2016-09-15 14:38:36 +02:00
|
|
|
vagrant halt
|
2016-02-03 22:00:48 +01:00
|
|
|
sleep 5
|
2016-09-15 14:38:36 +02:00
|
|
|
killall VBoxHeadless
|
2016-02-03 22:00:48 +01:00
|
|
|
sleep 5
|
2016-09-15 14:38:36 +02:00
|
|
|
killall -9 VBoxHeadless
|
2016-02-03 22:00:48 +01:00
|
|
|
echo "$(date -u) - cleanup done."
|
|
|
|
}
|
|
|
|
trap cleanup_all INT TERM EXIT
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -x
|
|
|
|
|
|
|
|
test -e ~/.cache/fdroidserver || mkdir -p ~/.cache/fdroidserver
|
|
|
|
|
|
|
|
# redirect homes to be in the git repo, so they'll get cleaned and reset
|
|
|
|
export XDG_CONFIG_HOME=$WORKSPACE
|
|
|
|
export VBOX_USER_HOME=$WORKSPACE/VirtualBox
|
|
|
|
mkdir $VBOX_USER_HOME
|
2016-09-15 14:38:36 +02:00
|
|
|
if which VBoxManage; then
|
|
|
|
VBoxManage setproperty machinefolder $WORKSPACE/virtualbox.d
|
|
|
|
VBoxManage setproperty logginglevel debug
|
|
|
|
fi
|
2016-02-03 22:00:48 +01:00
|
|
|
export VAGRANT_HOME=$WORKSPACE/vagrant.d
|
|
|
|
mkdir $VAGRANT_HOME
|
|
|
|
|
2017-12-05 12:26:15 +01:00
|
|
|
# delete leftovers from previous run
|
|
|
|
virsh -c qemu:///system undefine buildserver_default \
|
|
|
|
--nvram --managed-save --remove-all-storage --snapshots-metadata || true
|
|
|
|
virsh -c qemu:///system undefine builder_default \
|
|
|
|
--nvram --managed-save --remove-all-storage --snapshots-metadata || true
|
2018-09-19 23:41:15 +02:00
|
|
|
virsh -c qemu:///system undefine basebox-stretch64 \
|
|
|
|
--nvram --managed-save --remove-all-storage --snapshots-metadata || true
|
|
|
|
|
2017-12-28 22:51:55 +01:00
|
|
|
virsh -c qemu:///system vol-delete --pool default \
|
|
|
|
/var/lib/libvirt/images/buildserver_vagrant_box_image_0.img || true
|
2018-09-19 23:41:15 +02:00
|
|
|
virsh -c qemu:///system vol-delete --pool default \
|
|
|
|
/var/lib/libvirt/images/basebox-stretch64_vagrant_box_image_0.img || true
|
2017-12-28 22:51:55 +01:00
|
|
|
virsh -c qemu:///system vol-delete --pool default \
|
|
|
|
/var/lib/libvirt/images/jessie64_vagrant_box_image_0.img || true
|
2018-09-19 23:41:15 +02:00
|
|
|
|
2017-12-28 22:51:55 +01:00
|
|
|
rm -rf "$WORKSPACE"/../*/.testfiles
|
2017-12-05 12:26:15 +01:00
|
|
|
|
2016-02-03 22:00:48 +01:00
|
|
|
cd $WORKSPACE
|
2017-03-16 14:48:08 +01:00
|
|
|
echo "debian_mirror = 'https://deb.debian.org/debian/'" > $WORKSPACE/makebuildserver.config.py
|
2016-02-03 22:00:48 +01:00
|
|
|
echo "boot_timeout = 1200" >> $WORKSPACE/makebuildserver.config.py
|
|
|
|
echo "apt_package_cache = True" >> $WORKSPACE/makebuildserver.config.py
|
2016-06-23 17:12:06 +02:00
|
|
|
echo "copy_caches_from_host = True" >> $WORKSPACE/makebuildserver.config.py
|
2017-11-07 16:24:39 +01:00
|
|
|
echo "memory = 6144" >> $WORKSPACE/makebuildserver.config.py
|
|
|
|
echo "cpus = 2" >> $WORKSPACE/makebuildserver.config.py
|
2017-03-24 20:04:50 +01:00
|
|
|
./makebuildserver -vv --clean
|
2016-02-03 22:00:48 +01:00
|
|
|
|
2017-03-24 00:49:02 +01:00
|
|
|
if [ -z "`vagrant box list | egrep '^buildserver\s+\((libvirt|virtualbox), [0-9]+\)$'`" ]; then
|
|
|
|
vagrant box list
|
|
|
|
echo "ERROR: buildserver box does not exist!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-02-03 22:02:50 +01:00
|
|
|
# this can be handled in the jenkins job, or here:
|
2016-02-25 15:47:31 +01:00
|
|
|
if [ -e fdroiddata ]; then
|
|
|
|
cd fdroiddata
|
2017-11-27 10:06:47 +01:00
|
|
|
while ! git fetch origin --tags --prune; do sleep 10; done
|
2017-02-10 12:45:04 +01:00
|
|
|
git remote update -p
|
2016-03-14 09:35:23 +01:00
|
|
|
git checkout master
|
2017-02-10 12:45:04 +01:00
|
|
|
git reset --hard origin/master
|
2017-06-15 17:07:01 +02:00
|
|
|
git clean -fdx
|
2016-02-25 15:47:31 +01:00
|
|
|
cd ..
|
|
|
|
else
|
|
|
|
git clone --depth 1 https://gitlab.com/fdroid/fdroiddata.git fdroiddata
|
2016-02-03 22:02:50 +01:00
|
|
|
fi
|
2016-02-25 15:47:31 +01:00
|
|
|
|
2016-02-03 22:02:50 +01:00
|
|
|
cd fdroiddata
|
2017-11-27 09:58:51 +01:00
|
|
|
echo "build_server_always = True" > config.py
|
2017-02-09 15:50:58 +01:00
|
|
|
|
|
|
|
if [ -z $ANDROID_HOME ]; then
|
|
|
|
if [ -e ~/.android/bashrc ]; then
|
|
|
|
. ~/.android/bashrc
|
|
|
|
else
|
|
|
|
echo "ANDROID_HOME must be set!"
|
2017-03-24 00:49:02 +01:00
|
|
|
exit 1
|
2017-02-09 15:50:58 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2016-07-04 16:34:11 +02:00
|
|
|
# if it can't build fdroid, then its really broken
|
|
|
|
../fdroid build --verbose --stop --latest org.fdroid.fdroid
|
2016-02-25 16:03:06 +01:00
|
|
|
# Gradle, JNI, preassemble
|
2016-07-07 21:44:55 +02:00
|
|
|
../fdroid build --verbose --stop org.adaway:55
|
|
|
|
# building old versions should still work
|
|
|
|
../fdroid build --verbose --stop org.fdroid.fdroid:96150
|