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