#!/bin/bash # This script generates an MSI file for Yggdrasil for a given architecture. It # needs to run on Linux or macOS with Go 1.16, wixl and msitools installed. # # Author: Neil Alexander # 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 # Build Yggdrasil! [ "${PKGARCH}" == "x64" ] && GOOS=windows GOARCH=amd64 CGO_ENABLED=0 ./build -p -l "-aslr" [ "${PKGARCH}" == "x86" ] && GOOS=windows GOARCH=386 CGO_ENABLED=0 ./build -p -l "-aslr" [ "${PKGARCH}" == "arm" ] && GOOS=windows GOARCH=arm CGO_ENABLED=0 ./build -p -l "-aslr" #[ "${PKGARCH}" == "arm64" ] && GOOS=windows GOARCH=arm64 CGO_ENABLED=0 ./build # Create the postinstall script cat > updateconfig.bat << EOF if not exist %ALLUSERSPROFILE%\\Yggdrasil ( mkdir %ALLUSERSPROFILE%\\Yggdrasil ) if not exist %ALLUSERSPROFILE%\\Yggdrasil\\yggdrasil.conf ( if exist yggdrasil.exe ( if not exist %ALLUSERSPROFILE%\\Yggdrasil\\yggdrasil.conf ( yggdrasil.exe -genconf > %ALLUSERSPROFILE%\\Yggdrasil\\yggdrasil.conf ) ) ) EOF # Work out metadata for the package info PKGNAME=$(sh contrib/semver/name.sh) PKGVERSION=$(sh contrib/semver/version.sh --bare) PKGVERSIONMS=$(echo $PKGVERSION | tr - .) [ "${PKGARCH}" == "x64" ] && \ PKGGUID="77757838-1a23-40a5-a720-c3b43e0260cc" PKGINSTFOLDER="ProgramFiles64Folder" || \ PKGGUID="54a3294e-a441-4322-aefb-3bb40dd022bb" PKGINSTFOLDER="ProgramFilesFolder" # Download the Wintun driver curl -o wintun.zip https://www.wintun.net/builds/wintun-0.10.2.zip unzip wintun.zip if [ $PKGARCH = "x64" ]; then PKGWINTUNDLL=wintun/bin/amd64/wintun.dll elif [ $PKGARCH = "x86" ]; then PKGWINTUNDLL=wintun/bin/x86/wintun.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 if [ $PKGNAME != "master" ]; then PKGDISPLAYNAME="Yggdrasil Network (${PKGNAME} branch)" else PKGDISPLAYNAME="Yggdrasil Network" fi # Generate the wix.xml file cat > wix.xml << EOF EOF # Generate the MSI wixl -v wix.xml -a ${PKGARCH} -o ${PKGNAME}-${PKGVERSION}-${PKGARCH}.msi