aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile6
-rw-r--r--README.md10
-rwxr-xr-xscripts/get-syncthing.sh31
3 files changed, 34 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index 619c514..160b91a 100644
--- a/Makefile
+++ b/Makefile
@@ -80,7 +80,7 @@ clean:
.PHONY: distclean
distclean: clean
- rm -rf $(LOCAL_BINDIR) tools glide.lock vendor
+ rm -rf $(LOCAL_BINDIR) tools glide.lock vendor $(ROOT_SRCDIR)/*.zip
.PHONY: install
install: all
@@ -96,7 +96,7 @@ tools/glide:
.PHONY: tools/syncthing
tools/syncthing:
- @test -e $(LOCAL_TOOLSDIR)/syncthing -a -e $(LOCAL_TOOLSDIR)/syncthing-inotify || { \
+ @test -e $(LOCAL_TOOLSDIR)/syncthing$(EXT) -a -e $(LOCAL_TOOLSDIR)/syncthing-inotify$(EXT) || { \
mkdir -p $(LOCAL_TOOLSDIR); \
DESTDIR=$(LOCAL_TOOLSDIR) \
SYNCTHING_VERSION=$(SYNCTHING_VERSION) \
@@ -105,7 +105,7 @@ tools/syncthing:
.PHONY:
tools/syncthing/copytobin:
- @test -e $(LOCAL_TOOLSDIR)/syncthing -a -e $(LOCAL_TOOLSDIR)/syncthing-inotify || { echo "Please execute first: make tools/syncthing\n"; exit 1; }
+ @test -e $(LOCAL_TOOLSDIR)/syncthing$(EXT) -a -e $(LOCAL_TOOLSDIR)/syncthing-inotify$(EXT) || { echo "Please execute first: make tools/syncthing\n"; exit 1; }
@mkdir -p $(LOCAL_BINDIR)
@cp -f $(LOCAL_TOOLSDIR)/syncthing$(EXT) $(LOCAL_TOOLSDIR)/syncthing-inotify$(EXT) $(LOCAL_BINDIR)
diff --git a/README.md b/README.md
index ad8e6bb..4249251 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@ used to remotely cross build applications.
### Dependencies
-- Install and setup [Go](https://golang.org/doc/install) version 1.7 or
+- Install and setup [Go](https://golang.org/doc/install) version 1.8 or
higher to compile this tool.
@@ -35,6 +35,14 @@ And to install xds-agent in /usr/local/bin:
make install
```
+> **NOTE**: To cross build for example for Windows, just execute:
+```bash
+export GOOS=windows
+export GOARCH=amd64
+make all
+make package
+```
+
## How to run
## Configuration
diff --git a/scripts/get-syncthing.sh b/scripts/get-syncthing.sh
index 54ca7e1..da06d15 100755
--- a/scripts/get-syncthing.sh
+++ b/scripts/get-syncthing.sh
@@ -8,6 +8,8 @@
[ -z "$SYNCTHING_INOTIFY_VERSION" ] && { SYNCTHING_INOTIFY_VERSION=master; SYNCTHING_INOTIFY_CMID=af6fbf9d63f95a0; }
[ -z "$DESTDIR" ] && DESTDIR=/usr/local/bin
[ -z "$TMPDIR" ] && TMPDIR=/tmp
+[ -z "$GOOS" ] && GOOS=$(go env GOOS)
+[ -z "$GOARCH" ] && GOARCH=$(go env GOARCH)
TEMPDIR=$TMPDIR/.get-st.$$
@@ -18,20 +20,28 @@ cleanExit ()
rm -rf ${TEMPDIR}
}
+TB_EXT="tar.gz"
+EXT=""
+[[ "$GOOS" = "windows" ]] && { TB_EXT="zip"; EXT=".exe"; }
+
echo "Get Syncthing..."
## Install Syncthing + Syncthing-inotify
## gpg: key 00654A3E: public key "Syncthing Release Management <release@syncthing.net>" imported
gpg -q --keyserver pool.sks-keyservers.net --recv-keys 37C84554E7E0A261E4F76E1ED26E6ED000654A3E || exit 1
-tarball="syncthing-linux-amd64-v${SYNCTHING_VERSION}.tar.gz" \
+tarball="syncthing-${GOOS}-${GOARCH}-v${SYNCTHING_VERSION}.${TB_EXT}" \
&& curl -sfSL "https://github.com/syncthing/syncthing/releases/download/v${SYNCTHING_VERSION}/${tarball}" -O \
&& curl -sfSL "https://github.com/syncthing/syncthing/releases/download/v${SYNCTHING_VERSION}/sha1sum.txt.asc" -O \
&& gpg -q --verify sha1sum.txt.asc \
&& grep -E " ${tarball}\$" sha1sum.txt.asc | sha1sum -c - \
- && rm sha1sum.txt.asc \
- && tar -xvf "$tarball" --strip-components=1 "$(basename "$tarball" .tar.gz)"/syncthing \
- && mv syncthing ${DESTDIR}/syncthing || exit 1
+ && rm sha1sum.txt.asc
+ if [ "${TB_EXT}" = "tar.gz" ]; then
+ tar -xvf "$tarball" --strip-components=1 "$(basename "$tarball" .tar.gz)"/syncthing \
+ && mv syncthing ${DESTDIR}/syncthing || exit 1
+ else
+ unzip "$tarball" && mv syncthing-windows-*/syncthing.exe ${DESTDIR}/syncthing.exe || exit 1
+ fi
echo "Get Syncthing-inotify..."
if [ "$SYNCTHING_INOTIFY_VERSION" = "master" ]; then
@@ -46,13 +56,16 @@ if [ "$SYNCTHING_INOTIFY_VERSION" = "master" ]; then
git status
export GOPATH=$(realpath `pwd`/../../../..)
version=$(git describe --tags --always | sed 's/^v//')__patch_165
- go build -v -i -ldflags "-w -X main.Version=$version" -o ${DESTDIR}/syncthing-inotify || exit 1
+ go build -v -i -ldflags "-w -X main.Version=$version" -o ${DESTDIR}/syncthing-inotify${EXT} || exit 1
else
-tarball="syncthing-inotify-linux-amd64-v${SYNCTHING_INOTIFY_VERSION}.tar.gz" \
- && curl -sfSL "https://github.com/syncthing/syncthing-inotify/releases/download/v${SYNCTHING_INOTIFY_VERSION}/${tarball}" -O \
- && tar -xvf "${tarball}" syncthing-inotify \
- && mv syncthing-inotify ${DESTDIR}/syncthing-inotify
+ tarball="syncthing-inotify-${GOOS}-${GOARCH}-v${SYNCTHING_INOTIFY_VERSION}.${TB_EXT}"
+ curl -sfSL "https://github.com/syncthing/syncthing-inotify/releases/download/v${SYNCTHING_INOTIFY_VERSION}/${tarball}" -O || exit 1
+ if [ "${TB_EXT}" = "tar.gz" ]; then
+ tar -xvf "${tarball}" syncthing-inotify && mv syncthing-inotify ${DESTDIR}/syncthing-inotify || exit 1
+ else
+ unzip "$tarball" && mv syncthing-inotify.exe ${DESTDIR}/syncthing-inotify.exe || exit 1
+ fi
fi
echo "DONE: syncthing and syncthing-inotify successfuly installed in ${DESTDIR}" \ No newline at end of file