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.

326 lines
9.5 KiB

  1. @REM -----------------------------------------------------------------
  2. @REM
  3. @REM Adminpak.cmd - ClarkG
  4. @REM Make CAB files for Adminpak distribution (adminpak.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. Adminpak.cmd [-p] [-a]
  20. -p => called from PRS signing
  21. -a => always rebuild, skip file change check
  22. Make CAB files for Adminpak distribution (adminpak.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 386 (
  34. call logmsg.cmd "adminpak.cmd do nothing on non i386"
  35. goto :EOF
  36. )
  37. REM adminpak.msi is not applicable to languages with no server products.
  38. perl %RazzleToolPath%\cksku.pm -t:bla -l:%lang%
  39. if %errorlevel% EQU 0 goto :ValidSKU
  40. perl %RazzleToolPath%\cksku.pm -t:sbs -l:%lang%
  41. if %errorlevel% EQU 0 goto :ValidSKU
  42. perl %RazzleToolPath%\cksku.pm -t:srv -l:%lang%
  43. if %errorlevel% EQU 0 goto :ValidSKU
  44. perl %RazzleToolPath%\cksku.pm -t:ads -l:%lang%
  45. if %errorlevel% EQU 0 goto :ValidSKU
  46. perl %RazzleToolPath%\cksku.pm -t:dtc -l:%lang%
  47. if %errorlevel% EQU 0 goto :ValidSKU
  48. call logmsg.cmd "CABGEN: no server products for %lang%; nothing to do."
  49. goto :EOF
  50. :ValidSKU
  51. REM
  52. REM Generate cmbins.exe as it is needed below.
  53. REM
  54. if /i "%PRS%" == "1" (
  55. call %RazzleToolPath%\PostBuildScripts\cmbins.cmd -p
  56. ) else (
  57. call %RazzleToolPath%\PostBuildScripts\cmbins.cmd
  58. )
  59. REM
  60. REM Generate adminpak.msi
  61. REM
  62. if not exist %_NTPostBld%\adminpak (
  63. call errmsg.cmd "Directory %_NTPostBld%\adminpak not found."
  64. goto :EOF
  65. )
  66. pushd %_NTPostBld%\adminpak
  67. for %%i in (.\admin_pk.msi .\adminpak.ddf) do (
  68. if not exist %%i (
  69. call errmsg.cmd "File %_NTPostBld%\adminpak\%%i not found."
  70. popd& goto :EOF
  71. )
  72. )
  73. :RunIt
  74. REM
  75. REM Create adminpak.cab.
  76. REM As iexpress.exe does not set errorlevel in all error cases,
  77. REM base verification on adminpak.cab's existence.
  78. REM
  79. if exist adminpak.cab call ExecuteCmd.cmd "del /f adminpak.cab"
  80. if errorlevel 1 popd& goto :EOF
  81. REM
  82. REM verify whether all the files adminpak.ddf do exist or not
  83. REM this will help in analyzing the reason for the build break
  84. REM
  85. set count=0
  86. for /f "skip=15" %%i in (%_NTPOSTBLD%\adminpak\adminpak.ddf) do (
  87. if not exist %_NTPOSTBLD%\%%i (
  88. call errmsg.cmd "%_NTPOSTBLD%\%%i file is missing"
  89. set /a count+=1
  90. )
  91. )
  92. if NOT "%count%"=="0" (
  93. call errmsg.cmd "total %count% files are missing to build the adminpak.cab file"
  94. goto :EOF
  95. )
  96. call ExecuteCmd.cmd "start /wait /min makecab /D SourceDir=%_NTPOSTBLD% /F adminpak.ddf"
  97. if not exist adminpak.cab (
  98. call errmsg.cmd "Cab creation for adminpak.cab."
  99. popd& goto :EOF
  100. )
  101. REM
  102. REM Adminpak: check whether WiStream.vbs is present
  103. REM
  104. if NOT exist WiStream.vbs (
  105. call errmsg.cmd "Unable to find WiStream.vbs."
  106. goto :EOF
  107. )
  108. REM
  109. REM Adminpak: check whether the CA dll is present
  110. REM
  111. if NOT exist %_NTPostBld%\adminpak\adminpak.dll (
  112. call errmsg.cmd "Unable to find adminpak.dll ."
  113. goto :EOF
  114. )
  115. REM
  116. REM Adminpak: Stream the adminpak.dll into the Binary table
  117. REM
  118. call ExecuteCmd.cmd "WiStream.vbs admin_pk.msi %_NTPostBld%\adminpak\adminpak.dll Binary.AdminpakDLL.dll"
  119. if errorlevel 1 (
  120. call errmsg.cmd "Error updating Binary table."
  121. goto :EOF
  122. )
  123. REM
  124. REM SetBldno
  125. REM
  126. set ntverp=%_ntbindir%\public\sdk\inc\ntverp.h
  127. if not exist %ntverp% (
  128. call logmsg.cmd "File %ntverp% not found."
  129. goto continue
  130. )
  131. set bldno=
  132. for /f "tokens=6" %%i in ('findstr /c:"#define VER_PRODUCTBUILD " %ntverp%') do (
  133. set bldno=%%i
  134. )
  135. if "%bldno%" == "" (
  136. call logmsg.cmd "Unable to define bldno per %ntverp%"
  137. goto continue
  138. )
  139. REM
  140. REM Update the 'ProductVersion' property in the msi with the current build
  141. REM
  142. call ExecuteCmd.cmd "cscript.exe updversn.vbs admin_pk.msi %bldno%"
  143. if errorlevel 1 (
  144. call logmsg.cmd "Error updating Property table."
  145. goto continue
  146. )
  147. :continue
  148. REM
  149. REM Create adminpak.msi
  150. REM msifiler.exe needs the uncompressed files, so uncab adminpak.cab.
  151. REM
  152. call ExecuteCmd.cmd "copy admin_pk.msi adminpak.msi"
  153. if errorlevel 1 popd& goto :EOF
  154. REM
  155. REM Extract the Cabs table
  156. REM Copy the cab file into the Cabs directory
  157. REM Import the new Cab into the Cabs directory
  158. REM
  159. call ExecuteCmd.cmd "msidb.exe -d .\adminpak.msi -f %_NTPostBld%\adminpak -e Cabs"
  160. if errorlevel 1 popd& goto :EOF
  161. call ExecuteCmd.cmd "copy /y .\adminpak.CAB .\Cabs\adminpak.CAB.ibd"
  162. if errorlevel 1 popd& goto :EOF
  163. call ExecuteCmd.cmd "msidb.exe -d .\adminpak.msi -f %_NTPostBld%\adminpak -i Cabs.idt"
  164. if errorlevel 1 popd& goto :EOF
  165. call ExecuteCmd.cmd "del .\cabs.idt"
  166. if errorlevel 1 popd& goto :EOF
  167. call ExecuteCmd.cmd "rd /s /q Cabs"
  168. if errorlevel 1 popd& goto :EOF
  169. if exist .\cabtemp call ExecuteCmd.cmd "rd /q /s .\cabtemp"
  170. if errorlevel 1 popd& goto :EOF
  171. call ExecuteCmd.cmd "md .\cabtemp"
  172. if errorlevel 1 popd& goto :EOF
  173. call ExecuteCmd.cmd "extract.exe /Y /E /L .\cabtemp adminpak.cab"
  174. if errorlevel 1 popd& goto :EOF
  175. REM
  176. REM create a catalog
  177. REM but do this only when adminpak.cmd is ran without -p switch
  178. REM otherwise, catalog is already created and is now PRS signed
  179. REM
  180. if /i "%PRS%" NEQ "1" (
  181. REM *********************************************************
  182. REM files in the cab are extracted into a temporary directory
  183. REM just need to sign these files
  184. REM *********************************************************
  185. REM
  186. REM since the adminpak.dll is not there in the cab,
  187. REM get the file from the build location to this temporary folder
  188. REM
  189. call ExecuteCmd.cmd "copy %_ntpostbld%\adminpak\adminpak.dll .\cabtemp /y"
  190. REM
  191. REM make sure the delta.cat is not existing -- if exists, delete it first
  192. REM
  193. if exist .\cabtemp\delta.cat del .\cabtemp\delta.cat
  194. REM
  195. REM now run the deltacat.cmd on this folder
  196. REM
  197. call deltacat.cmd %_ntpostbld%\adminpak\cabtemp
  198. REM
  199. REM check whether delta.cat is created or not
  200. REM (this is only way thru which we can verify whether deltacat.cmd is succeeded or not)
  201. REM
  202. if not exist .\cabtemp\delta.cat (
  203. call errmsg.cmd "Failed to create the catalog file. deltacat.cmd failed."
  204. popd& goto :EOF
  205. )
  206. REM
  207. REM rename the just created delta.cat to adminpak.cat
  208. REM
  209. if exist .\cabtemp\adminpak.cat del /f .\cabtemp\adminpak.cat
  210. call ExecuteCmd.cmd "ren .\cabtemp\delta.cat adminpak.cat"
  211. REM
  212. REM copy the adminpak.cat folder pointed by %_NTPostBld% environment variable
  213. REM
  214. call ExecuteCmd.cmd "copy .\cabtemp\adminpak.cat %_ntpostbld%\adminpak.cat /y"
  215. )
  216. REM
  217. REM Rename some of the files in cabtemp so that
  218. REM msifiler.exe can find them in the file table
  219. REM and correctly update the verion and size informaiton.
  220. REM
  221. call ExecuteCmd.cmd "rename .\cabtemp\template.pmc template.cmp"
  222. call ExecuteCmd.cmd "rename .\cabtemp\template.smc template.cms"
  223. call ExecuteCmd.cmd "rename .\cabtemp\secon.chm seconcepts.chm"
  224. call ExecuteCmd.cmd "rename .\cabtemp\tapicons.chm tapiconcepts.chm"
  225. call ExecuteCmd.cmd "rename .\cabtemp\rsscon.chm rssconcepts.chm"
  226. call ExecuteCmd.cmd "rename .\cabtemp\riscon.chm risconcepts.chm"
  227. call ExecuteCmd.cmd "rename .\cabtemp\mscscon.chm mscsconcepts.chm"
  228. call ExecuteCmd.cmd "rename .\cabtemp\uadefs.chm uadef.chm"
  229. call ExecuteCmd.cmd "rename .\cabtemp\dnscon.chm dnsconcepts.chm"
  230. call ExecuteCmd.cmd "rename .\cabtemp\dhcpcon.chm dhcpconcepts.chm"
  231. call ExecuteCmd.cmd "rename .\cabtemp\dfcon.chm dfconcepts.chm"
  232. call ExecuteCmd.cmd "rename .\cabtemp\cscon.chm csconcepts.chm"
  233. call ExecuteCmd.cmd "rename .\cabtemp\tslic_el.chm tslic.chm"
  234. call ExecuteCmd.cmd "rename .\cabtemp\winscon.chm winsconcepts.chm"
  235. call ExecuteCmd.cmd "rename .\cabtemp\scS.chm sc.chm"
  236. call ExecuteCmd.cmd "rename .\cabtemp\acluiS.chm aclui.chm"
  237. call ExecuteCmd.cmd "rename .\cabtemp\dfsS.hlp dfs.hlp"
  238. call ExecuteCmd.cmd "rename .\cabtemp\cmmgr32S.hlp cmmgr32.hlp"
  239. call ExecuteCmd.cmd "rename .\cabtemp\adpropS.hlp adprop.hlp"
  240. call ExecuteCmd.cmd "rename .\cabtemp\adcon.chm adconcepts.chm"
  241. call ExecuteCmd.cmd "rename .\cabtemp\ctcon.chm ctconcepts.chm"
  242. call ExecuteCmd.cmd "rename .\cabtemp\ntcmdss.chm ntcmds.chm"
  243. call ExecuteCmd.cmd "rename .\cabtemp\tapis.chm tapi.chm"
  244. call ExecuteCmd.cmd "rename .\cabtemp\secauths.hlp secauth.hlp"
  245. call ExecuteCmd.cmd "rename .\cabtemp\acluis.hlp aclui.hlp"
  246. call ExecuteCmd.cmd "rename .\cabtemp\audits.chm audit.chm"
  247. call ExecuteCmd.cmd "rename .\cabtemp\certmgrs.chm certmgr.chm"
  248. call ExecuteCmd.cmd "rename .\cabtemp\certmgrs.hlp certmgr.hlp"
  249. call ExecuteCmd.cmd "rename .\cabtemp\cmcons.chm cmconcepts.chm"
  250. call ExecuteCmd.cmd "rename .\cabtemp\encrypts.chm encrypt.chm"
  251. call ExecuteCmd.cmd "rename .\cabtemp\passwds.chm password.chm"
  252. call ExecuteCmd.cmd "msifiler.exe -d .\adminpak.msi -s .\cabtemp\"
  253. if errorlevel 1 popd& goto :EOF
  254. rem
  255. rem Cleanup
  256. rem
  257. call ExecuteCmd.cmd "del /f .\adminpak.cab"
  258. call ExecuteCmd.cmd "rd /q /s .\cabtemp"
  259. REM
  260. REM Copy adminpak.msi to "retail"
  261. REM
  262. call ExecuteCmd.cmd "copy adminpak.msi ..\"
  263. if errorlevel 1 popd& goto :EOF
  264. popd