1 | @echo off
|
---|
2 | rem $Id: Combined-1-Prepare.cmd 106061 2024-09-16 14:03:52Z vboxsync $
|
---|
3 | rem rem @file
|
---|
4 | rem Windows NT batch script for preparing both amd64 and x86 for signing submission.
|
---|
5 | rem
|
---|
6 |
|
---|
7 | rem
|
---|
8 | rem Copyright (C) 2018-2024 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 | set _MY_PACK_EXTPACK=1
|
---|
42 | set _MY_PACK_ADDITIONS=0
|
---|
43 |
|
---|
44 | rem
|
---|
45 | rem Parse arguments.
|
---|
46 | rem
|
---|
47 | set _MY_OPT_UNTAR_DIR=%_MY_SCRIPT_DIR%\..\..\..
|
---|
48 | for %%i in (%_MY_OPT_UNTAR_DIR%) do set _MY_OPT_UNTAR_DIR=%%~fi
|
---|
49 | set _MY_OPT_EXTPACK=%_MY_OPT_UNTAR_DIR%\Oracle_VirtualBox_Extension_Pack-%_MY_VER_REV%.vbox-extpack
|
---|
50 | set _MY_OPT_EXTPACK_ENTERPRISE=%_MY_OPT_UNTAR_DIR%\Oracle_VirtualBox_Extension_Pack-%_MY_VER_REV%-ENTERPRISE.vbox-extpack
|
---|
51 | set _MY_OPT_BUILD_TYPE=@KBUILD_TYPE@
|
---|
52 | set _MY_OPT_OUTDIR=%_MY_OPT_UNTAR_DIR%\output
|
---|
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" == ".-g" goto opt_g
|
---|
66 | if ".%1" == ".--additions" goto opt_g
|
---|
67 | if ".%1" == ".-e" goto opt_e
|
---|
68 | if ".%1" == ".--extpack" goto opt_e
|
---|
69 | if ".%1" == ".--no-extpack" goto opt_ne
|
---|
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" == ".-t" goto opt_t
|
---|
75 | if ".%1" == ".--build-type" goto opt_t
|
---|
76 | if ".%1" == ".-u" goto opt_u
|
---|
77 | if ".%1" == ".--vboxall-untar-dir" goto opt_u
|
---|
78 | echo syntax error: Unknown option: %1
|
---|
79 | echo Try --help to list valid options.
|
---|
80 | goto end_failed
|
---|
81 |
|
---|
82 | :argument_loop_next_with_value
|
---|
83 | shift
|
---|
84 | shift
|
---|
85 | goto argument_loop
|
---|
86 |
|
---|
87 | :opt_g
|
---|
88 | set _MY_PACK_ADDITIONS=1
|
---|
89 | shift
|
---|
90 | goto argument_loop
|
---|
91 |
|
---|
92 | :opt_e
|
---|
93 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
94 | set _MY_OPT_EXTPACK=%~f2
|
---|
95 | goto argument_loop_next_with_value
|
---|
96 |
|
---|
97 | :opt_ne
|
---|
98 | set _MY_PACK_EXTPACK=0
|
---|
99 | shift
|
---|
100 | goto argument_loop
|
---|
101 |
|
---|
102 | :opt_h
|
---|
103 | echo Toplevel combined package: Prepare both x86 and amd64 for submission.
|
---|
104 | echo .
|
---|
105 | echo Usage: Combined-1-Prepare.cmd [-o output-dir] [-e/--extpack puel.vbox-extpack]
|
---|
106 | echo [-s/--extpack-enterprise puel-enterprise.vbox-extpack]
|
---|
107 | echo [--no-extpack] [-g/--additions]
|
---|
108 | echo [-u/--vboxall-dir unpacked-vboxall-dir] [-t build-type]
|
---|
109 | echo .
|
---|
110 | echo Default -e/--extpack value: %_MY_OPT_EXTPACK%
|
---|
111 | echo Default -s/--extpack-enterprise value: %_MY_OPT_EXTPACK_ENTERPRISE%
|
---|
112 | echo Default -u/--vboxall-untar-dir value: %_MY_OPT_UNTAR_DIR%
|
---|
113 | echo Default -o/--outdir value: %_MY_OPT_OUTDIR%
|
---|
114 | echo Default -t/--build-type value: %_MY_OPT_BUILD_TYPE%
|
---|
115 | echo .
|
---|
116 | goto end_failed
|
---|
117 |
|
---|
118 | :opt_o
|
---|
119 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
120 | set _MY_OPT_OUTDIR=%~f2
|
---|
121 | goto argument_loop_next_with_value
|
---|
122 |
|
---|
123 | :opt_s
|
---|
124 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
125 | set _MY_OPT_EXTPACK_ENTERPRISE=%~f2
|
---|
126 | goto argument_loop_next_with_value
|
---|
127 |
|
---|
128 | :opt_t
|
---|
129 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
130 | set _MY_OPT_BUILD_TYPE=%~2
|
---|
131 | goto argument_loop_next_with_value
|
---|
132 |
|
---|
133 | :opt_u
|
---|
134 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
135 | set _MY_OPT_UNTAR_DIR=%~f2
|
---|
136 | goto argument_loop_next_with_value
|
---|
137 |
|
---|
138 |
|
---|
139 | :syntax_error_missing_value
|
---|
140 | echo syntax error: missing or empty option value after %1
|
---|
141 | goto end_failed
|
---|
142 |
|
---|
143 |
|
---|
144 | :error_vboxall_untar_dir_not_found
|
---|
145 | echo syntax error: The VBoxAll untar directory was not found: "%_MY_OPT_UNTAR_DIR%"
|
---|
146 | goto end_failed
|
---|
147 |
|
---|
148 | :error_amd64_bindir_not_found
|
---|
149 | echo syntax error: The AMD64 bin directory was not found: "%_MY_BINDIR_AMD64%"
|
---|
150 | goto end_failed
|
---|
151 |
|
---|
152 | :error_x86_bindir_not_found
|
---|
153 | echo syntax error: The X86 bin directory was not found: "%_MY_BINDIR_X86%"
|
---|
154 | goto end_failed
|
---|
155 |
|
---|
156 | :error_amd64_repack_dir_not_found
|
---|
157 | echo syntax error: The AMD64 repack directory was not found: "%_MY_REPACK_DIR_AMD64%"
|
---|
158 | goto end_failed
|
---|
159 |
|
---|
160 | :error_x86_repack_dir_not_found
|
---|
161 | echo syntax error: The X86 repack directory was not found: "%_MY_REPACK_DIR_X86%"
|
---|
162 | goto end_failed
|
---|
163 |
|
---|
164 | :error_extpack_not_found
|
---|
165 | echo syntax error: Specified extension pack not found: "%_MY_OPT_EXTPACK%"
|
---|
166 | goto end_failed
|
---|
167 |
|
---|
168 | :error_enterprise_extpack_not_found
|
---|
169 | echo syntax error: Specified enterprise extension pack not found: "%_MY_OPT_EXTPACK_ENTERPRISE%"
|
---|
170 | goto end_failed
|
---|
171 |
|
---|
172 | :error_extpack_and_additions_together
|
---|
173 | echo usage error: You can't prepare extPack and GuestAdditions in one call
|
---|
174 | goto end_failed
|
---|
175 |
|
---|
176 | :no_more_arguments
|
---|
177 | rem
|
---|
178 | rem Validate and adjust specified options.
|
---|
179 | rem
|
---|
180 |
|
---|
181 | if not exist "%_MY_OPT_UNTAR_DIR%" goto error_vboxall_untar_dir_not_found
|
---|
182 |
|
---|
183 | set _MY_BINDIR_AMD64=%_MY_OPT_UNTAR_DIR%\win.amd64\%_MY_OPT_BUILD_TYPE%\bin
|
---|
184 | set _MY_BINDIR_X86=%_MY_OPT_UNTAR_DIR%\win.x86\%_MY_OPT_BUILD_TYPE%\bin
|
---|
185 | if not exist "%_MY_BINDIR_AMD64%" goto error_amd64_bindir_not_found
|
---|
186 | if not exist "%_MY_BINDIR_X86%" goto error_x86_bindir_not_found
|
---|
187 |
|
---|
188 | if ".%_MY_PACK_EXTPACK%" == ".%_MY_PACK_ADDITIONS%" goto error_extpack_and_additions_together
|
---|
189 |
|
---|
190 | set _MY_REPACK_DIR_AMD64=%_MY_OPT_UNTAR_DIR%\win.amd64\%_MY_OPT_BUILD_TYPE%\repack
|
---|
191 | set _MY_REPACK_DIR_X86=%_MY_OPT_UNTAR_DIR%\win.x86\%_MY_OPT_BUILD_TYPE%\repack
|
---|
192 | if ".%_MY_PACK_ADDITIONS%" == ".0" goto skip_additions_packing_options
|
---|
193 | set _MY_REPACK_DIR_AMD64=%_MY_OPT_UNTAR_DIR%\win.amd64\%_MY_OPT_BUILD_TYPE%\repackadd
|
---|
194 | set _MY_REPACK_DIR_X86=%_MY_OPT_UNTAR_DIR%\win.x86\%_MY_OPT_BUILD_TYPE%\repackadd
|
---|
195 | :skip_additions_packing_options
|
---|
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 | rem Make sure the output dir exists.
|
---|
200 | if not exist "%_MY_OPT_OUTDIR%" (mkdir "%_MY_OPT_OUTDIR%" || goto end_failed)
|
---|
201 |
|
---|
202 | rem
|
---|
203 | rem ExtPack section
|
---|
204 | rem
|
---|
205 | if ".%_MY_PACK_EXTPACK%" == ".0" goto skip_extpack_packing
|
---|
206 |
|
---|
207 | if not exist "%_MY_OPT_EXTPACK%" goto error_extpack_not_found
|
---|
208 | if not ".%_MY_OPT_EXTPACK_ENTERPRISE%" == "." if not exist "%_MY_OPT_EXTPACK_ENTERPRISE%" goto error_enterprise_extpack_not_found
|
---|
209 |
|
---|
210 | rem
|
---|
211 | rem Install the extpack in the bin directories.
|
---|
212 | rem Note! Not really necessary, but whatever.
|
---|
213 | rem
|
---|
214 | echo on
|
---|
215 | copy /y "%_MY_OPT_EXTPACK%" "%_MY_BINDIR_AMD64%\Oracle_VirtualBox_Extension_Pack.vbox-extpack" || goto end_failed
|
---|
216 | copy /y "%_MY_OPT_EXTPACK%" "%_MY_BINDIR_X86%\Oracle_VirtualBox_Extension_Pack.vbox-extpack" || goto end_failed
|
---|
217 | @echo off
|
---|
218 |
|
---|
219 | rem
|
---|
220 | rem Do the packing of ExtPack
|
---|
221 | rem
|
---|
222 | echo **************************************************************************
|
---|
223 | echo Packing AMD64 drivers
|
---|
224 | echo **************************************************************************
|
---|
225 | cd /d "%_MY_REPACK_DIR_AMD64%" || goto end_failed
|
---|
226 | call "%_MY_REPACK_DIR_AMD64%\PackDriversForSubmission.cmd" -b "%_MY_BINDIR_AMD64%" -a amd64 -e "%_MY_OPT_EXTPACK%" ^
|
---|
227 | -o "%_MY_OPT_OUTDIR%\VBoxDrivers-%_MY_VER_REV%-amd64.cab" || goto end_failed
|
---|
228 | echo .
|
---|
229 | echo **************************************************************************
|
---|
230 | echo Packing X86 drivers
|
---|
231 | echo **************************************************************************
|
---|
232 | cd /d "%_MY_REPACK_DIR_X86%" || goto end_failed
|
---|
233 | call "%_MY_REPACK_DIR_X86%\PackDriversForSubmission.cmd" -b "%_MY_BINDIR_X86%" -a x86 -e "%_MY_OPT_EXTPACK%" ^
|
---|
234 | -o "%_MY_OPT_OUTDIR%\VBoxDrivers-%_MY_VER_REV%-x86.cab" || goto end_failed
|
---|
235 | echo .
|
---|
236 | cd /d "%_MY_SAVED_CD%"
|
---|
237 | :skip_extpack_packing
|
---|
238 |
|
---|
239 | rem
|
---|
240 | rem GuestAdditions section
|
---|
241 | rem
|
---|
242 | if ".%_MY_PACK_ADDITIONS%" == ".0" goto skip_additions_packing
|
---|
243 |
|
---|
244 | rem
|
---|
245 | rem Do the packing of GuestAdditions
|
---|
246 | rem
|
---|
247 | echo **************************************************************************
|
---|
248 | echo Packing AMD64 additions
|
---|
249 | echo **************************************************************************
|
---|
250 | cd /d "%_MY_REPACK_DIR_AMD64%" || goto end_failed
|
---|
251 | call "%_MY_REPACK_DIR_AMD64%\PackDriversForSubmission.cmd" -b "%_MY_BINDIR_AMD64%" -a amd64 -x -n --no-main --ga ^
|
---|
252 | -o "%_MY_OPT_OUTDIR%\VBoxDrivers-%_MY_VER_REV%-amd64.cab" || goto end_failed
|
---|
253 | echo .
|
---|
254 | echo **************************************************************************
|
---|
255 | echo Packing X86 drivers
|
---|
256 | echo **************************************************************************
|
---|
257 | cd /d "%_MY_REPACK_DIR_X86%" || goto end_failed
|
---|
258 | call "%_MY_REPACK_DIR_X86%\PackDriversForSubmission.cmd" -b "%_MY_BINDIR_X86%" -a x86 -x -n --no-main --ga ^
|
---|
259 | -o "%_MY_OPT_OUTDIR%\VBoxDrivers-%_MY_VER_REV%-x86.cab" || goto end_failed
|
---|
260 | echo .
|
---|
261 | cd /d "%_MY_SAVED_CD%"
|
---|
262 | :skip_additions_packing
|
---|
263 |
|
---|
264 | rem
|
---|
265 | rem Generate script for taking the next step.
|
---|
266 | rem
|
---|
267 | set _MY_NEXT_SCRIPT_SHORT_NAME=Combined-3-Repack.cmd
|
---|
268 | set _MY_NEXT_SCRIPT=%_MY_OPT_OUTDIR%\%_MY_NEXT_SCRIPT_SHORT_NAME%
|
---|
269 | if ".%_MY_PACK_ADDITIONS%" == ".0" goto generate_legacy_script
|
---|
270 | set _MY_NEXT_SCRIPT_SHORT_NAME=Combined-3-RepackAdditions.cmd
|
---|
271 | set _MY_NEXT_SCRIPT=%_MY_OPT_OUTDIR%\%_MY_NEXT_SCRIPT_SHORT_NAME%
|
---|
272 | echo cd /d "%cd%" > "%_MY_NEXT_SCRIPT%"
|
---|
273 | echo call "%_MY_SCRIPT_DIR%%_MY_NEXT_SCRIPT_SHORT_NAME%" ^
|
---|
274 | --vboxall-untar-dir "%_MY_OPT_UNTAR_DIR%" ^
|
---|
275 | --outdir "%_MY_OPT_OUTDIR%" ^
|
---|
276 | --build-type "%_MY_OPT_BUILD_TYPE%" %%* >> "%_MY_NEXT_SCRIPT%"
|
---|
277 | goto show_next_steps
|
---|
278 | :generate_legacy_script
|
---|
279 | echo cd /d "%cd%" > "%_MY_NEXT_SCRIPT%"
|
---|
280 | echo call "%_MY_SCRIPT_DIR%%_MY_NEXT_SCRIPT_SHORT_NAME%" --extpack "%_MY_OPT_EXTPACK%" ^
|
---|
281 | --extpack-enterprise "%_MY_OPT_EXTPACK_ENTERPRISE%" ^
|
---|
282 | --vboxall-untar-dir "%_MY_OPT_UNTAR_DIR%" ^
|
---|
283 | --outdir "%_MY_OPT_OUTDIR%" ^
|
---|
284 | %_MY_OPT_SCRIPT_SKIPEXTPACK_PARAM% %_MY_OPT_SCRIPT_ADDITIONS_PARAM% ^
|
---|
285 | --build-type "%_MY_OPT_BUILD_TYPE%" %%* >> "%_MY_NEXT_SCRIPT%"
|
---|
286 |
|
---|
287 | :show_next_steps
|
---|
288 | rem
|
---|
289 | rem Instructions on what to do next.
|
---|
290 | rem
|
---|
291 | echo **************************************************************************
|
---|
292 | echo * First step is done.
|
---|
293 | echo *
|
---|
294 | echo * Created:
|
---|
295 | echo * %_MY_OPT_OUTDIR%\VBoxDrivers-%_MY_VER_REV%-amd64.cab
|
---|
296 | echo * %_MY_OPT_OUTDIR%\VBoxDrivers-%_MY_VER_REV%-x86.cab
|
---|
297 | echo *
|
---|
298 | echo * Next steps:
|
---|
299 | echo * 1. Submit the files to Microsoft for attestation signing.
|
---|
300 | echo * 2. Download the signed result.
|
---|
301 | echo * 3. "%_MY_NEXT_SCRIPT%" --signed-x86 {zip} --signed-amd64 {zip} %_MY_OPT_SCRIPT_SKIPEXTPACK_PARAM% %_MY_OPT_SCRIPT_ADDITIONAL_PARAMS%
|
---|
302 | goto end
|
---|
303 | :end_failed
|
---|
304 | @cd /d "%_MY_SAVED_CD%"
|
---|
305 | @endlocal
|
---|
306 | @endlocal
|
---|
307 | @echo * Failed!
|
---|
308 | @exit /b 1
|
---|
309 |
|
---|
310 | :end
|
---|
311 | @cd /d "%_MY_SAVED_CD%"
|
---|
312 | @endlocal
|
---|
313 | @endlocal
|
---|
314 |
|
---|