-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmanage.sh
executable file
·156 lines (135 loc) · 4.01 KB
/
manage.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/usr/bin/env bash
set -e
VERSION=$(grep "const VERSION_NUM" src/cmd/waarp-analyze/main.go | tr -d -c '0-9.')
TMP_DIR=$(mktemp -d)
DIST_DIR=dist
CURDIR=$(cd $(dirname $0) && pwd)
function cleanup {
if [[ -d $TMP_DIR ]]; then
rm -fr $TMP_DIR
fi
}
trap cleanup EXIT
architecture() {
case $1 in
amd64)
echo -n "x86_64"
;;
386)
echo -n "x86"
;;
*)
echo "unsupported"
return 1
;;
esac
}
make_package() {
if [[ $# != 2 ]]; then
echo "Usage: make_package GOOS GOARCH"
echo "ERR: missing GOOS and GOARCH variables"
exit 1
fi
local binfile="waarp-analyze-$1-$2"
GOOS=$1 GOARCH=$2 CGO_ENABLED=0 GOPATH="$CURDIR:$CURDIR/vendor" go build -v \
-o bin/$binfile -ldflags '-s -w' ./src/cmd/waarp-analyze
mkdir -p $TMP_DIR/usr/bin/
cp bin/$binfile $TMP_DIR/usr/bin/waarp-analyze
fpm -s dir -t rpm -C $TMP_DIR \
--package dist/ \
--name waarp-analyze \
--version $VERSION \
--iteration 1 \
--architecture $(architecture $2) \
--vendor "Waarp SAS" \
--maintainer "Bruno CARLIN <[email protected]>" \
--url "http://www.waarp.fr" \
--rpm-auto-add-directories \
--rpm-dist el6 \
.
fpm -s dir -t rpm -C $TMP_DIR \
--package dist/ \
--name waarp-analyze \
--version $VERSION \
--iteration 1 \
--architecture $(architecture $2) \
--vendor "Waarp SAS" \
--maintainer "Bruno CARLIN <[email protected]>" \
--url "http://www.waarp.fr" \
--rpm-auto-add-directories \
--rpm-dist el7 \
.
rm -rf $TMP_DIR/*
mkdir -p $TMP_DIR/waarp-analyze-$VERSION-$1-$2
cp bin/$binfile $TMP_DIR/waarp-analyze-$VERSION-$1-$2
cd $TMP_DIR
tar cfz waarp-analyze-$VERSION-$1-$2.tar.gz waarp-analyze-$VERSION-$1-$2
cd -
mv $TMP_DIR/waarp-analyze-$VERSION-$1-$2.tar.gz dist
rm -rf $TMP_DIR/*
}
build() {
mkdir -p dist
make_package "linux" "amd64"
make_package "linux" "386"
}
bump() {
if [[ $1 == "" ]]; then
echo "ERROR: Provide a version as argument"
exit 3
fi
sed -i -e "s|version = '[0-9\.]\+'|version = '"$1"'|" doc/source/conf.py
sed -i -e "s|release = '[0-9\.]\+'|release = '"$1"'|" doc/source/conf.py
sed -i -e 's|const VERSION_NUM = "[0-9\.]\+"|const VERSION_NUM = "'$1'"|' src/cmd/waarp-analyze/main.go
git add doc/source/conf.py src/cmd/waarp-analyze/main.go
git commit -m "version bump to $1"
git tag $1
}
doc_build() {
cd doc
make clean
make -e SPHINXBUILD=.venv/bin/sphinx-build html
mv build/html build/html-en
for locale in fr; do
make -e SPHINXBUILD=.venv/bin/sphinx-build -e SPHINXOPTS="-D language='$locale'" html
mv build/html build/html-$locale
done
}
doc_update() {
cd doc
make -e SPHINXBUILD=.venv/bin/sphinx-build clean gettext
./.venv/bin/sphinx-intl update -p build/locale -l fr
}
usage() {
echo "Usage: $0 task"
echo "TASKS"
echo " build Builds packages"
echo " doc build Builds documentation"
echo " doc update Updates documentation i18n"
echo " bump VERSION Bumps version everywhere it is used"
echo " help Show this help"
}
case $1 in
build)
build
;;
bump)
bump $2
;;
doc)
case $2 in
update)
doc_update
;;
build)
doc_build
;;
*)
usage
;;
esac
;;
*)
usage
;;
esac