-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-rhino
executable file
·174 lines (151 loc) · 6.7 KB
/
install-rhino
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
#!/usr/bin/env bash
set -eu
SCRIPT_DIR="$(cd -- "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
MAJOR_VERSION=7
WINE_RENDERER=no3d
REQUIREMENTS_ONLY=false
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help)
echo "Usage: $0"
echo " -h, --help Show this help message"
echo " --renderer <renderer> Set the renderer to use (no3d, gl, vulkan)"
echo " --requirements-only Only install the requirements, do not install Rhino"
echo " -v, --version <version> Set the major version of Rhino to install (6, 7, 8, wip)"
exit 0
;;
--renderer)
export WINE_RENDERER="$2"
shift
;;
--requirements-only)
REQUIREMENTS_ONLY=true
;;
-v|--version)
MAJOR_VERSION="$2"
shift
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
shift
done
export WINE="${WINE:-wine}"
export WINEARCH="${WINEARCH:-win64}"
export WINEPREFIX="${WINEPREFIX:-$SCRIPT_DIR/wineprefix}"
export BUILD_DIR="$SCRIPT_DIR/build"
export TOOLS_CACHE="$BUILD_DIR/tools"
export LOGS_DIR="$BUILD_DIR/logs"
mkdir -p "$BUILD_DIR" "$TOOLS_CACHE" "$LOGS_DIR"
run() {
local log_name="$1" log_path
shift
log_path="$LOGS_DIR/$log_name.log"
echo "Running: $*"
echo "Running: $*" >"$log_path"
"$@" >>"$log_path" 2>&1
}
RHINO_INSTALLER_URL="$(curl -s -D - "https://www.rhino3d.com/www-api/download/direct/?slug=rhino-for-windows/$MAJOR_VERSION/latest/" -o /dev/null | grep '^Location' | cut -d' ' -f2 | sed -e 's~[\r\n]~~g')"
if [[ -z "$RHINO_INSTALLER_URL" ]]; then
echo "Failed to get Rhino installer URL"
exit 1
fi
RHINO_INSTALLER="$(basename "$RHINO_INSTALLER_URL")"
if [[ ! -e "$TOOLS_CACHE/winetricks" ]]; then
mkdir -p "$TOOLS_CACHE"
wget -q -O "$TOOLS_CACHE/winetricks" "https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks"
chmod +x "$TOOLS_CACHE/winetricks"
fi
if [[ ! -e "$TOOLS_CACHE/$RHINO_INSTALLER" ]]; then
mkdir -p "$TOOLS_CACHE"
wget -q -O "$TOOLS_CACHE/$RHINO_INSTALLER" "$RHINO_INSTALLER_URL"
fi
if [[ ! -f ~/.cache/wine/wine-gecko-2.47.4-x86_64.msi ]]; then
mkdir -p ~/.cache/wine
# TODO: install debug symbols
wget -q -O ~/.cache/wine/wine-gecko-2.47.4-x86_64.msi.tmp https://dl.winehq.org/wine/wine-gecko/2.47.4/wine-gecko-2.47.4-x86_64.msi
mv ~/.cache/wine/wine-gecko-2.47.4-x86_64.msi.tmp ~/.cache/wine/wine-gecko-2.47.4-x86_64.msi
fi
if [[ ! -f ~/.cache/wine/wine-mono-9.3.0-x86.msi ]]; then
mkdir -p ~/.cache/wine
wget -q -O ~/.cache/wine/wine-mono-9.3.0-x86.msi.tmp https://dl.winehq.org/wine/wine-mono/9.3.0/wine-mono-9.3.0-x86.msi
mv ~/.cache/wine/wine-mono-9.3.0-x86.msi.tmp ~/.cache/wine/wine-mono-9.3.0-x86.msi
fi
mkdir -p "$WINEPREFIX"
run wineboot-init "$WINE" wineboot --init
run winetricks-win11 "$TOOLS_CACHE/winetricks" -q win11
run winetricks-corefonts "$TOOLS_CACHE/winetricks" -q corefonts
# (optional) Font for Grasshopper:
run winetricks-consolas "$TOOLS_CACHE/winetricks" -q consolas
# TODO: Font Segoe Print on Grasshopper:
# https://learn.microsoft.com/es-es/typography/font-list/segoe-print
# NOTE: Rhino 7 requires renderer=no3d or renderer=vulkan
run winetricks-renderer "$TOOLS_CACHE/winetricks" -q renderer="$WINE_RENDERER"
run winetricks-vcrun "$TOOLS_CACHE/winetricks" -q vcrun2005 vcrun2010 vcrun2013
if [[ "$MAJOR_VERSION" = 8 || "$MAJOR_VERSION" = wip ]]; then
run winetricks-vcrun2022 "$TOOLS_CACHE/winetricks" -q vcrun2022
else
run winetricks-vcrun2015 "$TOOLS_CACHE/winetricks" -q vcrun2015
fi
# NOTE: Rhino 7 and 8 require dotnet48,
# FIXME: Installing dotnet48 with winetricks sometimes hangs with RtlpWaitForCriticalSection on ntdll
if [[ ! -f "$TOOLS_CACHE/ndp48-x86-x64-allos-enu.exe" ]]; then
wget -O "$TOOLS_CACHE/ndp48-x86-x64-allos-enu.exe.tmp" https://download.visualstudio.microsoft.com/download/pr/7afca223-55d2-470a-8edc-6a1739ae3252/abd170b4b0ec15ad0222a809b761a036/ndp48-x86-x64-allos-enu.exe
mv "$TOOLS_CACHE/ndp48-x86-x64-allos-enu.exe.tmp" "$TOOLS_CACHE/ndp48-x86-x64-allos-enu.exe"
fi
run dotnet48 "$WINE" "$TOOLS_CACHE/ndp48-x86-x64-allos-enu.exe" /q /norestart
run winetricks-win11 "$TOOLS_CACHE/winetricks" -q win11
if [[ $MAJOR_VERSION = 8 || $MAJOR_VERSION = wip ]]; then
run winetricks-dotnetdesktop7 "$TOOLS_CACHE/winetricks" -q dotnetdesktop7
fi
if [[ $REQUIREMENTS_ONLY = false ]]; then
RHINO_INSTALLER_DIR="$SCRIPT_DIR/build/rhino-installer/${RHINO_INSTALLER%%.exe}"
run cabextract cabextract -d "$RHINO_INSTALLER_DIR" "$TOOLS_CACHE/$RHINO_INSTALLER"
cat "$RHINO_INSTALLER_DIR/0" | grep -o '<Payload Id[^>]*Packaging="embedded"[^>]*>' | while read -r line ; do
src_path="$(echo "$line" | grep -o 'SourcePath="[^"]*"' | cut -d'"' -f2)"
dst_path="$(echo "$line" | grep -o 'FilePath="[^"]*"' | cut -d'"' -f2)"
dst_path="${dst_path//\\//}"
dst_dir="$(dirname "$dst_path")"
mkdir -p "$RHINO_INSTALLER_DIR/$dst_dir"
mv "$RHINO_INSTALLER_DIR/$src_path" "$RHINO_INSTALLER_DIR/$dst_path"
done
echo "Patching Rhino installer for https://bugs.winehq.org/show_bug.cgi?id=56703"
cd "$RHINO_INSTALLER_DIR"
msiinfo export rhino.msi InstallExecuteSequence > InstallExecuteSequence.idt
sed \
-e 's~^InstallCertificates\t.*\t\([0-9]*\)~InstallCertificates\tSKIP_INSTALL_CERTIFICATES="0"\t\1~g' \
-e 's~^UninstallCertificates\t.*\t\([0-9]*\)~UninstallCertificates\tSKIP_UNINSTALL_CERTIFICATES="0"\t\1~g' \
-i InstallExecuteSequence.idt
msibuild rhino.msi -i InstallExecuteSequence.idt
cd -
run msiexec-rhino.msi "$WINE" msiexec /i "$RHINO_INSTALLER_DIR/rhino.msi" \
/quiet \
ARPSYSTEMCOMPONENT=1 \
MSIFASTINSTALL=7 \
DEFER_NET48_REBOOT=1 \
ENABLE_AUTOMATIC_UPDATES=0 \
SEND_STATISTICS=0 \
'/L*V' \
'C:\rhino.msi.log'
if [[ -e $WINEPREFIX/drive_c/rhino.msi.log ]]; then
mv $WINEPREFIX/drive_c/rhino.msi.log $LOGS_DIR/rhino.msi.log
fi
# run rhiexec.msi "$WINE" msiexec /i "$RHINO_INSTALLER_DIR/rhinoexec.msi" \
# /quiet \
# ARPSYSTEMCOMPONENT=1 \
# MSIFASTINSTALL=7 \
# '/L*V' \
# 'C:\rhiexec.msi.log'
# XXX: Disable McNeel Update Service
run reg-updater "$WINE" reg add 'HKLM\System\CurrentControlSet\Services\McNeelUpdate' /v Start /t reg_dword /d 3 /f
# XXX: Turn off Windows theme to avoid black tooltips
run reg-theme "$WINE" reg add 'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ThemeManager' /v ThemeActive /t REG_SZ /d 0 /f
# XXX: Adjust DPI to avoid tiny text
run reg-dpi-1 "$WINE" reg add 'HKEY_CURRENT_USER\Control Panel\Desktop' /v LogPixels /t REG_DWORD /d 192 /f
run reg-dpi-2 "$WINE" reg add 'HKEY_CURRENT_USER\Software\Wine\Fonts' /v LogPixels /t REG_DWORD /d 192 /f
fi
# XXX: wineserver -k can exit with code != 0, ignore it.
run wineserver-kill "$WINE" wineserver --kill=9 || true