Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

318 lines
10 KiB

  1. @REM -----------------------------------------------------------------
  2. @REM
  3. @REM drvcabck.cmd - VijeshS
  4. @REM Generates drvindex.inf files for each sku
  5. @REM
  6. @REM Copyright (c) Microsoft Corporation. All rights reserved.
  7. @REM
  8. @REM -----------------------------------------------------------------
  9. @if NOT defined HOST_PROCESSOR_ARCHITECTURE set HOST_PROCESSOR_ARCHITECTURE=%PROCESSOR_ARCHITECTURE%
  10. @if defined _CPCMAGIC goto CPCBegin
  11. @perl -x "%~f0" %*
  12. @goto :EOF
  13. #!perl
  14. use strict;
  15. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  16. use lib $ENV{RAZZLETOOLPATH};
  17. use PbuildEnv;
  18. use ParseArgs;
  19. sub Usage { print<<USAGE; exit(1) }
  20. drvcabck [-l <language>]
  21. Generates drvindex.inf files for each sku
  22. USAGE
  23. parseargs('?' => \&Usage);
  24. # *** TEMPLATE CODE ***
  25. $ENV{"_CPCMAGIC"}++;exit(system($0)>>8);
  26. __END__
  27. @:CPCBegin
  28. @set _CPCMAGIC=
  29. @setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
  30. @if not defined DEBUG echo off
  31. @REM *** CMD SCRIPT BELOW ***
  32. REM 1. Run INFSCAN per platform into <plat>.lst
  33. REM 2. Run cabcheck.exe taking as input <plat>.lst and the prod specific layout.inf for each product to give you the generated prod specific drvindex.gen.
  34. REM 3. Finally generate excdosnt.inf and copy drvindex.inf to the binaries directory.
  35. REM
  36. REM Note that winnt32/winnt is not smart enough to not copy files present in the driver cab
  37. REM when processing the [Files] section. However, it will still look for files when looking at
  38. REM BootFiles or the other sections associated with boot files.
  39. REM preconditions
  40. REM 1. infs have been generated in all binaries directories (srvinf, etc.)
  41. REM 2. ideally the PNF's have been generated for all the INF's
  42. REM BUGBUG "myarchitecture" is used inconsistantly below and should probably be removed
  43. REM cksku without -a defaults to _BuildArch
  44. REM ArchSwitch is based on _BuildArch
  45. REM Define "myarchitecture" as the architecture that we're processing.
  46. REM
  47. REM we use the %_BuildArch% variable if it's set, otherwise we fall back on
  48. REM %HOST_PROCESSOR_ARCHITECTURE%
  49. REM
  50. if not defined myarchitecture (
  51. if defined _BuildArch (
  52. set myarchitecture=%_BuildArch%
  53. ) else (
  54. set myarchitecture=%HOST_PROCESSOR_ARCHITECTURE%
  55. )
  56. )
  57. if not defined myarchitecture (
  58. call errmsg.cmd "variable myarchitecture not defined."
  59. goto end
  60. )
  61. REM
  62. REM this should expand into one of NTx86 NTamd64 NTia64
  63. REM new architectures require modification to infscan
  64. REM
  65. set InfScanSwitch=/V NT%_BuildArch%
  66. REM
  67. REM Do any per-arch overrides and setup ArchSwitch here
  68. REM
  69. if /i "%_BuildArch%" == "x86" (
  70. set ArchSwitch=i
  71. )
  72. if /i "%_BuildArch%" == "amd64" (
  73. set ArchSwitch=a
  74. )
  75. if /i "%_BuildArch%" == "ia64" (
  76. set ArchSwitch=m
  77. )
  78. REM
  79. REM now for common options
  80. REM ignore errors
  81. REM build out of date PNF's first (incremental hit)
  82. REM use 20 threads
  83. REM
  84. set InfScanSwitch=%InfScanSwitch% /I /G /T 1
  85. echo %myarchitecture%
  86. echo binaries = %_NTPostBld%
  87. REM Verify existence of build directory
  88. pushd .
  89. set scratchdir=%_NTPostBld%\congeal_scripts\drvgen
  90. call ExecuteCmd.cmd "if not exist %scratchdir% md %scratchdir%"
  91. cd /d %scratchdir%
  92. cd
  93. call ExecuteCmd.cmd "if exist ** del /f /q **"
  94. if errorlevel 1 popd& goto end
  95. set scratchsubdir=%scratchdir%\%lang%\%myarchitecture%
  96. call ExecuteCmd.cmd "if not exist %scratchsubdir% md %scratchsubdir%"
  97. if errorlevel 1 popd& goto end
  98. cd /d %scratchsubdir%
  99. cd
  100. call ExecuteCmd.cmd "if exist ** del /f /q **"
  101. REM
  102. REM Get the product flavors (per, bla, sbs, srv, ent, dtc) for the given language.
  103. REM Get the INF list for each product flavor
  104. REM (PRO is applicable to all languages.)
  105. REM
  106. cd /d %Razzletoolpath%\postbuildscripts
  107. cd
  108. if not exist %_NTPOSTBLD%\layout.inf (
  109. call errmsg.cmd "%_NTPOSTBLD%\Layout.Inf doesn't exist."
  110. popd
  111. goto end
  112. )
  113. set prods=
  114. echo Beginning INF Scanning
  115. call logmsg.cmd /t "Beginning INF Scanning"
  116. call logmsg.cmd "Scanning PRO INF's"
  117. call ExecuteCmd.cmd "infscan.exe %InfScanSwitch% /S %scratchsubdir%\pro.lst %_NTPOSTBLD%"
  118. if errorlevel 1 goto failscan
  119. perl %RazzleToolPath%\cksku.pm -t:per -l:%lang%
  120. if %errorlevel% EQU 0 (
  121. set prods=%prods% per
  122. REM get perinflayout.inf for later
  123. if exist %_NTPOSTBLD%\perinf\layout.inf (
  124. copy %_NTPOSTBLD%\perinf\layout.inf %scratchsubdir%\perinflayout.inf
  125. ) else (
  126. copy %_NTPOSTBLD%\layout.inf %scratchsubdir%\perinflayout.inf
  127. )
  128. call logmsg.cmd "Scanning PER INF's"
  129. call ExecuteCmd.cmd "infscan.exe %InfScanSwitch% /S %scratchsubdir%\per.lst /O perinf %_NTPOSTBLD%"
  130. if errorlevel 1 goto failscan
  131. )
  132. perl %RazzleToolPath%\cksku.pm -t:srv -l:%lang%
  133. if %errorlevel% EQU 0 (
  134. set prods=%prods% srv
  135. REM get srvinflayout.inf for later
  136. if exist %_NTPOSTBLD%\srvinf\layout.inf (
  137. copy %_NTPOSTBLD%\srvinf\layout.inf %scratchsubdir%\srvinflayout.inf
  138. ) else (
  139. copy %_NTPOSTBLD%\layout.inf %scratchsubdir%\srvinflayout.inf
  140. )
  141. call logmsg.cmd "Scanning SRV INF's"
  142. call ExecuteCmd.cmd "infscan.exe %InfScanSwitch% /S %scratchsubdir%\srv.lst /O srvinf %_NTPOSTBLD%"
  143. if errorlevel 1 goto failscan
  144. )
  145. perl %RazzleToolPath%\cksku.pm -t:bla -l:%lang%
  146. if %errorlevel% EQU 0 (
  147. set prods=%prods% bla
  148. REM get blainflayout.inf for later
  149. if exist %_NTPOSTBLD%\blainf\layout.inf (
  150. copy %_NTPOSTBLD%\blainf\layout.inf %scratchsubdir%\blainflayout.inf
  151. ) else if exist %_NTPOSTBLD%\srvinf\layout.inf (
  152. copy %_NTPOSTBLD%\srvinf\layout.inf %scratchsubdir%\blainflayout.inf
  153. ) else (
  154. copy %_NTPOSTBLD%\layout.inf %scratchsubdir%\blainflayout.inf
  155. )
  156. call logmsg.cmd "Scanning BLA INF's"
  157. call ExecuteCmd.cmd "infscan.exe %InfScanSwitch% /S %scratchsubdir%\bla.lst /O blainf /O srvinf %_NTPOSTBLD%"
  158. if errorlevel 1 goto failscan
  159. )
  160. perl %RazzleToolPath%\cksku.pm -t:sbs -l:%lang%
  161. if %errorlevel% EQU 0 (
  162. set prods=%prods% sbs
  163. REM get sbsinflayout.inf for later
  164. if exist %_NTPOSTBLD%\sbsinf\layout.inf (
  165. copy %_NTPOSTBLD%\sbsinf\layout.inf %scratchsubdir%\sbsinflayout.inf
  166. ) else if exist %_NTPOSTBLD%\srvinf\layout.inf (
  167. copy %_NTPOSTBLD%\srvinf\layout.inf %scratchsubdir%\sbsinflayout.inf
  168. ) else (
  169. copy %_NTPOSTBLD%\layout.inf %scratchsubdir%\sbsinflayout.inf
  170. )
  171. call logmsg.cmd "Scanning SBS INF's"
  172. call ExecuteCmd.cmd "infscan.exe %InfScanSwitch% /S %scratchsubdir%\sbs.lst /O sbsinf /O srvinf %_NTPOSTBLD%"
  173. if errorlevel 1 goto failscan
  174. )
  175. perl %RazzleToolPath%\cksku.pm -t:ads -l:%lang%
  176. if %errorlevel% EQU 0 (
  177. set prods=%prods% ent
  178. REM get entinflayout.inf for later
  179. if exist %_NTPOSTBLD%\entinf\layout.inf (
  180. copy %_NTPOSTBLD%\entinf\layout.inf %scratchsubdir%\entinflayout.inf
  181. ) else if exist %_NTPOSTBLD%\srvinf\layout.inf (
  182. copy %_NTPOSTBLD%\srvinf\layout.inf %scratchsubdir%\entinflayout.inf
  183. ) else (
  184. copy %_NTPOSTBLD%\layout.inf %scratchsubdir%\entinflayout.inf
  185. )
  186. call logmsg.cmd "Scanning ADS INF's"
  187. call ExecuteCmd.cmd "infscan.exe %InfScanSwitch% /S %scratchsubdir%\ent.lst /O entinf /O srvinf %_NTPOSTBLD%"
  188. if errorlevel 1 goto failscan
  189. )
  190. perl %RazzleToolPath%\cksku.pm -t:dtc -l:%lang%
  191. if %errorlevel% EQU 0 (
  192. set prods=%prods% dtc
  193. REM get dtcinflayout.inf for later
  194. if exist %_NTPOSTBLD%\dtcinf\layout.inf (
  195. copy %_NTPOSTBLD%\dtcinf\layout.inf %scratchsubdir%\dtcinflayout.inf
  196. ) else if exist %_NTPOSTBLD%\entinf\layout.inf (
  197. copy %_NTPOSTBLD%\entinf\layout.inf %scratchsubdir%\dtcinflayout.inf
  198. ) else if exist %_NTPOSTBLD%\srvinf\layout.inf (
  199. copy %_NTPOSTBLD%\srvinf\layout.inf %scratchsubdir%\dtcinflayout.inf
  200. ) else (
  201. copy %_NTPOSTBLD%\layout.inf %scratchsubdir%\dtcinflayout.inf
  202. )
  203. call logmsg.cmd "Scanning DTC INF's"
  204. call ExecuteCmd.cmd "infscan.exe %InfScanSwitch% /S %scratchsubdir%\dtc.lst /O dtcinf /O entinf /O srvinf %_NTPOSTBLD%"
  205. if errorlevel 1 goto failscan
  206. )
  207. call logmsg.cmd /t "INF Scanning is complete"
  208. echo Running cabcheck
  209. REM Call cabcheck.exe to generate the drvindex.inf that we think is right
  210. REM PRO - The workstation case
  211. call ExecuteCmd.cmd "cabcheck.exe %_NTPostBld%\layout.inf %scratchsubdir%\pro.lst %scratchsubdir%\drvindex.gen /%ArchSwitch%"
  212. if errorlevel 1 (
  213. call errmsg.cmd "Cabcheck.exe Failed to auto-generate the drvindex.inf file"
  214. popd
  215. goto end
  216. )
  217. REM Copy the generated files to its final location.
  218. call ExecuteCmd.cmd "copy /Y %scratchsubdir%\drvindex.gen %_NTPostBld%\drvindex.inf"
  219. if errorlevel 1 (
  220. call errmsg.cmd "Could not copy generated drvindex.inf to %_NTPostBld%"
  221. popd
  222. goto end
  223. )
  224. REM generate the appropriate excdosnt.inf
  225. call ExecuteCmd.cmd "xdosnet %_NTPostBld%\layout.inf %_NTPostBld%\drvindex.inf 1 %scratchsubdir%\foodosnt %myarchitecture% %_NTPostBld%\excdosnt.inf %_NTPostBld%\exclude.inf"
  226. REM Now do the other products - PER BLA SBS SRV ENT DTC
  227. for %%i in (%prods%) do (
  228. call ExecuteCmd.cmd "cabcheck.exe %scratchsubdir%\%%iinflayout.inf %scratchsubdir%\%%i.lst %scratchsubdir%\%%iinfdrvindex.gen /%ArchSwitch%"
  229. if errorlevel 1 (
  230. call errmsg.cmd "Cabcheck.exe Failed to auto-generate the drvindex.inf file"
  231. popd
  232. goto end
  233. )
  234. REM Copy the generated files to its final location.
  235. call ExecuteCmd.cmd "copy /Y %scratchsubdir%\%%iinfdrvindex.gen %_NTPostBld%\%%iinf\drvindex.inf"
  236. if errorlevel 1 (
  237. call errmsg.cmd "Could not copy generated %%iinfdrvindex.gen to %_NTPostBld%\%%iinf\drvindex.inf"
  238. popd
  239. goto end
  240. )
  241. REM generate the appropriate excdosnt.inf
  242. call ExecuteCmd.cmd "xdosnet %scratchsubdir%\%%iinflayout.inf %_NTPostBld%\%%iinf\drvindex.inf 1 %scratchsubdir%\foodosnt %myarchitecture% %_NTPostBld%\%%iinf\excdosnt.inf %_NTPostBld%\%%iinf\exclude.inf"
  243. )
  244. cd
  245. call logmsg.cmd /t "drvindex.inf generation complete"
  246. goto end
  247. :failscan
  248. call errmsg.cmd "Failed running infscan - Run tools\postbuildscripts\drvcabck by itself to debug."
  249. popd
  250. goto end
  251. :end
  252. seterror.exe "%errors%"& goto :EOF