1 | @echo off
|
---|
2 | rem $Id: Single-3-Repack.cmd 96407 2022-08-22 17:43:14Z 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-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_SIGNED=
|
---|
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" == ".-e" goto opt_e
|
---|
65 | if ".%1" == ".--extpack" goto opt_e
|
---|
66 | if ".%1" == ".-o" goto opt_o
|
---|
67 | if ".%1" == ".--outdir" goto opt_o
|
---|
68 | if ".%1" == ".-s" goto opt_s
|
---|
69 | if ".%1" == ".--extpack-enterprise" goto opt_s
|
---|
70 | if ".%1" == ".--signed" goto opt_signed
|
---|
71 | if ".%1" == ".-t" goto opt_t
|
---|
72 | if ".%1" == ".--build-type" goto opt_t
|
---|
73 | if ".%1" == ".-u" goto opt_u
|
---|
74 | if ".%1" == ".--vboxall-untar-dir" goto opt_u
|
---|
75 | echo syntax error: Unknown option: %1
|
---|
76 | echo Try --help to list valid options.
|
---|
77 | goto end_failed
|
---|
78 |
|
---|
79 | :argument_loop_next_with_value
|
---|
80 | shift
|
---|
81 | shift
|
---|
82 | goto argument_loop
|
---|
83 |
|
---|
84 | :opt_e
|
---|
85 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
86 | set _MY_OPT_EXTPACK=%~f2
|
---|
87 | goto argument_loop_next_with_value
|
---|
88 |
|
---|
89 | :opt_h
|
---|
90 | echo Toplevel combined package: Repack the installer and extpacks.
|
---|
91 | echo .
|
---|
92 | echo Usage: Combined-3-Repack.cmd [-o output-dir] [-e/--extpack puel.vbox-extpack]
|
---|
93 | echo [-s/--extpack-enterprise puel-enterprise.vbox-extpack]
|
---|
94 | echo [-u/--vboxall-dir unpacked-vboxall-dir] [-t build-type]
|
---|
95 | echo [--signed signed.zip]
|
---|
96 | echo
|
---|
97 | echo .
|
---|
98 | echo Default -e/--extpack value: %_MY_OPT_EXTPACK%
|
---|
99 | echo Default -s/--extpack-enterprise value: %_MY_OPT_EXTPACK_ENTERPRISE%
|
---|
100 | echo Default -u/--vboxall-untar-dir value: %_MY_OPT_UNTAR_DIR%
|
---|
101 | echo Default -o/--outdir value: %_MY_OPT_OUTDIR%
|
---|
102 | echo Default -t/--build-type value: %_MY_OPT_BUILD_TYPE%
|
---|
103 | echo .
|
---|
104 | goto end_failed
|
---|
105 |
|
---|
106 | :opt_o
|
---|
107 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
108 | set _MY_OPT_OUTDIR=%~f2
|
---|
109 | goto argument_loop_next_with_value
|
---|
110 |
|
---|
111 | :opt_s
|
---|
112 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
113 | set _MY_OPT_EXTPACK_ENTERPRISE=%~f2
|
---|
114 | goto argument_loop_next_with_value
|
---|
115 |
|
---|
116 | :opt_signed
|
---|
117 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
118 | set _MY_OPT_SIGNED=%~f2
|
---|
119 | goto argument_loop_next_with_value
|
---|
120 |
|
---|
121 | :opt_t
|
---|
122 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
123 | set _MY_OPT_BUILD_TYPE=%~2
|
---|
124 | goto argument_loop_next_with_value
|
---|
125 |
|
---|
126 | :opt_u
|
---|
127 | if ".%~2" == "." goto syntax_error_missing_value
|
---|
128 | set _MY_OPT_UNTAR_DIR=%~f2
|
---|
129 | goto argument_loop_next_with_value
|
---|
130 |
|
---|
131 |
|
---|
132 | :syntax_error_missing_value
|
---|
133 | echo syntax error: missing or empty option value after %1
|
---|
134 | goto end_failed
|
---|
135 |
|
---|
136 |
|
---|
137 | :error_vboxall_untar_dir_not_found
|
---|
138 | echo syntax error: The VBoxAll untar directory was not found: "%_MY_OPT_UNTAR_DIR%"
|
---|
139 | goto end_failed
|
---|
140 |
|
---|
141 | :error_bindir_not_found
|
---|
142 | echo syntax error: The bin directory was not found: "%_MY_BINDIR%"
|
---|
143 | goto end_failed
|
---|
144 |
|
---|
145 | :error_repack_dir_not_found
|
---|
146 | echo syntax error: The repack directory was not found: "%_MY_REPACK_DIR%"
|
---|
147 | goto end_failed
|
---|
148 |
|
---|
149 | :error_extpack_not_found
|
---|
150 | echo syntax error: Specified extension pack not found: "%_MY_OPT_EXTPACK%"
|
---|
151 | goto end_failed
|
---|
152 |
|
---|
153 | :error_enterprise_extpack_not_found
|
---|
154 | echo syntax error: Specified enterprise extension pack not found: "%_MY_OPT_EXTPACK_ENTERPRISE%"
|
---|
155 | goto end_failed
|
---|
156 |
|
---|
157 | :error_signed_not_found
|
---|
158 | echo syntax error: Zip with signed drivers not found: "%_MY_OPT_SIGNED%"
|
---|
159 | goto end_failed
|
---|
160 |
|
---|
161 |
|
---|
162 | :no_more_arguments
|
---|
163 | rem
|
---|
164 | rem Validate and adjust specified options.
|
---|
165 | rem
|
---|
166 |
|
---|
167 | if not exist "%_MY_OPT_UNTAR_DIR%" goto error_vboxall_untar_dir_not_found
|
---|
168 |
|
---|
169 | set _MY_BINDIR=%_MY_OPT_UNTAR_DIR%\bin
|
---|
170 | if not exist "%_MY_BINDIR%" goto error_bindir_not_found
|
---|
171 |
|
---|
172 | set _MY_REPACK_DIR=%_MY_OPT_UNTAR_DIR%\repack
|
---|
173 | if not exist "%_MY_REPACK_DIR%" goto error_repack_dir_not_found
|
---|
174 |
|
---|
175 | if not exist "%_MY_OPT_EXTPACK%" goto error_extpack_not_found
|
---|
176 | if not ".%_MY_OPT_EXTPACK_ENTERPRISE%" == "." if not exist "%_MY_OPT_EXTPACK_ENTERPRISE%" goto error_enterprise_extpack_not_found
|
---|
177 |
|
---|
178 | if not exist "%_MY_OPT_SIGNED%" goto error_signed_not_found
|
---|
179 |
|
---|
180 | rem Make sure the output dir exists.
|
---|
181 | if not exist "%_MY_OPT_OUTDIR%" (mkdir "%_MY_OPT_OUTDIR%" || goto end_failed)
|
---|
182 |
|
---|
183 | rem
|
---|
184 | rem Unpacking the driver zip.
|
---|
185 | rem
|
---|
186 | echo **************************************************************************
|
---|
187 | echo * Unpacking signed drivers...
|
---|
188 | echo **************************************************************************
|
---|
189 | cd /d "%_MY_REPACK_DIR%" || goto end_failed
|
---|
190 | call "%_MY_REPACK_DIR%\UnpackBlessedDrivers.cmd" -n -b "%_MY_BINDIR%" -i "%_MY_OPT_SIGNED%" || goto end_failed
|
---|
191 | echo .
|
---|
192 |
|
---|
193 |
|
---|
194 | rem
|
---|
195 | rem Do the work.
|
---|
196 | rem
|
---|
197 | echo **************************************************************************
|
---|
198 | echo * Repackaging installers
|
---|
199 | echo **************************************************************************
|
---|
200 | echo * Compiling WIX...
|
---|
201 | cd /d "%_MY_REPACK_DIR%" || goto end_failed
|
---|
202 | for %%i in (1-*.cmd) do (call %%i || goto end_failed)
|
---|
203 | echo .
|
---|
204 |
|
---|
205 | echo * Linking WIX...
|
---|
206 | for %%i in (2-*.cmd) do (call %%i || goto end_failed)
|
---|
207 | echo .
|
---|
208 |
|
---|
209 | echo * Applying language patches to MSI...
|
---|
210 | for %%i in (3-*.cmd) do (call %%i || goto end_failed)
|
---|
211 | echo .
|
---|
212 |
|
---|
213 | echo * Creating multi arch installer...
|
---|
214 | for %%i in (4-*.cmd) do (call %%i || goto end_failed)
|
---|
215 | echo .
|
---|
216 |
|
---|
217 |
|
---|
218 | set _MY_OUT_FILES=
|
---|
219 | cd /d "%_MY_REPACK_DIR%" || goto end_failed
|
---|
220 | for %%i in (VBoxMerge*msm) do (
|
---|
221 | copy /y "%%i" "%_MY_OPT_OUTDIR%" || goto end_failed
|
---|
222 | call set _MY_OUT_FILES=%%_MY_OUT_FILES%% %%~nxi
|
---|
223 | )
|
---|
224 | for %%i in (VirtualBox-*MultiArch*exe) do (
|
---|
225 | copy /y "%%i" "%_MY_OPT_OUTDIR%" || goto end_failed
|
---|
226 | call set _MY_OUT_FILES=%%_MY_OUT_FILES%% %%~nxi
|
---|
227 | )
|
---|
228 |
|
---|
229 |
|
---|
230 | rem
|
---|
231 | rem Repack the extension packs.
|
---|
232 | rem
|
---|
233 | echo **************************************************************************
|
---|
234 | echo * Repacking extension packs.
|
---|
235 | echo **************************************************************************
|
---|
236 | cd /d "%_MY_REPACK_DIR%" || goto end_failed
|
---|
237 |
|
---|
238 | echo * Regular PUEL...
|
---|
239 | set _MY_TMP_OUT=%_MY_OPT_EXTPACK%
|
---|
240 | for %%i in (%_MY_TMP_OUT%) do (
|
---|
241 | set _MY_TMP_OUT=%_MY_OPT_OUTDIR%\%%~nxi
|
---|
242 | call set _MY_OUT_FILES=%%_MY_OUT_FILES%% %%~nxi
|
---|
243 | )
|
---|
244 | call "%_MY_REPACK_DIR%\RepackExtPack.cmd" --bindir-amd64 "%_MY_BINDIR%" --bindir-x86 "%_MY_BINDIR%" ^
|
---|
245 | --input "%_MY_OPT_EXTPACK%" --output "%_MY_TMP_OUT%" || goto end_failed
|
---|
246 |
|
---|
247 | if ".%_MY_OPT_EXTPACK_ENTERPRISE%" == "." goto no_enterprise_repacking
|
---|
248 | echo * Enterprise PUEL...
|
---|
249 | set _MY_TMP_OUT=%_MY_OPT_EXTPACK_ENTERPRISE%
|
---|
250 | for %%i in (%_MY_TMP_OUT%) do (
|
---|
251 | set _MY_TMP_OUT=%_MY_OPT_OUTDIR%\%%~nxi
|
---|
252 | call set _MY_OUT_FILES=%%_MY_OUT_FILES%% %%~nxi
|
---|
253 | )
|
---|
254 | call "%_MY_REPACK_DIR%\RepackExtPack.cmd" --bindir-amd64 "%_MY_BINDIR%" --bindir-x86 "%_MY_BINDIR%" ^
|
---|
255 | --input "%_MY_OPT_EXTPACK_ENTERPRISE%" --output "%_MY_TMP_OUT%" || goto end_failed
|
---|
256 | :no_enterprise_repacking
|
---|
257 | @cd /d "%_MY_SAVED_CD%"
|
---|
258 |
|
---|
259 | rem
|
---|
260 | rem That's that.
|
---|
261 | rem
|
---|
262 | echo **************************************************************************
|
---|
263 | echo * The third and final step is done.
|
---|
264 | echo *
|
---|
265 | echo * Successfully created:
|
---|
266 | for %%i in (%_MY_OUT_FILES%) do echo * "%_MY_OPT_OUTDIR%\%%i"
|
---|
267 | goto end
|
---|
268 |
|
---|
269 |
|
---|
270 | :end_failed
|
---|
271 | @cd /d "%_MY_SAVED_CD%"
|
---|
272 | @endlocal
|
---|
273 | @endlocal
|
---|
274 | @echo * Failed!
|
---|
275 | @exit /b 1
|
---|
276 |
|
---|
277 | :end
|
---|
278 | @cd /d "%_MY_SAVED_CD%"
|
---|
279 | @endlocal
|
---|
280 | @endlocal
|
---|
281 |
|
---|
282 |
|
---|