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