Skip to content
This repository has been archived by the owner on Jun 7, 2021. It is now read-only.

Commit

Permalink
Add dockerfile et al
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jul 28, 2014
1 parent dafde2f commit b425cbc
Show file tree
Hide file tree
Showing 6 changed files with 301 additions and 0 deletions.
80 changes: 80 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# QGIS for Android build

FROM phusion/baseimage
MAINTAINER Matthias Kuhn <matthias dot kuhn at gmx dot ch>

ENV HOME /root

# Regenerate SSH host keys. baseimage-docker does not contain any, so you
# have to do that yourself. You may also comment out this instruction; the
# init system will auto-generate one during boot.
RUN /etc/my_init.d/00_regen_ssh_host_keys.sh

# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]

# Install packages
RUN apt-get update
RUN apt-get install -y ant wget git cmake bison flex unzip zip expect lib32stdc++6 libc6-i386 lib32z1 openjdk-7-jdk

# Get / Setup Android SDK
RUN wget http://dl.google.com/android/android-sdk_r23-linux.tgz
RUN tar -xvzf android-sdk_r23-linux.tgz -C /opt

ENV PATH ${PATH}:/opt/android-sdk-linux/tools
ENV PATH ${PATH}:/opt/android-sdk-linux/platform-tools

# 1: Build tools
#RUN echo "y" | android update sdk -u --filter platform-tools,android-14,extra-android-support,1
ADD files/install-android-sdk.sh /root/install-android-sdk.sh
RUN /root/install-android-sdk.sh
RUN rm /root/install-android-sdk.sh

# Get / Setup Android NDK
RUN wget http://dl.google.com/android/ndk/android-ndk32-r10-linux-x86_64.tar.bz2
RUN tar -xvjf android-ndk32-r10-linux-x86_64.tar.bz2 -C /opt

# Setup Qt SDK
ADD files/qt5.3.1.tar.bz2 /usr/src/qt

# Get QGIS build scripts and source code
RUN git clone -b qt5 https://github.com/qgis/QGIS-Android.git /usr/src/QGIS-Android

# Either add QGIS source code in a volume
VOLUME ["/usr/src/QGIS"]
# Or clone it from server to container
# RUN git clone -b final-2_4_0-qt5 https://github.com/m-kuhn/QGIS.git /usr/src/QGIS

# Start building
ADD config.conf /usr/src/QGIS-Android/scripts/config.conf
ENV QGIS_ANDROID_BUILD_ALL 1

RUN git -C /usr/src/QGIS-Android pull

ENV SCRIPT_DIR /usr/src/QGIS-Android/scripts

# Manually inject python packages (Download fails too often)
# ADD files/python_27.zip /usr/src/QGIS-Android/src/python_27.zip
# ADD files/python_extras_27.zip /usr/src/QGIS-Android/src/python_extras_27.zip
#
# RUN sed -i 's@wget -c https://android-python27.googlecode.com/hg/python-build-with-qt/binaries/python_27.zip@@' $SCRIPT_DIR/setup-env.sh
# RUN sed -i 's@wget -c https://android-python27.googlecode.com/hg/python-build-with-qt/binaries/python_extras_27.zip@@' $SCRIPT_DIR/setup-env.sh

# Run build scripts
RUN $SCRIPT_DIR/setup-env.sh -n
RUN $SCRIPT_DIR/build-libs.sh

# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN rm android-sdk_r23-linux.tgz
RUN rm android-ndk32-r10-linux-x86_64.tar.bz2

# Install build/sync data
ADD files/package-update.sh /root/package-update.sh

# For cronjobs

# ADD files/crontab /etc/crontab
# ADD ssh_config /root/.ssh/config
# ADD id_rsa /root/.ssh/id_rsa

19 changes: 19 additions & 0 deletions docker/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
This creates a docker container for building QGIS for android

Usage:
======
From the current directory run
docker build .


Development:
===========
The Qt SDK installer is a piece of software that only works with a GUI dialog
and that is not what we want it to do here. So you have to do some work in order
to get the SDK into the docker image.

* Download the latest Qt SDK. Host arch: 64 bit, Target arch: 32 bit
* Install it locally
* to /usr/src/qt
* cd /usr/src/qt
* tar -zcvf qt5.3.1.tar.bz2 Qt5.3.1
168 changes: 168 additions & 0 deletions docker/config.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
#!/bin/bash

# ***************************************************************************
# config.conf - configuration template for android QGIS
# --------------------------------------
# Date : 01-Jun-2011
# Copyright : (C) 2011 by Marco Bernasocchi
# Email : marco at bernawebdesign.ch
# ***************************************************************************
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU General Public License as published by *
# * the Free Software Foundation; either version 2 of the License, or *
# * (at your option) any later version. *
# * *
# ***************************************************************************/

echo ""
set -e
#######check if config was already loaded#######
if [ ! -n "${QGIS_ANDROID_CONF_LOADED+x}" ]; then

#############################
###### CONFIGURE HERE #######
#############################

############################
# PATHS
export QGIS_DIR=/usr/src/QGIS # cloned QGIS repo
export QT_ROOT=/usr/src/qt/Qt5.3.1/5.3/android_armv7 # downloaded Qt
export ANDROID_SDK_ROOT=/opt/android-sdk-linux # downloaded SDK
export ANDROID_NDK_ROOT=/opt/android-ndk-r10 # downloaded NDK

# WARNING: armeabi-v7a builds don't work on android emulators pre api 14
DEFAULT_ANDROID_ABI=armeabi-v7a #or armeabi
# passing ANDROID_ABI=armeabi-v7a when calling a script will override the default
# for example ANDROID_ABI=armeabi-v7a ./build-all.sh
# Possible values:
# ANDROID_ABI : "armeabi-v7a", "armeabi", "armeabi-v7a with NEON", "armeabi-v7a with VFPV3", "armeabi-v6 with VFP", "x86", "mips"
# WARNING tested only with "armeabi-v7a", "armeabi"
# TODO somehow support ANDROID_ABI with spaces in names since $ANDROID_ABI is used often in mkdir
# see ascripts/android.toolchain.cmake for details

############################
# GIT
export QGIS_ANDROID_BRANCH='qt5'

############################
# COMPILE
# passing BUILD_TYPE=Release when calling a script overrides the default (e.g. BUILD_TYPE=Release ./build-all.sh)
DEFAULT_BUILD_TYPE=Debug # or Release
#build python bindings
WITH_BINDINGS=FALSE
#which GUI should be build, both can be true
export WITH_MOBILE=FALSE
export WITH_DESKTOP=TRUE

############################
# LIBS VERSIONS
export FREEXL_NAME=freexl-1.0.0e
export SPATIALITE_NAME=libspatialite-4.1.1
export EXPAT_NAME=expat-2.0.1
export EXPAT_VERSION=2.0.1
export GEOS_NAME=geos-3.4.2
export GSL_NAME=gsl-1.14
export GDAL_NAME=gdal-1.10.1
export GDAL_DOWNLOAD_FOLDER=1.10.1
export PROJ_NAME=proj-4.9.0
export PROJ_DOWNLOAD_NAME=proj-4.9.0b2
export SPATIALINDEX_NAME=spatialindex-src-1.7.1
export SQLITE_NAME=sqlite-autoconf-3080002
export QWT_NAME=qwt-6.1.0
export QWT_VERSION=6.1.0
export QWTPOLAR_NAME=qwtpolar-1.1.0
export QWTPOLAR_VERSION=1.1.0
export ICONV_NAME=libiconv-1.13.1
export PQ_NAME=postgresql-9.0.4
export PQ_VERSION=9.0.4


################################################
######LIKELY UNNEEDED TO CONFIGURE FURTHER######
################################################
if [ ! -n "${ROOT_DIR+x}" ]; then
export ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )"
fi
if [ ! -n "${ANDROID_ABI+x}" ]; then
export ANDROID_ABI=$DEFAULT_ANDROID_ABI
fi
if [ ! -n "${BUILD_TYPE+x}" ]; then
export BUILD_TYPE=$DEFAULT_BUILD_TYPE
fi

export ADB=$ANDROID_SDK_ROOT/platform-tools/adb
export QGIS_BUILD_DIR=$QGIS_DIR/build-$BUILD_TYPE-$ANDROID_ABI
export INSTALL_DIR=$ROOT_DIR/out/$BUILD_TYPE/$ANDROID_ABI
export SCRIPT_DIR=$ROOT_DIR/scripts
export PATCH_DIR=$ROOT_DIR/patches
export SRC_DIR=$ROOT_DIR/src
export TMP_DIR=$ROOT_DIR/tmp
export ANDROID_LEVEL=14
export ANDROID_NDK_PLATFORM=android-$ANDROID_LEVEL
export ANDROID_NDK_HOST=linux-x86_64
export ANDROID_NDK_TOOLCHAIN_PREFIX=arm-linux-androideabi
if [ ! -n "${ANDROID_NDK_TOOLCHAIN_VERSION+x}" ]; then
export ANDROID_NDK_TOOLCHAIN_VERSION=4.8
export ANDROID_STANDALONE_TOOLCHAIN=$ANDROID_NDK_ROOT/standalonetoolchain-$ANDROID_NDK_PLATFORM-$ANDROID_NDK_TOOLCHAIN_VERSION # path where the toolchain will be created
fi
export QT_INCLUDE=$QT_ROOT/include
export QMAKE=$QT_ROOT/bin/qmake
export APK_DIR=$ROOT_DIR/apk
export GDB_SERVER=$ANDROID_NDK_ROOT/prebuilt/android-arm/gdbserver/gdbserver

#setting compilers names
#see https://groups.google.com/forum/?hl=en#!topic/android-ndk/DVNS_mQHxdA
export PATH=$ANDROID_STANDALONE_TOOLCHAIN/bin:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$PATH
export CC=arm-linux-androideabi-gcc
export CXX=arm-linux-androideabi-g++
export LD=arm-linux-androideabi-ld
export AR=arm-linux-androideabi-ar
export RANLIB=arm-linux-androideabi-ranlib
export AS=arm-linux-androideabi-as

export MY_STD_CONFIGURE_FLAGS="--prefix=$INSTALL_DIR --host=arm-linux-androideabi"
#FPU (floating point unit)FLAG:
#see http://gcc.gnu.org/onlinedocs/gcc-4.4.3/gcc/ARM-Options.html
#see http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0408f/index.html
#see NDK docs/STANDALONE-TOOLCHAIN.html
#for generic MY_FPU=vfp
MY_FPU=vfp
#for tegra processors (xoom, transformer, iconia, galaxy tab)
#MY_FPU=vfpv3-d16
#for hummingbird and neon supporting processors (galaxy phone) -mfpu=neon
#MY_FPU=neon
if [ "$ANDROID_ABI" = "armeabi-v7a with VFPV3" ]; then
MY_FPU=vfpv3
elif [ "$ANDROID_ABI" = "armeabi-v7a with NEON" ]; then
MY_FPU=neon
fi
ARMV7A_flags=" -march=armv7-a -mfloat-abi=softfp -mfpu=$MY_FPU"

#build mthumb instructions only in non Debug mode
if [ "$BUILD_TYPE" = "Debug" ]; then
extraFlags="-g -O0 -marm -finline-limit=300 -fno-strict-aliasing -fno-omit-frame-pointer -DDEBUG -D_DEBUG"
else
extraFlags="-mthumb -O2"
fi

#-std=gnu99: http://comments.gmane.org/gmane.comp.handhelds.android.ndk/8732
#-std=c99: http://stackoverflow.com/questions/9247151/compiling-icu-for-android-uint64-t-does-not-name-a-type
#http://stackoverflow.com/questions/5135734/whats-the-difference-in-gcc-between-std-gnu0x-and-std-c0x-and-which-one-s
export MY_STD_CFLAGS="-DANDROID -Wno-psabi -std=c99 $extraFlags"
if [ "$ANDROID_ABI" = "armeabi-v7a" ]; then
export MY_STD_CFLAGS=$MY_STD_CFLAGS$ARMV7A_flags
fi
export MY_STD_CXXFLAGS="-DANDROID -Wno-psabi -std=gnu++0x $extraFlags"
export MY_STD_LDFLAGS="-Wl,--fix-cortex-a8"

#############################
#######END CONFIGURE#########
#############################

#######detect cpu cores######
CORES=$(cat /proc/cpuinfo | grep processor | wc -l)
export CORES=1 #$(($CORES+1))
#######mark conf as loaded#######
export QGIS_ANDROID_CONF_LOADED=1
fi
16 changes: 16 additions & 0 deletions docker/files/crontab
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed

24 13 * * * root /root/package-update.sh
12 changes: 12 additions & 0 deletions docker/files/install-android-sdk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
expect -c '
set timeout -1 ;
spawn android update sdk -u --filter platform-tool,android-14,build-tools-20.0.0,extra-android-support;
expect {
"Do you accept the license" { exp_send "y\r" ; exp_continue }
eof
}
'
# Workaround for annotations.jar missing
# See
# http://stackoverflow.com/questions/24438748/fail-to-find-annotations-jar-after-updating-to-adt-23
cp /opt/android-sdk-linux/extras/android/support/annotations/android-support-annotations.jar /opt/android-sdk-linux/tools/support/annotations.jar
6 changes: 6 additions & 0 deletions docker/files/package-update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

/usr/src/QGIS-Android/scripts/build-qgis-and-apk.sh
cp /usr/src/QGIS-Android/apk/bin/qgis-debug.apk /root/packages/qgis-debug-$(date +%Y-%m-%d).apk
ln -sf qgis-debug-$(date +%Y-%m-%d).apk /root/packages/qgis-debug-latest.apk

0 comments on commit b425cbc

Please sign in to comment.