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.

500 lines
19 KiB

  1. @REM -----------------------------------------------------------------
  2. @REM
  3. @REM reskit.cmd - ClarkG
  4. @REM create the reskit tools cab
  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. reskit [-l <language>]
  20. Create the reskit tools cab.
  21. USAGE
  22. parseargs('?' => \&Usage);
  23. # *** TEMPLATE CODE ***
  24. $ENV{"_CPCMAGIC"}++;exit(system($0)>>8);
  25. __END__
  26. @:CPCBegin
  27. @set _CPCMAGIC=
  28. @setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
  29. @if not defined DEBUG echo off
  30. @REM *** CMD SCRIPT BELOW ***
  31. REM *****************************************
  32. REM reskit will not built on localized builds
  33. REM *****************************************
  34. if defined LANG (
  35. call logmsg.cmd "Windows .NET Server 2003 Resource Kit Language: %LANG%"
  36. if /i "%LANG%" neq "USA" (
  37. call logmsg.cmd "Windows .NET Server 2003 reskit tools will not build on localized builds."
  38. set errors=0
  39. goto end
  40. )
  41. )
  42. REM ----------------------------------------------------------------------------------------------------------------
  43. REM Check for the 32 bit platform, we do not build for 64 bit
  44. REM ----------------------------------------------------------------------------------------------------------------
  45. if not "%_BuildArch%" == "x86" (
  46. call logmsg.cmd "Windows .NET Server 2003 reskit tools currently support exist only for x86 platform."
  47. set errors=0
  48. goto end
  49. )
  50. REM *********************************************************
  51. REM build the fcsetup.exe using the fcsetup.sed in reskit\bin
  52. REM *********************************************************
  53. REM
  54. REM check for the existence of the reskit\bin directory
  55. REM
  56. if not exist %_NTPostBld%\reskit\bin (
  57. call errmsg.cmd "unexpected -- reskit\bin doesn't exist in post build directory"
  58. set errors=1
  59. goto end
  60. )
  61. REM
  62. REM check for the existence of all the required files
  63. REM
  64. set errors=0
  65. for %%i in (
  66. fcopy.exe
  67. fcopy.dll
  68. fcopysrv.exe
  69. fcopyhlp.dll
  70. fcopy.inf
  71. fcopysrv.bat
  72. fcopy.chm
  73. fcsetup.sed
  74. fcopy.txt
  75. ) do (
  76. if not exist %_NTPostBld%\reskit\bin\%%i (
  77. call errmsg.cmd "%%i doesn't exist in reskit\bin"
  78. set errors=1
  79. )
  80. )
  81. if not "%errors%"=="0" (
  82. call errmsg.cmd "fcsetup.exe could not be built -- exiting"
  83. goto end
  84. )
  85. REM
  86. REM all the required files are existing
  87. REM now build the fcsetup.exe using IEXPRESS
  88. REM
  89. pushd %_NTPostBld%\reskit\bin
  90. iexpress.exe /N /Q /M fcsetup.sed
  91. REM
  92. REM check the creation for the existence of fcsetup.exe
  93. REM this is because, IEXPRESS doesn't set the error code
  94. REM
  95. if not exist fcsetup.exe (
  96. call errmsg.cmd "failed to build the fcsetup.exe -- exiting"
  97. set errors=1
  98. goto end
  99. ) ELSE (
  100. call logmsg.cmd "IEXPRESS successfully built the FCSETUP.EXE"
  101. )
  102. REM ----------------------------------------------------------------------------------------------------------------
  103. REM Check for the working folder
  104. REM ----------------------------------------------------------------------------------------------------------------
  105. if NOT EXIST %_NTPostBld%\dump\reskit (
  106. call errmsg.cmd "%_NTPostBld%\dump\reskit does not exist; unable to create resource kit setup."
  107. goto end
  108. )
  109. cd /d %_NTPostBld%\dump\reskit
  110. if errorlevel 1 (
  111. goto end
  112. )
  113. set countddfexists=0
  114. REM ----------------------------------------------------------------------------------------------------------------
  115. REM CHECK IF reskit ddf EXISTS
  116. REM ----------------------------------------------------------------------------------------------------------------
  117. if NOT exist deployrk.ddf (
  118. call errmsg.cmd "Unable to find deployrk.ddf."
  119. set countddfexists=1
  120. )
  121. REM ----------------------------------------------------------------------------------------------------------------
  122. REM CHECK IF deployrk ddf EXISTS
  123. REM ----------------------------------------------------------------------------------------------------------------
  124. if NOT exist deployrk.ddf (
  125. call errmsg.cmd "Unable to find deployrk.ddf."
  126. set countddfexists=1
  127. )
  128. REM ----------------------------------------------------------------------------------------------------------------
  129. REM CHECK IF serverrk ddf EXISTS
  130. REM ----------------------------------------------------------------------------------------------------------------
  131. if NOT exist serverrk.ddf (
  132. call errmsg.cmd "Unable to find serverrk.ddf."
  133. set countddfexists=1
  134. )
  135. if NOT "%countddfexists%"=="0" (
  136. goto end
  137. )
  138. REM ----------------------------------------------------------------------------------------------------------------
  139. REM CHECK IF ALL REQUIRED BINARIES IN reskit.ddf EXIST
  140. REM ----------------------------------------------------------------------------------------------------------------
  141. set countAny=0
  142. set count1=0
  143. for /f "skip=15" %%i in (%_NTPOSTBLD%\dump\reskit\reskit.ddf) do (
  144. if not exist %_NTPOSTBLD%\%%i (
  145. call errmsg.cmd "Error: %_NTPOSTBLD%\%%i file is missing"
  146. set /a count1+=1
  147. set countAny=1
  148. )
  149. )
  150. REM ----------------------------------------------------------------------------------------------------------------
  151. REM CHECK IF ALL REQUIRED BINARIES IN deployrk.ddf EXIST
  152. REM ----------------------------------------------------------------------------------------------------------------
  153. set count2=0
  154. for /f "skip=15" %%i in (%_NTPOSTBLD%\dump\reskit\deployrk.ddf) do (
  155. if not exist %_NTPOSTBLD%\%%i (
  156. call errmsg.cmd "Error: %_NTPOSTBLD%\%%i file is missing"
  157. set /a count2+=1
  158. set countAny=1
  159. )
  160. )
  161. REM ----------------------------------------------------------------------------------------------------------------
  162. REM CHECK IF ALL REQUIRED BINARIES IN serverrk.ddf EXIST
  163. REM ----------------------------------------------------------------------------------------------------------------
  164. set count3=0
  165. for /f "skip=15" %%i in (%_NTPOSTBLD%\dump\reskit\serverrk.ddf) do (
  166. if not exist %_NTPOSTBLD%\%%i (
  167. call errmsg.cmd "Error: %_NTPOSTBLD%\%%i file is missing"
  168. set /a count3+=1
  169. set countAny=1
  170. )
  171. )
  172. REM ----------------------------------------------------------------------------------------------------------------
  173. REM ERROR OUT IF ANY FILE IS MISSING
  174. REM ----------------------------------------------------------------------------------------------------------------
  175. if NOT "%countAny%"=="0" (
  176. if NOT "%count1%"=="0" (
  177. call errmsg.cmd "Error: %count1% files are missing to build the reskit.cab file"
  178. )
  179. if NOT "%count2%"=="0" (
  180. call errmsg.cmd "Error: %count2% files are missing to build the deployrk.cab file"
  181. )
  182. if NOT "%count3%"=="0" (
  183. call errmsg.cmd "Error: %count3% files are missing to build the serverrk.cab file"
  184. )
  185. goto end
  186. )
  187. REM ----------------------------------------------------------------------------------------------------------------
  188. REM GENERATE reskit.cab
  189. REM ----------------------------------------------------------------------------------------------------------------
  190. if exist deployrk.cab call ExecuteCmd.cmd "del /f reskit.cab"
  191. if errorlevel 1 (
  192. call errmsg.cmd "Error deleting old reskit.cab."
  193. goto end
  194. )
  195. call ExecuteCmd.cmd "makecab /D SourceDir=%_NTPOSTBLD% /F reskit.ddf"
  196. if errorlevel 1 (
  197. call errmsg.cmd "Error generating reskit.cab."
  198. goto end
  199. )
  200. REM ----------------------------------------------------------------------------------------------------------------
  201. REM GENERATE deployrk.cab
  202. REM ----------------------------------------------------------------------------------------------------------------
  203. if exist deployrk.cab call ExecuteCmd.cmd "del /f deployrk.cab"
  204. if errorlevel 1 (
  205. call errmsg.cmd "Error deleting old deployrk.cab."
  206. goto end
  207. )
  208. call ExecuteCmd.cmd "makecab /D SourceDir=%_NTPOSTBLD% /F deployrk.ddf"
  209. if errorlevel 1 (
  210. call errmsg.cmd "Error generating deployrk.cab."
  211. goto end
  212. )
  213. REM ----------------------------------------------------------------------------------------------------------------
  214. REM GENERATE serverrk.cab
  215. REM ----------------------------------------------------------------------------------------------------------------
  216. if exist serverrk.cab call ExecuteCmd.cmd "del /f serverrk.cab"
  217. if errorlevel 1 (
  218. call errmsg.cmd "Error deleting old serverrk.cab."
  219. goto end
  220. )
  221. call ExecuteCmd.cmd "makecab /D SourceDir=%_NTPOSTBLD% /F serverrk.ddf"
  222. if errorlevel 1 (
  223. call errmsg.cmd "Error generating serverrk.cab."
  224. goto end
  225. )
  226. REM ----------------------------------------------------------------------------------------------------------------
  227. REM CHECK IF MSI FILES EXIST
  228. REM ----------------------------------------------------------------------------------------------------------------
  229. if NOT exist reskit.msi (
  230. call errmsg.cmd "Unable to find reskit.msi."
  231. goto end
  232. )
  233. if NOT exist deploy_rk.msi (
  234. call errmsg.cmd "Unable to find deploy_rk.msi."
  235. goto end
  236. )
  237. if NOT exist server_rk.msi (
  238. call errmsg.cmd "Unable to find server_rk.msi."
  239. goto end
  240. )
  241. REM ----------------------------------------------------------------------------------------------------------------
  242. REM IF TIMEBUILD IS RESUMED (IT HAPPENS A LOT) THEN MERGE WOULD FAIL SO MAKE SURE WE DELETE OLD COPIES
  243. REM RENAME deploy_rk.msi to deployrk. AND WORK OFF THIS COPY, and the same for server rk
  244. REM ----------------------------------------------------------------------------------------------------------------
  245. if exist deployrk.msi call ExecuteCmd.cmd "del /f deployrk.msi"
  246. if errorlevel 1 (
  247. call errmsg.cmd "Error deleting old deployrk.msi."
  248. goto end
  249. )
  250. call ExecuteCmd.cmd "copy deploy_rk.msi deployrk.msi"
  251. if errorlevel 1 (
  252. call errmsg.cmd "Error copying deploy_rk.msi to deployrk.msi."
  253. goto end
  254. )
  255. if exist serverrk.msi call ExecuteCmd.cmd "del /f serverrk.msi"
  256. if errorlevel 1 (
  257. call errmsg.cmd "Error deleting old serverrk.msi."
  258. goto end
  259. )
  260. call ExecuteCmd.cmd "copy server_rk.msi serverrk.msi"
  261. if errorlevel 1 (
  262. call errmsg.cmd "Error copying server_rk.msi to serverrk.msi."
  263. goto end
  264. )
  265. REM ----------------------------------------------------------------------------------------------------------------
  266. REM CHECK IF WiStream.vbs EXISTS
  267. REM ----------------------------------------------------------------------------------------------------------------
  268. if NOT exist WiStream.vbs (
  269. call errmsg.cmd "Unable to find WiStream.vbs ."
  270. goto end
  271. )
  272. REM ----------------------------------------------------------------------------------------------------------------
  273. REM CHECK IF the CA reskit.dll EXISTS
  274. REM ----------------------------------------------------------------------------------------------------------------
  275. if NOT exist %_NTPostBld%\reskit\bin\reskit.dll (
  276. call errmsg.cmd "Unable to find reskit.dll ."
  277. goto end
  278. )
  279. REM ----------------------------------------------------------------------------------------------------------------
  280. REM STREAM CA reskit.dll into BINARY TABLE
  281. REM ----------------------------------------------------------------------------------------------------------------
  282. call ExecuteCmd.cmd "WiStream.vbs reskit.msi %_NTPostBld%\reskit\bin\reskit.dll Binary.ReskitDll"
  283. if errorlevel 1 (
  284. call errmsg.cmd "Error updating Binary table."
  285. goto end
  286. )
  287. REM ----------------------------------------------------------------------------------------------------------------
  288. REM DETERMINE CURRENT NT BUILD NUMBER
  289. REM ----------------------------------------------------------------------------------------------------------------
  290. set ntverp=%_ntbindir%\public\sdk\inc\ntverp.h
  291. if not exist %ntverp% (
  292. call errmsg.cmd "File %ntverp% not found."
  293. goto end
  294. )
  295. set bldno=
  296. for /f "tokens=6" %%i in ('findstr /c:"#define VER_PRODUCTBUILD " %ntverp%') do (
  297. set bldno=%%i
  298. )
  299. if "%bldno%" == "" (
  300. call errmsg.cmd "Unable to define bldno per %ntverp%"
  301. goto end
  302. )
  303. REM ----------------------------------------------------------------------------------------------------------------
  304. REM SET MSI PRODUCT VERSION PROPERTY TO CURRENT NT BUILD NUMBER
  305. REM ----------------------------------------------------------------------------------------------------------------
  306. call ExecuteCmd.cmd "cscript.exe updversn.vbs reskit.msi %bldno%"
  307. if errorlevel 1 (
  308. call errmsg.cmd "Error updating Property table."
  309. goto end
  310. )
  311. REM ----------------------------------------------------------------------------------------------------------------
  312. REM MERGE RESKIT.MSI (tools) INTO DEPLOYRK.MSI(deploy docs) TO FORM THE DEPLOY SKU
  313. REM ----------------------------------------------------------------------------------------------------------------
  314. call ExecuteCmd.cmd "msidb.exe -d deployrk.msi -m reskit.msi"
  315. if errorlevel 1 (
  316. call errmsg.cmd "Error merging reskit.msi into deployrk.msi."
  317. goto end
  318. )
  319. REM ----------------------------------------------------------------------------------------------------------------
  320. REM MERGE RESKIT.MSI (tools) INTO SERVERRK.MSI(server docs) TO FORM THE SERVER SKU
  321. REM ----------------------------------------------------------------------------------------------------------------
  322. call ExecuteCmd.cmd "msidb.exe -d serverrk.msi -m reskit.msi"
  323. if errorlevel 1 (
  324. call errmsg.cmd "Error merging reskit.msi into serverrk.msi."
  325. goto end
  326. )
  327. REM ----------------------------------------------------------------------------------------------------------------
  328. REM EXTRACT THE "Cabs" MSI TABLE FOR BOTH SKU's
  329. REM ----------------------------------------------------------------------------------------------------------------
  330. if NOT exist %_NTPostBld%\dump\reskit\deploy (
  331. call ExecuteCmd.cmd "md %_NTPostBld%\dump\reskit\deploy"
  332. if errorlevel 1 (
  333. call errmsg.cmd "Error creating folder %_NTPostBld%\dump\reskit\deploy"
  334. goto end
  335. )
  336. )
  337. call ExecuteCmd.cmd "msidb.exe -d deployrk.msi -f %_NTPostBld%\dump\reskit\deploy -e Cabs"
  338. if errorlevel 1 (
  339. call errmsg.cmd "Error extracting deploy Cabs table."
  340. goto end
  341. )
  342. if NOT exist %_NTPostBld%\dump\reskit\server (
  343. call ExecuteCmd.cmd "md %_NTPostBld%\dump\reskit\server"
  344. if errorlevel 1 (
  345. call errmsg.cmd "Error creating folder %_NTPostBld%\dump\reskit\server"
  346. goto end
  347. )
  348. )
  349. call ExecuteCmd.cmd "msidb.exe -d serverrk.msi -f %_NTPostBld%\dump\reskit\server -e Cabs"
  350. if errorlevel 1 (
  351. call errmsg.cmd "Error extracting server Cabs table."
  352. goto end
  353. )
  354. REM ----------------------------------------------------------------------------------------------------------------
  355. REM COPY THE CAB FILES TO THE 'temporary' Cabs DIRECTORY
  356. REM ----------------------------------------------------------------------------------------------------------------
  357. call ExecuteCmd.cmd "copy /y reskit.CAB deploy\Cabs\reskit.CAB.ibd"
  358. if errorlevel 1 (
  359. call errmsg.cmd "Error creating deploy\Cabs\reskit.CAB.ibd."
  360. goto end
  361. )
  362. call ExecuteCmd.cmd "copy /y reskit.CAB server\Cabs\reskit.CAB.ibd"
  363. if errorlevel 1 (
  364. call errmsg.cmd "Error creating server\Cabs\reskit.CAB.ibd."
  365. goto end
  366. )
  367. call ExecuteCmd.cmd "copy /y deployrk.CAB deploy\Cabs\deployrk.CAB.ibd"
  368. if errorlevel 1 (
  369. call errmsg.cmd "Error creating deploy\Cabs\deployrk.CAB.ibd."
  370. goto end
  371. )
  372. call ExecuteCmd.cmd "copy /y serverrk.CAB server\Cabs\serverrk.CAB.ibd"
  373. if errorlevel 1 (
  374. call errmsg.cmd "Error creating server\Cabs\serverrk.CAB.ibd."
  375. goto end
  376. )
  377. REM ----------------------------------------------------------------------------------------------------------------
  378. REM IMPORT THE Cabs INTO THE "Cabs" MSI TABLE
  379. REM ----------------------------------------------------------------------------------------------------------------
  380. call ExecuteCmd.cmd "msidb.exe -d deployrk.msi -f %_NTPostBld%\dump\reskit\deploy -i Cabs.idt"
  381. if errorlevel 1 (
  382. call errmsg.cmd "Error importing Cabs table into deployrk.msi."
  383. goto end
  384. )
  385. call ExecuteCmd.cmd "msidb.exe -d serverrk.msi -f %_NTPostBld%\dump\reskit\server -i Cabs.idt"
  386. if errorlevel 1 (
  387. call errmsg.cmd "Error importing Cabs table into serverrk.msi."
  388. goto end
  389. )
  390. REM ----------------------------------------------------------------------------------------------------------------
  391. REM CLEANUP temporary STUFF
  392. REM ----------------------------------------------------------------------------------------------------------------
  393. call ExecuteCmd.cmd "rd /s /q deploy"
  394. if errorlevel 1 (
  395. call errmsg.cmd "Error deleting deploy folder."
  396. goto end
  397. )
  398. call ExecuteCmd.cmd "rd /s /q server"
  399. if errorlevel 1 (
  400. call errmsg.cmd "Error deleting server folder."
  401. goto end
  402. )
  403. REM ----------------------------------------------------------------------------------------------------------------
  404. REM CREATE temporary 'cabtemp' FOLDER TO EXTRACT cab FILES.
  405. REM ----------------------------------------------------------------------------------------------------------------
  406. call ExecuteCmd.cmd "if not exist cabtemp md cabtemp"
  407. if errorlevel 1 (
  408. call errmsg.cmd "Error creating cabtemp folder."
  409. goto end
  410. )
  411. REM ----------------------------------------------------------------------------------------------------------------
  412. REM EXTRACT THE CABS
  413. REM ----------------------------------------------------------------------------------------------------------------
  414. call ExecuteCmd.cmd "extract.exe /y /e /l cabtemp reskit.cab"
  415. if errorlevel 1 (
  416. call errmsg.cmd "Unable to extract reskit.cab."
  417. goto end
  418. )
  419. call ExecuteCmd.cmd "extract.exe /y /e /l cabtemp deployrk.cab"
  420. if errorlevel 1 (
  421. call errmsg.cmd "Unable to extract deployrk.cab."
  422. goto end
  423. )
  424. call ExecuteCmd.cmd "extract.exe /y /e /l cabtemp serverrk.cab"
  425. if errorlevel 1 (
  426. call errmsg.cmd "Unable to extract serverrk.cab."
  427. goto end
  428. )
  429. REM ----------------------------------------------------------------------------------------------------------------
  430. REM USING MSIFILER UPDATE THE MSI FILE TABLE
  431. REM ----------------------------------------------------------------------------------------------------------------
  432. call ExecuteCmd.cmd "msifiler.exe -d deployrk.msi -s cabtemp\"
  433. if errorlevel 1 (
  434. call errmsg.cmd "Unable to update deployrk.msi file table via msifiler."
  435. goto end
  436. )
  437. call ExecuteCmd.cmd "msifiler.exe -d serverrk.msi -s cabtemp\"
  438. if errorlevel 1 (
  439. call errmsg.cmd "Unable to update serverrk.msi file table via msifiler."
  440. goto end
  441. )
  442. REM ----------------------------------------------------------------------------------------------------------------
  443. REM CLEANUP temporary STUFF
  444. REM ----------------------------------------------------------------------------------------------------------------
  445. call ExecuteCmd.cmd "rd /q /s cabtemp"
  446. REM ----------------------------------------------------------------------------------------------------------------
  447. REM COPY BUILT MSI TO DESTINATION
  448. REM ----------------------------------------------------------------------------------------------------------------
  449. call ExecuteCmd.cmd "copy /Y deployrk.msi %_NTPostBld%\reskit\setup\deployrk"
  450. if errorlevel 1 (
  451. call errmsg.cmd "Unable to copy deployrk.msi to %_NTPostBld%\reskit\setup\deployrk"
  452. goto end
  453. )
  454. call ExecuteCmd.cmd "copy /Y serverrk.msi %_NTPostBld%\reskit\setup\serverrk"
  455. if errorlevel 1 (
  456. call errmsg.cmd "Unable to copy serverrk.msi to %_NTPostBld%\reskit\setup\serverrk"
  457. goto end
  458. )
  459. call logmsg.cmd "Windows .NET Server 2003 reskit tools Cabgen is completed successfully."
  460. popd
  461. goto end
  462. :end
  463. seterror.exe "%errors%"& goto :EOF