build-apk.sh 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/bash
  2. REPO_DIR=$GOPATH/src/github.com/refraction-networking/gotapdance/
  3. #sed -i.bak "s/buildInfo = \"\"/buildInfo = \"$TRAVIS_BRANCH-$TRAVIS_COMMIT\"/" tapdance/logger.go
  4. git clone https://github.com/Psiphon-Labs/psiphon-tunnel-core.git $GOPATH/src/github.com/Psiphon-Labs/psiphon-tunnel-core
  5. cd $GOPATH/src/github.com/Psiphon-Labs/psiphon-tunnel-core && git checkout -b build-refraction-networking
  6. go get github.com/kardianos/govendor
  7. cd $GOPATH/src/github.com/Psiphon-Labs/psiphon-tunnel-core && $GOPATH/bin/govendor remove github.com/refraction-networking/gotapdance/...
  8. sed -i.bak 's/refraction_networking_tapdance.Logger().Out = ioutil.Discard//' $GOPATH/src/github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/tapdance/tapdance.go
  9. # Conjure APK
  10. echo "Conjure APK before_Script"
  11. cd $GOPATH/src/github.com/refraction-networking/gotapdance
  12. docker pull refraction/psiandroid:latest
  13. mkdir -p $GOPATH/src/bitbucket.org/psiphon
  14. hg clone https://bitbucket.org/psiphon/psiphon-circumvention-system $GOPATH/src/bitbucket.org/psiphon/psiphon-circumvention-system
  15. cd $GOPATH/src/bitbucket.org/psiphon/psiphon-circumvention-system #&& hg checkout
  16. # Use modified EmbeddedValues.java for TapDance
  17. cd $GOPATH/src/github.com/refraction-networking/gotapdance
  18. /usr/local/ssl/bin/openssl enc -nosalt -aes-256-cbc -md sha512 -pbkdf2 -iter 1000 -pass pass:$aes_cbc_passwd -d -in build/EmbeddedValues.java.enc -out $GOPATH/src/bitbucket.org/psiphon/psiphon-circumvention-system/Android/app/src/main/java/com/psiphon3/psiphonlibrary/EmbeddedValues.java
  19. echo "patching..."
  20. # Patched tunneling protocol for TapDance
  21. patch $GOPATH/src/bitbucket.org/psiphon/psiphon-circumvention-system/Android/app/src/main/java/com/psiphon3/psiphonlibrary/TunnelManager.java build/TunnelManager.java.patch
  22. # Patch the Psiphon app's gradle build for java 1.8 compatibility [TODO]{priority:later} remove this when psiphon merges it themselves
  23. patch $GOPATH/src/bitbucket.org/psiphon/psiphon-circumvention-system/Android/app/build.gradle build/PsiphonCoreGradle.patch
  24. # Add dialer options to enable Conjure
  25. patch $GOPATH/src/github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/tapdance/tapdance.go build/conjure.golang.patch
  26. echo "digesting..."
  27. # Digest this branch's ClientConf into Psiphon's embedded_config
  28. ./test_scripts/psiphon_digest_cc.sh ./assets/ClientConf $GOPATH/src/github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/tapdance/embedded_config.go
  29. echo "Conjure APK script"
  30. cd $REPO_DIR
  31. # Build Psiphon Android Library ca.psiphon.aar
  32. #docker run -v $DOCKER_DIR:$GOPATH/go/src/github.com/refraction-networking/gotapdance -v $GOPATH/src/github.com/Psiphon-Labs/psiphon-tunnel-core:$GOPATH/go/src/github.com/Psiphon-Labs/psiphon-tunnel-core refraction/psiandroid /bin/bash -c 'cd $GOPATH/src/github.com/Psiphon-Labs/psiphon-tunnel-core/MobileLibrary/Android && ./make.bash "TAPDANCE"'
  33. docker run -v $REPO_DIR:/go/src/github.com/refraction-networking/gotapdance -v $GOPATH/src/github.com/Psiphon-Labs/psiphon-tunnel-core:/go/src/github.com/Psiphon-Labs/psiphon-tunnel-core refraction/psiandroid /bin/bash -c 'cd /go/src/github.com/Psiphon-Labs/psiphon-tunnel-core/MobileLibrary/Android && ./make.bash "TAPDANCE"'
  34. echo "moving .aar"
  35. cd $GOPATH/src/github.com/refraction-networking/gotapdance
  36. mv $GOPATH/src/github.com/Psiphon-Labs/psiphon-tunnel-core/MobileLibrary/Android/ca.psiphon.aar build/
  37. # Build Psiphon Android App PsiphonAndroid-debug.apk
  38. cp -f build/ca.psiphon.aar $GOPATH/src/bitbucket.org/psiphon/psiphon-circumvention-system/Android/app/libs/
  39. cd $GOPATH/src/github.com/refraction-networking/gotapdance
  40. echo "docker run gradlew assembleDebug.."
  41. #docker run -v $DOCKER_DIR:/go/src/github.com/refraction-networking/gotapdance -v $GOPATH/src/bitbucket.org/psiphon/psiphon-circumvention-system/Android:/go/src/bitbucket.org/psiphon/psiphon-circumvention-system/Android refraction/psiandroid /bin/bash -c 'yes | /android-sdk-linux/tools/bin/sdkmanager --update && cd /go/src/bitbucket.org/psiphon/psiphon-circumvention-system/Android && ./gradlew assembleDebug'
  42. docker run -v $REPO_DIR:/go/src/github.com/refraction-networking/gotapdance -v $GOPATH/src/bitbucket.org/psiphon/psiphon-circumvention-system/Android:/go/src/bitbucket.org/psiphon/psiphon-circumvention-system/Android refraction/psiandroid /bin/bash -c 'yes | /android-sdk-linux/tools/bin/sdkmanager --update && cd /go/src/bitbucket.org/psiphon/psiphon-circumvention-system/Android && ./gradlew assembleDebug'
  43. cp $GOPATH/src/bitbucket.org/psiphon/psiphon-circumvention-system/Android/app/build/outputs/apk/debug/PsiphonAndroid-debug.apk build/PsiphonAndroid-CJ-debug.apk
  44. pwd
  45. echo "build/PsiphonAndroid-CJ-debug.apk"