Skip to content

Commit

Permalink
Merge pull request guardianproject#51 from eighthave/WIP-fdroid-sdkma…
Browse files Browse the repository at this point in the history
…nager

reproducible fixes
  • Loading branch information
n8fr8 authored Nov 17, 2021
2 parents be44185 + 6eb914c commit f69168e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 38 deletions.
35 changes: 14 additions & 21 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ cache:
- .gradle/wrapper
- .gradle/caches

variables:
wget: "wget --quiet --tries=0"


.job-template: &job-template
artifacts:
Expand Down Expand Up @@ -58,13 +55,11 @@ variables:
pkg-config

- export GRADLE_USER_HOME=$PWD/.gradle
- ndk="android-ndk-r21e" # Long Term Support release
- export ANDROID_NDK_HOME=/opt/$ndk
- ndk_zip="${ndk}-linux-x86_64.zip"
- $wget https://dl.google.com/android/repository/$ndk_zip
- echo "ad7ce5467e18d40050dc51b8e7affc3e635c85bd8c59be62de32352328ed467e $ndk_zip"
| sha256sum -c
- unzip -qq -d /opt $ndk_zip

- git clone --depth=1 https://gitlab.com/fdroid/sdkmanager.git
- git -C sdkmanager describe --always
- ndkVersion=$(sed -En 's,NDK_REQUIRED_REVISION *:?= *([0-9.]+).*,\1,p' external/Makefile)
- ./sdkmanager/sdkmanager.py "ndk;$ndkVersion"

- export AVD_SDK=`echo $CI_JOB_NAME | awk '{print $2}'`
- export AVD_TAG=`echo $CI_JOB_NAME | awk '{print $3}'`
Expand Down Expand Up @@ -115,22 +110,20 @@ release:
stage: release
image: debian:buster
<<: *job-template
variables:
ANDROID_SDK_TOOLS: "4333796"
script:
- apt-get --quiet update --yes
- apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1 default-jdk-headless
- wget --quiet --continue --output-document=android-sdk.zip
https://dl.google.com/android/repository/sdk-tools-linux-${ANDROID_SDK_TOOLS}.zip
- echo "92ffee5a1d98d856634e8b71132e8a95d96c83a63fde1099be3d86df3106def9 android-sdk.zip"
| sha256sum -c
- export ANDROID_HOME=/opt/android-sdk-linux
- unzip -qq -d $ANDROID_HOME android-sdk.zip
- chmod +x ./gradlew
- apt-get --quiet install --yes
default-jdk-headless
lib32stdc++6
lib32z1
python3-requests
tar

- export ANDROID_HOME=/opt/android-sdk
- mkdir -p $ANDROID_HOME/licenses
- printf "\n8933bad161af4178b1185d1a37fbf41ea5269c55\nd56f5187479451eabf01fb78af6dfcb131a6481e\n24333f8a63b6825ea9c5514f83c2829b004d1fee" > $ANDROID_HOME/licenses/android-sdk-license

- *setup-template
- ./sdkmanager/sdkmanager.py "tools;26.1.1"

- git clean -fdx
- ./tor-droid-make.sh release -f
3 changes: 1 addition & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ configfile = YAML.load_file(File.join(srvpath, "/.gitlab-ci.yml"))
remote_url = 'https://github.com/guardianproject/tor-android.git'

# set up essential environment variables
env = configfile['variables']
env = env.merge(configfile['release']['variables'])
env = Hash.new
env['CI_PROJECT_DIR'] = '/builds/guardianproject/tor-android'
env_file = Tempfile.new('env')
File.chmod(0644, env_file.path)
Expand Down
1 change: 0 additions & 1 deletion external/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ ifeq ($(APP_ABI), )
endif

# matching NDK revisions are required for reproducible builds
ANDROID_NDK_HOME ?= /opt/android-ndk
NDK_REVISION := $(shell sed -n 's,^Pkg.Revision *= *\([^ ]*\),\1,p' $(ANDROID_NDK_HOME)/source.properties)
NDK_REQUIRED_REVISION := 21.4.7075529
MIN_NDK_VERSION := 19
Expand Down
39 changes: 25 additions & 14 deletions tor-droid-make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,36 @@ fetch_submodules()
git submodule update --init --recursive
}

# predictable build paths make reproducible builds easier, so this
# tries to find things at likely standard paths
check_android_dependencies()
{
if [ -z $ANDROID_HOME ]; then
if [ -d /opt/android-sdk ]; then
export ANDROID_HOME=/opt/android-sdk
elif [ ! -e "$ANDROID_HOME" ]; then
echo "ANDROID_HOME must be set!"
exit
exit 1
fi
export ANDROID_SDK_ROOT="$ANDROID_HOME"

if [ -z $ANDROID_NDK_HOME ]; then
echo "ANDROID_NDK_HOME not set and 'ndk-build' not in PATH"
exit
# openssl wants a var called ANDROID_NDK_HOME
if [ ! -e "$ANDROID_NDK_HOME" ]; then
ndkVersion=$(sed -En 's,NDK_REQUIRED_REVISION *:?= *([0-9.]+).*,\1,p' external/Makefile)
echo $ANDROID_HOME/ndks/$ndkVersion/source.properties
if [ -n "$ANDROID_NDK_ROOT" ]; then
export ANDROID_NDK_HOME="$ANDROID_NDK_ROOT"
elif [ -e "$ANDROID_HOME/ndks/$ndkVersion/source.properties" ]; then
export ANDROID_NDK_HOME="$ANDROID_HOME/ndks/$ndkVersion"
elif [ -e "$ANDROID_HOME/ndk-bundle/source.properties" ]; then
export ANDROID_NDK_HOME="$ANDROID_HOME/ndk-bundle"
else
echo "ANDROID_NDK_HOME must be set!"
exit 1
fi
export ANDROID_NDK_ROOT=$ANDROID_NDK_HOME
fi
echo "Using Android SDK: $ANDROID_HOME"
echo "Using Android NDK: $ANDROID_NDK_HOME"
}

build_external_dependencies()
Expand Down Expand Up @@ -174,15 +193,7 @@ release()
exit 1
fi

if [ ! -e "$ANDROID_HOME" ]; then
echo "ANDROID_HOME must be set!"
exit 1
fi

if [ ! -e "$ANDROID_NDK_HOME" ]; then
echo "ANDROID_NDK_HOME must be set!"
exit 1
fi
check_android_dependencies

# tame the build log to fit into GitLab CI's 4MB limit
export V=0
Expand Down

0 comments on commit f69168e

Please sign in to comment.