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