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