1 | @echo off
|
---|
2 | rem $Id: Single-1-Prepare.cmd 93115 2022-01-01 11:31:46Z vboxsync $
|
---|
3 | rem rem @file
|
---|
4 | rem Windows NT batch script for preparing single build (either amd64 and x86) for signing submission.
|
---|
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_ARCH=@KBUILD_TARGET_ARCH@
|
---|
42 |
|
---|
43 | :argument_loop
|
---|
44 | if ".%1" == "." goto no_more_arguments
|
---|
45 |
|
---|
46 | if ".%1" == ".-h" goto opt_h
|
---|
47 | if ".%1" == ".-?" goto opt_h
|
---|
48 | if ".%1" == "./h" goto opt_h
|
---|
49 | if ".%1" == "./H" goto opt_h
|
---|
50 | if ".%1" == "./?" goto opt_h
|
---|
51 | if ".%1" == ".-help" goto opt_h
|
---|
52 | if ".%1" == ".--help" goto opt_h
|
---|
53 |
|
---|
54 | if ".%1" == ".-a" goto opt_a
|
---|
55 | if ".%1" == ".--arch" goto opt_a
|
---|
56 | if ".%1" == ".-e" goto opt_e
|
---|
57 | if ".%1" == ".--extpack" goto opt_e
|
---|
58 | if ".%1" == ".-o" goto opt_o
|
---|
59 | if ".%1" == ".--outdir" goto opt_o
|
---|
60 | if ".%1" == ".-s" goto opt_s
|
---|
61 | if ".%1" == ".--extpack-enterprise" goto opt_s
|
---|
62 | if ".%1" == ".-t" goto opt_t
|
---|
63 | if ".%1" == ".--build-type" goto opt_t
|
---|
64 | if ".%1" == ".-u" goto opt_u
|
---|
65 | if ".%1" == ".--vboxall-untar-dir" goto opt_u
|
---|
66 | echo syntax error: Unknown option: %1
|
---|
67 | echo Try --help to list valid options.
|
---|
68 | goto end_failed
|
---|
69 |
|
---|
70 | :argument_loop_next_with_value
|
---|
71 | shift
|
---|
72 | shift
|
---|
73 | goto argument_loop
|
---|
74 |
|
---|
75 | :opt_a
|
---|
76 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
77 | if not "%2" == "x86" if not "%2" == "amd64" goto syntax_error_unknown_arch
|
---|
78 | set _MY_OPT_ARCH=%~2
|
---|
79 | goto argument_loop_next_with_value
|
---|
80 |
|
---|
81 | :opt_e
|
---|
82 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
83 | set _MY_OPT_EXTPACK=%~f2
|
---|
84 | goto argument_loop_next_with_value
|
---|
85 |
|
---|
86 | :opt_h
|
---|
87 | echo Toplevel single package: Prepare either x86 and amd64 for submission.
|
---|
88 | echo .
|
---|
89 | echo Usage: Single-1-Prepare.cmd [-o output-dir] [-e/--extpack puel.vbox-extpack]
|
---|
90 | echo [-s/--extpack-enterprise puel-enterprise.vbox-extpack]
|
---|
91 | echo [-u/--vboxall-dir unpacked-vboxall-dir] [-t build-type]
|
---|
92 | echo [-a x86/amd64]
|
---|
93 | echo .
|
---|
94 | echo Default -a/--arch value: %_MY_OPT_ARCH%
|
---|
95 | echo Default -e/--extpack value: %_MY_OPT_EXTPACK%
|
---|
96 | echo Default -s/--extpack-enterprise value: %_MY_OPT_EXTPACK_ENTERPRISE%
|
---|
97 | echo Default -u/--vboxall-untar-dir value: %_MY_OPT_UNTAR_DIR%
|
---|
98 | echo Default -o/--outdir value: %_MY_OPT_OUTDIR%
|
---|
99 | echo Default -t/--build-type value: %_MY_OPT_BUILD_TYPE%
|
---|
100 | echo .
|
---|
101 | goto end_failed
|
---|
102 |
|
---|
103 | :opt_o
|
---|
104 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
105 | set _MY_OPT_OUTDIR=%~f2
|
---|
106 | goto argument_loop_next_with_value
|
---|
107 |
|
---|
108 | :opt_s
|
---|
109 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
110 | set _MY_OPT_EXTPACK_ENTERPRISE=%~f2
|
---|
111 | goto argument_loop_next_with_value
|
---|
112 |
|
---|
113 | :opt_t
|
---|
114 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
115 | set _MY_OPT_BUILD_TYPE=%~2
|
---|
116 | goto argument_loop_next_with_value
|
---|
117 |
|
---|
118 | :opt_u
|
---|
119 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
120 | set _MY_OPT_UNTAR_DIR=%~f2
|
---|
121 | goto argument_loop_next_with_value
|
---|
122 |
|
---|
123 |
|
---|
124 | :syntax_error_missing_value
|
---|
125 | echo syntax error: missing or empty option value after %1
|
---|
126 | goto end_failed
|
---|
127 |
|
---|
128 | :syntax_error_unknown_arch
|
---|
129 | echo syntax error: Unknown architecture: %2
|
---|
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_bindir_not_found
|
---|
138 | echo syntax error: The bin directory was not found: "%_MY_BINDIR%"
|
---|
139 | goto end_failed
|
---|
140 |
|
---|
141 | :error_repack_dir_not_found
|
---|
142 | echo syntax error: The repack directory was not found: "%_MY_REPACK_DIR%"
|
---|
143 | goto end_failed
|
---|
144 |
|
---|
145 | :error_extpack_not_found
|
---|
146 | echo syntax error: Specified extension pack not found: "%_MY_OPT_EXTPACK%"
|
---|
147 | goto end_failed
|
---|
148 |
|
---|
149 | :error_enterprise_extpack_not_found
|
---|
150 | echo syntax error: Specified enterprise extension pack not found: "%_MY_OPT_EXTPACK_ENTERPRISE%"
|
---|
151 | goto end_failed
|
---|
152 |
|
---|
153 |
|
---|
154 |
|
---|
155 | :no_more_arguments
|
---|
156 | rem
|
---|
157 | rem Validate and adjust specified options.
|
---|
158 | rem
|
---|
159 |
|
---|
160 | if not exist "%_MY_OPT_UNTAR_DIR%" goto error_vboxall_untar_dir_not_found
|
---|
161 |
|
---|
162 | set _MY_BINDIR=%_MY_OPT_UNTAR_DIR%\bin
|
---|
163 | if not exist "%_MY_BINDIR%" goto error_bindir_not_found
|
---|
164 |
|
---|
165 | set _MY_REPACK_DIR=%_MY_OPT_UNTAR_DIR%\repack
|
---|
166 | if not exist "%_MY_REPACK_DIR%" goto error_repack_dir_not_found
|
---|
167 |
|
---|
168 | if not exist "%_MY_OPT_EXTPACK%" goto error_extpack_not_found
|
---|
169 | if not ".%_MY_OPT_EXTPACK_ENTERPRISE%" == "." if not exist "%_MY_OPT_EXTPACK_ENTERPRISE%" goto error_enterprise_extpack_not_found
|
---|
170 |
|
---|
171 |
|
---|
172 | rem Make sure the output dir exists.
|
---|
173 | if not exist "%_MY_OPT_OUTDIR%" (mkdir "%_MY_OPT_OUTDIR%" || goto end_failed)
|
---|
174 |
|
---|
175 | rem
|
---|
176 | rem Install the extpack in the bin directories.
|
---|
177 | rem Note! Not really necessary, but whatever.
|
---|
178 | rem
|
---|
179 | echo on
|
---|
180 | copy /y "%_MY_OPT_EXTPACK%" "%_MY_BINDIR%\Oracle_VM_VirtualBox_Extension_Pack.vbox-extpack" || goto end_failed
|
---|
181 | @echo off
|
---|
182 |
|
---|
183 | rem
|
---|
184 | rem Do the packing.
|
---|
185 | rem
|
---|
186 | echo **************************************************************************
|
---|
187 | echo Packing drivers
|
---|
188 | echo **************************************************************************
|
---|
189 | cd /d "%_MY_REPACK_DIR%" || goto end_failed
|
---|
190 | call "%_MY_REPACK_DIR%\PackDriversForSubmission.cmd" -b "%_MY_BINDIR%" -a %_MY_OPT_ARCH% -e "%_MY_OPT_EXTPACK%" ^
|
---|
191 | -o "%_MY_OPT_OUTDIR%\VBoxDrivers-%_MY_VER_REV%-%_MY_OPT_ARCH%.cab" || goto end_failed
|
---|
192 | echo .
|
---|
193 | cd /d "%_MY_SAVED_CD%"
|
---|
194 |
|
---|
195 | rem
|
---|
196 | rem Generate script for taking the next step.
|
---|
197 | rem
|
---|
198 | set _MY_NEXT_SCRIPT=%_MY_OPT_OUTDIR%\Single-3-Repack.cmd
|
---|
199 | rem If out dir is the same as repack dir this would erase original repack script
|
---|
200 | if not exist "%_MY_NEXT_SCRIPT%" goto generate_next_script
|
---|
201 | set _MY_NEXT_SCRIPT=%_MY_OPT_OUTDIR%\Single-3-Repack-Gen.cmd
|
---|
202 | :generate_next_script
|
---|
203 | echo cd /d "%cd%" > "%_MY_NEXT_SCRIPT%"
|
---|
204 | echo call "%_MY_SCRIPT_DIR%\Single-3-Repack.cmd" --extpack "%_MY_OPT_EXTPACK%" ^
|
---|
205 | --extpack-enterprise "%_MY_OPT_EXTPACK_ENTERPRISE%" ^
|
---|
206 | --vboxall-untar-dir "%_MY_OPT_UNTAR_DIR%" ^
|
---|
207 | --outdir "%_MY_OPT_OUTDIR%" ^
|
---|
208 | --build-type "%_MY_OPT_BUILD_TYPE%" %%* >> "%_MY_NEXT_SCRIPT%"
|
---|
209 |
|
---|
210 | rem
|
---|
211 | rem Instructions on what to do next.
|
---|
212 | rem
|
---|
213 | echo **************************************************************************
|
---|
214 | echo * First step is done.
|
---|
215 | echo *
|
---|
216 | echo * Created:
|
---|
217 | echo * %_MY_OPT_OUTDIR%\VBoxDrivers-%_MY_VER_REV%-%_MY_OPT_ARCH%.cab
|
---|
218 | echo *
|
---|
219 | echo * Next steps:
|
---|
220 | echo * 1. Submit the files to Microsoft for attestation signing.
|
---|
221 | echo * 2. Download the signed result.
|
---|
222 | echo * 3. "%_MY_NEXT_SCRIPT%" --signed {zip}
|
---|
223 |
|
---|
224 | goto end
|
---|
225 |
|
---|
226 |
|
---|
227 | :end_failed
|
---|
228 | @cd /d "%_MY_SAVED_CD%"
|
---|
229 | @endlocal
|
---|
230 | @endlocal
|
---|
231 | @echo * Failed!
|
---|
232 | @exit /b 1
|
---|
233 |
|
---|
234 | :end
|
---|
235 | @cd /d "%_MY_SAVED_CD%"
|
---|
236 | @endlocal
|
---|
237 | @endlocal
|
---|
238 |
|
---|