1 | @echo off
|
---|
2 | rem $Id: Combined-3-Repack.cmd 82274 2019-11-28 19:20:19Z vboxsync $
|
---|
3 | rem rem @file
|
---|
4 | rem Windows NT batch script for repacking signed amd64 and x86 drivers.
|
---|
5 | rem
|
---|
6 |
|
---|
7 | rem
|
---|
8 | rem Copyright (C) 2018-2019 Oracle Corporation
|
---|
9 | rem All rights reserved
|
---|
10 | rem
|
---|
11 |
|
---|
12 |
|
---|
13 | setlocal ENABLEEXTENSIONS
|
---|
14 | setlocal
|
---|
15 |
|
---|
16 | rem
|
---|
17 | rem Globals and checks for required enviornment variables.
|
---|
18 | rem
|
---|
19 | if ".%KBUILD_DEVTOOLS%" == "." (echo KBUILD_DEVTOOLS is not set & goto end_failed)
|
---|
20 | if ".%KBUILD_BIN_PATH%" == "." (echo KBUILD_BIN_PATH is not set & goto end_failed)
|
---|
21 | set _MY_SCRIPT_DIR=%~dp0
|
---|
22 | set _MY_SAVED_CD=%CD%
|
---|
23 | set _MY_VER_REV=@VBOX_VERSION_STRING@r@VBOX_SVN_REV@
|
---|
24 |
|
---|
25 | rem
|
---|
26 | rem Parse arguments.
|
---|
27 | rem
|
---|
28 | set _MY_OPT_UNTAR_DIR=%_MY_SCRIPT_DIR%\..\..\..\
|
---|
29 | for %%i in (%_MY_OPT_UNTAR_DIR%) do set _MY_OPT_UNTAR_DIR=%%~fi
|
---|
30 | set _MY_OPT_EXTPACK=%_MY_OPT_UNTAR_DIR%\Oracle_VM_VirtualBox_Extension_Pack-%_MY_VER_REV%.vbox-extpack
|
---|
31 | set _MY_OPT_EXTPACK_ENTERPRISE=%_MY_OPT_UNTAR_DIR%\Oracle_VM_VirtualBox_Extension_Pack-%_MY_VER_REV%-ENTERPRISE.vbox-extpack
|
---|
32 | set _MY_OPT_BUILD_TYPE=@KBUILD_TYPE@
|
---|
33 | set _MY_OPT_OUTDIR=%_MY_OPT_UNTAR_DIR%\output
|
---|
34 | set _MY_OPT_SIGNED_AMD64=
|
---|
35 | set _MY_OPT_SIGNED_X86=
|
---|
36 |
|
---|
37 | :argument_loop
|
---|
38 | if ".%1" == "." goto no_more_arguments
|
---|
39 |
|
---|
40 | if ".%1" == ".-h" goto opt_h
|
---|
41 | if ".%1" == ".-?" goto opt_h
|
---|
42 | if ".%1" == "./h" goto opt_h
|
---|
43 | if ".%1" == "./H" goto opt_h
|
---|
44 | if ".%1" == "./?" goto opt_h
|
---|
45 | if ".%1" == ".-help" goto opt_h
|
---|
46 | if ".%1" == ".--help" goto opt_h
|
---|
47 |
|
---|
48 | if ".%1" == ".-e" goto opt_e
|
---|
49 | if ".%1" == ".--extpack" goto opt_e
|
---|
50 | if ".%1" == ".-o" goto opt_o
|
---|
51 | if ".%1" == ".--outdir" goto opt_o
|
---|
52 | if ".%1" == ".-s" goto opt_s
|
---|
53 | if ".%1" == ".--extpack-enterprise" goto opt_s
|
---|
54 | if ".%1" == ".--signed-amd64" goto opt_signed_amd64
|
---|
55 | if ".%1" == ".--signed-x86" goto opt_signed_x86
|
---|
56 | if ".%1" == ".-t" goto opt_t
|
---|
57 | if ".%1" == ".--build-type" goto opt_t
|
---|
58 | if ".%1" == ".-u" goto opt_u
|
---|
59 | if ".%1" == ".--vboxall-untar-dir" goto opt_u
|
---|
60 | echo syntax error: Unknown option: %1
|
---|
61 | echo Try --help to list valid options.
|
---|
62 | goto end_failed
|
---|
63 |
|
---|
64 | :argument_loop_next_with_value
|
---|
65 | shift
|
---|
66 | shift
|
---|
67 | goto argument_loop
|
---|
68 |
|
---|
69 | :opt_e
|
---|
70 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
71 | set _MY_OPT_EXTPACK=%~f2
|
---|
72 | goto argument_loop_next_with_value
|
---|
73 |
|
---|
74 | :opt_h
|
---|
75 | echo Toplevel combined package: Repack the installer and extpacks.
|
---|
76 | echo .
|
---|
77 | echo Usage: Combined-3-Repack.cmd [-o output-dir] [-e/--extpack puel.vbox-extpack]
|
---|
78 | echo [-s/--extpack-enterprise puel-enterprise.vbox-extpack]
|
---|
79 | echo [-u/--vboxall-dir unpacked-vboxall-dir] [-t build-type]
|
---|
80 | echo [--signed-amd64 signed-amd64.zip]
|
---|
81 | echo [--signed-x86 signed-x86.zip]
|
---|
82 | echo
|
---|
83 | echo .
|
---|
84 | echo Default -e/--extpack value: %_MY_OPT_EXTPACK%
|
---|
85 | echo Default -s/--extpack-enterprise value: %_MY_OPT_EXTPACK_ENTERPRISE%
|
---|
86 | echo Default -u/--vboxall-untar-dir value: %_MY_OPT_UNTAR_DIR%
|
---|
87 | echo Default -o/--outdir value: %_MY_OPT_OUTDIR%
|
---|
88 | echo Default -t/--build-type value: %_MY_OPT_BUILD_TYPE%
|
---|
89 | echo .
|
---|
90 | goto end_failed
|
---|
91 |
|
---|
92 | :opt_o
|
---|
93 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
94 | set _MY_OPT_OUTDIR=%~f2
|
---|
95 | goto argument_loop_next_with_value
|
---|
96 |
|
---|
97 | :opt_s
|
---|
98 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
99 | set _MY_OPT_EXTPACK_ENTERPRISE=%~f2
|
---|
100 | goto argument_loop_next_with_value
|
---|
101 |
|
---|
102 | :opt_signed_amd64
|
---|
103 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
104 | set _MY_OPT_SIGNED_AMD64=%~f2
|
---|
105 | goto argument_loop_next_with_value
|
---|
106 |
|
---|
107 | :opt_signed_x86
|
---|
108 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
109 | set _MY_OPT_SIGNED_X86=%~f2
|
---|
110 | goto argument_loop_next_with_value
|
---|
111 |
|
---|
112 | :opt_t
|
---|
113 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
114 | set _MY_OPT_BUILD_TYPE=%~2
|
---|
115 | goto argument_loop_next_with_value
|
---|
116 |
|
---|
117 | :opt_u
|
---|
118 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
119 | set _MY_OPT_UNTAR_DIR=%~f2
|
---|
120 | goto argument_loop_next_with_value
|
---|
121 |
|
---|
122 |
|
---|
123 | :syntax_error_missing_value
|
---|
124 | echo syntax error: missing or empty option value after %1
|
---|
125 | goto end_failed
|
---|
126 |
|
---|
127 |
|
---|
128 | :error_vboxall_untar_dir_not_found
|
---|
129 | echo syntax error: The VBoxAll untar directory was not found: "%_MY_OPT_UNTAR_DIR%"
|
---|
130 | goto end_failed
|
---|
131 |
|
---|
132 | :error_amd64_bindir_not_found
|
---|
133 | echo syntax error: The AMD64 bin directory was not found: "%_MY_BINDIR_AMD64%"
|
---|
134 | goto end_failed
|
---|
135 |
|
---|
136 | :error_x86_bindir_not_found
|
---|
137 | echo syntax error: The X86 bin directory was not found: "%_MY_BINDIR_X86%"
|
---|
138 | goto end_failed
|
---|
139 |
|
---|
140 | :error_amd64_repack_dir_not_found
|
---|
141 | echo syntax error: The AMD64 repack directory was not found: "%_MY_REPACK_DIR_AMD64%"
|
---|
142 | goto end_failed
|
---|
143 |
|
---|
144 | :error_x86_repack_dir_not_found
|
---|
145 | echo syntax error: The X86 repack directory was not found: "%_MY_REPACK_DIR_X86%"
|
---|
146 | goto end_failed
|
---|
147 |
|
---|
148 | :error_extpack_not_found
|
---|
149 | echo syntax error: Specified extension pack not found: "%_MY_OPT_EXTPACK%"
|
---|
150 | goto end_failed
|
---|
151 |
|
---|
152 | :error_enterprise_extpack_not_found
|
---|
153 | echo syntax error: Specified enterprise extension pack not found: "%_MY_OPT_EXTPACK_ENTERPRISE%"
|
---|
154 | goto end_failed
|
---|
155 |
|
---|
156 | :error_signed_amd64_not_found
|
---|
157 | echo syntax error: Zip with signed AMD64 drivers not found: "%_MY_OPT_SIGNED_AMD64%"
|
---|
158 | goto end_failed
|
---|
159 |
|
---|
160 | :error_signed_x86_not_found
|
---|
161 | echo syntax error: Zip with signed X86 drivers not found: "%_MY_OPT_SIGNED_X86%"
|
---|
162 | goto end_failed
|
---|
163 |
|
---|
164 |
|
---|
165 | :no_more_arguments
|
---|
166 | rem
|
---|
167 | rem Validate and adjust specified options.
|
---|
168 | rem
|
---|
169 |
|
---|
170 | if not exist "%_MY_OPT_UNTAR_DIR%" goto error_vboxall_untar_dir_not_found
|
---|
171 |
|
---|
172 | set _MY_BINDIR_AMD64=%_MY_OPT_UNTAR_DIR%\win.amd64\%_MY_OPT_BUILD_TYPE%\bin
|
---|
173 | set _MY_BINDIR_X86=%_MY_OPT_UNTAR_DIR%\win.x86\%_MY_OPT_BUILD_TYPE%\bin
|
---|
174 | if not exist "%_MY_BINDIR_AMD64%" goto error_amd64_bindir_not_found
|
---|
175 | if not exist "%_MY_BINDIR_X86%" goto error_x86_bindir_not_found
|
---|
176 |
|
---|
177 | set _MY_REPACK_DIR_AMD64=%_MY_OPT_UNTAR_DIR%\win.amd64\%_MY_OPT_BUILD_TYPE%\repack
|
---|
178 | set _MY_REPACK_DIR_X86=%_MY_OPT_UNTAR_DIR%\win.x86\%_MY_OPT_BUILD_TYPE%\repack
|
---|
179 | if not exist "%_MY_REPACK_DIR_AMD64%" goto error_amd64_repack_dir_not_found
|
---|
180 | if not exist "%_MY_REPACK_DIR_X86%" goto error_x86_repack_dir_not_found
|
---|
181 |
|
---|
182 | if not exist "%_MY_OPT_EXTPACK%" goto error_extpack_not_found
|
---|
183 | if not ".%_MY_OPT_EXTPACK_ENTERPRISE%" == "." if not exist "%_MY_OPT_EXTPACK_ENTERPRISE%" goto error_enterprise_extpack_not_found
|
---|
184 |
|
---|
185 | if not exist "%_MY_OPT_SIGNED_AMD64%" goto error_signed_amd64_not_found
|
---|
186 | if not exist "%_MY_OPT_SIGNED_X86%" goto error_signed_x86_not_found
|
---|
187 |
|
---|
188 | rem Make sure the output dir exists.
|
---|
189 | if not exist "%_MY_OPT_OUTDIR%" (mkdir "%_MY_OPT_OUTDIR%" || goto end_failed)
|
---|
190 |
|
---|
191 | rem
|
---|
192 | rem Unpacking the two driver zips.
|
---|
193 | rem
|
---|
194 | echo **************************************************************************
|
---|
195 | echo * AMD64: Unpacking signed drivers...
|
---|
196 | echo **************************************************************************
|
---|
197 | cd /d "%_MY_REPACK_DIR_AMD64%" || goto end_failed
|
---|
198 | call "%_MY_REPACK_DIR_AMD64%\UnpackBlessedDrivers.cmd" -b "%_MY_BINDIR_AMD64%" -i "%_MY_OPT_SIGNED_AMD64%" || goto end_failed
|
---|
199 | echo .
|
---|
200 |
|
---|
201 | echo **************************************************************************
|
---|
202 | echo * X86: Unpacking signed drivers...
|
---|
203 | echo **************************************************************************
|
---|
204 | cd /d "%_MY_REPACK_DIR_X86%" || goto end_failed
|
---|
205 | call "%_MY_REPACK_DIR_X86%\UnpackBlessedDrivers.cmd" -b "%_MY_BINDIR_X86%" -i "%_MY_OPT_SIGNED_X86%" || goto end_failed
|
---|
206 | echo .
|
---|
207 |
|
---|
208 |
|
---|
209 | rem
|
---|
210 | rem Do the AMD64 work.
|
---|
211 | rem
|
---|
212 | echo **************************************************************************
|
---|
213 | echo * AMD64: Repackaging installers
|
---|
214 | echo **************************************************************************
|
---|
215 | echo * AMD64: Compiling WIX...
|
---|
216 | cd /d "%_MY_REPACK_DIR_AMD64%" || goto end_failed
|
---|
217 | for %%i in (1-*.cmd) do (call %%i || goto end_failed)
|
---|
218 | echo .
|
---|
219 |
|
---|
220 | echo * AMD64: Linking WIX...
|
---|
221 | for %%i in (2-*.cmd) do (call %%i || goto end_failed)
|
---|
222 | echo .
|
---|
223 |
|
---|
224 | echo * AMD64: Applying language patches to MSI...
|
---|
225 | for %%i in (3-*.cmd) do (call %%i || goto end_failed)
|
---|
226 | echo .
|
---|
227 |
|
---|
228 |
|
---|
229 | rem
|
---|
230 | rem Do the X86 work.
|
---|
231 | rem
|
---|
232 | echo **************************************************************************
|
---|
233 | echo * X86: Repackaging installers
|
---|
234 | echo **************************************************************************
|
---|
235 | echo * X86: Compiling WIX...
|
---|
236 | cd /d "%_MY_REPACK_DIR_X86%" || goto end_failed
|
---|
237 | for %%i in (1-*.cmd) do (call %%i || goto end_failed)
|
---|
238 | echo .
|
---|
239 |
|
---|
240 | echo * X86: Linking WIX...
|
---|
241 | for %%i in (2-*.cmd) do (call %%i || goto end_failed)
|
---|
242 | echo .
|
---|
243 |
|
---|
244 | echo * X86: Applying language patches to MSI...
|
---|
245 | for %%i in (3-*.cmd) do (call %%i || goto end_failed)
|
---|
246 | echo .
|
---|
247 |
|
---|
248 | echo * X86: Creating multi arch installer...
|
---|
249 | for %%i in (4-*.cmd) do (call %%i || goto end_failed)
|
---|
250 | echo .
|
---|
251 |
|
---|
252 | set _MY_OUT_FILES=
|
---|
253 | cd /d "%_MY_REPACK_DIR_AMD64%" || goto end_failed
|
---|
254 | for %%i in (VBoxMerge*msm) do (
|
---|
255 | copy /y "%%i" "%_MY_OPT_OUTDIR%" || goto end_failed
|
---|
256 | call set _MY_OUT_FILES=%%_MY_OUT_FILES%% %%~nxi
|
---|
257 | )
|
---|
258 | cd /d "%_MY_REPACK_DIR_X86%" || goto end_failed
|
---|
259 | for %%i in (VBoxMerge*msm) do (
|
---|
260 | copy /y "%%i" "%_MY_OPT_OUTDIR%" || goto end_failed
|
---|
261 | call set _MY_OUT_FILES=%%_MY_OUT_FILES%% %%~nxi
|
---|
262 | )
|
---|
263 | for %%i in (VirtualBox-*MultiArch*exe) do (
|
---|
264 | copy /y "%%i" "%_MY_OPT_OUTDIR%" || goto end_failed
|
---|
265 | call set _MY_OUT_FILES=%%_MY_OUT_FILES%% %%~nxi
|
---|
266 | )
|
---|
267 |
|
---|
268 |
|
---|
269 | rem
|
---|
270 | rem Repack the extension packs.
|
---|
271 | rem
|
---|
272 | echo **************************************************************************
|
---|
273 | echo * Repacking extension packs.
|
---|
274 | echo **************************************************************************
|
---|
275 | cd /d "%_MY_REPACK_DIR_X86%" || goto end_failed
|
---|
276 |
|
---|
277 | echo * Regular PUEL...
|
---|
278 | set _MY_TMP_OUT=%_MY_OPT_EXTPACK%
|
---|
279 | for %%i in (%_MY_TMP_OUT%) do (
|
---|
280 | set _MY_TMP_OUT=%_MY_OPT_OUTDIR%\%%~nxi
|
---|
281 | call set _MY_OUT_FILES=%%_MY_OUT_FILES%% %%~nxi
|
---|
282 | )
|
---|
283 | call "%_MY_REPACK_DIR_X86%\RepackExtPack.cmd" --bindir-amd64 "%_MY_BINDIR_AMD64%" --bindir-x86 "%_MY_BINDIR_X86%" ^
|
---|
284 | --input "%_MY_OPT_EXTPACK%" --output "%_MY_TMP_OUT%" || goto end_failed
|
---|
285 |
|
---|
286 | if ".%_MY_OPT_EXTPACK_ENTERPRISE%" == "." goto no_enterprise_repacking
|
---|
287 | echo * Enterprise PUEL...
|
---|
288 | set _MY_TMP_OUT=%_MY_OPT_EXTPACK_ENTERPRISE%
|
---|
289 | for %%i in (%_MY_TMP_OUT%) do (
|
---|
290 | set _MY_TMP_OUT=%_MY_OPT_OUTDIR%\%%~nxi
|
---|
291 | call set _MY_OUT_FILES=%%_MY_OUT_FILES%% %%~nxi
|
---|
292 | )
|
---|
293 | call "%_MY_REPACK_DIR_X86%\RepackExtPack.cmd" --bindir-amd64 "%_MY_BINDIR_AMD64%" --bindir-x86 "%_MY_BINDIR_X86%" ^
|
---|
294 | --input "%_MY_OPT_EXTPACK_ENTERPRISE%" --output "%_MY_TMP_OUT%" || goto end_failed
|
---|
295 | :no_enterprise_repacking
|
---|
296 | @cd /d "%_MY_SAVED_CD%"
|
---|
297 |
|
---|
298 | rem
|
---|
299 | rem That's that.
|
---|
300 | rem
|
---|
301 | echo **************************************************************************
|
---|
302 | echo * The third and final step is done.
|
---|
303 | echo *
|
---|
304 | echo * Successfully created:
|
---|
305 | for %%i in (%_MY_OUT_FILES%) do echo * "%_MY_OPT_OUTDIR%\%%i"
|
---|
306 | goto end
|
---|
307 |
|
---|
308 |
|
---|
309 | :end_failed
|
---|
310 | @cd /d "%_MY_SAVED_CD%"
|
---|
311 | @endlocal
|
---|
312 | @endlocal
|
---|
313 | @echo * Failed!
|
---|
314 | @exit /b 1
|
---|
315 |
|
---|
316 | :end
|
---|
317 | @cd /d "%_MY_SAVED_CD%"
|
---|
318 | @endlocal
|
---|
319 | @endlocal
|
---|
320 |
|
---|
321 |
|
---|