diff --git a/build_core.sh b/build_core.sh index a38e86edc9ae2e9b3b3f0d7382500f5af8485967..46515f4f7824a4d30f38bd4c985ce441028c35dc 100755 --- a/build_core.sh +++ b/build_core.sh @@ -17,17 +17,17 @@ function showtitle { showtitle "Installing golang" if [[ "$OSTYPE" == "linux-gnu"* ]]; then - GO_VERSION=go1.17.10.linux-amd64 - EXPECTED_FP=87fc728c9c731e2f74e4a999ef53cf07302d7ed3504b0839027bd9c10edaa3fd + GO_VERSION=go1.19.8.linux-amd64 + EXPECTED_FP=e1a0bf0ab18c8218805a1003fd702a41e2e807710b770e787e5979d1cf947aba elif [[ "$OSTYPE" == "darwin"* ]]; then # Mac OSX ARCH=`uname -a | rev | cut -d " " -f 1 | rev` if [[ "$ARCH" = "x86_64" ]]; then - GO_VERSION=go1.17.10.darwin-amd64 - EXPECTED_FP=84979d5985c70cee6f303050a7e811440aad7f304efdf28665b200f096b01945 + GO_VERSION=go1.19.8.darwin-amd64 + EXPECTED_FP=d63e12909b3639df24f2614284868869ce14fdea2059ed365752da82ca59f994 else - GO_VERSION=go1.17.10.darwin-arm64 - EXPECTED_FP=32098bea40117ea1ec23e7124cd188db6bdddd0ea41e2ec9bea3ba35a487e39c + GO_VERSION=go1.19.8.darwin-arm64 + EXPECTED_FP=12df6263329794c55b1d63160cda9dd62de4ecd65fe52ddca33bc96a57c38ea6 fi else echo "$OSTYPE is currently not supported." diff --git a/build_core_dev.sh b/build_core_dev.sh new file mode 100755 index 0000000000000000000000000000000000000000..042f1577d486f997b013fc902693496a02cc3342 --- /dev/null +++ b/build_core_dev.sh @@ -0,0 +1,149 @@ +#!/bin/bash + +RED='\033[0;31m' +GREEN='\033[0;32m' +NC='\033[0m' + +function quit { + echo -e "${RED}Task failed. $1 ${NC}" + exit 1 +} + +function showtitle { + echo -e "\n\n${GREEN}--- $1 ...${NC}\n" +} + +# -------- install golang --------------- +showtitle "Installing golang" + +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + GO_VERSION=go1.19.8.linux-amd64 + EXPECTED_FP=e1a0bf0ab18c8218805a1003fd702a41e2e807710b770e787e5979d1cf947aba +elif [[ "$OSTYPE" == "darwin"* ]]; then + # Mac OSX + ARCH=`uname -a | rev | cut -d " " -f 1 | rev` + if [[ "$ARCH" = "x86_64" ]]; then + GO_VERSION=go1.19.8.darwin-amd64 + EXPECTED_FP=d63e12909b3639df24f2614284868869ce14fdea2059ed365752da82ca59f994 + else + GO_VERSION=go1.19.8.darwin-arm64 + EXPECTED_FP=12df6263329794c55b1d63160cda9dd62de4ecd65fe52ddca33bc96a57c38ea6 + fi +else + echo "$OSTYPE is currently not supported." + exit 1 +fi + + +if [[ $(ls -A ${GO_VERSION}.tar.gz) ]] +then + echo "Reusing downloaded golang bundle" +else + echo "Installing go lang bundle ${GO_VERSION}.tar.gz from https://golang.org/dl/$GO_VERSION.tar.gz" + curl -L -o "${GO_VERSION}.tar.gz" "https://golang.org/dl/${GO_VERSION}.tar.gz" + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + ACTUAL_FP=`sha256sum $GO_VERSION.tar.gz | cut -d " " -f1` + else + ACTUAL_FP=`shasum -a 256 $GO_VERSION.tar.gz | cut -d " " -f1` + fi + + if [[ ! $ACTUAL_FP == $EXPECTED_FP ]] + then + quit "Download seems to be corrupted. Cancelling build." + fi +fi + +if [[ -d ./golang ]] +then + if [[ $(ls -A ./golang/*) ]] + then + rm -r ./golang/* + fi +else + mkdir ./golang +fi +tar -C ./golang -xzf $GO_VERSION.tar.gz || quit "Could not untar $GO_VERSION.tar.gz" + + +# -------- update submodules --------------- +showtitle "Updating submodules" +# git submodule sync --recursive || quit "git submodule sync --recursive" +# git submodule update --init --recursive || quit "git submodule update --init --recursive" + + +# -------- init environment variables --------------- +cd ./golang +export GOPATH=`pwd` +export GO_LANG=`pwd`/go/bin +export GO_COMPILED=`pwd`/bin +export PATH="${GO_LANG}:${GO_COMPILED}:${PATH}" +# the next line can be removed if we use golang v1.18+ +go env -w GOFLAGS=-mod=mod +go env +cd .. + +# -------- init gomobile --------------- +showtitle "Getting gomobile" +#./golang/go/bin/go install golang.org/x/mobile/cmd/gomobile || quit "./golang/go/bin/go install golang.org/x/mobile/cmd/gomobile" + +showtitle "initiating gomobile" +#./golang/bin/gomobile init || quit "./golang/bin/gomobile init" + + +# -------- prepare snowflake --------------- +showtitle "Checking out snowflake repository" +cd ./IPtProxy/snowflake +git checkout --force --quiet 36f03dfd4483922b3e7400dedc71df9cf2f30b6b || quit "Failed to checkout snowflake at commit 36f03dfd4483922b3e7400dedc71df9cf2f30b6b" +git submodule update --init --recursive || quit "Failed to update snowflake submodules" +cd .. + +showtitle "Applying patches to snowflake" +patch --directory=snowflake --strip=1 < snowflake.patch || quit +cd .. + +showtitle "Applying patch to IPtProxy" +patch --directory=IPtProxy --strip=1 < iptproxy.patch || quit + +# -------- preparing obfsvpn --------------- +showtitle "Applying patch to obfsvpn" +patch --directory=obfsvpn --strip=1 < obfsvpn.patch || quit + +# -------- preparing shapeshifter --------------- +showtitle "Applying patch to shapeshifter" +patch --directory=shapeshifter --strip=1 < shapeshifter.patch || quit + +# -------- preparing motd --------------- +showtitle "Applying patch to motd (message of the day)" +patch --directory=motd --strip=1 < motd.patch || quit + + +# -------- build core --------------- + +if [[ -d ./lib ]] +then + if [[ $(ls -A ./lib/*) ]] + then + rm -r ./lib/* + fi +else + mkdir ./lib +fi + + +showtitle "Building Bitmask core as full aar" +gomobile bind -target='android' -o ./lib/bitmaskcore.aar -v org.0xacab/leap/bitmaskcore/shapeshifter org.0xacab/leap/bitmaskcore/obfsvpn/client org.0xacab/leap/bitmaskcore/IPtProxy/IPtProxy.go org.0xacab/leap/bitmaskcore/motd + +showtitle "Building Bitmask web core as full aar including pgpverify" +gomobile bind -target='android' -o ./lib/bitmaskcore_web.aar -v org.0xacab/leap/bitmaskcore/pgpverify org.0xacab/leap/bitmaskcore/shapeshifter org.0xacab/leap/bitmaskcore/obfsvpn/client org.0xacab/leap/bitmaskcore/IPtProxy/IPtProxy.go org.0xacab/leap/bitmaskcore/motd + +showtitle "Building Bitmask core for armv7" +gomobile bind -target='android/arm' -o ./lib/bitmaskcore_arm.aar -v org.0xacab/leap/bitmaskcore/shapeshifter org.0xacab/leap/bitmaskcore/obfsvpn/client org.0xacab/leap/bitmaskcore/IPtProxy/IPtProxy.go org.0xacab/leap/bitmaskcore/motd + +showtitle "Building Bitmask core for x86" +gomobile bind -target='android/386' -o ./lib/bitmaskcore_x86.aar -v org.0xacab/leap/bitmaskcore/shapeshifter org.0xacab/leap/bitmaskcore/obfsvpn/client org.0xacab/leap/bitmaskcore/IPtProxy/IPtProxy.go org.0xacab/leap/bitmaskcore/motd + +showtitle "Building Bitmask core for arm64" +gomobile bind -target='android/arm64' -o ./lib/bitmaskcore_arm64.aar -v org.0xacab/leap/bitmaskcore/shapeshifter org.0xacab/leap/bitmaskcore/obfsvpn/client org.0xacab/leap/bitmaskcore/IPtProxy/IPtProxy.go org.0xacab/leap/bitmaskcore/motd + +showtitle "Building Bitmask core for x86_64" +gomobile bind -target='android/amd64' -o ./lib/bitmaskcore_x86_64.aar -v org.0xacab/leap/bitmaskcore/shapeshifter org.0xacab/leap/bitmaskcore/obfsvpn/client org.0xacab/leap/bitmaskcore/IPtProxy/IPtProxy.go org.0xacab/leap/bitmaskcore/motd