forked from yinqiwen/gsnova
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build64.sh
executable file
·94 lines (83 loc) · 2.26 KB
/
build64.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env bash
VERSION="0.19.4"
#this part is copied from ANT's script
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
case "`uname`" in
CYGWIN*) cygwin=true ;;
esac
GSNOVA_DIR=`dirname $0 | sed -e "s#^\\([^/]\\)#${PWD}/\\1#"` # sed makes absolute
if $cygwin; then
if [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null ; then
format=mixed
else
format=windows
fi
GSNOVA_DIR=`cygpath --path --$format "$GSNOVA_DIR"`
fi
build_product()
{
export GOPATH="$GSNOVA_DIR"
go get -u github.com/yinqiwen/godns
cd src
#mv common/constants.go{,.bak}
rm common/constants.go
echo "package common" >> common/constants.go
echo "var Version string = \"$VERSION\"" >> common/constants.go
echo "var Product string = \"$1\"" >> common/constants.go
go install -v ...
#mv common/constants.go{.bak,}
}
export GOROOT="C:\Soft\Develop\OfficialGo\go64\go"
export PATH=$GOROOT/bin:$PATH
build_dist()
{
build_product $*
if test $? -eq 1; then
echo "Build gsnova failed!"
return 1
fi
cd $GSNOVA_DIR
DIST_DIR=$GSNOVA_DIR/${1}-${VERSION}
mkdir -p $DIST_DIR/cert
mkdir -p $DIST_DIR/spac
mkdir -p $DIST_DIR/hosts
OS="`go env GOOS`"
ARCH="`go env GOARCH`"
exename=$1
if [ "$OS" = "windows" ]; then
exename="$1".exe
fi
cp $GSNOVA_DIR/README.md $DIST_DIR
cp $GSNOVA_DIR/*.txt $DIST_DIR
cp $GSNOVA_DIR/bin/main $DIST_DIR/$exename
cp $GSNOVA_DIR/conf/*_hosts.conf $DIST_DIR/hosts
cp $GSNOVA_DIR/conf/Fake* $DIST_DIR/cert
cp $GSNOVA_DIR/conf/*_spac.json $DIST_DIR/spac
cp $GSNOVA_DIR/conf/user-gfwlist.txt $DIST_DIR/spac
cp -R $GSNOVA_DIR/web $DIST_DIR
cp $GSNOVA_DIR/conf/"$1".conf $DIST_DIR
if [ "$OS" = "windows" ]; then
zip -r "$1"_"$VERSION"_"$OS"_"$ARCH".zip ${1}-${VERSION}/*
else
chmod 744 $DIST_DIR/gsnova
chmod 600 $DIST_DIR/gsnova.conf
chmod 644 $DIST_DIR/*.txt
chmod -R 644 $DIST_DIR/cert/*
chmod -R 644 $DIST_DIR/hosts/*
chmod -R 644 $DIST_DIR/spac/*
#chmod -R 644 $DIST_DIR/web/*
tar czf ${1}_${VERSION}_${OS}_${ARCH}.tar.gz ${1}-${VERSION}
fi
rm -rf $DIST_DIR
}
main()
{
if [ "x$1" = "xdist" ]; then
shift
build_dist $*
else
build_product $*
fi
}
main $*