mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-09-11 15:13:27 +02:00
120 lines
3.7 KiB
Bash
Executable File
120 lines
3.7 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# runs here:
|
|
# https://jenkins.debian.net/job/reproducible_setup_fdroid_build_environment
|
|
|
|
if [ `dirname $0` != "." ]; then
|
|
echo "only run this script like ./`basename $0`"
|
|
exit
|
|
fi
|
|
|
|
if [ -z $WORKSPACE ]; then
|
|
WORKSPACE=`pwd`
|
|
fi
|
|
|
|
if [ -z $LC_ALL ] || [ $LC_ALL == "C.UTF-8" ] || [[ $LC_ALL != *.UTF-8 ]]; then
|
|
for var in `set | grep -Eo '^(LANG|LC_[A-Z]+)' | sort -u`; do
|
|
unset $var
|
|
done
|
|
export LC_ALL=en_US.UTF-8
|
|
echo "Forced locale to ${LC_ALL}:"
|
|
set | grep -E '^(LANG|LC_[A-Z]+)'
|
|
fi
|
|
|
|
# make sure that no VirtualBox processes are left running
|
|
cleanup_all() {
|
|
set +e
|
|
echo "$(date -u) - cleanup in progress..."
|
|
ps auxww | grep -e VBox -e qemu
|
|
virsh --connect qemu:///system list --all
|
|
ls -hl /var/lib/libvirt/images
|
|
cd $WORKSPACE/buildserver
|
|
vagrant halt
|
|
sleep 5
|
|
killall VBoxHeadless
|
|
sleep 5
|
|
killall -9 VBoxHeadless
|
|
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
|
|
if which VBoxManage; then
|
|
VBoxManage setproperty machinefolder $WORKSPACE/virtualbox.d
|
|
VBoxManage setproperty logginglevel debug
|
|
fi
|
|
export VAGRANT_HOME=$WORKSPACE/vagrant.d
|
|
mkdir $VAGRANT_HOME
|
|
|
|
# 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
|
|
virsh -c qemu:///system undefine basebox-stretch64 \
|
|
--nvram --managed-save --remove-all-storage --snapshots-metadata || true
|
|
|
|
virsh -c qemu:///system vol-delete --pool default \
|
|
/var/lib/libvirt/images/buildserver_vagrant_box_image_0.img || true
|
|
virsh -c qemu:///system vol-delete --pool default \
|
|
/var/lib/libvirt/images/basebox-stretch64_vagrant_box_image_0.img || true
|
|
virsh -c qemu:///system vol-delete --pool default \
|
|
/var/lib/libvirt/images/jessie64_vagrant_box_image_0.img || true
|
|
|
|
rm -rf "$WORKSPACE"/../*/.testfiles
|
|
|
|
cd $WORKSPACE
|
|
echo "debian_mirror = 'https://deb.debian.org/debian/'" > $WORKSPACE/makebuildserver.config.py
|
|
echo "boot_timeout = 1200" >> $WORKSPACE/makebuildserver.config.py
|
|
echo "apt_package_cache = True" >> $WORKSPACE/makebuildserver.config.py
|
|
echo "copy_caches_from_host = True" >> $WORKSPACE/makebuildserver.config.py
|
|
echo "memory = 6144" >> $WORKSPACE/makebuildserver.config.py
|
|
echo "cpus = 2" >> $WORKSPACE/makebuildserver.config.py
|
|
./makebuildserver -vv --clean
|
|
|
|
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
|
|
|
|
# this can be handled in the jenkins job, or here:
|
|
if [ -e fdroiddata ]; then
|
|
cd fdroiddata
|
|
while ! git fetch origin --tags --prune; do sleep 10; done
|
|
git remote update -p
|
|
git checkout master
|
|
git reset --hard origin/master
|
|
git clean -fdx
|
|
cd ..
|
|
else
|
|
git clone --depth 1 https://gitlab.com/fdroid/fdroiddata.git fdroiddata
|
|
fi
|
|
|
|
cd fdroiddata
|
|
echo "build_server_always = True" > config.py
|
|
|
|
if [ -z $ANDROID_HOME ]; then
|
|
if [ -e ~/.android/bashrc ]; then
|
|
. ~/.android/bashrc
|
|
else
|
|
echo "ANDROID_HOME must be set!"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# if it can't build fdroid, then its really broken
|
|
../fdroid build --verbose --stop --latest org.fdroid.fdroid
|
|
# Gradle, JNI, preassemble
|
|
../fdroid build --verbose --stop org.adaway:55
|
|
# building old versions should still work
|
|
../fdroid build --verbose --stop org.fdroid.fdroid:96150
|