VirtualBox

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

Last change on this file since 82468 was 82468, checked in by vboxsync, 5 years ago

RepackGA scripts: updating repacking scripts. bugref:9587

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 5.4 KB
Line 
1@echo off
2rem $Id: UnpackBlessedDrivers.cmd 82468 2019-12-06 16:32:09Z vboxsync $
3rem rem @file
4rem Windows NT batch script for unpacking drivers after being signed.
5rem
6
7rem
8rem Copyright (C) 2018-2019 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=VBoxDrv VBoxNetAdp6 VBoxNetLwf VBoxUSB VBoxUSBMon
28set _MY_DRIVER_BASE_NAMES=VBoxDrv VBoxNetAdp6 VBoxNetLwf VBoxUSB VBoxUSBMon
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
59
60echo syntax error: Unknown option: %1
61echo Try --help to list valid options.
62goto end_failed
63
64:argument_loop_next_with_value
65shift
66shift
67goto argument_loop
68
69:opt_b
70if ".%~2" == "." goto syntax_error_missing_value
71set _MY_OPT_BINDIR=%~2
72goto argument_loop_next_with_value
73
74:opt_h
75echo This script unpacks the zip-file containing the blessed driver files from
76echo Microsoft, replacing original files in the bin directory. The catalog files
77echo will be signed again and the Microsoft signature merged with ours.
78echo .
79echo Usage: UnpackBlessedDrivers.cmd [-b bindir] [-n/--no-sign-cat] [-v/--no-sign-verify] -i input.zip
80echo .
81echo Warning! This script should normally be invoked from the repack directory
82goto end_failed
83
84:opt_i
85if ".%~2" == "." goto syntax_error_missing_value
86set _MY_OPT_INPUT=%~2
87goto argument_loop_next_with_value
88
89:opt_n
90set _MY_OPT_SIGN_CAT=0
91shift
92goto argument_loop
93
94:opt_v
95set _MY_OPT_SIGN_VERIFY=0
96shift
97goto argument_loop
98
99:syntax_error_missing_value
100echo syntax error: missing or empty option value after %1
101goto end_failed
102
103:error_bindir_does_not_exist
104echo syntax error: Specified BIN directory does not exist: "%_MY_OPT_BINDIR%"
105goto end_failed
106
107:error_input_not_found
108echo error: Input file does not exist: "%_MY_OPT_INPUT%"
109goto end_failed
110
111:no_more_arguments
112rem validate specified options
113if not exist "%_MY_OPT_BINDIR%" goto error_bindir_does_not_exist
114
115rem figure defaults here: if ".%_MY_OPT_INPUT%" == "." if exist "%_MY_OPT_BINDIR%\x86" set _MY_OPT_INPUT=VBoxDrivers-amd64.cab
116rem figure defaults here: if ".%_MY_OPT_INPUT%" == "." set _MY_OPT_INPUT=VBoxDrivers-x86.cab
117if not exist "%_MY_OPT_INPUT%" goto error_input_not_found
118
119rem
120rem Unpack the stuff.
121rem We ignore error level 1 here as that is what unzip returns on warning (slashes).
122rem
123"%_MY_UNZIP%" -o -j "%_MY_OPT_INPUT%" -d "%_MY_OPT_BINDIR%" && goto unzip_okay
124if NOT ERRORLEVEL 1 goto end_failed
125:unzip_okay
126
127if ".%_MY_OPT_SIGN_VERIFY%" == ".0" goto no_sign_verify
128rem
129rem Verify it against the PreW10 catalog files we saved.
130rem
131set _MY_SIGNTOOL=%KBUILD_DEVTOOLS%\win.x86\sdk\v8.1\bin\x86\signtool.exe
132if not exist "%_MY_SIGNTOOL%" set _MY_SIGNTOOL=%KBUILD_DEVTOOLS%\win.x86\selfsign\r3\signtool.exe
133
134for %%d in (%_MY_DRIVER_BASE_NAMES%) do (
135 @echo * Verifying %%d against %%d.cat...
136 "%_MY_SIGNTOOL%" verify /kp /c "%_MY_OPT_BINDIR%\%%d.cat" "%_MY_OPT_BINDIR%\%%d.inf" || goto end_failed
137 "%_MY_SIGNTOOL%" verify /kp /c "%_MY_OPT_BINDIR%\%%d.cat" "%_MY_OPT_BINDIR%\%%d.sys" || goto end_failed
138 @echo * Verifying %%d against %%d-PreW10.cat...
139 "%_MY_SIGNTOOL%" verify /kp /c "%_MY_OPT_BINDIR%\%%d-PreW10.cat" "%_MY_OPT_BINDIR%\%%d.inf" || goto end_failed
140 "%_MY_SIGNTOOL%" verify /kp /c "%_MY_OPT_BINDIR%\%%d-PreW10.cat" "%_MY_OPT_BINDIR%\%%d.sys" || goto end_failed
141)
142:no_sign_verify
143
144rem
145rem Modify the catalog signatures.
146rem
147if "%_MY_OPT_SIGN_CAT%" == "0" goto no_sign_cat
148set PATH=%PATH%;%_MY_OPT_BINDIR%
149for %%d in (%_MY_DRIVER_BASE_NAMES%) do (
150 copy /y "%_MY_OPT_BINDIR%\%%d.cat" "%_MY_OPT_BINDIR%\%%d.cat.ms" || goto end_failed
151 call sign-dual.cmd "%_MY_OPT_BINDIR%\%%d.cat" || goto end_failed
152 "%_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
153)
154:no_sign_cat
155goto end
156
157:end_failed
158@echo failed (%ERRORLEVEL%)
159@endlocal
160@endlocal
161@exit /b 1
162
163:end
164@endlocal
165@endlocal
166
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