-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathbuild.sh
executable file
·191 lines (157 loc) · 6.69 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/bin/bash
# shellcheck disable=SC2002
cd "$(dirname "$0")"
set -e
# Valheim configuration
appid=892970
depotid=892971
# Stable (public)
branch="public"
buildid=14349377
manifestid=6968333214162889388
version="0.218.15"
depotdownloaderversion="2.5.0"
depotdownloaderarch="arm64"
depotdownloaderhash="e46b90b6a838e055c21856931e21f096"
unityversion="2022.3.17f1"
unityhash="4fc78088f837"
variant="macos_x64_player_nondevelopment_mono"
steamworksversion="20.2.0"
steamworkshash="6c8e7f5101176ed13d32cf704a4febe6"
playfabpartyversion="1.8.0"
playfabpartyasset="PlayFabPartyMac.framework-for-macOS-Release.zip"
playfabpartyhash="93c4967e7dc74b281ca7614b96c941a9"
outdir="build"
# Intel (x86_64) support
if [ "$(arch)" = "i386" ]; then
depotdownloaderarch="x64"
depotdownloaderhash="c9862fc3a73960a60130551fa4141b82"
fi
# Beta (public-test)
if [[ " $* " =~ " --beta " ]]; then
branch="public-test"
buildid=14349377
unset manifestid
version="0.218.15"
unityversion="2022.3.17f1"
unityhash="4fc78088f837"
playfabpartyversion="1.8.0"
playfabpartyasset="PlayFabPartyMac.framework-for-macOS-Release.zip"
playfabpartyhash="93c4967e7dc74b281ca7614b96c941a9"
outdir="build-beta"
fi
confirm() {
read -r -p "${1:-Are you sure?} [y/N] " response
case "$response" in
[yY][eE][sS]|[yY])
true
;;
*)
false
;;
esac
}
verify() {
local hash
hash=$(md5 -q "$1")
if [ "$hash" != "$2" ]; then
echo "The file '$1' may be corrupted: md5 hash $hash != $2 (expected)"
if ! confirm "Do you still want to continue? (not recommended)"; then
exit 1
fi
fi
}
cd vendor
if [ ! -d "depots/$depotid/$buildid" ]; then
if confirm "Download Valheim $version (~1.5GB) from Steam?"; then
if [ ! -d "depotdownloader-$depotdownloaderversion-$depotdownloaderarch" ]; then
if confirm "Download (~80MB) and unzip DepotDownloader ($depotdownloaderarch) to download Valheim from Steam?"; then
curl -L https://github.com/SteamRE/DepotDownloader/releases/download/DepotDownloader_$depotdownloaderversion/depotdownloader-macos-$depotdownloaderarch.zip -o depotdownloader-$depotdownloaderversion-macos-$depotdownloaderarch.zip
verify depotdownloader-$depotdownloaderversion-macos-$depotdownloaderarch.zip $depotdownloaderhash
unzip depotdownloader-$depotdownloaderversion-macos-$depotdownloaderarch.zip -d depotdownloader-$depotdownloaderversion-$depotdownloaderarch
fi
if [ ! -d "depotdownloader-$depotdownloaderversion-$depotdownloaderarch" ]; then
echo "DepotDownloader not found, exiting.."
exit 1
fi
fi
xattr -c depotdownloader-$depotdownloaderversion-$depotdownloaderarch/DepotDownloader
chmod u+x depotdownloader-$depotdownloaderversion-$depotdownloaderarch/DepotDownloader
echo -n "Steam username: "
read -r username
./depotdownloader-$depotdownloaderversion-$depotdownloaderarch/DepotDownloader -app $appid -depot $depotid -manifest $manifestid -beta $branch -os linux -username "$username"
fi
if [ ! -d "depots/$depotid/$buildid/valheim_Data" ]; then
echo "Valheim data for build $buildid not found, exiting.."
echo "(the build script may need to be updated if a patch was recently released)"
exit 1
fi
fi
if [ ! -d "Unity-$unityversion" ]; then
if confirm "Download Unity v$unityversion data files (~3.5GB)?"; then
curl -L https://download.unity3d.com/download_unity/$unityhash/MacEditorInstaller/Unity.pkg -o Unity-$unityversion.pkg
echo "(unpacking Unity.pkg, this may take a while...)"
pkgutil --expand-full Unity-$unityversion.pkg Unity-$unityversion
fi
if [ ! -d "Unity-$unityversion" ]; then
echo "Unity package $unityversion not found, exiting.."
exit 1
fi
fi
if [ ! -d "Steamworks.NET-Standalone_$steamworksversion" ]; then
if confirm "Download Steamworks.NET v$steamworksversion (~2.5MB) from GitHub?"; then
curl -L https://github.com/rlabrecque/Steamworks.NET/releases/download/$steamworksversion/Steamworks.NET-Standalone_$steamworksversion.zip -o Steamworks.NET-Standalone_$steamworksversion.zip
verify Steamworks.NET-Standalone_$steamworksversion.zip $steamworkshash
unzip Steamworks.NET-Standalone_$steamworksversion.zip -d Steamworks.NET-Standalone_$steamworksversion
fi
if [ ! -d "Steamworks.NET-Standalone_$steamworksversion" ]; then
echo "Steamworks.NET not found, exiting.."
exit 1
fi
fi
if [ ! -d "PlayFabParty-for-macOS_v$playfabpartyversion" ]; then
if confirm "Download PlayFabParty v$playfabpartyversion (~100MB) from GitHub?"; then
curl -L "https://github.com/PlayFab/PlayFabParty/releases/download/v$playfabpartyversion/$playfabpartyasset" -o "PlayFabParty-for-macOS_v$playfabpartyversion.zip"
verify "PlayFabParty-for-macOS_v$playfabpartyversion.zip" $playfabpartyhash
unzip "PlayFabParty-for-macOS_v$playfabpartyversion.zip" -d "PlayFabParty-for-macOS_v$playfabpartyversion"
fi
if [ ! -d "PlayFabParty-for-macOS_v$playfabpartyversion" ]; then
echo "PlayFabParty not found, exiting.."
exit 1
fi
fi
cd ..
cd plugins
if [ ! -f "DiskSpacePlugin/build/DiskSpacePlugin.dylib" ]; then
echo "Building DiskSpacePlugin for macOS..."
cd DiskSpacePlugin
make build
cd ..
fi
cd ..
mkdir -p $outdir
rm -rf ${outdir:?}/*
cp -r skeleton/* $outdir/
prefix="$outdir/Valheim.app/Contents"
unityprefix="vendor/Unity-$unityversion/Unity.pkg.tmp/Payload/Unity/Unity.app/Contents/PlaybackEngines/MacStandaloneSupport"
cat skeleton/Valheim.app/Contents/Info.plist \
| sed "s|\$appid|$appid|g" \
| sed "s|\$unityhash|$unityhash|g" \
| sed "s|\$unityversion|$unityversion|g" \
| sed "s|\$unityyear|${unityversion:0:4}|g" \
| sed "s|\$version|$version|g" \
> $prefix/Info.plist
cp $unityprefix/Variations/$variant/UnityPlayer.app/Contents/Frameworks/* $prefix/Frameworks/
cp $unityprefix/Variations/$variant/UnityPlayer.app/Contents/MacOS/UnityPlayer $prefix/MacOS/Valheim
cp -r $unityprefix/Source/Player/MacPlayer/MacPlayerEntryPoint/Resources/MainMenu.nib $prefix/Resources/
cp -r $unityprefix/MonoBleedingEdge $prefix/MonoBleedingEdge
cp -r vendor/depots/$depotid/$buildid/valheim_Data $prefix/Resources/Data
cp -r $prefix/Resources/Data/Resources/* $prefix/Resources/
rm $prefix/Resources/UnityPlayer.png
cp plugins/DiskSpacePlugin/build/DiskSpacePlugin.dylib $prefix/PlugIns/
cp vendor/depots/$depotid/$buildid/valheim_Data/Plugins/Steamworks.NET.txt $prefix/PlugIns/
cp -r vendor/Steamworks.NET-Standalone_$steamworksversion/OSX-Linux-x64/steam_api.bundle $prefix/Plugins/
cp -r "vendor/PlayFabParty-for-macOS_v$playfabpartyversion/PlayFabPartyMacOS.bundle" $prefix/Plugins/party.bundle
rm -rf $prefix/Resources/Data/Plugins
rm -rf $prefix/Resources/Data/MonoBleedingEdge
echo "Building Valheim $version complete: $outdir/Valheim.app"