Source code of Windows XP (NT5)
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.

349 lines
8.8 KiB

  1. @echo off
  2. if defined _echo echo on
  3. if defined verbose echo on
  4. setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
  5. REM -------------------------------------------------------------------------------------------
  6. REM Template for the postbuild scripts:
  7. REM SD Location: %sdxroot%\tools\postbuildscripts
  8. REM
  9. REM (1) Code section description:
  10. REM PreMain - Developer adaptable code. Use this model and add your script params
  11. REM Main - Developer code section. This is where your work gets done.
  12. REM PostMain - Logging support code. No changes should be made here.
  13. REM
  14. REM (2) GetParams.pm - Usage
  15. REM run perl.exe GetParams.pm /? for complete usage
  16. REM
  17. REM (3) Reserved Variables -
  18. REM lang - The specified language. Defaults to USA.
  19. REM logfile - The path and filename of the logs file.
  20. REM logfile_bak - The path and filename of the logfile.
  21. REM errfile - The path and filename of the error file.
  22. REM tmpfile - The path and filename of the temp file.
  23. REM errors - The scripts errorlevel.
  24. REM script_name - The script name.
  25. REM script_args - The arguments passed to the script.
  26. REM CMD_LINE - The script name plus arguments passed to the script.
  27. REM _NTPostBld - Abstracts the language from the files path that
  28. REM postbuild operates on.
  29. REM _NTPostBld_Bak - Reserved support var.
  30. REM _temp_bak - Reserved support var.
  31. REM _logs_bak - Reserved support var.
  32. REM
  33. REM (4) Reserved Subs -
  34. REM Usage - Use this sub to discribe the scripts usage.
  35. REM ValidateParams - Use this sub to verify the parameters passed to the script.
  36. REM
  37. REM
  38. REM (8) Do not turn echo off, copy the 3 lines from the beginning of the template
  39. REM instead.
  40. REM
  41. REM (9) Use setlocal/endlocal as in this template.
  42. REM
  43. REM (10)Have your changes reviewed by a member of the US build team (ntbusa) and
  44. REM by a member of the international build team (ntbintl).
  45. REM
  46. REM -------------------------------------------------------------------------------------------
  47. REM PreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMain
  48. REM Begin PreProcessing Section - Adapt this section but do not remove support
  49. REM scripts or reorder section.
  50. REM PreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMain
  51. :PreMain
  52. REM
  53. REM Define SCRIPT_NAME. Used by the logging scripts.
  54. REM Define CMD_LINE. Used by the logging scripts.
  55. REM Define SCRIPT_ARGS. Used by the logging scripts.
  56. REM
  57. set SCRIPT_NAME=%~nx0
  58. set CMD_LINE=%script_name% %*
  59. set SCRIPT_ARGS=%*
  60. REM
  61. REM Parse the command line arguments - Add your scripts command line arguments
  62. REM as indicated by brackets.
  63. REM For complete usage run: perl.exe GetParams.pm /?
  64. REM
  65. for %%h in (./ .- .) do if ".%SCRIPT_ARGS%." == "%%h?." goto Usage
  66. REM call :GetParams -n <add required prams> -o l:<add optional params> -p "lang <add variable names>" %SCRIPT_ARGS%
  67. call :GetParams -o l: -p "lang" %SCRIPT_ARGS%
  68. if errorlevel 1 goto :End
  69. REM
  70. REM Set up the local enviroment extensions.
  71. REM
  72. call :LocalEnvEx -i
  73. if errorlevel 1 goto :End
  74. REM
  75. REM Validate the command line parameters.
  76. REM
  77. call :ValidateParams
  78. if errorlevel 1 goto :End
  79. REM
  80. REM Execute Main
  81. REM
  82. call :Main
  83. :End_PreMain
  84. goto PostMain
  85. REM /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  86. REM Begin Main code section
  87. REM /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  88. REM (5) Call other executables or command scripts by using:
  89. REM call ExecuteCmd.cmd "<command>"
  90. REM Check for errors by using:
  91. REM if errorlevel 1 ...
  92. REM Note that the executable/script you're calling with ExecuteCmd must return a
  93. REM non-zero value on errors to make the error checking mechanism work.
  94. REM
  95. REM Example
  96. REM call ExecuteCmd.cmd "xcopy /f foo1 foo2"
  97. REM if errorlevel 1 (
  98. REM set errors=%errorlevel%
  99. REM goto end
  100. REM )
  101. REM
  102. REM (6) Log non-error information by using:
  103. REM call logmsg.cmd "<log message>"
  104. REM and log error information by using:
  105. REM call errmsg.cmd "<error message>"
  106. REM
  107. REM (7) Exit from the option routines with
  108. REM set errors=%errorlevel%
  109. REM goto end
  110. REM if errors found during execution and with
  111. REM goto end
  112. REM otherwise.
  113. :Main
  114. REM Main code section
  115. REM <Start your script's code here>
  116. REM
  117. REM Check for the 32 bit platform, we do not build for 64 bit
  118. REM
  119. if not "%_BuildArch%" == "x86" (
  120. call logmsg.cmd "Whistler Support Tools Cabgen supported for 32 bit only."
  121. set errors=0
  122. goto end
  123. )
  124. REM
  125. REM Check for the working folder
  126. REM
  127. if NOT EXIST %_NTPostBld%\dump\supporttools (
  128. call errmsg.cmd "%_NTPostBld%\dump\supporttools does not exist; unable to create support.cab and deploy.cab."
  129. goto end
  130. )
  131. REM
  132. REM If there are old bits clean them.
  133. REM
  134. REM if EXIST %_NTPostBld%\dump\supporttools\obj (
  135. REM cd /d %_NTPostBld%\dump\supporttools
  136. REM if errorlevel 1 goto end
  137. REM call ExecuteCmd.cmd "rd obj /s /q"
  138. REM if errorlevel 1 goto end
  139. REM )
  140. REM
  141. REM Come back to the working folder and hit nmake to build the cabs
  142. REM
  143. cd /d %_NTPostBld%\dump\supporttools
  144. if errorlevel 1 goto end
  145. call ExecuteCmd.cmd "nmake /F makefile.support"
  146. if errorlevel 1 goto end
  147. REM
  148. REM Copy the cabs into the support\tools folder to update the msi with them.
  149. REM
  150. REM if not exist %_NTPostBld%\support\tools md %_NTPostBld%\support\tools
  151. REM call ExecuteCmd.cmd "copy /y %_NTPostBld%\reskit\bin\supporttools\obj\i386\*.cab %_NTPostBld%\support\tools"
  152. REM if errorlevel 1 (
  153. REM goto end
  154. REM )
  155. REM
  156. REM Support Tools: Now %_NTPostBld%\support\tools is the working folder
  157. REM
  158. cd /d %_NTPostBld%\support\tools
  159. if errorlevel 1 goto end
  160. pushd %_NTPostBld%\support\tools
  161. if errorlevel 1 goto end
  162. REM
  163. REM Support Tools: create a 'cabtemp' folder to extract the cab files.
  164. REM
  165. call ExecuteCmd.cmd "if not exist cabtemp md cabtemp"
  166. if errorlevel 1 (
  167. popd
  168. goto end
  169. )
  170. REM
  171. REM Support Tools: check whether the copy of the cabs have been successfull.
  172. REM
  173. if NOT exist support.cab (
  174. call errmsg.cmd "Unable to find support.cab."
  175. popd
  176. goto end
  177. )
  178. REM
  179. REM Support Tools: check whether the msi database is there for the updating
  180. REM
  181. if NOT exist suptools.msi (
  182. call errmsg.cmd "Unable to find suptools.msi."
  183. popd
  184. goto end
  185. )
  186. REM
  187. REM Support Tools: extract the cabs
  188. REM
  189. call ExecuteCmd.cmd "extract.exe /y /e /l cabtemp support.cab"
  190. if errorlevel 1 (
  191. popd
  192. goto end
  193. )
  194. REM
  195. REM Support Tools: Use msifiler to update the msi database with the cab contents.
  196. REM
  197. call ExecuteCmd.cmd "msifiler.exe -d suptools.msi -s cabtemp\"
  198. if errorlevel 1 (
  199. popd
  200. goto end
  201. )
  202. REM
  203. REM Support Tools: Remove the cabtemp folder as it is not needed.
  204. REM
  205. call ExecuteCmd.cmd "rd /q /s cabtemp"
  206. call logmsg.cmd "Whistler Support Tools Cabgen completed successfully."
  207. popd
  208. goto end
  209. :ValidateParams
  210. REM
  211. REM Validate the option given as parameter.
  212. REM
  213. goto end
  214. :Usage
  215. REM Usage of the script
  216. REM If errors, goto end
  217. echo Usage: %script_name% [-l lang][-?]
  218. echo -l lang 2-3 letter language identifier
  219. echo -? Displays usage
  220. set ERRORS=1
  221. goto end
  222. REM /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  223. REM End Main code section
  224. REM /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  225. :End_Main
  226. goto PostMain
  227. REM SupportSubsSupportSubsSupportSubsSupportSubsSupportSubsSupportSubsSupportSubs
  228. REM Support Subs - Do not touch this section!
  229. REM SupportSubsSupportSubsSupportSubsSupportSubsSupportSubsSupportSubsSupportSubs
  230. :GetParams
  231. REM
  232. REM Parse the command line arguments
  233. REM
  234. set ERRORS=0
  235. for %%h in (./ .- .) do if ".%SCRIPT_ARGS%." == "%%h?." goto Usage
  236. pushd %RazzleToolPath%\PostBuildScripts
  237. set ERRORS=0
  238. for /f "tokens=1 delims=;" %%c in ('perl.exe GetParams.pm %*') do (
  239. set commandline=%%c
  240. set commandtest=!commandline:~0,3!
  241. if /i "!commandtest!" neq "set" (
  242. if /i "!commandtest!" neq "ech" (
  243. echo %%c
  244. ) else (
  245. %%c
  246. )
  247. ) else (
  248. %%c
  249. )
  250. )
  251. if "%errorlevel%" neq "0" (
  252. set ERRORS=%errorlevel%
  253. goto end
  254. )
  255. popd
  256. goto end
  257. :LocalEnvEx
  258. REM
  259. REM Manage local script environment extensions
  260. REM
  261. pushd %RazzleToolPath%\PostBuildScripts
  262. for /f "tokens=1 delims=;" %%c in ('perl.exe LocalEnvEx.pm %1') do (
  263. set commandline=%%c
  264. set commandtest=!commandline:~0,3!
  265. if /i "!commandtest!" neq "set" (
  266. if /i "!commandtest!" neq "ech" (
  267. echo %%c
  268. ) else (
  269. %%c
  270. )
  271. ) else (
  272. %%c
  273. )
  274. )
  275. if "%errorlevel%" neq "0" (
  276. set errors=%errorlevel%
  277. goto end
  278. )
  279. popd
  280. goto end
  281. :end
  282. seterror.exe "%errors%"& goto :EOF
  283. REM PostMainPostMainPostMainPostMainPostMainPostMainPostMainPostMainPostMain
  284. REM Begin PostProcessing - Do not touch this section!
  285. REM PostMainPostMainPostMainPostMainPostMainPostMainPostMainPostMainPostMain
  286. :PostMain
  287. REM
  288. REM End the local environment extensions.
  289. REM
  290. call :LocalEnvEx -e
  291. REM
  292. REM Check for errors
  293. REM
  294. endlocal& seterror.exe "%errors%"