diff options
author | gilcu3 | 2022-03-24 13:13:16 +0100 |
---|---|---|
committer | gilcu3 | 2022-03-24 13:13:16 +0100 |
commit | e38d04d11e25c8bb2e9ec273e2ab67a81fbc11e0 (patch) | |
tree | 10619d2e0be392230b1cf2b1ceafaf45a861f097 | |
parent | 3b400ba1311b3d09c06707acb968eef202b2f686 (diff) | |
download | aur-e38d04d11e25c8bb2e9ec273e2ab67a81fbc11e0.tar.gz |
fixed go issues
-rw-r--r-- | .SRCINFO | 2 | ||||
-rw-r--r-- | PKGBUILD | 51 | ||||
-rw-r--r-- | make.bash | 96 |
3 files changed, 111 insertions, 38 deletions
@@ -15,8 +15,10 @@ pkgbase = psiphon-tunnel-core-git source = git+https://github.com/Psiphon-Labs/psiphon-tunnel-core.git source = psiphon.conf source = psiphon.service + source = make.bash sha256sums = SKIP sha256sums = c2c414831ad29bdeecd00313c473fbaa448f4750e70df1c10e863870bde179aa sha256sums = d0227e69cac62480951e9c83747d43fccd7bdd18224652428ab20369b84173aa + sha256sums = SKIP pkgname = psiphon-tunnel-core-git @@ -32,11 +32,13 @@ makedepends=('go-pie' 'perl' 'git') depends=('glibc') source=("git+$url.git" "psiphon.conf" - "psiphon.service") + "psiphon.service" + "make.bash") backup=('etc/psiphon.conf' 'usr/lib/systemd/user/psiphon.service') sha256sums=('SKIP' 'c2c414831ad29bdeecd00313c473fbaa448f4750e70df1c10e863870bde179aa' - 'd0227e69cac62480951e9c83747d43fccd7bdd18224652428ab20369b84173aa') + 'd0227e69cac62480951e9c83747d43fccd7bdd18224652428ab20369b84173aa' + 'SKIP') pkgver() { cd $_pkgname @@ -47,45 +49,18 @@ pkgver() { } build() { - cd "$_pkgname/ConsoleClient" + export GOPATH=$(pwd) - # Copied from the README file - EXE_BASENAME="psiphon-tunnel-core" - BUILDINFOFILE="${EXE_BASENAME}_buildinfo.txt" - 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') - 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 "}") + mkdir -p "${GOPATH}/src/github.com/Psiphon-Labs" - - PKG_LDFLAGS="\ --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 \ --s -w -" - export CGO_CPPFLAGS="${CPPFLAGS}" - export CGO_CFLAGS="${CFLAGS}" - export CGO_CXXFLAGS="${CXXFLAGS}" - export CGO_LDFLAGS="${LDFLAGS}" - - echo -e "${BUILDDATE}\n${BUILDREPO}\n${BUILDREV}\n" > $BUILDINFOFILE - - if [ ! -d bin ]; then - mkdir bin - fi + ln -sf "../../../$_pkgname/" "src/github.com/Psiphon-Labs/psiphon-tunnel-core" + + cp "$srcdir/make.bash" "$_pkgname/ConsoleClient/" + + cd "$_pkgname/ConsoleClient" - GOOS=linux GOARCH=amd64 go build -v -x -buildmode=pie -trimpath -ldflags "-linkmode external ${PKG_LDFLAGS}" -tags "${BUILD_TAGS}" -o $_pkgname - RETVAL=$? - if [ $RETVAL != 0 ]; then - echo "....gox failed, exiting" - exit $RETVAL - fi - unset RETVAL + ./make.bash linux # TODO: Figure out how to do the stripping? # https://wiki.archlinux.org/index.php/Go_package_guidelines#Flags_and_build_options @@ -94,7 +69,7 @@ build() { package() { cd $_pkgname/ConsoleClient/ - install -Dm755 $_pkgname "$pkgdir/usr/bin/$_pkgname" + install -Dm755 "bin/linux/$_pkgname-x86_64" "$pkgdir/usr/bin/$_pkgname" install -Dm644 "$srcdir/psiphon.conf" "$pkgdir/etc/psiphon.conf" install -Dm644 "$srcdir/psiphon.service" "$pkgdir/usr/lib/systemd/user/psiphon.service" } diff --git a/make.bash b/make.bash new file mode 100644 index 000000000000..1c8094331ea2 --- /dev/null +++ b/make.bash @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +set -e -u -x + +if [ ! -f make.bash ]; then + echo "make.bash must be run from $GOPATH/src/github.com/Psiphon-Labs/psiphon-tunnel-core/ConsoleClient" + exit 1 +fi + +# $2, if specified, is go build tags +if [ -z ${2+x} ]; then BUILD_TAGS=""; else BUILD_TAGS="$2"; fi + +# At this time, we don't support modules +export GO111MODULE=off + +EXE_BASENAME="psiphon-tunnel-core" + +prepare_build () { + BUILDINFOFILE="${EXE_BASENAME}_buildinfo.txt" + 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') + + # 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 "}") + + MY_LDFLAGS="\ + -s \ + -w \ + -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 + + echo "Variables for ldflags:" + echo " Build date: ${BUILDDATE}" + echo " Build repo: ${BUILDREPO}" + echo " Build revision: ${BUILDREV}" + echo " Go version: ${GOVERSION}" + echo " Dependencies: ${DEPENDENCIES}" + echo "" + + +} + +if [ ! -d bin ]; then + mkdir bin +fi + + +build_for_linux () { + prepare_build linux + + echo "...Building linux-x86_64" + GOOS=linux GOARCH=amd64 go build -v -x -ldflags "$MY_LDFLAGS" -tags "${BUILD_TAGS}" \ + -trimpath -buildmode=pie -ldflags "-linkmode external -extldflags \"${LDFLAGS}\"" \ + -gcflags=-trimpath=${PWD} -asmflags=-trimpath=${PWD} \ + -o bin/linux/${EXE_BASENAME}-x86_64 + RETVAL=$? + if [ $RETVAL != 0 ]; then + echo "....gox failed, exiting" + exit $RETVAL + fi + unset RETVAL + + #echo "....UPX packaging output" + #goupx --best bin/linux/${EXE_BASENAME}-x86_64 + #RETVAL=$? + #if [ $RETVAL != 0 ]; then + #echo ".....goupx failed, exiting" + #exit $RETVAL + #fi + #unset RETVAL +} + +TARGET=$1 +case $TARGET in + linux) + echo "..Building for Linux" + build_for_linux + exit $? + + ;; + *) + echo "..invalid target" + exit 1 + + ;; + +esac + +echo "Done" |