VirtualBox

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

Last change on this file since 72041 was 72041, checked in by vboxsync, 7 years ago

Installer/win: Added script for repacking an extension pack. bugref:8691 [fix stupid for expansion]

  • 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 72041 2018-04-26 14:02:34Z 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 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=..\bin
33set _MY_OPT_BINDIR_AMD64=
34set _MY_OPT_INPUT=
35set _MY_OPT_OUTPUT=
36set _MY_OPT_STAGE_DIR=.\repack-extpack-%RANDOM%
37set _MY_OPT_SIGN_CAT=1
38
39:argument_loop
40if ".%1" == "." goto no_more_arguments
41
42if ".%1" == ".-h" goto opt_h
43if ".%1" == ".-?" goto opt_h
44if ".%1" == "./h" goto opt_h
45if ".%1" == "./H" goto opt_h
46if ".%1" == "./?" goto opt_h
47if ".%1" == ".-help" goto opt_h
48if ".%1" == ".--help" goto opt_h
49
50if ".%1" == ".-a" goto opt_a
51if ".%1" == ".--bindir-amd64" goto opt_a
52if ".%1" == ".-b" goto opt_b
53if ".%1" == ".--bindir-x86" goto opt_b
54if ".%1" == ".-i" goto opt_i
55if ".%1" == ".--input" goto opt_i
56if ".%1" == ".-o" goto opt_o
57if ".%1" == ".--output" goto opt_o
58if ".%1" == ".-s" goto opt_s
59if ".%1" == ".--stage-dir" goto opt_s
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_a
70if ".%2" == "." goto syntax_error_missing_value
71set _MY_OPT_BINDIR_AMD64=%2
72goto argument_loop_next_with_value
73
74:opt_b
75if ".%2" == "." goto syntax_error_missing_value
76set _MY_OPT_BINDIR_X86=%2
77goto argument_loop_next_with_value
78
79:opt_h
80echo This script repacks an extension pack replacing windows .r0 files with
81echo blessed copies from the bin directory. The ASSUMPTION here is that prior
82echo to invoking this script, the UnpackBlessedDrivers.cmd script was executed
83echo both for win.amd64 and win.x86.
84echo .
85echo Usage: RepackExtPack.cmd [-b bindir-x86] [-a bindir-amd64] [-s staging-dir]
86echo -i input.vbox-extpack -o output.vbox-extpack
87echo .
88echo Warning! This script should normally be invoked from the win.x86 repack directory.
89goto end_failed
90
91:opt_i
92if ".%2" == "." goto syntax_error_missing_value
93set _MY_OPT_INPUT=%2
94goto argument_loop_next_with_value
95
96:opt_o
97if ".%2" == "." goto syntax_error_missing_value
98set _MY_OPT_OUTPUT=%2
99goto argument_loop_next_with_value
100
101:opt_s
102if ".%2" == "." goto syntax_error_missing_value
103set _MY_OPT_STAGE_DIR=%2
104goto argument_loop_next_with_value
105
106:syntax_error_missing_value
107echo syntax error: missing or empty option value after %1
108goto end_failed
109
110:error_bindir_amd64_does_not_exist
111echo syntax error: Specified AMD64 BIN directory does not exist: "%_MY_OPT_BINDIR_AMD64%"
112goto end_failed
113
114:error_bindir_x86_does_not_exist
115echo syntax error: Specified x86 BIN directory does not exist: "%_MY_OPT_BINDIR_X86%"
116goto end_failed
117
118:error_input_not_found
119echo error: Input file does not exist: "%_MY_OPT_INPUT%"
120goto end_failed
121
122:error_stage_dir_exists
123echo error: Temporary staging directory exists: "%_MY_OPT_STAGE_DIR%"
124goto end_failed
125
126:no_more_arguments
127rem validate specified options
128if not exist "%_MY_OPT_BINDIR_X86%" goto error_bindir_x86_does_not_exist
129
130if ".%_MY_OPT_BINDIR_AMD64%" == "." set _MY_OPT_BINDIR_AMD64=_MY_OPT_BINDIR_X86\..\..\..\win.amd64\release\bin
131if not exist "%_MY_OPT_BINDIR_AMD64%" goto error_bindir_amd64_does_not_exist
132
133if ".%_MY_OPT_INPUT%" == "." set _MY_OPT_INPUT=%_MY_OPT_BINDIR_X86%\Oracle_VM_VirtualBox_Extension_Pack.vbox-extpack
134if not exist "%_MY_OPT_INPUT%" goto error_input_not_found
135
136if ".%_MY_OPT_OUTPUT%" == "." set _MY_OPT_OUTPUT=Oracle_VM_VirtualBox_Extension_Pack.vbox-extpack
137
138rem Make _MY_OPT_STAGE_DIR absolute.
139for %%i in (%_MY_OPT_STAGE_DIR%) do set _MY_OPT_STAGE_DIR=%%~fi
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