VirtualBox

source: vbox/trunk/src/VBox/Installer/win/Scripts/RepackExtPack.cmd@ 78271

Last change on this file since 78271 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 7.4 KB
Line 
1@echo off
2rem $Id: RepackExtPack.cmd 76553 2019-01-01 01:45:53Z vboxsync $
3rem rem @file
4rem Windows NT batch script for repacking an extension pack with blessed .r0 files.
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 Check for environment variables we need.
25rem
26if ".%KBUILD_DEVTOOLS%" == "." (echo KBUILD_DEVTOOLS is not set & goto end_failed)
27rem if ".%KBUILD_BIN_PATH%" == "." (echo KBUILD_BIN_PATH is not set & goto end_failed)
28
29rem
30rem Parse arguments.
31rem
32set _MY_OPT_BINDIR_X86=..\..\..\win.x86\@KBUILD_TYPE@\bin
33set _MY_OPT_BINDIR_AMD64=..\..\..\win.amd64\@KBUILD_TYPE@\bin
34set _MY_OPT_INPUT=
35set _MY_OPT_OUTPUT=
36set _MY_OPT_STAGE_DIR=.\repack-extpack-%RANDOM%
37for %%i in (%_MY_OPT_STAGE_DIR%) do set _MY_OPT_STAGE_DIR=%%~fi
38set _MY_OPT_SIGN_CAT=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" == ".-a" goto opt_a
52if ".%1" == ".--bindir-amd64" goto opt_a
53if ".%1" == ".-b" goto opt_b
54if ".%1" == ".--bindir-x86" goto opt_b
55if ".%1" == ".-i" goto opt_i
56if ".%1" == ".--input" goto opt_i
57if ".%1" == ".-o" goto opt_o
58if ".%1" == ".--output" goto opt_o
59if ".%1" == ".-s" goto opt_s
60if ".%1" == ".--stage-dir" goto opt_s
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_a
71if ".%~2" == "." goto syntax_error_missing_value
72set _MY_OPT_BINDIR_AMD64=%~f2
73goto argument_loop_next_with_value
74
75:opt_b
76if ".%~2" == "." goto syntax_error_missing_value
77set _MY_OPT_BINDIR_X86=%~f2
78goto argument_loop_next_with_value
79
80:opt_h
81echo This script repacks an extension pack replacing windows .r0 files with
82echo blessed copies from the bin directory. The ASSUMPTION here is that prior
83echo to invoking this script, the UnpackBlessedDrivers.cmd script was executed
84echo both for win.amd64 and win.x86.
85echo .
86echo Usage: RepackExtPack.cmd [-b bindir-x86] [-a bindir-amd64] [-s staging-dir]
87echo -i input.vbox-extpack -o output.vbox-extpack
88echo .
89echo Warning! This script should normally be invoked from the win.x86 repack directory.
90goto end_failed
91
92:opt_i
93if ".%~2" == "." goto syntax_error_missing_value
94set _MY_OPT_INPUT=%~f2
95goto argument_loop_next_with_value
96
97:opt_o
98if ".%~2" == "." goto syntax_error_missing_value
99set _MY_OPT_OUTPUT=%~f2
100goto argument_loop_next_with_value
101
102:opt_s
103if ".%~2" == "." goto syntax_error_missing_value
104set _MY_OPT_STAGE_DIR=%~f2
105goto argument_loop_next_with_value
106
107:syntax_error_missing_value
108echo syntax error: missing or empty option value after %1
109goto end_failed
110
111:error_bindir_amd64_does_not_exist
112echo syntax error: Specified AMD64 BIN directory does not exist: "%_MY_OPT_BINDIR_AMD64%"
113goto end_failed
114
115:error_bindir_x86_does_not_exist
116echo syntax error: Specified x86 BIN directory does not exist: "%_MY_OPT_BINDIR_X86%"
117goto end_failed
118
119:error_input_not_found
120echo error: Input file does not exist: "%_MY_OPT_INPUT%"
121goto end_failed
122
123:error_stage_dir_exists
124echo error: Temporary staging directory exists: "%_MY_OPT_STAGE_DIR%"
125goto end_failed
126
127:no_more_arguments
128rem
129rem Validate and adjust specified options.
130rem
131if not exist "%_MY_OPT_BINDIR_X86%" goto error_bindir_x86_does_not_exist
132if not exist "%_MY_OPT_BINDIR_AMD64%" goto error_bindir_amd64_does_not_exist
133
134if ".%_MY_OPT_INPUT%" == "." set _MY_OPT_INPUT=%_MY_OPT_BINDIR_X86%\Oracle_VM_VirtualBox_Extension_Pack.vbox-extpack
135if not exist "%_MY_OPT_INPUT%" goto error_input_not_found
136
137if ".%_MY_OPT_OUTPUT%" == "." for %%i in ("%_MY_OPT_INPUT%") do set _MY_OPT_OUTPUT=.\%%~nxi
138
139rem Make _MY_OPT_STAGE_DIR absolute.
140if exist "%_MY_OPT_STAGE_DIR%" goto error_stage_dir_exists
141
142rem
143rem Modify PATH to facilitate using our zip, gzip and manifest tools
144rem
145rem TODO: Use RTTar for creation too.
146rem TODO: Not sure how well the bsdtar output actually work with 5.1...
147rem TODO: Check whether we need stupid cygwin to get the right execute bits (x) on unix.
148rem
149set PATH=%PATH%;%_MY_OPT_BINDIR_AMD64%
150set _MY_TOOL_TAR_EXPAND="%_MY_OPT_BINDIR_AMD64%\tools\RTTar.exe" -x
151set _MY_TOOL_TAR_CREATE="%KBUILD_DEVTOOLS%\win.x86\gnuwin32\r1\bin\bsdtar.exe" -c --format ustar
152set _MY_TOOL_GZIP=%_MY_OPT_BINDIR_AMD64%\tools\RTGzip.exe
153set _MY_TOOL_MANIFEST=%_MY_OPT_BINDIR_AMD64%\tools\RTManifest.exe
154
155rem
156rem Unpack the extension pack.
157rem
158echo * Unpacking "%_MY_OPT_INPUT" to "%_MY_OPT_STAGE_DIR%"...
159mkdir "%_MY_OPT_STAGE_DIR%" || goto end_failed
160%_MY_TOOL_TAR_EXPAND% -vzf "%_MY_OPT_INPUT%" -C "%_MY_OPT_STAGE_DIR%" || goto end_failed_cleanup
161
162rem
163rem Copy over the blessed .r0 files.
164rem
165echo * Copying over blessed .r0 binaries...
166if not exist "%_MY_OPT_STAGE_DIR%\win.x86" goto no_win_x86
167for %%i in ("%_MY_OPT_STAGE_DIR%\win.x86\*.r0") do (
168 echo -=- %%i
169 copy /y "%_MY_OPT_BINDIR_X86%\%%~nxi" "%_MY_OPT_STAGE_DIR%\win.x86" || goto end_failed_cleanup
170)
171:no_win_x86
172
173for %%i in ("%_MY_OPT_STAGE_DIR%\win.amd64\*.r0") do (
174 echo -=- %%i
175 copy /y "%_MY_OPT_BINDIR_AMD64%\%%~nxi" "%_MY_OPT_STAGE_DIR%\win.amd64" || goto end_failed_cleanup
176)
177
178rem
179rem Recreate the manifest.
180rem
181echo * Collecting files for manifest...
182set _MY_MANIFEST_FILES=
183for /D %%d in ("%_MY_OPT_STAGE_DIR%\*") do (
184 for %%f in ("%%d\*") do call set _MY_MANIFEST_FILES=%%_MY_MANIFEST_FILES%% %%~nxd/%%~nxf
185)
186for %%f in ("%_MY_OPT_STAGE_DIR%\*") do (
187 if not "%%~nxf" == "ExtPack.manifest" if not "%%~nxf" == "ExtPack.signature" call set _MY_MANIFEST_FILES=%%_MY_MANIFEST_FILES%% %%~nxf
188)
189rem echo _MY_MANIFEST_FILES=%_MY_MANIFEST_FILES%
190
191echo * Creating manifest...
192echo on
193"%_MY_TOOL_MANIFEST%" --manifest "%_MY_OPT_STAGE_DIR%\ExtPack.manifest" --chdir "%_MY_OPT_STAGE_DIR%" %_MY_MANIFEST_FILES% || goto end_failed_cleanup
194@echo off
195
196rem
197rem Repackage the damn thing.
198rem
199@echo * Packing extension pack...
200
201echo on
202%_MY_TOOL_TAR_CREATE% -vf "%_MY_OPT_OUTPUT%.tmp" -C "%_MY_OPT_STAGE_DIR%" . || goto end_failed_cleanup
203"%_MY_TOOL_GZIP%" -9 -n "%_MY_OPT_OUTPUT%.tmp" || goto end_failed_cleanup
204move /Y "%_MY_OPT_OUTPUT%.tmp.gz" "%_MY_OPT_OUTPUT%" || goto end_failed_cleanup
205echo off
206
207rem
208rem Cleanup and we're good.
209rem
210echo * Cleaning up...
211rmdir /s /q "%_MY_OPT_STAGE_DIR%"
212
213echo * Successfully created: "%_MY_OPT_OUTPUT%
214goto end
215
216:end_failed_cleanup
217@rmdir /s /q "%_MY_OPT_STAGE_DIR%"
218@if exist "%_MY_OPT_OUTPUT%.tmp" del "%_MY_OPT_OUTPUT%.tmp"
219@if exist "%_MY_OPT_OUTPUT%.tmp.gz" del "%_MY_OPT_OUTPUT%.tmp.gz"
220
221:end_failed
222@endlocal
223@endlocal
224@echo * Failed!
225@exit /b 1
226
227:end
228@endlocal
229@endlocal
230
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