VirtualBox

source: vbox/trunk/src/VBox/Installer/win/Scripts/UnpackBlessedDrivers.cmd@ 94280

Last change on this file since 94280 was 94159, checked in by vboxsync, 3 years ago

Repack scripts: Tell the script unpacking the drivers to check GA files if appropriate, instead of telling it to skip the sanity checking. The re-signing for older Windows version should work, except that the merging of the MS signature might be removed next.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 5.6 KB
Line 
1@echo off
2rem $Id: UnpackBlessedDrivers.cmd 94159 2022-03-10 19:22:05Z vboxsync $
3rem rem @file
4rem Windows NT batch script for unpacking drivers after being signed.
5rem
6
7rem
8rem Copyright (C) 2018-2022 Oracle Corporation
9rem
10rem This file is part of VirtualBox Open Source Edition (OSE), as
11rem available from http://www.virtualbox.org. This file is free software;
12rem you can redistribute it and/or modify it under the terms of the GNU
13rem General Public License (GPL) as published by the Free Software
14rem Foundation, in version 2 as it comes in the "COPYING" file of the
15rem VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16rem hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17rem
18
19
20setlocal ENABLEEXTENSIONS
21setlocal
22
23rem
24rem Globals and Check for environment variables we need.
25rem
26if ".%KBUILD_DEVTOOLS%" == "." (echo KBUILD_DEVTOOLS is not set & goto end_failed)
27set _MY_DRIVER_BASE_NAMES=VBoxSup VBoxNetAdp6 VBoxNetLwf VBoxUSB VBoxUSBMon
28set _MY_GUEST_ADDITIONS_DRIVER_BASE_NAMES=VBoxVideo VBoxWddm VBoxGuest VBoxMouse
29set _MY_UNZIP=%KBUILD_DEVTOOLS%\win.x86\bin\unzip.exe
30if not exist "%_MY_UNZIP%" (echo "%_MY_UNZIP%" does not exist & goto end_failed)
31
32rem
33rem Parse arguments.
34rem
35set _MY_OPT_BINDIR=..\bin
36set _MY_OPT_INPUT=
37set _MY_OPT_SIGN_CAT=1
38set _MY_OPT_SIGN_VERIFY=1
39
40:argument_loop
41if ".%1" == "." goto no_more_arguments
42
43if ".%1" == ".-h" goto opt_h
44if ".%1" == ".-?" goto opt_h
45if ".%1" == "./h" goto opt_h
46if ".%1" == "./H" goto opt_h
47if ".%1" == "./?" goto opt_h
48if ".%1" == ".-help" goto opt_h
49if ".%1" == ".--help" goto opt_h
50
51if ".%1" == ".-b" goto opt_b
52if ".%1" == ".--bindir" goto opt_b
53if ".%1" == ".-i" goto opt_i
54if ".%1" == ".--input" goto opt_i
55if ".%1" == ".-n" goto opt_n
56if ".%1" == ".--no-sign-cat" goto opt_n
57if ".%1" == ".-v" goto opt_v
58if ".%1" == ".--no-sign-verify" goto opt_v
59if ".%1" == ".--guest-additions" goto opt_ga
60
61echo syntax error: Unknown option: %1
62echo Try --help to list valid options.
63goto end_failed
64
65:argument_loop_next_with_value
66shift
67shift
68goto argument_loop
69
70:opt_b
71if ".%~2" == "." goto syntax_error_missing_value
72set _MY_OPT_BINDIR=%~2
73goto argument_loop_next_with_value
74
75:opt_h
76echo This script unpacks the zip-file containing the blessed driver files from
77echo Microsoft, replacing original files in the bin directory. The catalog files
78echo will be signed again and the Microsoft signature merged with ours.
79echo .
80echo Usage: UnpackBlessedDrivers.cmd [-b bindir] [-n/--no-sign-cat] [-v/--no-sign-verify] -i input.zip
81echo .
82echo Warning! This script should normally be invoked from the repack directory
83goto end_failed
84
85:opt_i
86if ".%~2" == "." goto syntax_error_missing_value
87set _MY_OPT_INPUT=%~2
88goto argument_loop_next_with_value
89
90:opt_n
91set _MY_OPT_SIGN_CAT=0
92shift
93goto argument_loop
94
95:opt_v
96set _MY_OPT_SIGN_VERIFY=0
97shift
98goto argument_loop
99
100:opt_ga
101set _MY_DRIVER_BASE_NAMES=%_MY_GUEST_ADDITIONS_DRIVER_BASE_NAMES%
102shift
103goto argument_loop
104
105:syntax_error_missing_value
106echo syntax error: missing or empty option value after %1
107goto end_failed
108
109:error_bindir_does_not_exist
110echo syntax error: Specified BIN directory does not exist: "%_MY_OPT_BINDIR%"
111goto end_failed
112
113:error_input_not_found
114echo error: Input file does not exist: "%_MY_OPT_INPUT%"
115goto end_failed
116
117:no_more_arguments
118rem validate specified options
119if not exist "%_MY_OPT_BINDIR%" goto error_bindir_does_not_exist
120
121rem figure defaults here: if ".%_MY_OPT_INPUT%" == "." if exist "%_MY_OPT_BINDIR%\x86" set _MY_OPT_INPUT=VBoxDrivers-amd64.cab
122rem figure defaults here: if ".%_MY_OPT_INPUT%" == "." set _MY_OPT_INPUT=VBoxDrivers-x86.cab
123if not exist "%_MY_OPT_INPUT%" goto error_input_not_found
124
125rem
126rem Unpack the stuff.
127rem We ignore error level 1 here as that is what unzip returns on warning (slashes).
128rem
129"%_MY_UNZIP%" -o -j "%_MY_OPT_INPUT%" -d "%_MY_OPT_BINDIR%" && goto unzip_okay
130if NOT ERRORLEVEL 1 goto end_failed
131:unzip_okay
132
133if ".%_MY_OPT_SIGN_VERIFY%" == ".0" goto no_sign_verify
134rem
135rem Verify it against the PreW10 catalog files we saved.
136rem
137set _MY_SIGNTOOL=%KBUILD_DEVTOOLS%\win.x86\sdk\v8.1\bin\x86\signtool.exe
138if not exist "%_MY_SIGNTOOL%" set _MY_SIGNTOOL=%KBUILD_DEVTOOLS%\win.x86\selfsign\r3\signtool.exe
139
140for %%d in (%_MY_DRIVER_BASE_NAMES%) do (
141 @echo * Verifying %%d against %%d.cat...
142 "%_MY_SIGNTOOL%" verify /kp /c "%_MY_OPT_BINDIR%\%%d.cat" "%_MY_OPT_BINDIR%\%%d.inf" || goto end_failed
143 "%_MY_SIGNTOOL%" verify /kp /c "%_MY_OPT_BINDIR%\%%d.cat" "%_MY_OPT_BINDIR%\%%d.sys" || goto end_failed
144 @echo * Verifying %%d against %%d-PreW10.cat...
145 "%_MY_SIGNTOOL%" verify /kp /c "%_MY_OPT_BINDIR%\%%d-PreW10.cat" "%_MY_OPT_BINDIR%\%%d.inf" || goto end_failed
146 "%_MY_SIGNTOOL%" verify /kp /c "%_MY_OPT_BINDIR%\%%d-PreW10.cat" "%_MY_OPT_BINDIR%\%%d.sys" || goto end_failed
147)
148:no_sign_verify
149
150rem
151rem Modify the catalog signatures.
152rem
153if "%_MY_OPT_SIGN_CAT%" == "0" goto no_sign_cat
154set PATH=%PATH%;%_MY_OPT_BINDIR%
155for %%d in (%_MY_DRIVER_BASE_NAMES%) do (
156 copy /y "%_MY_OPT_BINDIR%\%%d.cat" "%_MY_OPT_BINDIR%\%%d.cat.ms" || goto end_failed
157 call sign-dual.cmd "%_MY_OPT_BINDIR%\%%d.cat" || goto end_failed
158 "%_MY_OPT_BINDIR%\tools\RTSignTool.exe" add-nested-cat-signature -v "%_MY_OPT_BINDIR%\%%d.cat" "%_MY_OPT_BINDIR%\%%d.cat.ms" || goto end_failed
159)
160:no_sign_cat
161goto end
162
163:end_failed
164@echo failed (%ERRORLEVEL%)
165@endlocal
166@endlocal
167@exit /b 1
168
169:end
170@endlocal
171@endlocal
172
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette