contrib/windows/build-installer.sh (1872 bytes)
1 #!/bin/sh 2 3 # build-installer.sh: make sbm-VERSION-setup.exe, the Windows installer, in 4 # the top directory of the source. The script needs makensis (NSIS), curl, 5 # unzip and sha256sum. It runs on Linux, and on Windows under Cygwin. 6 # 7 # sh contrib/windows/build-installer.sh 8 # 9 # The script gets fzf.exe from the fzf release on GitHub. It stops if the 10 # SHA-256 sum of the download is not the expected one. 11 12 set -e 13 14 fzf_version=0.74.4 15 fzf_sum=5e63c0e798406fcb9c51a9fed4988398e25fdabf8c670e32c16caf7b4a7ed02d 16 17 here=$(cd "$(dirname "$0")" && pwd) 18 top=$(cd "$here/../.." && pwd) 19 version=$(sed -n 's/^VERSION=//p' "$top/config.mk") 20 # VIProductVersion needs four numbers: 0.3 becomes 0.3.0.0. 21 viversion=$(printf '%s.0.0.0\n' "$version" | cut -d. -f1-4) 22 out=$top/sbm-$version-setup.exe 23 24 # makensis for Windows needs Windows paths. 25 native () { 26 if command -v cygpath >/dev/null 2>&1; then 27 cygpath -w "$1" 28 else 29 printf '%s\n' "$1" 30 fi 31 } 32 33 work=${TMPDIR:-/tmp}/sbm-installer.$$ 34 mkdir "$work" 35 trap 'rm -rf "$work"' EXIT INT TERM 36 mkdir "$work/libexec" "$work/share" "$work/etc" 37 38 make -s -C "$top" install PREFIX="$work" >/dev/null 39 cp "$here/fzf" "$work/bin/" 40 cp "$here/sbm-setup" "$work/libexec/" 41 cp "$here/sbm.sh" "$work/etc/" 42 cp "$top/engines" "$top/usertags" "$top/LICENSE" "$work/share/" 43 44 url=https://github.com/junegunn/fzf/releases/download/v$fzf_version 45 curl -fsSL -o "$work/fzf.zip" "$url/fzf-$fzf_version-windows_amd64.zip" 46 printf '%s %s\n' "$fzf_sum" "$work/fzf.zip" | sha256sum -c - >/dev/null 47 unzip -q "$work/fzf.zip" fzf.exe -d "$work/libexec" 48 curl -fsSL -o "$work/libexec/fzf-LICENSE.txt" \ 49 "https://raw.githubusercontent.com/junegunn/fzf/v$fzf_version/LICENSE" 50 51 makensis -V2 -DVERSION="$version" -DVIVERSION="$viversion" \ 52 -DSRC="$(native "$work")" -DOUTFILE="$(native "$out")" \ 53 "$(native "$here/sbm.nsi")" 54 printf '%s\n' "$out"