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