Просмотр исходного кода

Remove dependencies and gomobile build info

- Both were broken in various build scripts.

- With all dependencies vendored, the dependencies list would always be
  empty.

- Go mobile is now also covered by the single buildinfo.buildRev commit value
  (with one caveat: builds that install Go mobile in a Docker image must
  ensure that the Docker image is updated as part of the build process).
Rod Hynes 3 лет назад
Родитель
Сommit
c97d6ff37a

+ 0 - 6
ClientLibrary/build-darwin.sh

@@ -80,10 +80,6 @@ prepare_build () {
   BUILDREV=$(git rev-parse --short HEAD)
   GOVERSION=$(go version | perl -ne '/go version (.*?) / && print $1')
 
-  # see DEPENDENCIES comment in MobileLibrary/Android/make.bash
-  cd ${GOPATH}/src/github.com/Psiphon-Labs/psiphon-tunnel-core/ClientLibrary
-  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 "}")
-
   LDFLAGS="\
   -s \
   -w \
@@ -91,7 +87,6 @@ prepare_build () {
   -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.buildRepo=$BUILDREPO \
   -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.buildRev=$BUILDREV \
   -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.goVersion=$GOVERSION \
-  -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.dependencies=$DEPENDENCIES \
   "
 
   echo "Variables for ldflags:"
@@ -99,7 +94,6 @@ prepare_build () {
   echo " Build repo: ${BUILDREPO}"
   echo " Build revision: ${BUILDREV}"
   echo " Go version: ${GOVERSION}"
-  echo " Dependencies: ${DEPENDENCIES}"
   echo ""
 
 }

+ 0 - 5
ClientLibrary/make.bash

@@ -23,9 +23,6 @@ prepare_build () {
   BUILDREV=$(git rev-parse --short HEAD)
   GOVERSION=$(go version | perl -ne '/go version (.*?) / && print $1')
 
-  # see DEPENDENCIES comment in MobileLibrary/Android/make.bash
-  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 "}")
-
   LDFLAGS="\
   -s \
   -w \
@@ -33,7 +30,6 @@ prepare_build () {
   -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.buildRepo=$BUILDREPO \
   -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.buildRev=$BUILDREV \
   -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.goVersion=$GOVERSION \
-  -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.dependencies=$DEPENDENCIES \
   "
 
   echo "Variables for ldflags:"
@@ -41,7 +37,6 @@ prepare_build () {
   echo " Build repo: ${BUILDREPO}"
   echo " Build revision: ${BUILDREV}"
   echo " Go version: ${GOVERSION}"
-  echo " Dependencies: ${DEPENDENCIES}"
   echo ""
 
 }

+ 3 - 29
ConsoleClient/main.go

@@ -20,16 +20,13 @@
 package main
 
 import (
-	"bytes"
 	"context"
-	"encoding/json"
 	"flag"
 	"fmt"
 	"io"
 	"io/ioutil"
 	"os"
 	"os/signal"
-	"sort"
 	"strings"
 	"sync"
 	"syscall"
@@ -117,32 +114,9 @@ func main() {
 
 	if versionDetails {
 		b := buildinfo.GetBuildInfo()
-
-		var printableDependencies bytes.Buffer
-		var dependencyMap map[string]string
-		longestRepoUrl := 0
-		json.Unmarshal(b.Dependencies, &dependencyMap)
-
-		sortedRepoUrls := make([]string, 0, len(dependencyMap))
-		for repoUrl := range dependencyMap {
-			repoUrlLength := len(repoUrl)
-			if repoUrlLength > longestRepoUrl {
-				longestRepoUrl = repoUrlLength
-			}
-
-			sortedRepoUrls = append(sortedRepoUrls, repoUrl)
-		}
-		sort.Strings(sortedRepoUrls)
-
-		for repoUrl := range sortedRepoUrls {
-			printableDependencies.WriteString(fmt.Sprintf("    %s  ", sortedRepoUrls[repoUrl]))
-			for i := 0; i < (longestRepoUrl - len(sortedRepoUrls[repoUrl])); i++ {
-				printableDependencies.WriteString(" ")
-			}
-			printableDependencies.WriteString(fmt.Sprintf("%s\n", dependencyMap[sortedRepoUrls[repoUrl]]))
-		}
-
-		fmt.Printf("Psiphon Console Client\n  Build Date: %s\n  Built With: %s\n  Repository: %s\n  Revision: %s\n  Dependencies:\n%s\n", b.BuildDate, b.GoVersion, b.BuildRepo, b.BuildRev, printableDependencies.String())
+		fmt.Printf(
+			"Psiphon Console Client\n  Build Date: %s\n  Built With: %s\n  Repository: %s\n  Revision: %s\n",
+			b.BuildDate, b.GoVersion, b.BuildRepo, b.BuildRev)
 		os.Exit(0)
 	}
 

+ 0 - 5
ConsoleClient/make.bash

@@ -19,9 +19,6 @@ prepare_build () {
   BUILDREV=$(git rev-parse --short HEAD)
   GOVERSION=$(go version | perl -ne '/go version (.*?) / && print $1')
 
-  # see DEPENDENCIES comment in MobileLibrary/Android/make.bash
-  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 "}")
-
   LDFLAGS="\
   -s \
   -w \
@@ -29,7 +26,6 @@ prepare_build () {
   -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.buildRepo=$BUILDREPO \
   -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.buildRev=$BUILDREV \
   -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.goVersion=$GOVERSION \
-  -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.dependencies=$DEPENDENCIES \
   "
   echo -e "${BUILDDATE}\n${BUILDREPO}\n${BUILDREV}\n" > $BUILDINFOFILE
 
@@ -38,7 +34,6 @@ prepare_build () {
   echo " Build repo: ${BUILDREPO}"
   echo " Build revision: ${BUILDREV}"
   echo " Go version: ${GOVERSION}"
-  echo " Dependencies: ${DEPENDENCIES}"
   echo ""
 }
 

+ 0 - 35
MobileLibrary/Android/make.bash

@@ -18,37 +18,6 @@ BUILDDATE=$(date --iso-8601=seconds)
 BUILDREPO=$(git config --get remote.origin.url)
 BUILDREV=$(git rev-parse --short HEAD)
 GOVERSION=$(go version | perl -ne '/go version (.*?) / && print $1')
-GOMOBILEVERSION=$(gomobile version | perl -ne '/gomobile version (.*?) / && print $1')
-
-# DEPENDENCIES
-#
-# - this script produces a JSON object listing all Go package dependencies,
-#   excluding packages under github.com/Psiphon-Labs/psiphon-tunnel-core/
-#   (thus also excluding vendored packages) which will all have the same rev
-#   as BUILDREV
-#
-# - starts the string with a `{` and ends with a `}`
-#
-# - uses the `go list` command and passes it a template string (using the Go
-#   template syntax) saying I want all the dependencies of the package in the
-#   current directory, printing 1/line via printf
-#
-# - pipes to `xargs` to run a command on each line output from the first
-#   command and uses `go list` with a template string to print the "Import
-#   Path" (from just below `$GOPATH/src`) if the package is not part of the
-#   standard library
-#
-# - pipes to `xargs` again, specifiying `pkg` as the placeholder name for each
-#   item being operated on (which is the list of non standard library import
-#   paths from the previous step); `xargs` runs a bash script (via `-c`) which
-#   changes to each import path in sequence, then echoes out, after the
-#   exclusion check, `"<import path>":"<subshell output of getting the short
-#   git revision>",`
-#
-# - for non-empty dependency lists, the last command leaves a trailing `,\n` at
-#   the end, so use `sed` and `tr` to remove the suffix.
-#
-DEPENDENCIES=$(cd ../psi && echo -n "{" && GOOS=android go list -tags "${BUILD_TAGS}" -f '{{range $dep := .Deps}}{{printf "%s\n" $dep}}{{end}}' | GOOS=android 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 "}")
 
 LDFLAGS="\
 -s \
@@ -57,8 +26,6 @@ LDFLAGS="\
 -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.buildRepo=$BUILDREPO \
 -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.buildRev=$BUILDREV \
 -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.goVersion=$GOVERSION \
--X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.gomobileVersion=$GOMOBILEVERSION \
--X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.dependencies=$DEPENDENCIES \
 "
 
 echo -e "${BUILDDATE}\n${BUILDREPO}\n${BUILDREV}\n" > $BUILDINFOFILE
@@ -68,8 +35,6 @@ echo " Build date: ${BUILDDATE}"
 echo " Build repo: ${BUILDREPO}"
 echo " Build revision: ${BUILDREV}"
 echo " Go version: ${GOVERSION}"
-echo " Gomobile version: ${GOMOBILEVERSION}"
-echo " Dependencies: ${DEPENDENCIES}"
 echo ""
 
 gomobile bind -v -x -target=android/arm,android/arm64,android/386,android/amd64 -tags="${BUILD_TAGS}" -ldflags="$LDFLAGS" github.com/Psiphon-Labs/psiphon-tunnel-core/MobileLibrary/psi

+ 0 - 8
MobileLibrary/iOS/build-psiphon-framework.sh

@@ -137,11 +137,6 @@ BUILDDATE=$(date +%Y-%m-%dT%H:%M:%S%z)
 BUILDREPO=$(git config --get remote.origin.url)
 BUILDREV=$(git rev-parse --short HEAD)
 GOVERSION=$(go version | perl -ne '/go version (.*?) / && print $1')
-GOMOBILEVERSION=$("${GOPATH}"/bin/gomobile version | perl -ne '/gomobile version (.*?) / && print $1')
-
-# see DEPENDENCIES comment in MobileLibrary/Android/make.bash
-cd "${GOPATH}"/src/github.com/Psiphon-Labs/psiphon-tunnel-core/MobileLibrary/psi
-DEPENDENCIES=$(echo -n "{" && GOOS=darwin go list -tags "${BUILD_TAGS}" -f '{{range $dep := .Deps}}{{printf "%s\n" $dep}}{{end}}' | GOOS=darwin 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 "}")
 
 LDFLAGS="\
 -s \
@@ -150,8 +145,6 @@ LDFLAGS="\
 -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.buildRepo=${BUILDREPO} \
 -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.buildRev=${BUILDREV} \
 -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.goVersion=${GOVERSION} \
--X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.gomobileVersion=${GOMOBILEVERSION} \
--X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.dependencies=${DEPENDENCIES} \
 "
 
 echo -e "${BUILDDATE}\n${BUILDREPO}\n${BUILDREV}\n" > "$BUILDINFOFILE"
@@ -162,7 +155,6 @@ echo " Build date: ${BUILDDATE}"
 echo " Build repo: ${BUILDREPO}"
 echo " Build revision: ${BUILDREV}"
 echo " Go version: ${GOVERSION}"
-echo " Gomobile version: ${GOMOBILEVERSION}"
 echo ""
 
 

+ 0 - 5
Server/make.bash

@@ -20,16 +20,12 @@ prepare_build () {
   BUILDREV=$(git rev-parse --short HEAD)
   GOVERSION=$(go version | perl -ne '/go version (.*?) / && print $1')
 
-  # see DEPENDENCIES comment in MobileLibrary/Android/make.bash
-  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 "}")
-
   LDFLAGS="\
   -linkmode external -extldflags \"-static\" \
   -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.buildDate=$BUILDDATE \
   -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.buildRepo=$BUILDREPO \
   -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.buildRev=$BUILDREV \
   -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.goVersion=$GOVERSION \
-  -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.dependencies=$DEPENDENCIES \
   "
   echo -e "${BUILDDATE}\n${BUILDREPO}\n${BUILDREV}\n" > $BUILDINFOFILE
 
@@ -38,7 +34,6 @@ prepare_build () {
   echo " Build repo: ${BUILDREPO}"
   echo " Build revision: ${BUILDREV}"
   echo " Go version: ${GOVERSION}"
-  echo " Dependencies: ${DEPENDENCIES}"
   echo ""
 }
 

+ 15 - 36
psiphon/common/buildinfo/buildinfo.go

@@ -20,7 +20,6 @@
 package buildinfo
 
 import (
-	"encoding/json"
 	"strings"
 
 	"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/values"
@@ -46,37 +45,24 @@ var buildRev string
 // -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.goVersion=`go version | perl -ne '/go version (.*?) / && print $1'`
 var goVersion string
 
-// -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/buildinfo.gomobileVersion=`gomobile version | perl -ne '/gomobile version (.*?) / && print $1'`
-var gomobileVersion string
-
-// -X github.com/Psiphon-Labs/psiphon-tunnel-core/common/buildinfo.dependencies=`echo -n "{" && go list -f '{{range $dep := .Deps}}{{printf "%s\n" $dep}}{{end}}' | xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' | xargs -I pkg bash -c 'cd $GOPATH/src/pkg && echo -n "\"pkg\":\"$(git rev-parse --short HEAD)\","' | sed 's/,$/}/'`
-// Dependencies should be listed as a JSON object like the following (no spaces) {"github.com/Psiphon-Labs/psiphon-tunnel-core":"abcdef","...":"..."}
-var dependencies string
-
 // BuildInfo captures relevant build information here for use in clients or servers
 type BuildInfo struct {
-	BuildDate       string          `json:"buildDate"`
-	BuildRepo       string          `json:"buildRepo"`
-	BuildRev        string          `json:"buildRev"`
-	GoVersion       string          `json:"goVersion"`
-	GomobileVersion string          `json:"gomobileVersion,omitempty"`
-	Dependencies    json.RawMessage `json:"dependencies"`
-	ValuesRev       string          `json:"valuesRev"`
+	BuildDate string `json:"buildDate"`
+	BuildRepo string `json:"buildRepo"`
+	BuildRev  string `json:"buildRev"`
+	GoVersion string `json:"goVersion"`
+	ValuesRev string `json:"valuesRev"`
 }
 
 // ToMap converts 'BuildInfo' struct to 'map[string]interface{}'
 func (bi *BuildInfo) ToMap() map[string]interface{} {
 
-	var dependenciesMap map[string]interface{}
-	json.Unmarshal([]byte(bi.Dependencies), &dependenciesMap)
-
 	buildInfoMap := map[string]interface{}{
-		"buildDate":    bi.BuildDate,
-		"buildRepo":    bi.BuildRepo,
-		"buildRev":     bi.BuildRev,
-		"goVersion":    bi.GoVersion,
-		"dependencies": dependenciesMap,
-		"valuesRev":    bi.ValuesRev,
+		"buildDate": bi.BuildDate,
+		"buildRepo": bi.BuildRepo,
+		"buildRev":  bi.BuildRev,
+		"goVersion": bi.GoVersion,
+		"valuesRev": bi.ValuesRev,
 	}
 
 	return buildInfoMap
@@ -85,19 +71,12 @@ func (bi *BuildInfo) ToMap() map[string]interface{} {
 // GetBuildInfo returns an instance of the BuildInfo struct
 func GetBuildInfo() *BuildInfo {
 
-	deps := strings.TrimSpace(dependencies)
-	if deps == "" {
-		deps = "{}"
-	}
-
 	buildInfo := BuildInfo{
-		BuildDate:       strings.TrimSpace(buildDate),
-		BuildRepo:       strings.TrimSpace(buildRepo),
-		BuildRev:        strings.TrimSpace(buildRev),
-		GoVersion:       strings.TrimSpace(goVersion),
-		GomobileVersion: strings.TrimSpace(gomobileVersion),
-		Dependencies:    json.RawMessage(deps),
-		ValuesRev:       values.GetRevision(),
+		BuildDate: strings.TrimSpace(buildDate),
+		BuildRepo: strings.TrimSpace(buildRepo),
+		BuildRev:  strings.TrimSpace(buildRev),
+		GoVersion: strings.TrimSpace(goVersion),
+		ValuesRev: values.GetRevision(),
 	}
 
 	return &buildInfo