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.

362 lines
10 KiB

  1. @REM -----------------------------------------------------------------
  2. @REM
  3. @REM uddi.cmd - creeves
  4. @REM Make CAB files for uddi distribution (uddi.msi)
  5. @REM
  6. @REM Copyright (c) Microsoft Corporation. All rights reserved.
  7. @REM
  8. @REM -----------------------------------------------------------------
  9. @if defined _CPCMAGIC goto CPCBegin
  10. @perl -x "%~f0" %*
  11. @goto :EOF
  12. #!perl
  13. use strict;
  14. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  15. use lib $ENV{RAZZLETOOLPATH};
  16. use PbuildEnv;
  17. use ParseArgs;
  18. sub Usage { print<<USAGE; exit(1) }
  19. uddi.cmd [-p] [-a]
  20. -p => called from PRS signing
  21. -a => always rebuild, skip file change check
  22. Make CAB files for uddi distribution (uddixxx.msi)
  23. USAGE
  24. parseargs('?' => \&Usage, 'p' =>\$ENV{PRS});
  25. # *** TEMPLATE CODE ***
  26. $ENV{"_CPCMAGIC"}++;exit(system($0)>>8);
  27. __END__
  28. @:CPCBegin
  29. @set _CPCMAGIC=
  30. @setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
  31. @if not defined DEBUG echo off
  32. @REM *** CMD SCRIPT BELOW ***
  33. IF NOT DEFINED SCRIPT_NAME SET SCRIPT_NAME=uddipostbuild.cmd
  34. IF NOT DEFINED MyCopyDir SET MyCopyDir=.
  35. IF NOT DEFINED UDDILOG SET UDDILOG=%MyCopyDir%\%SCRIPT_NAME%.log
  36. IF NOT DEFINED UDDIERRLOG SET UDDIERRLOG=%MyCopyDir%\%SCRIPT_NAME%.err
  37. @if defined DEBUG @ECHO Log is %UDDIERRLOG%
  38. if "%_buildarch%" NEQ "x86" (
  39. call logmsg.cmd "uddi.cmd do nothing on non i386" %UDDILOG%
  40. goto :EOF
  41. )
  42. REM
  43. REM Only run if this is a server SKU (not blade)
  44. REM
  45. for %%i in ( sbs srv ads dtc ) do (
  46. perl %RazzleToolPath%\cksku.pm -t:%%i -l:%lang%
  47. if %errorlevel% EQU 0 goto :ValidSKU
  48. )
  49. call logmsg.cmd "CABGEN: no server products for %lang%; nothing to do." %UDDILOG%
  50. goto :EOF
  51. :ValidSKU
  52. REM
  53. REM Generate cmbins.exe as it is needed below.
  54. REM
  55. REM if /i "%PRS%" == "1" (
  56. REM call %RazzleToolPath%\PostBuildScripts\cmbins.cmd -p
  57. REM ) else (
  58. REM call %RazzleToolPath%\PostBuildScripts\cmbins.cmd
  59. REM )
  60. REM
  61. REM Verify that the \binaries\uddi folder exists
  62. REM
  63. if not exist %_NTPostBld%\uddi (
  64. call errmsg.cmd "*** Failure - see error log ***" %UDDILOG%
  65. call errmsg.cmd "Directory %_NTPostBld%\uddi not found." %UDDIERRLOG%
  66. goto :EOF
  67. )
  68. REM
  69. REM delete the MSI files that are left in the binaries folder
  70. REM
  71. call logmsg.cmd "--- Delete old MSI files ..." %UDDILOG%
  72. for %%i in ( uddiadm uddidb uddiweb ) do (
  73. if exist %_NTPostBld%\%%i.msi (
  74. call ExecuteCmd.cmd "del /f %_NTPostBld%\%%i.msi"
  75. )
  76. )
  77. REM
  78. REM loop through all the installers
  79. REM
  80. for %%i in ( uddiadm uddidb uddiweb ) do (
  81. if not exist %_NTPostBld%\uddi\%%i.msi (
  82. call errmsg.cmd "*** Failure - see error log ***" %UDDILOG%
  83. call errmsg.cmd "*** File %_NTPostBld%\uddi\%%i.msi not found." %UDDIERRLOG%
  84. goto :EOF
  85. )
  86. call LogMsg.cmd "--- Building %%i.msi ..." %UDDILOG%
  87. REM
  88. REM delete any existing DDF or CAB files
  89. REM
  90. call logmsg.cmd "--- Delete existing DDF or CAB files ..." %UDDILOG%
  91. if exist %_NTPostBld%\uddi\%%i.cab (
  92. call ExecuteCmd.cmd "del /f %_NTPostBld%\uddi\%%i.ddf %_NTPostBld%\uddi\%%i.cab"
  93. )
  94. REM
  95. REM Generate the DDF files based in the MSI files
  96. REM
  97. call logmsg.cmd "--- Generate %%i.DDF ..." %UDDILOG%
  98. call ExecuteCmd.cmd "%_NTPostBld%\uddi\msitoddf.exe %_NTPostBld%\uddi\%%i.msi -L %UDDIERRLOG%"
  99. if errorlevel 1 (
  100. call errmsg.cmd "*** Failure - see error log ***" %UDDILOG%
  101. call errmsg.cmd "Generation of %%i.DDF failed" %UDDIERRLOG%
  102. goto :EOF
  103. )
  104. REM
  105. REM Create the cab file
  106. REM
  107. call logmsg.cmd "--- Generate %%i.CAB ..." %UDDILOG%
  108. if exist %_NTPostBld%\uddi\%%i.ddf (
  109. pushd %_NTPostBld%\uddi
  110. call ExecuteCmd.cmd "makecab /D SourceDir=%_NTPOSTBLD%\uddi /F %_NTPostBld%\uddi\%%i.ddf"
  111. popd
  112. if errorlevel 1 (
  113. call errmsg.cmd "*** Failure - see error log ***" %UDDILOG%
  114. call errmsg.cmd "Generation of %%i.cab failed" %UDDIERRLOG%
  115. goto :EOF
  116. )
  117. )
  118. REM
  119. REM Extract the Cabs table from the msi file (creates a \Cabs folder)
  120. REM
  121. call logmsg.cmd "--- Extract %%i.MSI Cab Table into a temp folder ..." %UDDILOG%
  122. call ExecuteCmd.cmd "msidb.exe -d %_NTPostBld%\uddi\%%i.msi -f %_NTPostBld%\uddi -e Cabs"
  123. if errorlevel 1 (
  124. call errmsg.cmd "*** Failure - see error log ***" %UDDILOG%
  125. call errmsg.cmd "msidb.exe -d %_NTPostBld%\uddi\%%i.msi failed" %UDDIERRLOG%
  126. goto :EOF
  127. )
  128. REM
  129. REM Copy the new cab file into the \Cabs folder
  130. REM
  131. call logmsg.cmd "--- %%i.CAB into the temp cab folder ..." %UDDILOG%
  132. call ExecuteCmd.cmd "copy /y %_NTPostBld%\uddi\%%i.CAB %_NTPostBld%\uddi\Cabs\w1.cab.ibd"
  133. if errorlevel 1 (
  134. call errmsg.cmd "*** Failure - see error log ***" %UDDILOG%
  135. call errmsg.cmd "Copy the new cab file into the \Cabs folder failed" %UDDIERRLOG%
  136. goto :EOF
  137. )
  138. REM
  139. REM Import the new cab file into the Cabs Table (-i switch)
  140. REM
  141. pushd %_NTPostBld%\uddi
  142. call ExecuteCmd.cmd "msidb.exe -d .\%%i.msi -f %_NTPostBld%\uddi -i Cabs.idt"
  143. popd
  144. if errorlevel 1 (
  145. call errmsg.cmd "*** Failure - see error log ***" %UDDILOG%
  146. call errmsg.cmd "Import the new cab file into the Cabs Table failed" %UDDIERRLOG%
  147. goto :EOF
  148. )
  149. REM
  150. REM Delete the cab files and folder
  151. REM
  152. call logmsg.cmd "--- Delete the CAB temp folder ..." %UDDILOG%
  153. call ExecuteCmd.cmd "del %_NTPostBld%\uddi\cabs.idt"
  154. if errorlevel 1 (
  155. call errmsg.cmd "*** Failure - see error log ***" %UDDILOG%
  156. call errmsg.cmd "Deleting uddi\cabs.idt failed" %UDDIERRLOG%
  157. goto :EOF
  158. )
  159. call ExecuteCmd.cmd "rd /s /q %_NTPostBld%\uddi\Cabs"
  160. if errorlevel 1 (
  161. call errmsg.cmd "*** Failure - see error log ***" %UDDILOG%
  162. call errmsg.cmd "Delete the CAB temp folder failed" %UDDIERRLOG%
  163. goto :EOF
  164. )
  165. REM
  166. REM Now we need to extract the new cab file into a temp folder
  167. REM so that we can run a utility that will update the file
  168. REM sizes and version in the MSI "Files" table.
  169. REM After extraction, the files are named the "decorated" names as in
  170. REM the first column of the file table
  171. REM
  172. call logmsg.cmd "--- Extract %%i.CAB into \cabtemp, using File.File names ..." %UDDILOG%
  173. if exist %_NTPostBld%\uddi\cabtemp (
  174. call ExecuteCmd.cmd "rd /q /s %_NTPostBld%\uddi\cabtemp"
  175. if errorlevel 1 (
  176. call errmsg.cmd "*** Failure - see error log ***" %UDDILOG%
  177. call errmsg.cmd "Error deleting \cabtemp" %UDDIERRLOG%
  178. goto :EOF
  179. )
  180. )
  181. call ExecuteCmd.cmd "md %_NTPostBld%\uddi\cabtemp"
  182. if errorlevel 1 (
  183. call errmsg.cmd "*** Failure - see error log ***" %UDDILOG%
  184. call errmsg.cmd "Error creating \cabtemp folder" %UDDIERRLOG%
  185. goto :EOF
  186. )
  187. call ExecuteCmd.cmd "extract.exe /Y /E /L %_NTPostBld%\uddi\cabtemp %_NTPostBld%\uddi\%%i.cab"
  188. if errorlevel 1 (
  189. call errmsg.cmd "*** Failure - see error log ***" %UDDILOG%
  190. call errmsg.cmd "Error extracting cab files" %UDDIERRLOG%
  191. goto :EOF
  192. )
  193. REM
  194. REM UDDIMSIFILER will update the version, size, language and hash information for all the files
  195. REM
  196. call logmsg.cmd "--- Update the version, size, language and hash information in %%i.MSI ..." %UDDILOG%
  197. call ExecuteCmd.cmd "%_NTPostBld%\uddi\uddimsifiler.exe -d %_NTPostBld%\uddi\%%i.msi -s %_NTPostBld%\uddi\cabtemp -L %UDDIERRLOG% -v %_NTPostBld%\uddiocm.dll"
  198. if errorlevel 1 (
  199. call errmsg.cmd "*** Failure - see error log ***" %UDDILOG%
  200. call errmsg.cmd "Error running uddimsifiler.exe" %UDDIERRLOG%
  201. goto :EOF
  202. )
  203. REM
  204. REM Copy uddi.msi to "retail"
  205. REM
  206. call logmsg.cmd "--- Copy %%i.msi to the root of the binaries folder ..." %UDDILOG%
  207. call ExecuteCmd.cmd "copy %_NTPostBld%\uddi\%%i.msi %_NTPostBld%"
  208. if errorlevel 1 (
  209. call errmsg.cmd "*** Failure - see error log ***" %UDDILOG%
  210. call errmsg.cmd "Error copying %%i.msi to the root of the binaries folder" %UDDIERRLOG%
  211. goto :EOF
  212. )
  213. REM
  214. REM Cleanup
  215. REM
  216. call logmsg.cmd "--- Cleanup %%i..." %UDDILOG%
  217. call ExecuteCmd.cmd "del /f %_NTPostBld%\uddi\%%i.cab"
  218. call ExecuteCmd.cmd "rd /q /s %_NTPostBld%\uddi\cabtemp"
  219. call ExecuteCmd.cmd "del /f %_NTPostBld%\uddi\%%i.ddf"
  220. )
  221. REM
  222. REM Create uddi.cat
  223. REM
  224. call logmsg.cmd "--- Beginning creation of uddi.cat ..." %UDDILOG%
  225. call logmsg.cmd "--- Create \cabtemp folder ..." %UDDILOG%
  226. if exist %_NTPostBld%\uddi\cabtemp (
  227. call ExecuteCmd.cmd "rd /q /s %_NTPostBld%\uddi\cabtemp"
  228. if errorlevel 1 (
  229. call errmsg.cmd "*** Failure - see error log ***" %UDDILOG%
  230. call errmsg.cmd "Error deleting \cabtemp" %UDDIERRLOG%
  231. goto :EOF
  232. )
  233. )
  234. call ExecuteCmd.cmd "md %_NTPostBld%\uddi\cabtemp"
  235. if errorlevel 1 (
  236. call errmsg.cmd "*** Failure - see error log ***" %UDDILOG%
  237. call errmsg.cmd "Error creating \cabtemp folder" %UDDIERRLOG%
  238. goto :EOF
  239. )
  240. REM
  241. REM loop through all the installers, expanding msi files and cabs
  242. REM
  243. for %%i in ( uddiadm uddidb uddiweb ) do (
  244. call logmsg.cmd "--- Calling explodemsi on %%i.msi ..." %UDDILOG%
  245. call ExecuteCmd.cmd "explodemsi.exe -a %_NTPostBld%\uddi\%%i.msi %_NTPostBld%\uddi\cabtemp"
  246. if errorlevel 1 (
  247. call errmsg.cmd "*** Failure - see error log ***" %UDDILOG%
  248. call errmsg.cmd "Error exploding msi files" %UDDIERRLOG%
  249. goto :EOF
  250. )
  251. )
  252. call logmsg.cmd "--- Expanding all cab files ..." %UDDILOG%
  253. call ExecuteCmd.cmd "expand.exe -r -F:* %_NTPostBld%\uddi\cabtemp\cabs\*.cab %_NTPostBld%\uddi\cabtemp"
  254. if errorlevel 1 (
  255. call errmsg.cmd "*** Failure - see error log ***" %UDDILOG%
  256. call errmsg.cmd "Error expanding cab files" %UDDIERRLOG%
  257. goto :EOF
  258. )
  259. call ExecuteCmd.cmd "del %_NTPostBld%\uddi\cabtemp\*."
  260. if errorlevel 1 (
  261. call errmsg.cmd "*** Failure - see error log ***" %UDDILOG%
  262. call errmsg.cmd "Error removing inappropriate files for signing from msi" %UDDIERRLOG%
  263. goto :EOF
  264. )
  265. call ExecuteCmd.cmd "rd /s /q %_NTPostBld%\uddi\cabtemp\cabs"
  266. if errorlevel 1 (
  267. call errmsg.cmd "*** Failure - see error log ***" %UDDILOG%
  268. call errmsg.cmd "Error removing cabtemp\cabs" %UDDIERRLOG%
  269. goto :EOF
  270. )
  271. call logmsg.cmd "--- Create uddi.cat ..." %UDDILOG%
  272. pushd %_NTPostBld%\uddi\cabtemp
  273. call ExecuteCmd.cmd "%SDXROOT%\tools\deltacat.cmd %_NTPostBld%\uddi\cabtemp"
  274. popd
  275. if errorlevel 1 (
  276. call errmsg.cmd "*** Failure - see error log ***" %UDDILOG%
  277. call errmsg.cmd "Error creating delta.cat in \cabtemp" %UDDIERRLOG%
  278. goto :EOF
  279. )
  280. call ExecuteCmd.cmd "copy %_NTPostBld%\uddi\cabtemp\delta.cat %_NTPostBld%\uddi.cat"
  281. if errorlevel 1 (
  282. call errmsg.cmd "*** Failure - see error log ***" %UDDILOG%
  283. call errmsg.cmd "Error copying delta.cat to the root of the binaries folder as uddi.cat" %UDDIERRLOG%
  284. goto :EOF
  285. )
  286. REM
  287. REM Cleanup
  288. REM
  289. call logmsg.cmd "--- Cleanup ..." %UDDILOG%
  290. call ExecuteCmd.cmd "rd /q /s %_NTPostBld%\uddi\cabtemp"
  291. :EOF