1 | @echo off
|
---|
2 | rem $Id: Single-3-Repack.cmd 104863 2024-06-06 14:29:21Z vboxsync $
|
---|
3 | rem rem @file
|
---|
4 | rem Windows NT batch script for repacking signed amd64 or 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_VirtualBox_Extension_Pack-%_MY_VER_REV%.vbox-extpack
|
---|
48 | set _MY_OPT_EXTPACK_ENTERPRISE=%_MY_OPT_UNTAR_DIR%\Oracle_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=
|
---|
52 | set _MY_OPT_NOEXTPACK=
|
---|
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" == ".-n" goto opt_n
|
---|
68 | if ".%1" == ".--no-extpack" goto opt_n
|
---|
69 | if ".%1" == ".-o" goto opt_o
|
---|
70 | if ".%1" == ".--outdir" goto opt_o
|
---|
71 | if ".%1" == ".-s" goto opt_s
|
---|
72 | if ".%1" == ".--extpack-enterprise" goto opt_s
|
---|
73 | if ".%1" == ".--signed" goto opt_signed
|
---|
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_e
|
---|
88 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
89 | set _MY_OPT_EXTPACK=%~f2
|
---|
90 | goto argument_loop_next_with_value
|
---|
91 |
|
---|
92 | :opt_h
|
---|
93 | echo Toplevel combined package: Repack the installer and extpacks.
|
---|
94 | echo .
|
---|
95 | echo Usage: Combined-3-Repack.cmd [-o output-dir] [-e/--extpack puel.vbox-extpack]
|
---|
96 | echo [-s/--extpack-enterprise puel-enterprise.vbox-extpack]
|
---|
97 | echo [-u/--vboxall-dir unpacked-vboxall-dir] [-t build-type]
|
---|
98 | echo [--signed signed.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_n
|
---|
110 | set _MY_OPT_NOEXTPACK=1
|
---|
111 | shift
|
---|
112 | goto argument_loop
|
---|
113 |
|
---|
114 | :opt_o
|
---|
115 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
116 | set _MY_OPT_OUTDIR=%~f2
|
---|
117 | goto argument_loop_next_with_value
|
---|
118 |
|
---|
119 | :opt_s
|
---|
120 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
121 | set _MY_OPT_EXTPACK_ENTERPRISE=%~f2
|
---|
122 | goto argument_loop_next_with_value
|
---|
123 |
|
---|
124 | :opt_signed
|
---|
125 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
126 | set _MY_OPT_SIGNED=%~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_bindir_not_found
|
---|
150 | echo syntax error: The bin directory was not found: "%_MY_BINDIR%"
|
---|
151 | goto end_failed
|
---|
152 |
|
---|
153 | :error_repack_dir_not_found
|
---|
154 | echo syntax error: The repack directory was not found: "%_MY_REPACK_DIR%"
|
---|
155 | goto end_failed
|
---|
156 |
|
---|
157 | :error_extpack_not_found
|
---|
158 | echo syntax error: Specified extension pack not found: "%_MY_OPT_EXTPACK%"
|
---|
159 | goto end_failed
|
---|
160 |
|
---|
161 | :error_enterprise_extpack_not_found
|
---|
162 | echo syntax error: Specified enterprise extension pack not found: "%_MY_OPT_EXTPACK_ENTERPRISE%"
|
---|
163 | goto end_failed
|
---|
164 |
|
---|
165 | :error_signed_not_found
|
---|
166 | echo syntax error: Zip with signed drivers not found: "%_MY_OPT_SIGNED%"
|
---|
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=%_MY_OPT_UNTAR_DIR%\bin
|
---|
178 | if not exist "%_MY_BINDIR%" goto error_bindir_not_found
|
---|
179 |
|
---|
180 | set _MY_REPACK_DIR=%_MY_OPT_UNTAR_DIR%\repack
|
---|
181 | if not exist "%_MY_REPACK_DIR%" goto error_repack_dir_not_found
|
---|
182 |
|
---|
183 | if ".%_MY_OPT_NOEXTPACK%" == ".1" goto no_enterprise_check
|
---|
184 | if not exist "%_MY_OPT_EXTPACK%" goto error_extpack_not_found
|
---|
185 | if not ".%_MY_OPT_EXTPACK_ENTERPRISE%" == "." if not exist "%_MY_OPT_EXTPACK_ENTERPRISE%" goto error_enterprise_extpack_not_found
|
---|
186 | :no_enterprise_check
|
---|
187 |
|
---|
188 | if not exist "%_MY_OPT_SIGNED%" goto error_signed_not_found
|
---|
189 |
|
---|
190 | rem Make sure the output dir exists.
|
---|
191 | if not exist "%_MY_OPT_OUTDIR%" (mkdir "%_MY_OPT_OUTDIR%" || goto end_failed)
|
---|
192 |
|
---|
193 | rem
|
---|
194 | rem Unpacking the driver zip.
|
---|
195 | rem
|
---|
196 | echo **************************************************************************
|
---|
197 | echo * Unpacking signed drivers...
|
---|
198 | echo **************************************************************************
|
---|
199 | cd /d "%_MY_REPACK_DIR%" || goto end_failed
|
---|
200 | call "%_MY_REPACK_DIR%\UnpackBlessedDrivers.cmd" -n -b "%_MY_BINDIR%" -i "%_MY_OPT_SIGNED%" || goto end_failed
|
---|
201 | echo .
|
---|
202 |
|
---|
203 |
|
---|
204 | rem
|
---|
205 | rem Do the work.
|
---|
206 | rem
|
---|
207 | echo **************************************************************************
|
---|
208 | echo * Repackaging installers
|
---|
209 | echo **************************************************************************
|
---|
210 | echo * Compiling WIX...
|
---|
211 | cd /d "%_MY_REPACK_DIR%" || goto end_failed
|
---|
212 | for %%i in (1-*.cmd) do (call %%i || goto end_failed)
|
---|
213 | echo .
|
---|
214 |
|
---|
215 | echo * Linking WIX...
|
---|
216 | for %%i in (2-*.cmd) do (call %%i || goto end_failed)
|
---|
217 | echo .
|
---|
218 |
|
---|
219 | echo * Applying language patches to MSI...
|
---|
220 | for %%i in (3-*.cmd) do (call %%i || goto end_failed)
|
---|
221 | echo .
|
---|
222 |
|
---|
223 | echo * Creating multi arch installer...
|
---|
224 | for %%i in (4-*.cmd) do (call %%i || goto end_failed)
|
---|
225 | echo .
|
---|
226 |
|
---|
227 |
|
---|
228 | set _MY_OUT_FILES=
|
---|
229 | cd /d "%_MY_REPACK_DIR%" || goto end_failed
|
---|
230 | for %%i in (VBoxMerge*msm) do (
|
---|
231 | copy /y "%%i" "%_MY_OPT_OUTDIR%" || goto end_failed
|
---|
232 | call set _MY_OUT_FILES=%%_MY_OUT_FILES%% %%~nxi
|
---|
233 | )
|
---|
234 | for %%i in (VirtualBox-*MultiArch*exe) do (
|
---|
235 | copy /y "%%i" "%_MY_OPT_OUTDIR%" || goto end_failed
|
---|
236 | call set _MY_OUT_FILES=%%_MY_OUT_FILES%% %%~nxi
|
---|
237 | )
|
---|
238 |
|
---|
239 |
|
---|
240 | if ".%_MY_OPT_NOEXTPACK%" == ".1" goto no_enterprise_repacking
|
---|
241 | rem
|
---|
242 | rem Repack the extension packs.
|
---|
243 | rem
|
---|
244 | echo **************************************************************************
|
---|
245 | echo * Repacking extension packs.
|
---|
246 | echo **************************************************************************
|
---|
247 | cd /d "%_MY_REPACK_DIR%" || goto end_failed
|
---|
248 |
|
---|
249 | echo * Regular PUEL...
|
---|
250 | set _MY_TMP_OUT=%_MY_OPT_EXTPACK%
|
---|
251 | for %%i in (%_MY_TMP_OUT%) do (
|
---|
252 | set _MY_TMP_OUT=%_MY_OPT_OUTDIR%\%%~nxi
|
---|
253 | call set _MY_OUT_FILES=%%_MY_OUT_FILES%% %%~nxi
|
---|
254 | )
|
---|
255 | call "%_MY_REPACK_DIR%\RepackExtPack.cmd" --bindir-amd64 "%_MY_BINDIR%" --bindir-x86 "%_MY_BINDIR%" ^
|
---|
256 | --input "%_MY_OPT_EXTPACK%" --output "%_MY_TMP_OUT%" || goto end_failed
|
---|
257 |
|
---|
258 | if ".%_MY_OPT_EXTPACK_ENTERPRISE%" == "." goto no_enterprise_repacking
|
---|
259 | echo * Enterprise PUEL...
|
---|
260 | set _MY_TMP_OUT=%_MY_OPT_EXTPACK_ENTERPRISE%
|
---|
261 | for %%i in (%_MY_TMP_OUT%) do (
|
---|
262 | set _MY_TMP_OUT=%_MY_OPT_OUTDIR%\%%~nxi
|
---|
263 | call set _MY_OUT_FILES=%%_MY_OUT_FILES%% %%~nxi
|
---|
264 | )
|
---|
265 | call "%_MY_REPACK_DIR%\RepackExtPack.cmd" --bindir-amd64 "%_MY_BINDIR%" --bindir-x86 "%_MY_BINDIR%" ^
|
---|
266 | --input "%_MY_OPT_EXTPACK_ENTERPRISE%" --output "%_MY_TMP_OUT%" || goto end_failed
|
---|
267 | :no_enterprise_repacking
|
---|
268 | @cd /d "%_MY_SAVED_CD%"
|
---|
269 |
|
---|
270 | rem
|
---|
271 | rem That's that.
|
---|
272 | rem
|
---|
273 | echo **************************************************************************
|
---|
274 | echo * The third and final step is done.
|
---|
275 | echo *
|
---|
276 | echo * Successfully created:
|
---|
277 | for %%i in (%_MY_OUT_FILES%) do echo * "%_MY_OPT_OUTDIR%\%%i"
|
---|
278 | goto end
|
---|
279 |
|
---|
280 |
|
---|
281 | :end_failed
|
---|
282 | @cd /d "%_MY_SAVED_CD%"
|
---|
283 | @endlocal
|
---|
284 | @endlocal
|
---|
285 | @echo * Failed!
|
---|
286 | @exit /b 1
|
---|
287 |
|
---|
288 | :end
|
---|
289 | @cd /d "%_MY_SAVED_CD%"
|
---|
290 | @endlocal
|
---|
291 | @endlocal
|
---|