2021-06-13 09:42:31 +00:00
|
|
|
#!/bin/sh
|
2019-11-28 00:35:29 +00:00
|
|
|
|
2019-11-28 13:00:52 +00:00
|
|
|
# This script generates an MSI file for Yggdrasil for a given architecture. It
|
2022-04-17 22:38:16 +00:00
|
|
|
# needs to run on Windows within MSYS2 and Go 1.17 or later must be installed on
|
|
|
|
# the system and within the PATH. This is ran currently by GitHub Actions (see
|
|
|
|
# the workflows in the repository).
|
2019-11-28 13:00:52 +00:00
|
|
|
#
|
|
|
|
# Author: Neil Alexander <neilalexander@users.noreply.github.com>
|
|
|
|
|
2019-11-28 00:35:29 +00:00
|
|
|
# Get arch from command line if given
|
|
|
|
PKGARCH=$1
|
|
|
|
if [ "${PKGARCH}" == "" ];
|
|
|
|
then
|
2022-04-17 22:38:16 +00:00
|
|
|
echo "tell me the architecture: x86, x64, arm or arm64"
|
2019-11-28 00:35:29 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-06-13 09:42:31 +00:00
|
|
|
# Download the wix tools!
|
|
|
|
if [ ! -d wixbin ];
|
|
|
|
then
|
2022-04-17 22:38:16 +00:00
|
|
|
curl -LO https://wixtoolset.org/downloads/v3.14.0.3910/wix314-binaries.zip
|
|
|
|
if [ `md5sum wix314-binaries.zip | cut -f 1 -d " "` != "34f655cf108086838dd5a76d4318063b" ];
|
2021-06-13 09:42:31 +00:00
|
|
|
then
|
|
|
|
echo "wix package didn't match expected checksum"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
mkdir -p wixbin
|
2022-04-17 22:38:16 +00:00
|
|
|
unzip -o wix314-binaries.zip -d wixbin || (
|
2021-06-13 09:42:31 +00:00
|
|
|
echo "failed to unzip WiX"
|
|
|
|
exit 1
|
|
|
|
)
|
|
|
|
fi
|
|
|
|
|
2019-11-28 13:00:52 +00:00
|
|
|
# Build Yggdrasil!
|
2021-06-13 10:04:27 +00:00
|
|
|
[ "${PKGARCH}" == "x64" ] && GOOS=windows GOARCH=amd64 CGO_ENABLED=0 ./build
|
|
|
|
[ "${PKGARCH}" == "x86" ] && GOOS=windows GOARCH=386 CGO_ENABLED=0 ./build
|
|
|
|
[ "${PKGARCH}" == "arm" ] && GOOS=windows GOARCH=arm CGO_ENABLED=0 ./build
|
2022-04-17 22:38:16 +00:00
|
|
|
[ "${PKGARCH}" == "arm64" ] && GOOS=windows GOARCH=arm64 CGO_ENABLED=0 ./build
|
2019-11-28 00:35:29 +00:00
|
|
|
|
|
|
|
# Create the postinstall script
|
2019-11-29 11:06:08 +00:00
|
|
|
cat > updateconfig.bat << EOF
|
|
|
|
if not exist %ALLUSERSPROFILE%\\Yggdrasil (
|
|
|
|
mkdir %ALLUSERSPROFILE%\\Yggdrasil
|
|
|
|
)
|
|
|
|
if not exist %ALLUSERSPROFILE%\\Yggdrasil\\yggdrasil.conf (
|
|
|
|
if exist yggdrasil.exe (
|
2021-06-13 09:42:31 +00:00
|
|
|
yggdrasil.exe -genconf > %ALLUSERSPROFILE%\\Yggdrasil\\yggdrasil.conf
|
2019-11-29 11:06:08 +00:00
|
|
|
)
|
2019-11-28 00:35:29 +00:00
|
|
|
)
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# Work out metadata for the package info
|
|
|
|
PKGNAME=$(sh contrib/semver/name.sh)
|
2021-06-13 09:58:15 +00:00
|
|
|
PKGVERSION=$(sh contrib/msi/msversion.sh --bare)
|
2019-11-28 00:35:29 +00:00
|
|
|
PKGVERSIONMS=$(echo $PKGVERSION | tr - .)
|
2022-04-17 22:38:16 +00:00
|
|
|
([ "${PKGARCH}" == "x64" ] || [ "${PKGARCH}" == "arm64" ]) && \
|
2019-11-28 00:35:29 +00:00
|
|
|
PKGGUID="77757838-1a23-40a5-a720-c3b43e0260cc" PKGINSTFOLDER="ProgramFiles64Folder" || \
|
|
|
|
PKGGUID="54a3294e-a441-4322-aefb-3bb40dd022bb" PKGINSTFOLDER="ProgramFilesFolder"
|
|
|
|
|
|
|
|
# Download the Wintun driver
|
2021-06-13 10:07:19 +00:00
|
|
|
if [ ! -d wintun ];
|
|
|
|
then
|
2022-01-30 21:57:10 +00:00
|
|
|
curl -o wintun.zip https://www.wintun.net/builds/wintun-0.14.1.zip
|
2021-06-13 10:07:19 +00:00
|
|
|
unzip wintun.zip
|
2021-06-13 10:13:02 +00:00
|
|
|
fi
|
|
|
|
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
|
2022-04-17 22:38:16 +00:00
|
|
|
elif [ $PKGARCH = "arm64" ]; then
|
|
|
|
PKGWINTUNDLL=wintun/bin/arm64/wintun.dll
|
2021-06-13 10:13:02 +00:00
|
|
|
else
|
|
|
|
echo "wasn't sure which architecture to get wintun for"
|
|
|
|
exit 1
|
2019-11-28 00:35:29 +00:00
|
|
|
fi
|
|
|
|
|
2019-12-10 11:38:58 +00:00
|
|
|
if [ $PKGNAME != "master" ]; then
|
|
|
|
PKGDISPLAYNAME="Yggdrasil Network (${PKGNAME} branch)"
|
2019-12-10 11:40:16 +00:00
|
|
|
else
|
2019-12-10 11:38:58 +00:00
|
|
|
PKGDISPLAYNAME="Yggdrasil Network"
|
|
|
|
fi
|
|
|
|
|
2019-11-28 00:35:29 +00:00
|
|
|
# Generate the wix.xml file
|
|
|
|
cat > wix.xml << EOF
|
|
|
|
<?xml version="1.0" encoding="windows-1252"?>
|
|
|
|
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
|
|
|
|
<Product
|
2019-12-10 11:38:58 +00:00
|
|
|
Name="${PKGDISPLAYNAME}"
|
2019-11-28 00:35:29 +00:00
|
|
|
Id="*"
|
|
|
|
UpgradeCode="${PKGGUID}"
|
|
|
|
Language="1033"
|
|
|
|
Codepage="1252"
|
|
|
|
Version="${PKGVERSIONMS}"
|
|
|
|
Manufacturer="github.com/yggdrasil-network">
|
|
|
|
|
|
|
|
<Package
|
|
|
|
Id="*"
|
|
|
|
Keywords="Installer"
|
|
|
|
Description="Yggdrasil Network Installer"
|
2019-12-10 11:17:15 +00:00
|
|
|
Comments="Yggdrasil Network standalone router for Windows."
|
2019-11-28 00:35:29 +00:00
|
|
|
Manufacturer="github.com/yggdrasil-network"
|
|
|
|
InstallerVersion="200"
|
2019-11-29 11:06:08 +00:00
|
|
|
InstallScope="perMachine"
|
2019-11-28 00:35:29 +00:00
|
|
|
Languages="1033"
|
|
|
|
Compressed="yes"
|
|
|
|
SummaryCodepage="1252" />
|
|
|
|
|
|
|
|
<MajorUpgrade
|
|
|
|
AllowDowngrades="yes" />
|
|
|
|
|
|
|
|
<Media
|
|
|
|
Id="1"
|
|
|
|
Cabinet="Media.cab"
|
2019-12-10 11:17:15 +00:00
|
|
|
EmbedCab="yes"
|
|
|
|
CompressionLevel="high" />
|
2019-11-28 00:35:29 +00:00
|
|
|
|
|
|
|
<Directory Id="TARGETDIR" Name="SourceDir">
|
|
|
|
<Directory Id="${PKGINSTFOLDER}" Name="PFiles">
|
|
|
|
<Directory Id="YggdrasilInstallFolder" Name="Yggdrasil">
|
|
|
|
|
|
|
|
<Component Id="MainExecutable" Guid="c2119231-2aa3-4962-867a-9759c87beb24">
|
|
|
|
<File
|
|
|
|
Id="Yggdrasil"
|
|
|
|
Name="yggdrasil.exe"
|
|
|
|
DiskId="1"
|
|
|
|
Source="yggdrasil.exe"
|
|
|
|
KeyPath="yes" />
|
|
|
|
|
2021-06-13 09:47:14 +00:00
|
|
|
<File
|
|
|
|
Id="Wintun"
|
|
|
|
Name="wintun.dll"
|
|
|
|
DiskId="1"
|
|
|
|
Source="${PKGWINTUNDLL}" />
|
|
|
|
|
2019-11-28 00:35:29 +00:00
|
|
|
<ServiceInstall
|
|
|
|
Id="ServiceInstaller"
|
|
|
|
Account="LocalSystem"
|
|
|
|
Description="Yggdrasil Network router process"
|
|
|
|
DisplayName="Yggdrasil Service"
|
|
|
|
ErrorControl="normal"
|
|
|
|
LoadOrderGroup="NetworkProvider"
|
2019-12-04 09:29:30 +00:00
|
|
|
Name="Yggdrasil"
|
2019-11-28 00:35:29 +00:00
|
|
|
Start="auto"
|
|
|
|
Type="ownProcess"
|
2019-11-29 11:06:08 +00:00
|
|
|
Arguments='-useconffile "%ALLUSERSPROFILE%\\Yggdrasil\\yggdrasil.conf" -logto "%ALLUSERSPROFILE%\\Yggdrasil\\yggdrasil.log"'
|
2019-11-28 00:35:29 +00:00
|
|
|
Vital="yes" />
|
|
|
|
|
|
|
|
<ServiceControl
|
|
|
|
Id="ServiceControl"
|
|
|
|
Name="yggdrasil"
|
|
|
|
Start="install"
|
|
|
|
Stop="both"
|
|
|
|
Remove="uninstall" />
|
|
|
|
</Component>
|
|
|
|
|
|
|
|
<Component Id="CtrlExecutable" Guid="a916b730-974d-42a1-b687-d9d504cbb86a">
|
|
|
|
<File
|
|
|
|
Id="Yggdrasilctl"
|
|
|
|
Name="yggdrasilctl.exe"
|
|
|
|
DiskId="1"
|
|
|
|
Source="yggdrasilctl.exe"
|
|
|
|
KeyPath="yes"/>
|
|
|
|
</Component>
|
|
|
|
|
|
|
|
<Component Id="ConfigScript" Guid="64a3733b-c98a-4732-85f3-20cd7da1a785">
|
|
|
|
<File
|
|
|
|
Id="Configbat"
|
2019-11-28 09:52:14 +00:00
|
|
|
Name="updateconfig.bat"
|
2019-11-28 00:35:29 +00:00
|
|
|
DiskId="1"
|
2019-11-29 11:06:08 +00:00
|
|
|
Source="updateconfig.bat"
|
2019-11-28 00:35:29 +00:00
|
|
|
KeyPath="yes"/>
|
|
|
|
</Component>
|
|
|
|
</Directory>
|
|
|
|
</Directory>
|
|
|
|
</Directory>
|
|
|
|
|
2019-12-10 10:55:20 +00:00
|
|
|
<Feature Id="YggdrasilFeature" Title="Yggdrasil" Level="1">
|
2019-11-28 00:35:29 +00:00
|
|
|
<ComponentRef Id="MainExecutable" />
|
|
|
|
<ComponentRef Id="CtrlExecutable" />
|
|
|
|
<ComponentRef Id="ConfigScript" />
|
|
|
|
</Feature>
|
|
|
|
|
|
|
|
<CustomAction
|
|
|
|
Id="UpdateGenerateConfig"
|
|
|
|
Directory="YggdrasilInstallFolder"
|
2019-11-28 09:52:14 +00:00
|
|
|
ExeCommand="cmd.exe /c updateconfig.bat"
|
2019-11-28 10:42:57 +00:00
|
|
|
Execute="deferred"
|
2019-11-29 11:06:08 +00:00
|
|
|
Return="check"
|
|
|
|
Impersonate="yes" />
|
2019-11-28 00:35:29 +00:00
|
|
|
|
|
|
|
<InstallExecuteSequence>
|
|
|
|
<Custom
|
|
|
|
Action="UpdateGenerateConfig"
|
2021-06-13 09:42:31 +00:00
|
|
|
Before="StartServices">
|
|
|
|
NOT Installed AND NOT REMOVE
|
|
|
|
</Custom>
|
2019-11-28 00:35:29 +00:00
|
|
|
</InstallExecuteSequence>
|
|
|
|
|
|
|
|
</Product>
|
|
|
|
</Wix>
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# Generate the MSI
|
2021-06-13 09:42:31 +00:00
|
|
|
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 WixUtilExtension.dll -out ${PKGNAME}-${PKGVERSION}-${PKGARCH}.msi ${PKGNAME}-${PKGVERSION}-${PKGARCH}.wixobj
|