1 | @echo off
|
---|
2 | rem $Id: Combined-3-Repack.cmd 72050 2018-04-27 08:39:57Z 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 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: Prepare both x86 and amd64 for submission.
|
---|
83 | echo .
|
---|
84 | echo Usage: Combined-1-Prepare.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
|
---|
88 | echo .
|
---|
89 | echo Default -e/--extpack value: %_MY_OPT_EXTPACK%
|
---|
90 | echo Default -s/--extpack-enterprise value: %_MY_OPT_EXTPACK_ENTERPRISE%
|
---|
91 | echo Default -u/--vboxall-untar-dir value: %_MY_OPT_UNTAR_DIR%
|
---|
92 | echo Default -o/--outdir value: %_MY_OPT_OUTDIR%
|
---|
93 | echo Default -t/--build-type value: %_MY_OPT_BUILD_TYPE%
|
---|
94 | echo .
|
---|
95 | goto end_failed
|
---|
96 |
|
---|
97 | :opt_o
|
---|
98 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
99 | set _MY_OPT_OUTDIR=%~f2
|
---|
100 | goto argument_loop_next_with_value
|
---|
101 |
|
---|
102 | :opt_s
|
---|
103 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
104 | set _MY_OPT_EXTPACK_ENTERPRISE=%~f2
|
---|
105 | goto argument_loop_next_with_value
|
---|
106 |
|
---|
107 | :opt_signed_amd64
|
---|
108 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
109 | set _MY_OPT_SIGNED_AMD64=%~f2
|
---|
110 | goto argument_loop_next_with_value
|
---|
111 |
|
---|
112 | :opt_signed_x86
|
---|
113 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
114 | set _MY_OPT_SIGNED_X86=%~f2
|
---|
115 | goto argument_loop_next_with_value
|
---|
116 |
|
---|
117 | :opt_t
|
---|
118 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
119 | set _MY_OPT_BUILD_TYPE=%~2
|
---|
120 | goto argument_loop_next_with_value
|
---|
121 |
|
---|
122 | :opt_u
|
---|
123 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
124 | set _MY_OPT_UNTAR_DIR=%~f2
|
---|
125 | goto argument_loop_next_with_value
|
---|
126 |
|
---|
127 |
|
---|
128 | :syntax_error_missing_value
|
---|
129 | echo syntax error: missing or empty option value after %1
|
---|
130 | goto end_failed
|
---|
131 |
|
---|
132 |
|
---|
133 | :error_vboxall_untar_dir_not_found
|
---|
134 | echo syntax error: The VBoxAll untar directory was not found: "%_MY_OPT_UNTAR_DIR%"
|
---|
135 | goto end_failed
|
---|
136 |
|
---|
137 | :error_amd64_bindir_not_found
|
---|
138 | echo syntax error: The AMD64 bin directory was not found: "%_MY_BINDIR_AMD64%"
|
---|
139 | goto end_failed
|
---|
140 |
|
---|
141 | :error_x86_bindir_not_found
|
---|
142 | echo syntax error: The AMD64 bin directory was not found: "%_MY_BINDIR_X86%"
|
---|
143 | goto end_failed
|
---|
144 |
|
---|
145 | :error_amd64_repack_dir_not_found
|
---|
146 | echo syntax error: The AMD64 bin directory was not found: "%_MY_REPACK_DIR_AMD64%"
|
---|
147 | goto end_failed
|
---|
148 |
|
---|
149 | :error_x86_repack_dir_not_found
|
---|
150 | echo syntax error: The AMD64 bin directory was not found: "%_MY_REPACK_DIR_X86%"
|
---|
151 | goto end_failed
|
---|
152 |
|
---|
153 | :error_extpack_not_found
|
---|
154 | echo syntax error: Specified extension pack not found: "%_MY_OPT_EXTPACK%"
|
---|
155 | goto end_failed
|
---|
156 |
|
---|
157 | :error_enterprise_extpack_not_found
|
---|
158 | echo syntax error: Specified enterprise extension pack not found: "%_MY_OPT_EXTPACK_ENTERPRISE%"
|
---|
159 | goto end_failed
|
---|
160 |
|
---|
161 | :error_signed_amd64_not_found
|
---|
162 | echo syntax error: Zip with signed AMD64 drivers not found: "%_MY_OPT_SIGNED_AMD64%"
|
---|
163 | goto end_failed
|
---|
164 |
|
---|
165 | :error_signed_x86_not_found
|
---|
166 | echo syntax error: Zip with signed X86 drivers not found: "%_MY_OPT_SIGNED_X86%"
|
---|
167 | goto end_failed
|
---|
168 |
|
---|
169 |
|
---|
170 | :no_more_arguments
|
---|
171 | rem
|
---|
172 | rem Validate and adjust specified options.
|
---|
173 | rem
|
---|
174 |
|
---|
175 | if not exist "%_MY_OPT_UNTAR_DIR%" goto error_vboxall_untar_dir_not_found
|
---|
176 |
|
---|
177 | set _MY_BINDIR_AMD64=%_MY_OPT_UNTAR_DIR%\win.amd64\%_MY_OPT_BUILD_TYPE%\bin
|
---|
178 | set _MY_BINDIR_X86=%_MY_OPT_UNTAR_DIR%\win.amd64\%_MY_OPT_BUILD_TYPE%\bin
|
---|
179 | if not exist "%_MY_BINDIR_AMD64%" goto error_amd64_bindir_not_found
|
---|
180 | if not exist "%_MY_BINDIR_X86%" goto error_x86_bindir_not_found
|
---|
181 |
|
---|
182 | set _MY_REPACK_DIR_AMD64=%_MY_OPT_UNTAR_DIR%\win.amd64\%_MY_OPT_BUILD_TYPE%\repack
|
---|
183 | set _MY_REPACK_DIR_X86=%_MY_OPT_UNTAR_DIR%\win.x86\%_MY_OPT_BUILD_TYPE%\repack
|
---|
184 | if not exist "%_MY_REPACK_DIR_AMD64%" goto error_amd64_repack_dir_not_found
|
---|
185 | if not exist "%_MY_REPACK_DIR_X86%" goto error_x86_repack_dir_not_found
|
---|
186 |
|
---|
187 | if not exist "%_MY_OPT_EXTPACK%" goto error_extpack_not_found
|
---|
188 | if not ".%_MY_OPT_EXTPACK_ENTERPRISE%" == "." if not exist "%_MY_OPT_EXTPACK_ENTERPRISE%" goto error_enterprise_extpack_not_found
|
---|
189 |
|
---|
190 | if not exist "%_MY_OPT_SIGNED_AMD64%" goto error_signed_amd64_not_found
|
---|
191 | if not exist "%_MY_OPT_SIGNED_X86%" goto error_signed_x86_not_found
|
---|
192 |
|
---|
193 | rem Make sure the output dir exists.
|
---|
194 | if not exist "%_MY_OPT_OUTDIR%" (mkdir "%_MY_OPT_OUTDIR%" || goto end_failed)
|
---|
195 |
|
---|
196 | rem
|
---|
197 | rem Unpacking the two driver zips.
|
---|
198 | rem
|
---|
199 | echo **************************************************************************
|
---|
200 | echo * AMD64: Unpacking signed drivers...
|
---|
201 | echo **************************************************************************
|
---|
202 | cd /d "%_MY_REPACK_DIR_AMD64%" || goto end_failed
|
---|
203 | call "%_MY_REPACK_DIR_AMD64%\UnpackBlessedDrivers.cmd" -b "%_MY_BINDIR_AMD64%" -i "%_MY_OPT_SIGNED_AMD64%" || goto end_failed
|
---|
204 | echo .
|
---|
205 |
|
---|
206 | echo **************************************************************************
|
---|
207 | echo * X86: Unpacking signed drivers...
|
---|
208 | echo **************************************************************************
|
---|
209 | cd /d "%_MY_REPACK_DIR_X86%" || goto end_failed
|
---|
210 | call "%_MY_REPACK_DIR_X86%\UnpackBlessedDrivers.cmd" -b "%_MY_BINDIR_X86%" -i "%_MY_OPT_SIGNED_X86%" || goto end_failed
|
---|
211 | echo .
|
---|
212 |
|
---|
213 |
|
---|
214 | rem
|
---|
215 | rem Do the AMD64 work.
|
---|
216 | rem
|
---|
217 | echo **************************************************************************
|
---|
218 | echo * AMD64: Compiling WIX...
|
---|
219 | echo **************************************************************************
|
---|
220 | cd /d "%_MY_REPACK_DIR_AMD64%" || goto end_failed
|
---|
221 | for %%i in (1-*.cmd) do (call %%i || goto end_failed)
|
---|
222 | echo .
|
---|
223 |
|
---|
224 | echo * AMD64: Linking WIX...
|
---|
225 | for %%i in (2-*.cmd) do (call %%i || goto end_failed)
|
---|
226 | echo .
|
---|
227 |
|
---|
228 | echo * AMD64: Applying language patches to MSI...
|
---|
229 | for %%i in (3-*.cmd) do (call %%i || goto end_failed)
|
---|
230 | echo .
|
---|
231 |
|
---|
232 |
|
---|
233 | rem
|
---|
234 | rem Do the X86 work.
|
---|
235 | rem
|
---|
236 | echo **************************************************************************
|
---|
237 | echo * X86: Compiling WIX...
|
---|
238 | echo **************************************************************************
|
---|
239 | cd /d "%_MY_REPACK_DIR_X86%" || goto end_failed
|
---|
240 | for %%i in (1-*.cmd) do (call %%i || goto end_failed)
|
---|
241 | echo .
|
---|
242 |
|
---|
243 | echo * X86: Linking WIX...
|
---|
244 | for %%i in (2-*.cmd) do (call %%i || goto end_failed)
|
---|
245 | echo .
|
---|
246 |
|
---|
247 | echo * X86: Applying language patches to MSI...
|
---|
248 | for %%i in (3-*.cmd) do (call %%i || goto end_failed)
|
---|
249 | echo .
|
---|
250 |
|
---|
251 | echo * X86: Creating multi arch installer...
|
---|
252 | for %%i in (4-*.cmd) do (call %%i || goto end_failed)
|
---|
253 | echo .
|
---|
254 |
|
---|
255 | set _MY_OUT_FILES=
|
---|
256 | for %%i in (VirtualBox-*MultiArch*exe) do (
|
---|
257 | copy /y "%%i" "%_MY_OPT_OUTDIR%" || goto end_failed
|
---|
258 | set _MY_OUT_FILES=%%_MY_OUT_FILES%% %%~nxi
|
---|
259 | )
|
---|
260 |
|
---|
261 |
|
---|
262 | rem
|
---|
263 | rem Repack the extension packs.
|
---|
264 | rem
|
---|
265 | echo **************************************************************************
|
---|
266 | echo * Repacking extension packs.
|
---|
267 | echo **************************************************************************
|
---|
268 | cd /d "%_MY_REPACK_DIR_X86%" || goto end_failed
|
---|
269 |
|
---|
270 | echo * Regular PUEL...
|
---|
271 | set _MY_TMP_OUT=%_MY_OPT_EXTPACK%
|
---|
272 | for %%i in (%_MY_TMP_OUT%) do (
|
---|
273 | set _MY_TMP_OUT=%_MY_OPT_OUTDIR%\%%~nxi
|
---|
274 | set _MY_OUT_FILES=%%_MY_OUT_FILES%% %%~nix
|
---|
275 | )
|
---|
276 | call "%_MY_REPACK_DIR_X86%\RepackExtPack.cmd" --bindir-amd64 "%_MY_BINDIR_AMD64%" --bindir-x86 "%_MY_BINDIR_X86%" ^
|
---|
277 | --input "%_MY_OPT_EXTPACK%" --output "%_MY_TMP_OUT%" || goto end_failed
|
---|
278 |
|
---|
279 | if ".%_MY_OPT_EXTPACK_ENTERPRISE%" == "." goto no_enterprise_repacking
|
---|
280 | echo * Enterprise PUEL...
|
---|
281 | set _MY_TMP_OUT=%_MY_OPT_EXTPACK_ENTERPRISE%
|
---|
282 | for %%i in (%_MY_TMP_OUT%) do (
|
---|
283 | set _MY_TMP_OUT=%_MY_OPT_OUTDIR%\%%~nxi
|
---|
284 | set _MY_OUT_FILES=%%_MY_OUT_FILES%% %%~nix
|
---|
285 | )
|
---|
286 | call "%_MY_REPACK_DIR_X86%\RepackExtPack.cmd" --bindir-amd64 "%_MY_BINDIR_AMD64%" --bindir-x86 "%_MY_BINDIR_X86%" ^
|
---|
287 | --input "%_MY_OPT_EXTPACK_ENTERPRISE%" --output "%_MY_TMP_OUT%" || goto end_failed
|
---|
288 | :no_enterprise_repacking
|
---|
289 | @cd /d "%_MY_SAVED_CD%"
|
---|
290 |
|
---|
291 | rem
|
---|
292 | rem That's that.
|
---|
293 | rem
|
---|
294 | echo **************************************************************************
|
---|
295 | echo * The third and final step is done.
|
---|
296 | echo *
|
---|
297 | echo * Successfully created:
|
---|
298 | for %%i in (%_MY_OUT_FILES%) do echo * "%_MY_OPT_OUTDIR%\%%i"
|
---|
299 | goto end
|
---|
300 |
|
---|
301 |
|
---|
302 | :end_failed
|
---|
303 | @cd /d "%_MY_SAVED_CD%"
|
---|
304 | @endlocal
|
---|
305 | @endlocal
|
---|
306 | @echo * Failed!
|
---|
307 | @exit /b 1
|
---|
308 |
|
---|
309 | :end
|
---|
310 | @cd /d "%_MY_SAVED_CD%"
|
---|
311 | @endlocal
|
---|
312 | @endlocal
|
---|
313 |
|
---|
314 |
|
---|