1- #! /bin/sh
1+ #! /bin/bash
22
33# This script generates an MSI file for Yggdrasil for a given architecture. It
4- # needs to run on Windows within MSYS2 and Go 1.13 or later must be installed on
5- # the system and within the PATH. This is ran currently by Appveyor (see
6- # appveyor.yml in the repository root) for both x86 and x64.
4+ # needs to run on Linux or macOS with Go 1.16, wixl and msitools installed.
75#
86# Author: Neil Alexander <neilalexander@users.noreply.github.com>
97
108# Get arch from command line if given
119PKGARCH=$1
1210if [ " ${PKGARCH} " == " " ];
1311then
14- echo " tell me the architecture: x86 or x64 "
12+ echo " tell me the architecture: x86, x64 or arm "
1513 exit 1
1614fi
1715
2826 git checkout ${APPVEYOR_REPO_BRANCH}
2927fi
3028
31- # Install prerequisites within MSYS2
32- pacman -S --needed --noconfirm unzip git curl
33-
34- # Download the wix tools!
35- if [ ! -d wixbin ];
36- then
37- curl -LO https://github.com/wixtoolset/wix3/releases/download/wix3112rtm/wix311-binaries.zip
38- if [ ` md5sum wix311-binaries.zip | cut -f 1 -d " " ` != " 47a506f8ab6666ee3cc502fb07d0ee2a" ];
39- then
40- echo " wix package didn't match expected checksum"
41- exit 1
42- fi
43- mkdir -p wixbin
44- unzip -o wix311-binaries.zip -d wixbin || (
45- echo " failed to unzip WiX"
46- exit 1
47- )
48- fi
49-
5029# Build Yggdrasil!
51- [ " ${PKGARCH} " == " x64" ] && GOOS=windows GOARCH=amd64 CGO_ENABLED=0 ./build
52- [ " ${PKGARCH} " == " x86" ] && GOOS=windows GOARCH=386 CGO_ENABLED=0 ./build
30+ [ " ${PKGARCH} " == " x64" ] && GOOS=windows GOARCH=amd64 CGO_ENABLED=0 ./build -p -l " -aslr"
31+ [ " ${PKGARCH} " == " x86" ] && GOOS=windows GOARCH=386 CGO_ENABLED=0 ./build -p -l " -aslr"
32+ [ " ${PKGARCH} " == " arm" ] && GOOS=windows GOARCH=arm CGO_ENABLED=0 ./build -p -l " -aslr"
33+ # [ "${PKGARCH}" == "arm64" ] && GOOS=windows GOARCH=arm64 CGO_ENABLED=0 ./build
5334
5435# Create the postinstall script
5536cat > updateconfig.bat << EOF
@@ -58,7 +39,9 @@ if not exist %ALLUSERSPROFILE%\\Yggdrasil (
5839)
5940if not exist %ALLUSERSPROFILE%\\ Yggdrasil\\ yggdrasil.conf (
6041 if exist yggdrasil.exe (
61- yggdrasil.exe -genconf > %ALLUSERSPROFILE%\\ Yggdrasil\\ yggdrasil.conf
42+ if not exist %ALLUSERSPROFILE%\\ Yggdrasil\\ yggdrasil.conf (
43+ yggdrasil.exe -genconf > %ALLUSERSPROFILE%\\ Yggdrasil\\ yggdrasil.conf
44+ )
6245 )
6346)
6447EOF
@@ -72,12 +55,16 @@ PKGVERSIONMS=$(echo $PKGVERSION | tr - .)
7255 PKGGUID=" 54a3294e-a441-4322-aefb-3bb40dd022bb" PKGINSTFOLDER=" ProgramFilesFolder"
7356
7457# Download the Wintun driver
58+ curl -o wintun.zip https://www.wintun.net/builds/wintun-0.10.2.zip
59+ unzip wintun.zip
7560if [ $PKGARCH = " x64" ]; then
76- PKGMSMNAME=wintun-x64.msm
77- curl -o ${PKGMSMNAME} https://www.wintun.net/builds/wintun-amd64-0.7.msm || (echo " couldn't get wintun" ; exit 1)
61+ PKGWINTUNDLL=wintun/bin/amd64/wintun.dll
7862elif [ $PKGARCH = " x86" ]; then
79- PKGMSMNAME=wintun-x86.msm
80- curl -o ${PKGMSMNAME} https://www.wintun.net/builds/wintun-x86-0.7.msm || (echo " couldn't get wintun" ; exit 1)
63+ PKGWINTUNDLL=wintun/bin/x86/wintun.dll
64+ elif [ $PKGARCH = " arm" ]; then
65+ PKGWINTUNDLL=wintun/bin/arm/wintun.dll
66+ # elif [ $PKGARCH = "arm64" ]; then
67+ # PKGWINTUNDLL=wintun/bin/arm64/wintun.dll
8168else
8269 echo " wasn't sure which architecture to get wintun for"
8370 exit 1
@@ -100,6 +87,7 @@ cat > wix.xml << EOF
10087 Language="1033"
10188 Codepage="1252"
10289 Version="${PKGVERSIONMS} "
90+ Platform="${PKGARCH} "
10391 Manufacturer="github.com/yggdrasil-network">
10492
10593 <Package
@@ -136,6 +124,12 @@ cat > wix.xml << EOF
136124 Source="yggdrasil.exe"
137125 KeyPath="yes" />
138126
127+ <File
128+ Id="Wintun"
129+ Name="wintun.dll"
130+ DiskId="1"
131+ Source="${PKGWINTUNDLL} " />
132+
139133 <ServiceInstall
140134 Id="ServiceInstaller"
141135 Account="LocalSystem"
@@ -176,12 +170,6 @@ cat > wix.xml << EOF
176170 </Component>
177171 </Directory>
178172 </Directory>
179-
180- <Merge
181- Id="Wintun"
182- Language="0"
183- DiskId="1"
184- SourceFile="${PKGMSMNAME} " />
185173 </Directory>
186174
187175 <Feature Id="YggdrasilFeature" Title="Yggdrasil" Level="1">
@@ -190,13 +178,6 @@ cat > wix.xml << EOF
190178 <ComponentRef Id="ConfigScript" />
191179 </Feature>
192180
193- <Feature Id="WintunFeature" Title="Wintun" Level="1">
194- <Condition Level="0">
195- UPGRADINGPRODUCTCODE
196- </Condition>
197- <MergeRef Id="Wintun" />
198- </Feature>
199-
200181 <CustomAction
201182 Id="UpdateGenerateConfig"
202183 Directory="YggdrasilInstallFolder"
@@ -208,17 +189,12 @@ cat > wix.xml << EOF
208189 <InstallExecuteSequence>
209190 <Custom
210191 Action="UpdateGenerateConfig"
211- Before="StartServices">
212- NOT Installed AND NOT REMOVE
213- </Custom>
192+ Before="StartServices" />
214193 </InstallExecuteSequence>
215194
216195 </Product>
217196</Wix>
218197EOF
219198
220199# Generate the MSI
221- CANDLEFLAGS=" -nologo"
222- LIGHTFLAGS=" -nologo -spdb -sice:ICE71 -sice:ICE61"
223- wixbin/candle $CANDLEFLAGS -out ${PKGNAME} -${PKGVERSION} -${PKGARCH} .wixobj -arch ${PKGARCH} wix.xml && \
224- wixbin/light $LIGHTFLAGS -ext WixUtilExtension.dll -out ${PKGNAME} -${PKGVERSION} -${PKGARCH} .msi ${PKGNAME} -${PKGVERSION} -${PKGARCH} .wixobj
200+ wixl -v wix.xml -a ${PKGARCH} -o ${PKGNAME} -${PKGVERSION} -${PKGARCH} .msi
0 commit comments