github.com/Psiphon-Labs/psiphon-tunnel-core@v2.0.28+incompatible/Server/make.bash (about) 1 #!/usr/bin/env bash 2 3 set -e -u -x 4 5 BASE_DIR=$( cd "$(dirname "$0")" ; pwd -P ) 6 cd $BASE_DIR 7 8 if [ ! -f make.bash ]; then 9 echo "make.bash must be run from $GOPATH/src/github.com/Psiphon-Labs/psiphon-tunnel-core/Server" 10 exit 1 11 fi 12 13 # $1, if specified, is go build tags 14 if [ -z ${1+x} ]; then BUILD_TAGS=""; else BUILD_TAGS="$1"; fi 15 16 # At this time, we don't support modules 17 export GO111MODULE=off 18 19 prepare_build () { 20 BUILDINFOFILE="psiphond_buildinfo.txt" 21 BUILDDATE=$(date -Iseconds) 22 BUILDREPO=$(git config --get remote.origin.url) 23 BUILDREV=$(git rev-parse --short HEAD) 24 GOVERSION=$(go version | perl -ne '/go version (.*?) / && print $1') 25 26 # see DEPENDENCIES comment in MobileLibrary/Android/make.bash 27 DEPENDENCIES=$(echo -n "{" && GOOS=$1 go list -tags "${BUILD_TAGS}" -f '{{range $dep := .Deps}}{{printf "%s\n" $dep}}{{end}}' | GOOS=$1 xargs go list -tags "${BUILD_TAGS}" -f '{{if not .Standard}}{{.ImportPath}}{{end}}' | xargs -I pkg bash -c 'cd $GOPATH/src/$0 && if echo -n "$0" | grep -vEq "^github.com/Psiphon-Labs/psiphon-tunnel-core/" ; then echo -n "\"$0\":\"$(git rev-parse --short HEAD)\"," ; fi' pkg | sed 's/,$//' | tr -d '\n' && echo -n "}") 28 29 LDFLAGS="\ 30 -linkmode external -extldflags \"-static\" \ 31 -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.buildDate=$BUILDDATE \ 32 -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.buildRepo=$BUILDREPO \ 33 -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.buildRev=$BUILDREV \ 34 -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.goVersion=$GOVERSION \ 35 -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.dependencies=$DEPENDENCIES \ 36 " 37 echo -e "${BUILDDATE}\n${BUILDREPO}\n${BUILDREV}\n" > $BUILDINFOFILE 38 39 echo "Variables for ldflags:" 40 echo " Build date: ${BUILDDATE}" 41 echo " Build repo: ${BUILDREPO}" 42 echo " Build revision: ${BUILDREV}" 43 echo " Go version: ${GOVERSION}" 44 echo " Dependencies: ${DEPENDENCIES}" 45 echo "" 46 } 47 48 build_for_linux () { 49 prepare_build linux 50 GOOS=linux GOARCH=amd64 go build -v -x -tags "${BUILD_TAGS}" -ldflags "$LDFLAGS" -o psiphond 51 if [ $? != 0 ]; then 52 echo "...'go build' failed, exiting" 53 exit $? 54 fi 55 chmod 555 psiphond 56 57 if [ "$1" == "generate" ]; then 58 ./psiphond --ipaddress 0.0.0.0 --web 3000 --protocol SSH:3001 --protocol OSSH:3002 --logFilename /var/log/psiphond/psiphond.log generate 59 60 chmod 666 psiphond.config 61 chmod 666 psiphond-traffic-rules.config 62 chmod 666 psiphond-osl.config 63 chmod 666 psiphond-tactics.config 64 chmod 666 server-entry.dat 65 fi 66 67 } 68 69 build_for_linux generate 70 echo "Done"