-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
+if [ "$SYNCTHING_INOTIFY_VERSION" = "master" ]; then
+ mkdir -p ${TEMPDIR}/syncthing-inotify-build/src/github.com/syncthing || exit 1
+ cd ${TEMPDIR}/syncthing-inotify-build/src/github.com/syncthing
+ [[ ! -d ./syncthing ]] && (git clone https://github.com/syncthing/syncthing || exit 1; )
+ [[ ! -d ./syncthing-inotify ]] && (git clone https://github.com/syncthing/syncthing-inotify || exit 1; )
+ cd syncthing-inotify
+ git status
+ version=$(git describe --tags --always | sed 's/^v//')__patch_165
+ if [ "$SYNCTHING_INOTIFY_CMID" != "" ]; then
+ git checkout -q $SYNCTHING_INOTIFY_CMID || exit 1
+ version=${version}__patch_165
+ fi
+
+ # Workaround about "cannot find package "golang.org/x/sys/unix"
+ go get -u golang.org/x/sys/unix
+
+ # Workaround about "undefined: stream" error when cross-building MacOS
+ # https://github.com/rjeczalik/notify/issues/108
+ OPTS=""
+ [[ "$GOOS_STI" = "darwin" ]] && OPTS="-tags kqueue"
+
+ export GOPATH=$(cd ../../../.. && pwd)
+ go build ${OPTS} -v -i -ldflags "-w -X main.Version=$version" -o ${DESTDIR}/syncthing-inotify${EXT} || exit 1
+else
+
+ tarball="syncthing-inotify-${GOOS_STI}-${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
+ rm -rf syncthing-inotify-${GOOS_STI}-${GOARCH}-v${SYNCTHING_INOTIFY_VERSION}
+ 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