forked from p4gefau1t/trojan-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-all.sh
executable file
·69 lines (58 loc) · 2.05 KB
/
build-all.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
PLATFORMS="darwin/amd64 darwin/386"
PLATFORMS="$PLATFORMS windows/amd64 windows/386"
PLATFORMS="$PLATFORMS windows/arm"
PLATFORMS="$PLATFORMS linux/amd64 linux/386"
PLATFORMS="$PLATFORMS linux/ppc64 linux/ppc64le"
PLATFORMS="$PLATFORMS linux/mips64 linux/mips64le"
PLATFORMS="$PLATFORMS linux/mips linux/mipsle"
PLATFORMS="$PLATFORMS linux/arm64 linux/arm"
PLATFORMS="$PLATFORMS linux/s390x"
PLATFORMS="$PLATFORMS dragonfly/amd64"
PLATFORMS="$PLATFORMS openbsd/arm64 openbsd/arm"
PLATFORMS="$PLATFORMS openbsd/amd64 openbsd/386"
PLATFORMS="$PLATFORMS freebsd/amd64 freebsd/386"
PLATFORMS="$PLATFORMS freebsd/arm64 freebsd/arm"
type setopt >/dev/null 2>&1
rm -rd release
rm -rd temp
rm ./*.dat
mkdir release
mkdir temp
wget https://github.com/v2ray/domain-list-community/raw/release/dlc.dat -O geosite.dat
wget https://github.com/v2ray/geoip/raw/release/geoip.dat -O geoip.dat
SCRIPT_NAME=`basename "$0"`
FAILURES=""
for PLATFORM in $PLATFORMS; do
GOOS=${PLATFORM%/*}
GOARCH=${PLATFORM#*/}
ZIP_FILENAME="trojan-go-${GOOS}-${GOARCH}.zip"
CMD="CGO_ENABLE=0 GOOS=${GOOS} GOARCH=${GOARCH} go build -tags \"full\" -o temp -ldflags=\"-s -w\""
echo "${CMD}"
eval $CMD || FAILURES="${FAILURES} ${PLATFORM}"
zip -j release/$ZIP_FILENAME temp/* ./*.dat
zip release/$ZIP_FILENAME example/*
sha1sum release/$ZIP_FILENAME >> release/checksum.sha1
rm temp/*
done
# arm
PLATFORMS_ARM="windows linux freebsd netbsd"
for GOOS in $PLATFORMS_ARM; do
# build for each ARM version
GOARCH="arm"
for GOARM in 7 6 5; do
ZIP_FILENAME="trojan-go-${GOOS}-${GOARCH}v${GOARM}.zip"
CMD="CGO_ENABLE=0 GOARM=${GOARM} GOOS=${GOOS} GOARCH=${GOARCH} go build -tags \"full\" -o temp -ldflags \"-s -w\""
echo "${CMD}"
eval "${CMD}" || FAILURES="${FAILURES} ${GOOS}/${GOARCH}v${GOARM}"
zip -j release/$ZIP_FILENAME temp/* ./*.dat
zip release/$ZIP_FILENAME example/*
sha1sum release/$ZIP_FILENAME >> release/checksum.sha1
rm temp/*
done
done
# eval errors
if [[ "${FAILURES}" != "" ]]; then
echo ""
echo "${SCRIPT_NAME} failed on: ${FAILURES}"
fi