This repository has been archived by the owner on Jan 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
prepare.sh
executable file
·69 lines (56 loc) · 1.61 KB
/
prepare.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
set -euo pipefail
if [[ -z ${syncthing_version:-} ]] ; then
syncthing_version=$(curl -s https://api.github.com/repos/syncthing/syncthing/releases/latest \
| grep tag_name \
| awk '{print $2}' \
| tr -d \",v)
fi
if [[ -z ${go_version:-} ]] ; then
go_version=latest
fi
ver="${syncthing_version}"
if [[ ! -z ${extra_version:-} ]] ; then
ver="$syncthing_version.$extra_version"
else
rels=$(curl -s https://synology.kastelo.net/v1/packages)
i=1
while echo "$rels" | grep -q -- "-$ver.spk" ; do
ver="$syncthing_version.$i"
i=$((i + 1))
done
fi
echo "Version $ver"
echo -n "$ver" > syncthing/INFO_VERSION
rm -rf build
mkdir -p build
pushd build
curl -skL "https://github.com/syncthing/syncthing/releases/download/v${syncthing_version}/syncthing-source-v${syncthing_version}.tar.gz" | tar zxf -
pushd syncthing
dst=../../syncthing
mkdir -p "$dst/bin"
mkdir -p "$dst/doc"
build() {
goos=$1
goarch=$2
goarm=${3:-}
echo Build "$goos-$goarch $goarm" using "golang:$go_version"
docker run --rm \
-v $(pwd):/syncthing \
-v /tmp/syncthing-gopath:/go \
-v /tmp/syncthing-cache:/root/.cache \
-w /syncthing \
-e BUILD_HOST=kastelo.net \
-e BUILD_USER=synology \
"golang:$go_version" \
go run build.go -no-upgrade -goos $goos -goarch $goarch build
mv syncthing "$dst/bin/syncthing-$goos-$goarch$goarm"
}
build linux amd64
build linux 386
GOARM=7 build linux arm v7
GOARM=8 build linux arm v8
cp README.md LICENSE AUTHORS CONTRIBUTING.md CONDUCT.md GOALS.md "$dst/doc"
popd
popd
rm -rf build