#!/bin/sh # This script generates an MSI file for Mesh for a given architecture. It # needs to run on Windows within MSYS2 and Go 1.13 or later must be installed on # the system and within the PATH. This is ran currently by Appveyor or GitHub Actions (see # appveyor.yml in the repository root) for both x86 and x64. # # Author: Neil Alexander , Vadym Vikulin # Get arch from command line if given PKGARCH=$1 if [ "${PKGARCH}" == "" ]; then echo "tell me the architecture: x86, x64 or arm" exit 1 fi # Get the rest of the repository history. This is needed within Appveyor because # otherwise we don't get all of the branch histories and therefore the semver # scripts don't work properly. if [ "${APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH}" != "" ]; then git fetch --all git checkout ${APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH} elif [ "${APPVEYOR_REPO_BRANCH}" != "" ]; then git fetch --all git checkout ${APPVEYOR_REPO_BRANCH} fi # Install prerequisites within MSYS2 pacman -S --needed --noconfirm unzip git curl # Download the wix tools! if [ ! -d wixbin ]; then curl -LO https://wixtoolset.org/downloads/v3.14.0.6526/wix314-binaries.zip if [ `md5sum wix314-binaries.zip | cut -f 1 -d " "` != "aecd655bb56238d48ef5254cd4dc958e" ]; then echo "wix package didn't match expected checksum" exit 1 fi mkdir -p wixbin unzip -o wix314-binaries.zip -d wixbin || ( echo "failed to unzip WiX" exit 1 ) fi # Work out metadata for the package info PKGNAME=$(sh contrib/semver/name.sh) PKGVERSION=$(sh contrib/msi/msversion.sh --bare) PKGVERSIONMS=$(echo $PKGVERSION | tr - .) PKGUIFOLDER=contrib/ui/mesh-ui/ui/ PKGLICENSEFILE=LICENSE.rtf #Build winres go-winres simply --icon riv.ico --file-version $PKGVERSION --file-description "RiV-mesh (c) service, 2022 RIV CHAIN" \ --product-version $PKGVERSION --product-name "RiV-mesh" --copyright "Copyright (c) 2022, RIV CHAIN" cp *.syso cmd/mesh go-winres simply --icon riv.ico --file-version $PKGVERSION --file-description "RiV-mesh (c) GUI, 2022 RIV CHAIN" \ --product-version $PKGVERSION --product-name "RiV-mesh" --copyright "Copyright (c) 2022, RIV CHAIN" --manifest gui cp *.syso contrib/ui/mesh-ui go-winres simply --file-version $PKGVERSION --file-description "RiV-mesh (c) CLI, 2022 RIV CHAIN" \ --product-version $PKGVERSION --product-name "RiV-mesh" --copyright "Copyright (c) 2022, RIV CHAIN" --manifest cli cp *.syso cmd/meshctl # Build Mesh! [ "${PKGARCH}" == "x64" ] && GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ ./build [ "${PKGARCH}" == "x86" ] && GOOS=windows GOARCH=386 CGO_ENABLED=1 CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ ./build [ "${PKGARCH}" == "arm" ] && GOOS=windows GOARCH=arm CGO_ENABLED=0 ./build # Create the postinstall script cat > updateconfig.bat << EOF if not exist %ALLUSERSPROFILE%\\RiV-mesh ( mkdir %ALLUSERSPROFILE%\\RiV-mesh ) if not exist %ALLUSERSPROFILE%\\RiV-mesh\\mesh.conf ( if exist mesh.exe ( mesh.exe -genconf > %ALLUSERSPROFILE%\\RiV-mesh\\mesh.conf ) ) EOF [ "${PKGARCH}" == "x64" ] && \ PKGGUID="5bcfdddd-66a7-4eb7-b5f7-4a7500dcc65d" PKGINSTFOLDER="ProgramFiles64Folder" || \ PKGGUID="cbf6ffa1-219e-4bb2-a0e5-74dbf1b58a45" PKGINSTFOLDER="ProgramFilesFolder" # Download the Wintun driver if [ ! -d wintun ]; then curl -o wintun.zip https://www.wintun.net/builds/wintun-0.14.1.zip unzip wintun.zip fi if [ $PKGARCH = "x64" ]; then PKGWINTUNDLL=wintun/bin/amd64/wintun.dll PKGWEBVIEWFILE=contrib/ui/mesh-ui/dll/x64/webview.dll PKGWEBVIEWFILELOADER=contrib/ui/mesh-ui/dll/x64/WebView2Loader.dll elif [ $PKGARCH = "x86" ]; then PKGWINTUNDLL=wintun/bin/x86/wintun.dll PKGWEBVIEWFILE=contrib/ui/mesh-ui/dll/x86/webview.dll PKGWEBVIEWFILELOADER=contrib/ui/mesh-ui/dll/x86/WebView2Loader.dll elif [ $PKGARCH = "arm" ]; then PKGWINTUNDLL=wintun/bin/arm/wintun.dll #elif [ $PKGARCH = "arm64" ]; then # PKGWINTUNDLL=wintun/bin/arm64/wintun.dll else echo "wasn't sure which architecture to get wintun for" exit 1 fi PKG_UI_ASSETS_ZIP=$(pwd)/ui.zip ( cd "$PKGUIFOLDER" && 7z a "$PKG_UI_ASSETS_ZIP" * ) if [ $PKGNAME != "master" ]; then PKGDISPLAYNAME="RiV-mesh Network (${PKGNAME} branch)" else PKGDISPLAYNAME="RiV-mesh Network" fi # Generate the wix.xml file cat > wix.xml << EOF WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed 1 NOT Installed AND NOT REMOVE ASSISTANCE_START_VIA_REGISTRY EOF # Generate the MSI CANDLEFLAGS="-nologo" LIGHTFLAGS="-nologo -spdb -sice:ICE71 -sice:ICE61" wixbin/candle $CANDLEFLAGS -out ${PKGNAME}-${PKGVERSION}-${PKGARCH}.wixobj -arch ${PKGARCH} wix.xml && \ wixbin/light $LIGHTFLAGS -ext WixUIExtension -ext WixUtilExtension -out ${PKGNAME}-${PKGVERSION}-${PKGARCH}.msi ${PKGNAME}-${PKGVERSION}-${PKGARCH}.wixobj