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.

1706 lines
47 KiB

  1. @echo off
  2. if defined _echo echo on
  3. if defined verbose echo on
  4. setlocal ENABLEDELAYEDEXPANSION
  5. REM Check the command line for /? -? or ?
  6. for %%a in (./ .- .) do if ".%1." == "%%a?." goto Usage
  7. goto MAIN
  8. :BeginBuildPackage
  9. REM Set PackageType=retail or PackageType=beta.
  10. REM This affects "redist.txt" and whether or not it lists the files that are
  11. REM redistributable
  12. set PackageType=beta
  13. REM Do a clean build of the msi things
  14. if exist %_NTTREE%\dbg\files\msi rd /s /q %_NTTREE%\dbg\files\msi
  15. del /s /q %_NTTREE%\dbg\redist*
  16. REM Build the msi stuff
  17. call logmsg "Building the redist directory"
  18. cd redist
  19. build -cZ
  20. cd ..
  21. call logmsg "Building the msi directory"
  22. cd msi
  23. build -cZ
  24. cd ..
  25. REM Make sure that mergemod.dll has been regsvr'd
  26. call logmsg "Registering %_NTDRIVE%%_NTROOT%\tools\x86\mergemod.dll
  27. regsvr32 /s %_NTDRIVE%%_NTROOT%\tools\x86\mergemod.dll
  28. for %%a in (%cmdline%) do (
  29. set CorrectEntry=no
  30. if /i "%%a" == "debuggers" (
  31. set CorrectEntry=yes
  32. )
  33. if /i "%%a" == "debuggers.cmd" (
  34. set CorrectEntry=yes
  35. )
  36. if /i "!CorrectEntry!" == no (
  37. goto Usage
  38. )
  39. )
  40. set DbgErrors=no
  41. set SRCDIR=%_NTTREE%\dbg\files
  42. set SRCSDKLIBDIR=%_NTDRIVE%%_NTROOT%\public\sdk\lib
  43. set SRCSDKINCDIR=%_NTDRIVE%%_NTROOT%\public\sdk\inc
  44. set SRCSAMPLEDIR=%CD%\samples
  45. set SDKLIBDIR=%SRCDIR%\sdk\lib
  46. set SDKINCDIR=%SRCDIR%\sdk\inc
  47. set SAMPLEDIR=%SRCDIR%\sdk\samples
  48. set WEBDIR=%_NTTREE%\dbg\web
  49. set SDKDIR=%_NTTREE%\dbg\sdk
  50. set DOCDIR=%_NTTREE%\dbg\msi\docs
  51. set PRICHMPATH=\\dbg\web$\docs\htmlhelp\Private_Version
  52. set PRICHIPATH=\\dbg\web$\docs\htmlhelp\Private_Version
  53. set PRICHM=debugMS.chm
  54. set PRICHI=debugMS.chi
  55. set MSIDIR=%_NTTREE%\dbg\msi
  56. set CABDIR=%_NTTREE%\dbg\cabs
  57. set DDFDIR=%MSIDIR%\ddfs
  58. set IDTDIR=%MSIDIR%\idts
  59. set TOOLPATH=%_NTDRIVE%%_NTROOT%\Tools
  60. set DESTDIR=%_NTTREE%\dbg
  61. set MSIIDTDIR=%MSIDIR%\msiidts
  62. set MSMDIR=%DESTDIR%\sdk
  63. set MAKEFILE=%MSIDIR%\ddfs\makefile
  64. set CABLIST=%DDFDIR%\cabs.txt
  65. REM
  66. REM The msi that goes on the CD needs to be slightly
  67. REM different than the one that we distribute for stress
  68. REM
  69. set CDMSIDIR=%DESTDIR%\sdk
  70. set CDMSIIDTDIR=%MSIDIR%\cd\msiidts
  71. if exist %CDMSIDIR% rd /s /q %CDMSIDIR%
  72. if exist %CDMSIIDTDIR% rd /s /q %CDMSIIDTDIR%
  73. REM Cleanup and create the directory where the self-extracting
  74. REM exe that we post to the web goes.
  75. if not exist %WEBDIR% mkdir %WEBDIR%
  76. REM
  77. REM Make directories
  78. REM
  79. if NOT EXIST %CABDIR% MD %CABDIR%
  80. if NOT EXIST %DDFDIR% MD %DDFDIR%
  81. if NOT EXIST %IDTDIR% MD %IDTDIR%
  82. if NOT EXIST %DESTDIR% md %DESTDIR%
  83. if NOT EXIST %MSIIDTDIR% md %MSIIDTDIR%
  84. if NOT EXIST %MSMDIR% md %MSMDIR%
  85. if NOT EXIST %CDMSIDIR% md %CDMSIDIR%
  86. if NOT EXIST %CDMSIIDTDIR% md %CDMSIIDTDIR%
  87. del /q /f %MSMDIR%\*
  88. set COMPONEN=%IDTDIR%\componen.idt
  89. set DIRECTOR=%IDTDIR%\director.idt
  90. set FEATUREC=%IDTDIR%\featurec.idt
  91. set FILE=%IDTDIR%\file.idt
  92. set MEDIA=%IDTDIR%\media.idt
  93. set MODULECO=%IDTDIR%\moduleco.idt
  94. set MODULESI=%IDTDIR%\modulesi.idt
  95. set SHORTCUT=%IDTDIR%\shortcut.idt
  96. set REGISTRY=%IDTDIR%\registry.idt
  97. set DATA=%MSIDIR%\dbgdata.txt
  98. REM Set the MSI name according to build architecture
  99. if /i "%_BuildArch%" == "x86" (
  100. set MSINAME=dbg_x86
  101. set OEMNAME=dbg_oem
  102. set CurArch=i386
  103. goto EndSetBuildArch
  104. )
  105. if /i "%_BuildArch%" == "IA64" (
  106. set OEMNAME=
  107. set MSINAME=dbg_ia64
  108. set CurArch=ia64
  109. goto EndSetBuildArch
  110. )
  111. call errmsg "Build architecture (_BuildArch) is unknown"
  112. goto errend
  113. :EndSetBuildArch
  114. REM Make directories for the source files
  115. REM and copy them in
  116. call logmsg.cmd "Copying in the SDK files..."
  117. if not exist %SDKLIBDIR%\i386 md %SDKLIBDIR%\i386
  118. if not exist %SDKLIBDIR%\ia64 md %SDKLIBDIR%\ia64
  119. if not exist %SDKINCDIR% md %SDKINCDIR%
  120. if not exist %SAMPLEDIR% md %SAMPLEDIR%
  121. for %%a in ( exts simplext dumpstk ) do (
  122. if not exist %SAMPLEDIR%\%%a md %SAMPLEDIR%\%%a
  123. copy %SRCSAMPLEDIR%\%%a\* %SAMPLEDIR%\%%a
  124. )
  125. for %%a in ( dbgeng.h wdbgexts.h dbghelp.h ) do (
  126. copy %SRCSDKINCDIR%\%%a %SDKINCDIR%\%%a > nul
  127. )
  128. for %%a in ( dbgeng.lib dbghelp.lib ) do (
  129. copy %SRCSDKLIBDIR%\i386\%%a %SDKLIBDIR%\i386\%%a > nul
  130. copy %SRCSDKLIBDIR%\ia64\%%a %SDKLIBDIR%\ia64\%%a > nul
  131. )
  132. REM Get the empty ones ready
  133. REM Prepare dbg.msi
  134. if exist %DESTDIR%\%MSINAME%.msi del %DESTDIR%\%MSINAME%.msi
  135. if exist %MSIDIR%\%MSINAME%.msi del %MSIDIR%\%MSINAME%.msi
  136. copy %MSIDIR%\dbgx.msi %MSIDIR%\%MSINAME%.msi > nul
  137. REM Get the docs copied in
  138. call logmsg.cmd "Copying in the private docs ..."
  139. if not exist %DOCDIR% (
  140. call errmsg "Docs are not binplaced to %DOCDIR%"
  141. goto errend
  142. )
  143. if exist %PRICHMPATH%\%PRICHM% (
  144. copy %PRICHMPATH%\%PRICHM% %DOCDIR%\%PRICHM% > nul
  145. ) else (
  146. call errmsg "Cannot find %PRICHMPATH%\%PRICHM%"
  147. goto errend
  148. )
  149. if exist %PRICHIPATH%\%PRICHI% (
  150. copy %PRICHIPATH%\%PRICHI% %DOCDIR%\%PRICHI% > nul
  151. ) else (
  152. call errmsg "Cannot find %PRICHIPATH%\%PRICHI%"
  153. goto errend
  154. )
  155. if not exist %DOCDIR%\%PRICHM% (
  156. call errmsg "Copy failed for %PRICHMPATH%\%PRICHM% to %DOCDIR%\%PRICHM%"
  157. )
  158. if not exist %DOCDIR%\%PRICHI% (
  159. call errmsg "Copy failed for %PRICHIPATH%\%PRICHI% to %DOCDIR%\%PRICHI%"
  160. )
  161. if exist %CABDIR%\dbg*.CABinet del /f /q %CABDIR%\dbg*.CABinet
  162. if exist %MAKEFILE% del /f /q %MAKEFILE%
  163. if exist %CABLIST% del /f /q %CABLIST%
  164. REM Give every package that gets generated, a new product
  165. REM and package code. MSI will always think its upgrading
  166. call :UpdateProductCode %MSIDIR%\%MSINAME%.msi %MSIIDTDIR%
  167. call :UpdatePackageCode %MSIDIR%\%MSINAME%.msi %MSIIDTDIR%
  168. call :SetUpgradeCode %MSIDIR%\%MSINAME%.msi %MSIIDTDIR%
  169. REM Update redist.txt to have the correct version number
  170. call :UpdateRedist
  171. REM Put the current build number into the ProductVersion
  172. REM fields
  173. call :SetVersion %MSIDIR%\%MSINAME%.msi %MSIIDTDIR%
  174. REM Possible first entries are
  175. REM 1. MergeModule
  176. REM 2. Directory
  177. REM 3. File
  178. REM Put the data into the idt's
  179. REM Arguments for "file
  180. REM %%a = "file"
  181. REM %%b = component
  182. REM %%c = GUID
  183. REM %%d = file name
  184. REM Arguments for "directory
  185. set /a count=0
  186. set /a modulecount=1
  187. set ModuleName=none
  188. REM This variable determines whether any of the files
  189. REM that are supposed to go into a merge module exist.
  190. REM For example, w2kfre and w2kchk extensions do not
  191. REM exist for alpha installs.
  192. set FilesExist=no
  193. call :CreateMSIHeaders
  194. REM Start a DDF that contains all the files
  195. call :CreateDDFHeader %MSINAME%
  196. for /f "tokens=1,2,3,4,5,6,7,8,9,10,11,12,13* delims=," %%a in (%DATA%) do (
  197. if /i "%%a" == "MergeModule" (
  198. REM Create/finish the current merge module if it exists
  199. if /i NOT "!ModuleName!" == "none" (
  200. REM For this architecture there may be no files in this
  201. REM MergeModule. If this is the case don't finish it
  202. if /i "!FilesExist!" == "yes" (
  203. call :FinishMergeModule
  204. set /a modulecount=!modulecount!+1
  205. if /i "!PrevFile!" NEQ "none" (
  206. echo !PrevFile!>>%MAKEFILE%
  207. echo makecab /F %DDFDir%\!ModuleName!.ddf>>%MAKEFILE%
  208. echo.>>%MAKEFILE%
  209. )
  210. )
  211. set FilesExist=no
  212. )
  213. REM Decide if this is a correct merge module for this architecture
  214. set skippingmodule=yes
  215. if /i "%_BuildArch%" == "x86" (
  216. if /i "%%b" == "32" set skippingmodule=no
  217. )
  218. if /i "%_BuildArch%" == "ia64" (
  219. if /i "%%b" == "64" set skippingmodule=no
  220. )
  221. if /i "%%b" EQU "3264" set skippingmodule=no
  222. call logmsg "Module %%c -- skipping=!skippingmodule!"
  223. if /i "!skippingmodule!" == "no" (
  224. REM CurSrcDir is the directory where the source files are found in
  225. REM our tree
  226. set CurSrcDir=%SRCDIR%
  227. REM Create a new set of headers
  228. call :CreateIDTHeaders
  229. set ModuleName=%%c
  230. REM set guidlet equal to the guid with _ instead of -'s
  231. call :MungeGUID %%d
  232. set ModuleGuidlet=!guidlet!
  233. set ModuleSig=!ModuleName!.!guidlet!
  234. set MergeFeature=%%e
  235. set MergeParent=%%f
  236. if /i "%_BuildArch%" == "ia64" (
  237. if /i "!MergeParent!" == "SystemFolder" (
  238. set MergeParent=System64Folder
  239. )
  240. )
  241. echo !ModuleSig! 0 01.00.0000.0000>>%MODULESI%
  242. call :CreateDDFHeader !ModuleName!
  243. set PrevFile=none
  244. set CabStart=yes
  245. )
  246. )
  247. if /i "!skippingmodule!" == "no" (
  248. if /i "%%a" == "file" (
  249. call :MungeGUID %%b
  250. set guid={%%b}
  251. set filename=%%c
  252. set filenamekey=!filename!.!guidlet!
  253. set component=!ModuleName!.!guidlet!
  254. set condition=%%d
  255. set attributes=0
  256. REM if we every start doing this as a one-step build we
  257. REM can put this in and take out the call later to
  258. REM FixComponentAttributes
  259. REM if /i "%_BuildArch%" == "ia64" (
  260. REM set attributes=256
  261. REM )
  262. echo !component! !guid! !CurInstallDir! !attributes! !condition! !filenamekey!>>%COMPONEN%
  263. set /a count=!count!+1
  264. echo !filenamekey! !component! !filename! 0 1033 512 !count!>>%FILE%
  265. echo !component! !ModuleSig! ^0>>%MODULECO%
  266. REM We have different file lists for different architectures
  267. REM If a file is missing on this architecture, don't put it in the DDF
  268. if /i exist !CurSrcDir!\!filename! (
  269. set FilesExist=yes
  270. REM Don't write out a \ unless this file is not the last one
  271. REM Save it and write it out next
  272. if /i "!CabStart!" EQU "yes" (
  273. echo %CabDir%\!ModuleName!.CABinet: \>>%MAKEFILE%
  274. echo !ModuleName!>>%CABLIST%
  275. set CabStart=no
  276. )
  277. if /i "!PrevFile!" NEQ "none" (
  278. echo !PrevFile! \>>%MAKEFILE%
  279. )
  280. set PrevFile=!CurSrcDir!\!filename!
  281. echo !CurSrcDir!\!filename! !filenamekey!>>%DDFDIR%\!ModuleName!.ddf
  282. echo !CurSrcDir!\!filename! !filenamekey!>>%DDFDIR%\%MSINAME%.ddf
  283. ) else (
  284. call errmsg "****!CurSrcDir!\!filename! is missing!!!!"
  285. goto errend
  286. )
  287. )
  288. if /i "%%a" == "directory" (
  289. set CurInstallDir=%%b.!ModuleGuidlet!
  290. set CurAppend=%%e
  291. if /i "!CurAppend!" == "*" (
  292. set CurAppend=%CurArch%
  293. )
  294. if /i NOT "!CurAppend!" == "" (
  295. if /i NOT "!CurAppend!" == "^." (
  296. set CurSrcDir=!CurSrcDir!\!CurAppend!
  297. )
  298. )
  299. set parentdir=%%c.!ModuleGuidlet!
  300. if /i "%%d" == "*" (
  301. set installdirname=%CurArch%
  302. ) else (
  303. set installdirname=%%d
  304. )
  305. echo !CurInstallDir! !parentdir! !installdirname!:!CurAppend!>>%DIRECTOR%
  306. )
  307. if /i "%%a" == "registry" (
  308. call :MungeGUID %%b
  309. set guid={%%b}
  310. set component=!ModuleName!.!guidlet!
  311. set CurInstallDir=INSTDIR
  312. set attributes=4
  313. REM Get the root
  314. set root=
  315. if /i "%%c" == "HKLM" (
  316. set root=2
  317. )
  318. if /i "%%c" == "HKCU" (
  319. set root=1
  320. )
  321. if not defined root (
  322. call errmsg.cmd "Root is not HKLM or HKCU for %%b registry entry
  323. goto errend
  324. )
  325. set key=%%d
  326. set name=
  327. if /i "%%e" NEQ "none" set name=%%e
  328. set value=
  329. if /i "%%f" NEQ "none" set value=%%f
  330. set condition=%%g
  331. set filenamekey=DBG_REG_%%c.!guidlet!
  332. echo !component! !guid! !CurInstallDir! !attributes! !condition! !filenamekey!>>%COMPONEN%
  333. echo !filenamekey! !root! !key! !name! !value! !component!>>%REGISTRY%
  334. echo !component! !ModuleSig! ^0>>%MODULECO%
  335. )
  336. if /i "%%a" == "shortcut" (
  337. call :MungeGUID %%b
  338. set guid={%%b}
  339. set component=!ModuleName!.!guidlet!
  340. set s_shortcut=DBG_SC.!guidlet!
  341. set s_directory=%%c
  342. set s_name=%%d
  343. set s_target=%%e
  344. set s_args=
  345. if /i "%%f" NEQ "none" set s_args=%%f
  346. set s_desc=%%g
  347. set s_hotkey=
  348. if /i "%%h" NEQ "none" set s_hotkey=%%h
  349. set s_icon=
  350. if /i "%%i" NEQ "none" set s_icon=%%i
  351. set s_iconindex=
  352. if /i "%%j" NEQ "none" set s_iconindex=%%j
  353. set s_showcmd=
  354. if /i "%%k" NEQ "none" set s_showcmd=%%k
  355. set s_wkdir=
  356. set c_dir=%%l.!ModuleGuidlet!
  357. if /i "%%l" NEQ "none" (
  358. set s_wkdir=%%l.!ModuleGuidlet!
  359. set c_dir=%%l.!ModuleGuidlet!
  360. )
  361. if /i "!ModuleName!" EQU "dbgrel" (
  362. set c_dir=DBG_RELNOTES.!ModuleGuidlet!
  363. )
  364. if /i "!ModuleName!" EQU "dbgrel.64" (
  365. set c_dir=DBG_RELNOTES.!ModuleGuidlet!
  366. )
  367. set reg_wkdir=
  368. if /i "%%m" NEQ "none" set reg_wkdir=%%m.!ModuleGuidlet!]
  369. set keypath=DBG_REG_HKCU.!guidlet!
  370. echo !s_shortcut! !s_directory! !s_name! !component! !s_target! !s_args! !s_desc! !s_hotkey! !s_icon! !s_iconindex! !s_showcmd! !s_wkdir!>>%SHORTCUT%
  371. echo !component! !guid! !c_dir! 4 !keypath!>>%COMPONEN%
  372. echotime /N "!keypath! 1 Software\Microsoft\DebuggingTools !s_desc! !reg_wkdir! !component!">>%REGISTRY%
  373. )
  374. )
  375. )
  376. REM Process the last module
  377. if /i NOT "!ModuleName!" == "none" (
  378. if /i "!skippingmodule!" == "no" (
  379. REM For this architecture there may be no files in this
  380. REM MergeModule. If this is the case don't finish it
  381. if /i "!FilesExist!" == "yes" (
  382. call :FinishMergeModule
  383. )
  384. REM Finish the makefile
  385. if /i "!PrevFile!" NEQ "none" (
  386. echo !PrevFile!>>%MAKEFILE%>>%MAKEFILE%
  387. echo makecab /F %DDFDir%\!ModuleName!.ddf>>%MAKEFILE%
  388. echo.>>%MAKEFILE%
  389. )
  390. )
  391. )
  392. REM Merge the media table into the msi
  393. call cscript.exe %TOOLPATH%\wiimport.vbs //nologo %MSIDIR%\%MSINAME%.msi %IDTDIR% media.idt
  394. REM Add all the dependencies to the feature components table
  395. call :AddInstallationDependencies %MSIDIR%\%MSINAME%.msi %MSIIDTDIR%
  396. REM Set the component attribute to 256 for ia64 binaries
  397. call :FixComponentAttributes %MSIDIR%\%MSINAME%.msi %MSIIDTDIR%
  398. REM Fix the feature table if this is ia64
  399. call :FixFeatureTable %MSIDIR%\%MSINAME%.msi %MSIIDTDIR%
  400. REM Add Components for features
  401. call :AddComponentsForFeatures %MSIDIR%\%MSINAME%.msi %MSIIDTDIR%
  402. REM Copy dbg.msi to %_NTTREE%\dbg\dbg.msi
  403. copy %MSIDIR%\%MSINAME%.msi %DESTDIR%\%MSINAME%.msi > nul
  404. REM
  405. REM Convert this to the dbg.msi that goes on the Symbolcd
  406. REM
  407. copy %MSIDIR%\%MSINAME%.msi %CDMSIDIR%\%MSINAME%.msi > nul
  408. REM Give every package that gets generated, a new product
  409. REM and package code. MSI will always think its upgrading
  410. call :UpdateProductCode %CDMSIDIR%\%MSINAME%.msi %CDMSIIDTDIR%
  411. call :UpdatePackageCode %CDMSIDIR%\%MSINAME%.msi %CDMSIIDTDIR%
  412. REM Fix the install mode so that it doesn't force all files to
  413. REM install, but rather goes by the version.
  414. call :DefaultInstallMode %CDMSIDIR%\%MSINAME%.msi %CDMSIIDTDIR%
  415. REM Remove the Internal extensions
  416. call :RemoveInternalExtensions %CDMSIDIR%\%MSINAME%.msi %CDMSIIDTDIR%
  417. REM
  418. REM Convert this to the dbg_oem.msi that goes to kanalyze
  419. REM
  420. if /i "%CurArch%" == "i386" (
  421. copy %MSIDIR%\%MSINAME%.msi %CDMSIDIR%\%OEMNAME%.msi > nul
  422. REM Give every package that gets generated, a new product
  423. REM and package code. MSI will always think its upgrading
  424. call :UpdateProductCode %CDMSIDIR%\%OEMNAME%.msi %CDMSIIDTDIR%
  425. call :UpdatePackageCode %CDMSIDIR%\%OEMNAME%.msi %CDMSIIDTDIR%
  426. REM Fix the install mode so that it doesn't force all files to
  427. REM install, but rather goes by the version.
  428. call :DefaultInstallMode %CDMSIDIR%\%OEMNAME%.msi %CDMSIIDTDIR%
  429. REM Remove the Internal extensions
  430. call :RemoveInternalExtensions %CDMSIDIR%\%OEMNAME%.msi %CDMSIIDTDIR%
  431. )
  432. )
  433. REM
  434. REM Create all the cabs
  435. REM
  436. :CreateCabs
  437. if NOT EXIST %CABDIR% md %CABDIR%
  438. if NOT EXIST %DDFDIR%\temp md %DDFDIR%\temp
  439. if /i EXIST %DDFDir%\temp\*.txt del /f /q %DDFDir%\temp\*.txt
  440. for /F "tokens=1" %%a in (%CABLIST%) do (
  441. sleep 1
  442. start "PB_SymCabGen %%a" /MIN cmd /c "%RazzleToolPath%\PostBuildScripts\SymCabGen.cmd -f:%%a.CABinet -s:%DDFDir% -t:CAB -d:%CABDIR%"
  443. )
  444. call logmsg.cmd "Waiting for symbol cabs to finish ... "
  445. :wait
  446. sleep 5
  447. if EXIST %DDFDir%\temp\*.txt goto wait
  448. :Verify
  449. REM
  450. REM Verify that all the cabs are there
  451. REM
  452. set AllCreated=TRUE
  453. call logmsg.cmd "Verifying that all the cabs got created ..."
  454. for /F "tokens=1" %%a in ( %CABLIST% ) do (
  455. if NOT EXIST %CABDIR%\%%a.CABinet (
  456. set AllCreated=FALSE
  457. call logmsg.cmd "%CABDIR%\%%a.CABinet didn't get created "
  458. )
  459. )
  460. if /i "%AllCreated%" == "FALSE" goto errend
  461. call logmsg.cmd "All cabs were created"
  462. :EndCreateCabs
  463. REM
  464. REM Put the cabs into the merge modules, and the msi files.
  465. REM The private files go into the msi in
  466. call logmsg.cmd "Add the cabs to the msi's and the merge modules"
  467. for /f %%a in (%CABLIST%) do (
  468. call logmsg " Adding %%a.CABinet"
  469. set found=no
  470. set match=0
  471. if /i "%%a" EQU "dbgdoc" set match=1
  472. if /i "%%a" EQU "dbgdoc.64" set match=1
  473. if /i "%%a" EQU "dbgtriage" set match=1
  474. if /i "%%a" EQU "dbgtriage.64" set match=1
  475. if /i "!match!" EQU "1" (
  476. REM Put the public one into the merge module
  477. REM and the retail package
  478. REM and the OEM package
  479. msidb.exe -d %MSMDIR%\%%a.msm -a %CABDIR%\%%a.CABinet >nul
  480. msidb.exe -d %CDMSIDIR%\%MSINAME%.msi -a %CABDIR%\%%a.CABinet >nul
  481. if /i "%CurArch%" EQU "i386" (
  482. msidb.exe -d %CDMSIDIR%\%OEMNAME%.msi -a %CABDIR%\%%a.CABinet >nul
  483. )
  484. REM Put the private one into the internal msi
  485. msidb.exe -d %DESTDIR%\%MSINAME%.msi -a %DOCDIR%\%%a.CABinet >nul
  486. set found=yes
  487. )
  488. set match=0
  489. if /i "%%a" EQU "dbgntsd" set match=1
  490. if /i "%%a" EQU "dbgntsd.64" set match=1
  491. if /i "%%a" EQU "dbgextp" set match=1
  492. if /i "%%a" EQU "dbgextp.64" set match=1
  493. if /i "!match!" EQU "1" (
  494. REM This only goes in the internal msi
  495. msidb.exe -d %DESTDIR%\%MSINAME%.msi -a %CABDIR%\%%a.CABinet% >nul
  496. set found=yes
  497. )
  498. if /i "%%a" EQU "dbgrel" (
  499. REM Put the x86 one into the merge module
  500. REM and the retail package and the internal package
  501. msidb.exe -d %MSMDIR%\%%a.msm -a %CABDIR%\%%a.CABinet >nul
  502. msidb.exe -d %CDMSIDIR%\%MSINAME%.msi -a %CABDIR%\%%a.CABinet >nul
  503. msidb.exe -d %DESTDIR%\%MSINAME%.msi -a %CABDIR%\%%a.CABinet >nul
  504. REM Put the oem one into the oem msi
  505. msidb.exe -d %CDMSIDIR%\%OEMNAME%.msi -a %DOCDIR%\%%a.CABinet >nul
  506. set found=yes
  507. )
  508. if /i "!found!" EQU "no" (
  509. REM Put this into the merge module, the retail msi and the internal msi
  510. REM and the OEM package
  511. msidb.exe -d %MSMDIR%\%%a.msm -a %CABDIR%\%%a.CABinet >nul
  512. msidb.exe -d %CDMSIDIR%\%MSINAME%.msi -a %CABDIR%\%%a.CABinet >nul
  513. if /i "%CurArch%" EQU "i386" (
  514. msidb.exe -d %CDMSIDIR%\%OEMNAME%.msi -a %CABDIR%\%%a.CABinet >nul
  515. )
  516. msidb.exe -d %DESTDIR%\%MSINAME%.msi -a %CABDIR%\%%a.CABinet >nul
  517. set found=yes
  518. )
  519. )
  520. :CreateSelfExtractingExe
  521. REM Create the self-extracting exes for the web page release
  522. REM
  523. call logmsg "Creating %SDKDIR%\%MSINAME%.exe ...
  524. if exist %WEBDIR%\%MSINAME%.exe del /f %WEBDIR%\%MSINAME%.exe
  525. cl -DTARGET=%WEBDIR%\%MSINAME%.exe -DEXENAME=%MSINAME%.exe -DAPP="msiexec /i %MSINAME%.msi" -DMSINAME=%MSINAME%.msi -DMSIDIR=%CDMSIDIR% -EP %MSIDIR%\dbgx.sed > %MSIDIR%\dbg.sed
  526. iexpress.exe /n %MSIDIR%\dbg.sed /q /m >nul 2>nul
  527. if not exist %WEBDIR%\%MSINAME%.exe (
  528. call errmsg "Errors creating the self-extracting exe %SDKDIR%\%MSINAME%.exe"
  529. )
  530. goto DbgFinished
  531. REM
  532. REM Subroutines
  533. REM
  534. :FinishMergeModule
  535. if exist %MSMDIR%\%ModuleName%.msm del %MSMDIR%\%ModuleName%.msm
  536. if /i "%ModuleName%" EQU "dbgem" (
  537. copy %MSIDIR%\dbgemx.msm %MSMDIR%\%ModuleName%.msm > nul
  538. ) else (
  539. copy %MSIDIR%\dbgx.msm %MSMDIR%\%ModuleName%.msm > nul
  540. )
  541. for %%a in (componen featurec file moduleco modulesi registry shortcut) do (
  542. call cscript.exe %TOOLPATH%\wiimport.vbs //nologo %MSMDIR%\!ModuleName!.msm %IDTDIR% %%a.idt
  543. )
  544. REM Don't merge the directory table into dbgemx.msm
  545. if /i "%ModuleName%" NEQ "dbgem" (
  546. for %%a in ( director) do (
  547. call cscript.exe %TOOLPATH%\wiimport.vbs //nologo %MSMDIR%\!ModuleName!.msm %IDTDIR% %%a.idt
  548. )
  549. )
  550. )
  551. REM Update the merge module with the correct file versions and sizes
  552. REM
  553. call logmsg "msifiler.exe -v -d %MSMDIR%\%ModuleName%.msm -s !CurSrcDir!"
  554. msifiler.exe -v -d %MSMDIR%\%ModuleName%.msm -s !CurSrcDir!\ >nul
  555. REM Merge the merge module into the msi
  556. call logmsg.cmd "Merging !ModuleName!.msm"
  557. call cscript.exe %TOOLPATH%\wimsmmerge.vbs //nologo %MSIDIR%\%MSINAME%.msi !MSMDIR!\!ModuleName!.msm !MergeFeature! %MergeParent% %LOGFILE%
  558. REM Add the correct line to the media table
  559. if EXIST %MSIIDTDIR%\file.idt del %MSIIDTDIR%\file.idt
  560. call cscript.exe %TOOLPATH%\wiexport.vbs //nologo %MSIDIR%\%MSINAME%.msi %MSIIDTDIR% File
  561. REM Figure out which number is currently the highest sequence in the file table
  562. set /a lastsequence="0"
  563. for /f "tokens=1,2,3,4,5,6,7,8 delims= " %%a in (%MSIIDTDIR%\File.idt) do (
  564. set /a curlastsequence="0"
  565. REM Some of the fields could be empty so get the last token
  566. set found=no
  567. for %%z in (%%h %%g %%f %%e %%d %%c %%b %%a) do (
  568. if "!found!" == "no" (
  569. set /a curlastsequence="%%z"
  570. set found=yes
  571. )
  572. )
  573. if !curlastsequence! GTR !lastsequence! (
  574. set /a lastsequence="!curlastsequence!"
  575. )
  576. )
  577. echo !modulecount! !lastsequence! #!ModuleName!.CABinet >>%MEDIA%
  578. REM Create the cabs and put them into the msm's and also the msi
  579. REM If this is the doc cab, make one for the private and for retail
  580. set match=0
  581. if /i "!ModuleName!" == "dbgdoc" set match=1
  582. if /i "!ModuleName!" == "dbgdoc.64" set match=1
  583. if /i "!match!" == "1" (
  584. REM Make the private debugger doc cab and save it to %DOCDIR%\dbgdoc.CABinet
  585. copy %DOCDIR%\%PRICHM% %_NTTREE%\dbg\files\bin\debugger.chm > nul
  586. copy %DOCDIR%\%PRICHI% %_NTTREE%\dbg\files\bin\debugger.chi > nul
  587. call logmsg.cmd "Creating private debugger documentation cab"
  588. makecab /f %DDFDIR%\!ModuleName!.ddf > nul
  589. if /i not exist !CABDIR!\!ModuleName!.CABinet (
  590. call errmsg.cmd "Error creating !CABDIR!\!ModuleName!.CABinet"
  591. set DbgErrors=yes
  592. goto :EOF
  593. )
  594. copy !CABDIR!\!ModuleName!.CABinet %DOCDIR%\!ModuleName!.CABinet > nul
  595. del /f /q !cABDIR!\!ModuleName!.CABinet
  596. REM Now, get ready to make the public debugger doc cabinet
  597. del /f /q %_NTTREE%\dbg\files\bin\debugger.chm
  598. del /f /q %_NTTREE%\dbg\files\bin\debugger.chi
  599. REM Now, get ready to make the public debugger doc cabinet
  600. if not exist %DOCDIR%\debugger.chm (
  601. call errmsg.cmd "Debugger.chm must be binplaced to %DOCDIR%"
  602. goto :EOF
  603. )
  604. if not exist %DOCDIR%\debugger.chi (
  605. call errmsg.cmd "Debugger.chi must be binplaced to %DOCDIR%"
  606. goto :EOF
  607. )
  608. copy %DOCDIR%\debugger.chm %_NTTREE%\dbg\files\bin\debugger.chm > nul
  609. copy %DOCDIR%\debugger.chi %_NTTREE%\dbg\files\bin\debugger.chi > nul
  610. )
  611. set match=0
  612. if /i "!ModuleName!" == "dbgrel" set match=1
  613. if /i "!match!" == "1" (
  614. REM Make the oem relnote cab with the oem redist.txt
  615. REM and save it to %DOCDIR%\dbgrel_oem.CABinet
  616. copy %DOCDIR%\redist_oem.txt %_NTTREE%\dbg\files\redist.txt > nul
  617. call logmsg.cmd "Creating OEM release notes cab"
  618. makecab /f %DDFDIR%\!ModuleName!.ddf > nul
  619. if /i not exist !CABDIR!\!ModuleName!.CABinet (
  620. call errmsg.cmd "Error creating !CABDIR!\!ModuleName!.CABinet"
  621. set DbgErrors=yes
  622. goto :EOF
  623. )
  624. copy !CABDIR!\!ModuleName!.CABinet %DOCDIR%\!ModuleName!.CABinet > nul
  625. del /f /q !cABDIR!\!ModuleName!.CABinet
  626. REM Now, get ready to make the public release notes cabinet
  627. del /f /q %_NTTREE%\dbg\files\redist.txt
  628. copy %DOCDIR%\redist_x86.txt %_NTTREE%\dbg\files\redist.txt > nul
  629. )
  630. set match=0
  631. if /i "!ModuleName!" == "dbgrel.64" set match=1
  632. if /i "!match!" == "1" (
  633. REM Now, get ready to make the public release notes cabinet
  634. del /f /q %_NTTREE%\dbg\files\redist.txt
  635. copy %DOCDIR%\redist_ia64.txt %_NTTREE%\dbg\files\redist.txt > nul
  636. )
  637. set match=0
  638. if /i "!ModuleName!" == "dbgtriage" set match=1
  639. if /i "!ModuleName!" == "dbgtriage.64" set match=1
  640. if /i "!match!" == "1" (
  641. REM Make the private cab and save it to %DOCDIR%\dbgtriage.CABinet
  642. copy %SDXROOT%\stress\wsstress\tools\triage\triage.ini %_NTTREE%\dbg\files\bin\triage\triage.ini > nul
  643. copy %DOCDIR%\pooltag.pri %_NTTREE%\dbg\files\bin\triage\pooltag.txt > nul
  644. call logmsg.cmd "Creating private triage cab"
  645. makecab /f %DDFDIR%\!ModuleName!.ddf > nul
  646. if /i not exist !CABDIR!\!ModuleName!.CABinet (
  647. call errmsg.cmd "Error creating !CABDIR!\!ModuleName!.CABinet"
  648. set DbgErrors=yes
  649. goto :EOF
  650. )
  651. copy !CABDIR!\!ModuleName!.CABinet %DOCDIR%\!ModuleName!.CABinet > nul
  652. del /f /q !CABDIR!\!ModuleName!.CABinet
  653. REM Now, get ready to make the public dbgtriage cabinet
  654. del /f /q %_NTTREE%\dbg\files\bin\triage\pooltag.txt
  655. del /f /q %_NTTREE%\dbg\files\bin\triage\triage.ini
  656. REM Now, get ready to make the public debugger doc cabinet
  657. if not exist %DOCDIR%\pooltag.txt (
  658. call errmsg.cmd "Public pooltag.txt must be binplaced to %DOCDIR%"
  659. goto :EOF
  660. )
  661. if not exist %DOCDIR%\triage.ini (
  662. call errmsg.cmd "Public triage.ini must be binplaced to %DOCDIR%"
  663. goto :EOF
  664. )
  665. copy %DOCDIR%\pooltag.txt %_NTTREE%\dbg\files\bin\triage\pooltag.txt > nul
  666. copy %DOCDIR%\triage.ini %_NTTREE%\dbg\files\bin\triage\triage.ini > nul
  667. )
  668. :EndFinishMergeModule
  669. goto :EOF
  670. :CreateIDTHeaders
  671. echo Component ComponentId Directory_ Attributes Condition KeyPath>%COMPONEN%
  672. echo s72 S38 s72 i2 S255 S72>>%COMPONEN%
  673. echo Component Component>>%COMPONEN%
  674. echo Directory Directory_Parent DefaultDir>%DIRECTOR%
  675. echo s72 S72 l255>>%DIRECTOR%
  676. echo Directory Directory>>%DIRECTOR%
  677. echo Feature_ Component_>%FEATUREC%
  678. echo s32 s72>>%FEATUREC%
  679. echo FeatureComponents Feature_ Component_>>%FEATUREC%
  680. echo File Component_ FileName FileSize Version Language Attributes Sequence>%FILE%
  681. echo s72 s72 l255 i4 S72 S20 I2 i2>>%FILE%
  682. echo File File>>%FILE%
  683. echo Component ModuleID Language>%MODULECO%
  684. echo s72 s72 i2>>%MODULECO%
  685. echo ModuleComponents Component ModuleID Language>>%MODULECO%
  686. echo ModuleID Language Version>%MODULESI%
  687. echo s72 i2 s32>>%MODULESI%
  688. echo ModuleSignature ModuleID Language>>%MODULESI%
  689. echo Shortcut Directory_ Name Component_ Target Arguments Description Hotkey Icon_ IconIndex ShowCmd WkDir>%SHORTCUT%
  690. echo s72 s128 l128 s128 s72 S255 L255 I2 S72 I2 I2 S72>>%SHORTCUT%
  691. echo Shortcut Shortcut>>%SHORTCUT%
  692. echo Registry Root Key Name Value Component_>%REGISTRY%
  693. echo s128 i2 l255 L255 L0 s128>>%REGISTRY%
  694. echo Registry Registry>>%REGISTRY%
  695. goto :EOF
  696. :CreateMSIHeaders
  697. echo DiskId LastSequence DiskPrompt Cabinet VolumeLabel Source>%MEDIA%
  698. echo i2 i2 L64 S255 S32 S32>>%MEDIA%
  699. echo Media DiskId>>%MEDIA%
  700. goto :EOF
  701. :CreateDDFHeader
  702. set CurDDF=%DDFDIR%\%1.ddf
  703. echo ^.Option Explicit>%CurDDF%
  704. echo ^.Set DiskDirectoryTemplate=%CABDIR%>>%CurDDF%
  705. echo ^.Set CabinetName1=%1.CABinet>>%CurDDF%
  706. echo ^.Set RptFilename=nul>>%CurDDF%
  707. echo ^.Set InfFileName=nul>>%CurDDF%
  708. echo ^.Set InfAttr=>>%CurDDF%
  709. echo ^.Set MaxDiskSize=CDROM>>%CurDDF%
  710. echo ^.Set CompressionType=MSZIP>>%CurDDF%
  711. echo ^.Set CompressionMemory=21>>%CurDDF%
  712. echo ^.Set CompressionLevel=1 >>%CurDDF%
  713. echo ^.Set Compress=ON>>%CurDDF%
  714. echo ^.Set Cabinet=ON>>%CurDDF%
  715. echo ^.Set UniqueFiles=ON>>%CurDDF%
  716. echo ^.Set FolderSizeThreshold=1000000>>%CurDDF%
  717. echo ^.Set MaxErrors=300>>%CurDDF%
  718. goto :EOF
  719. :UpdateProductCode
  720. REM Update the product code GUID in the property table
  721. REM
  722. REM %1 is the msi file
  723. REM %2 is the msi idt directory
  724. call logmsg "Updating the product code GUID in the property table"
  725. call cscript.exe %TOOLPATH%\wiexport.vbs //nologo %1 %2 Property
  726. copy %2\Property.idt %2\Property.idt.old > nul
  727. del /f %2\Property.idt
  728. uuidgen.exe -c -o%2\productguid
  729. for /f "tokens=1" %%a in (%2\productguid) do (
  730. set NewGuid=%%a
  731. )
  732. call logmsg "ProductCode GUID = !NewGuid!"
  733. for /f "tokens=1,2 delims= " %%a in (%2\Property.idt.old) do (
  734. if /i "%%a" == "ProductCode" (
  735. echo %%a {%NewGuid%}>>%2\Property.idt
  736. ) else (
  737. echo %%a %%b>>%2\Property.idt
  738. )
  739. )
  740. call cscript.exe %TOOLPATH%\wiimport.vbs //nologo %1 %2 Property.idt
  741. goto :EOF
  742. :SetUpgradeCode
  743. REM Update the upgrade code GUID in the property table
  744. REM
  745. REM %1 is the msi file
  746. REM %2 is the msi idt directory
  747. call logmsg "Setting the upgrade code GUID in the property table"
  748. call cscript.exe %TOOLPATH%\wiexport.vbs //nologo %1 %2 Property
  749. copy %2\Property.idt %2\Property.idt.old > nul
  750. del /f %2\Property.idt
  751. if /i "!CurArch!" == "i386" (
  752. set CurUpgradeGUID=AEBA607E-D79B-47EC-9C9B-4B3807853863
  753. )
  754. if /i "!CurArch!" == "ia64" (
  755. set CurUpgradeGUID=DFA2AD24-BADF-475F-8FBC-DDE7CBB7BFFD
  756. )
  757. call logmsg "!CurArch! Upgrade Code GUID = !CurUpgradeGUID!"
  758. for /f "tokens=1,2 delims= " %%a in (%2\Property.idt.old) do (
  759. if /i "%%a" == "UpgradeCode" (
  760. echo %%a {!CurUpgradeGuid!}>>%2\Property.idt
  761. ) else (
  762. echo %%a %%b>>%2\Property.idt
  763. )
  764. )
  765. call cscript.exe %TOOLPATH%\wiimport.vbs //nologo %1 %2 Property.idt
  766. REM Update the upgrade code GUID in the Upgrade table
  767. call logmsg "Updating the upgrade code in the Upgrade table
  768. call cscript.exe %TOOLPATH%\wiexport.vbs //nologo %1 %2 Upgrade
  769. copy %2\Upgrade.idt %2\Upgrade.idt.old > nul
  770. del /f %2\Upgrade.idt
  771. REM
  772. REM Put the header to the file
  773. REM Echo the first three lines to the file
  774. set /a count=1
  775. for /f "tokens=*" %%a in (%2\upgrade.idt.old) do (
  776. if !count! LEQ 3 echo %%a>>%2\Upgrade.idt
  777. set /a count=!count!+1
  778. )
  779. for /f "skip=3 tokens=1,2,3,4,5,6* delims= " %%a in (%2\Upgrade.idt.old) do (
  780. echo {!CurUpgradeGuid!} %%b %%c %%d %%e %%f>>%2\Upgrade.idt
  781. )
  782. call cscript.exe %TOOLPATH%\wiimport.vbs //nologo %1 %2 Upgrade.idt
  783. goto :EOF
  784. :UpdatePackageCode
  785. REM
  786. REM Update the guid for the package code in the _SummaryInformation table
  787. REM %1 is the msi file
  788. REM %2 is the msiidt directory
  789. call logmsg "Updating the package code GUID in the _SummaryInformation table"
  790. call cscript.exe %TOOLPATH%\wiexport.vbs //nologo %1 %2 _SummaryInformation
  791. copy %2\_SummaryInformation.idt %2\_SummaryInformation.idt.old > nul
  792. del /f %2\_SummaryInformation.idt
  793. uuidgen.exe -c -o%2\packageguid
  794. for /f "tokens=1" %%a in (%2\packageguid) do (
  795. set NewGuid=%%a
  796. )
  797. call logmsg "ProductCode GUID (package code) = !NewGuid!"
  798. for /f "tokens=1,2 delims= " %%a in (%2\_SummaryInformation.idt.old) do (
  799. if "%%a" == "9" (
  800. echo %%a {%NewGuid%}>>%2\_SummaryInformation.idt
  801. ) else (
  802. echo %%a %%b>>%2\_SummaryInformation.idt
  803. )
  804. )
  805. call cscript.exe %TOOLPATH%\wiimport.vbs //nologo %1 %2 _SummaryInformation.idt
  806. goto :EOF
  807. :SetVersion
  808. REM
  809. REM Update the version in the Property table
  810. REM and update the version in the Upgrade Table
  811. REM
  812. REM %1 is the msi file
  813. REM %2 is the msiidt directory
  814. set ntverp=%CD%\dbg-common\dbgver.h
  815. if NOT EXIST %ntverp% (echo Can't find dbgver.h.&goto :ErrEnd)
  816. for /f "tokens=3 delims=, " %%i in ('findstr /c:"#define VER_PRODUCTMAJORVERSION " %ntverp%') do (
  817. set /a ProductMajor="%%i"
  818. set BuildNum=%%i
  819. )
  820. for /f "tokens=3 delims=, " %%i in ('findstr /c:"#define VER_PRODUCTMINORVERSION " %ntverp%') do (
  821. set /a ProductMinor="%%i"
  822. set BuildNum=!BuildNum!.%%i
  823. )
  824. for /f "tokens=3" %%i in ('findstr /c:"#define VER_PRODUCTBUILD " %ntverp%') do (
  825. set /a ProductBuild="%%i"
  826. set BuildNum=!BuildNum!.%%i
  827. )
  828. for /f "tokens=3" %%i in ('findstr /c:"#define VER_PRODUCTBUILD_QFE " %ntverp%') do (
  829. set /a ProductQfe="%%i"
  830. set BuildNum=!BuildNum!.%%i
  831. )
  832. call logmsg "Updating the ProductVersion to !BuildNum! in the property table"
  833. call cscript.exe %TOOLPATH%\wiexport.vbs //nologo %1 %2 Property
  834. copy %2\Property.idt %2\Property.idt.old > nul
  835. del /f %2\Property.idt
  836. for /f "tokens=1,2 delims= " %%a in (%2\Property.idt.old) do (
  837. if /i "%%a" == "ProductVersion" (
  838. echo %%a !BuildNum!>>%2\Property.idt
  839. ) else (
  840. echo %%a %%b>>%2\Property.idt
  841. )
  842. )
  843. call cscript.exe %TOOLPATH%\wiimport.vbs //nologo %1 %2 Property.idt
  844. call logmsg "Updating the Maximum Upgrade version in the Upgrade table
  845. call cscript.exe %TOOLPATH%\wiexport.vbs //nologo %1 %2 Upgrade
  846. copy %2\Upgrade.idt %2\Upgrade.idt.old > nul
  847. del /f %2\Upgrade.idt
  848. REM
  849. REM Put the header to the file
  850. REM Echo the first three lines to the file
  851. set /a count=1
  852. for /f "tokens=*" %%a in (%2\upgrade.idt.old) do (
  853. if !count! LEQ 3 echo %%a>>%2\Upgrade.idt
  854. set /a count=!count!+1
  855. )
  856. REM
  857. REM Read in the lines after the header
  858. REM There are supposed to be 7 fields, but right now the language field
  859. REM is blank, so it gets skipped.
  860. REM Echo the line back, but put the buildnum as token three for the maximum
  861. REM version to upgrade. THen echo two tabs since we are skipping the language
  862. REM field, which was field four. It was empty, so it didn't get read in as a
  863. REM token. THen echo the other three tokens
  864. REM
  865. REM NOTE: I had problems saying tokens=1,2,3* and echo'ing %%d for the rest of
  866. REM the line because an extra tab gets written out at the end of the line
  867. REM
  868. REM First figure out what the maximum upgrade build number i
  869. REM It needs to be less than the current build num
  870. if !ProductQfe! GTR 0 (
  871. set /a ProductQfe="!ProductQfe!-1"
  872. ) else (
  873. set /a ProductBuild="!ProductBuild!-1"
  874. )
  875. set UpgradeBuildNum=!ProductMajor!.!ProductMinor!.!ProductBuild!.!ProductQfe!
  876. for /f "skip=3 tokens=1,2,3,4,5,6* delims= " %%a in (%2\Upgrade.idt.old) do (
  877. echo %%a %%b !UpgradeBuildNum! %%d %%e %%f>>%2\Upgrade.idt
  878. )
  879. call cscript.exe %TOOLPATH%\wiimport.vbs //nologo %1 %2 Upgrade.idt
  880. goto :EOF
  881. REM
  882. REM This creates redist_x86.txt and redist_oem.txt in the %DOCDIR% directory
  883. REM
  884. :UpdateRedist
  885. if /i "%CurArch%" == "i386" (
  886. set redist_list=redist_x86 redist_oem
  887. )
  888. if /i "%CurArch%" == "ia64" (
  889. set redist_list=redist_ia64
  890. )
  891. for %%a in ( %redist_list% ) do (
  892. call logmsg "Fixing %DOCDIR%\%%a.txt to have correct file versions"
  893. if /i "%PackageType%" == "retail" (
  894. if not exist %DOCDIR%\redist.txt (
  895. call errmsg "%DOCDIR%\redist.txt does not exist."
  896. goto :EOF
  897. )
  898. copy %DOCDIR%\redist.txt %DOCDIR%\%%a.txt
  899. REM get dbghelp's version number
  900. for /f "tokens=5 delims= " %%b in ('filever %SRCDIR%\bin\dbghelp.dll') do (
  901. set dbghelp_ver=%%b
  902. )
  903. call logmsg "dbghelp.dll's file version is !dbghelp_ver!"
  904. echotime /N "===================" >> %DOCDIR%\%%a.txt
  905. echotime /N "DBGHELP.DLL" >> %DOCDIR%\%%a.txt
  906. echotime /N "===================" >> %DOCDIR%\%%a.txt
  907. echo. >> %DOCDIR%\%%a.txt
  908. echotime /N "(1) You may redistribute dbghelp.dll version !dbghelp_ver!" >> %DOCDIR%\%%a.txt
  909. echo. >> %DOCDIR%\%%a.txt
  910. for /f "tokens=5 delims= " %%b in ('filever %SRCDIR%\bin\symsrv.dll') do (
  911. set symsrv_ver=%%b
  912. )
  913. call logmsg "symsrv.dll's file version is !symsrv_ver!"
  914. echotime /N "===================" >> %DOCDIR%\%%a.txt
  915. echotime /N "SYMSRV.DLL" >> %DOCDIR%\%%a.txt
  916. echotime /N "===================" >> %DOCDIR%\%%a.txt
  917. echo. >> %DOCDIR%\%%a.txt
  918. echotime /N "(1) You may redistribute symsrv.dll version !symsrv_ver!" >> %DOCDIR%\%%a.txt
  919. echo. >> %DOCDIR%\%%a.txt
  920. if /i "%%a" == "redist_oem" (
  921. for /f "tokens=5 delims= " %%b in ('filever %SRCDIR%\bin\dbgeng.dll') do (
  922. set dbgeng_ver=%%b
  923. )
  924. call logmsg "dbgeng.dll's file version is !dbgeng_ver!"
  925. echotime /N "===================" >> %DOCDIR%\%%a.txt
  926. echotime /N "DBGENG.DLL" >> %DOCDIR%\%%a.txt
  927. echotime /N "===================" >> %DOCDIR%\%%a.txt
  928. echo. >> %DOCDIR%\%%a.txt
  929. echotime /N "(1) You may redistribute dbgeng.dll version !dbgeng_ver!" >> %DOCDIR%\%%a.txt
  930. echo. >> %DOCDIR%\%%a.txt
  931. )
  932. ) else (
  933. echotime /N "This is a Beta package and no files in it are redistributable." > %DOCDIR%\%%a.txt
  934. )
  935. call logmsg "%DOCDIR%\%%a.txt is finished"
  936. )
  937. goto :EOF
  938. :DefaultInstallMode
  939. REM Update the REINSTALLMODE in the property table
  940. REM
  941. REM %1 is the msi file
  942. REM %2 is the msi idt directory
  943. call logmsg "Updating the REINSTALLMODE in the property table"
  944. call cscript.exe %TOOLPATH%\wiexport.vbs //nologo %1 %2 Property
  945. copy %2\Property.idt %2\Property.idt.old > nul
  946. del /f %2\Property.idt
  947. for /f "tokens=1,2 delims= " %%a in (%2\Property.idt.old) do (
  948. if /i "%%a" == "REINSTALLMODE" (
  949. echo %%a emus>>%2\Property.idt
  950. ) else (
  951. echo %%a %%b>>%2\Property.idt
  952. )
  953. )
  954. call cscript.exe %TOOLPATH%\wiimport.vbs //nologo %1 %2 Property.idt
  955. goto :EOF
  956. :RemoveInternalExtensions
  957. call logmsg "Removing Internal extensions from the feature table
  958. call cscript.exe %TOOLPATH%\wiexport.vbs //nologo %1 %2 Feature
  959. copy %2\Feature.idt %2\Feature.idt.old > nul
  960. del /f %2\Feature.idt
  961. REM
  962. REM Put the header to the file
  963. REM Echo the first three lines to the file
  964. set /a count=1
  965. for /f "tokens=*" %%a in (%2\Feature.idt.old) do (
  966. if !count! LEQ 3 echo %%a>>%2\Feature.idt
  967. set /a count=!count!+1
  968. )
  969. REM
  970. REM Read in the lines after the header
  971. REM Look for DBG.DbgExts.Internal and disable it
  972. for /f "skip=3 tokens=1,2,3,4,5,6,7* delims= " %%a in (%2\Feature.idt.old) do (
  973. if /i "%%a" == "DBG.DbgExts.Internal" (
  974. echo %%a %%b %%c %%d 0 0 %%g>>%2\Feature.idt
  975. ) else (
  976. if /i "%%a" == "DBG.NtsdFix.Internal" (
  977. echo %%a %%b %%c %%d 0 0 %%g>>%2\Feature.idt
  978. ) else (
  979. REM Some feature don't have a parent, so print a tab for the second field
  980. REM if the last token is a tab or equal to nothing
  981. if /i "%%g" == " " (
  982. echo %%a %%b %%c %%d %%e %%f>>%2\Feature.idt
  983. ) else (
  984. if /i "%%g" == "" (
  985. echo %%a %%b %%c %%d %%e %%f>>%2\Feature.idt
  986. ) else (
  987. echo %%a %%b %%c %%d %%e %%f %%g>>%2\Feature.idt
  988. )
  989. )
  990. )
  991. )
  992. )
  993. call cscript.exe %TOOLPATH%\wiimport.vbs //nologo %1 %2 Feature.idt
  994. goto :EOF
  995. :FixFeatureTable
  996. if /i "%_BuildArch%" == "ia64" (
  997. call logmsg.cmd "Making ia64 specific changes to the feature table"
  998. call cscript.exe %TOOLPATH%\wiexport.vbs //nologo %1 %2 Feature
  999. if exist %2\Feature.idt.old del /q %2\Feature.idt.old
  1000. copy %2\Feature.idt %2\Feature.idt.old > nul
  1001. del /f %2\Feature.idt
  1002. REM
  1003. REM Put the header to the file
  1004. REM Echo the first three lines to the file
  1005. set /a count=1
  1006. for /f "tokens=*" %%a in (%2\Feature.idt.old) do (
  1007. if !count! LEQ 3 echo %%a>>%2\Feature.idt
  1008. set /a count=!count!+1
  1009. )
  1010. REM
  1011. REM Read in the lines after the header
  1012. REM Look for DBG.DbgExts.Internal and disable it
  1013. for /f "skip=3 tokens=1,2,3,4,5,6,7* delims= " %%a in (%2\Feature.idt.old) do (
  1014. set done=no
  1015. if /i "%%a" == "DBG.DbgExts.Nt4Chk" (
  1016. echo %%a %%b %%c %%d 0 0 %%g>>%2\Feature.idt
  1017. set done=yes
  1018. )
  1019. if /i "%%a" == "DBG.DbgExts.Nt4Fre" (
  1020. echo %%a %%b %%c %%d 0 0 %%g>>%2\Feature.idt
  1021. set done=yes
  1022. )
  1023. if /i "%%a" == "DBG.DbgExts.Nt5Chk" (
  1024. echo %%a %%b %%c %%d 0 0 %%g>>%2\Feature.idt
  1025. set done=yes
  1026. )
  1027. if /i "%%a" == "DBG.DbgExts.Nt5Fre" (
  1028. echo %%a %%b %%c %%d 0 0 %%g>>%2\Feature.idt
  1029. set done=yes
  1030. )
  1031. if /i "%%a" == "DBG.Tools.Em" (
  1032. echo %%a %%b %%c %%d 0 0 %%g>>%2\Feature.idt
  1033. set done=yes
  1034. )
  1035. if /i "%%a" == "DBG.Docs.Em" (
  1036. echo %%a %%b %%c %%d 0 0 %%g>>%2\Feature.idt
  1037. set done=yes
  1038. )
  1039. if /i "%%a" == "DBG.Tools.Adplus" (
  1040. echo %%a %%b %%c %%d 0 0 %%g>>%2\Feature.idt
  1041. set done=yes
  1042. )
  1043. if /i "!done!" == "no" (
  1044. REM Some features don't have a parent, so print a tab for the second field
  1045. REM if the last token is a tab or equal to nothing
  1046. if /i "%%g" == " " (
  1047. echo %%a %%b %%c %%d %%e %%f>>%2\Feature.idt
  1048. ) else (
  1049. if /i "%%g" == "" (
  1050. echo %%a %%b %%c %%d %%e %%f>>%2\Feature.idt
  1051. ) else (
  1052. echo %%a %%b %%c %%d %%e %%f %%g>>%2\Feature.idt
  1053. )
  1054. )
  1055. )
  1056. )
  1057. call cscript.exe %TOOLPATH%\wiimport.vbs //nologo %1 %2 Feature.idt
  1058. )
  1059. goto :EOF
  1060. :MungeGUID
  1061. for /f "tokens=1,2,3,4,5 delims=-" %%m in ("%1") do (
  1062. set guidlet=%%m_%%n_%%o_%%p_%%q
  1063. )
  1064. goto :EOF
  1065. :FixComponentAttributes
  1066. if /i "%_BuildArch%" == "ia64" (
  1067. call cscript.exe %TOOLPATH%\wiexport.vbs //nologo %1 %2 Component
  1068. copy %2\Component.idt %2\Component.idt.old > nul
  1069. del /q %2\Component.idt
  1070. echo Component ComponentId Directory_ Attributes Condition KeyPath>%2\Component.idt
  1071. echo s72 S38 s72 i2 S255 S72>>%2\Component.idt
  1072. echo Component Component>>%2\Component.idt
  1073. for /f "skip=3 tokens=1,2,3,4,5,6* delims= " %%a in (%2\Component.idt.old) do (
  1074. if /i "%%d" == "0" (
  1075. set num4=256
  1076. ) else (
  1077. set num4=%%d
  1078. )
  1079. if "%%f" == "" (
  1080. set num5=
  1081. set num6=%%e
  1082. ) else (
  1083. set num5=%%e
  1084. set num6=%%f
  1085. )
  1086. echotime /N "%%a %%b %%c !num4! !num5! !num6!">>%2\Component.idt
  1087. )
  1088. call cscript.exe %TOOLPATH%\wiimport.vbs //nologo %1 %2 Component.idt
  1089. call logmsg "Set Component attributes to 256 for 64-bit install
  1090. )
  1091. goto :EOF
  1092. REM AddInstallationDependencies
  1093. REM This reads through dbgdata.txt and adds dependencies to the feature components table
  1094. REM
  1095. :AddInstallationDependencies
  1096. if exist %2\FeatureComponents.idt del /q %2\FeatureComponents.idt
  1097. if exist %2\FeatureComponents.idt.old del /q %2\Featurecomponents.idt.old
  1098. call cscript.exe %TOOLPATH%\wiexport.vbs //nologo %1 %2 FeatureComponents
  1099. copy %2\FeatureComponents.idt %2\FeatureComponents.idt.old > nul
  1100. for /f "tokens=1,2,3,4,5 delims=," %%a in (%DATA%) do (
  1101. REM Decide if this is a correct dependency for this package
  1102. set DoThisDependency=no
  1103. if /i "%%a" == "dependency" (
  1104. if /i "%%b" == "32" (
  1105. if /i "%_BuildArch%" == "x86" (
  1106. set DoThisDependency=yes
  1107. )
  1108. )
  1109. if /i "%%b" == "64" (
  1110. if /i "%_BuildArch%" == "ia64" (
  1111. set DoThisDependency=yes
  1112. )
  1113. )
  1114. if /i "%%b" == "3264" set DoThisDependency=yes
  1115. )
  1116. if /i "!DoThisDependency!" == "yes" (
  1117. REM If this dependency is for a feature, add all the components of this feature
  1118. REM to the feature listed in the dependency table
  1119. for /f "skip=3 tokens=1,2,3,4* delims= " %%f in (%2\FeatureComponents.idt.old) do (
  1120. if /i "%%f" == "%%d" (
  1121. echotime /N "%%c %%g">>%2\FeatureComponents.idt
  1122. )
  1123. if /i "%%g" == "%%d" (
  1124. echotime /N "%%c %%d">>%2\FeatureComponents.idt
  1125. )
  1126. )
  1127. )
  1128. )
  1129. call cscript.exe %TOOLPATH%\wiimport.vbs //nologo %1 %2 FeatureComponents.idt
  1130. goto :EOF
  1131. REM
  1132. REM Add components for all the features
  1133. REM
  1134. :AddComponentsForFeatures
  1135. call logmsg.cmd "Adding a component for each feature"
  1136. if exist %2\FeatureComponents.idt del /q %2\FeatureComponents.idt
  1137. if exist %2\Component.idt del /q %2\Component.idt
  1138. if exist %2\CreateFolder.idt del /q %2\CreateFolder.idt
  1139. call cscript.exe %TOOLPATH%\wiexport.vbs //nologo %1 %2 FeatureComponents
  1140. call cscript.exe %TOOLPATH%\wiexport.vbs //nologo %1 %2 Component
  1141. call cscript.exe %TOOLPATH%\wiexport.vbs //nologo %1 %2 CreateFolder
  1142. for /f "eol=; tokens=1,2,3,4* delims=," %%a in (%DATA%) do (
  1143. if /i "%%a" == "feature" (
  1144. if /i "%CurArch%" == "i386" set ThisGuid=%%c
  1145. if /i "%CurArch%" == "ia64" set ThisGuid=%%d
  1146. call :MungeGuid !ThisGuid!
  1147. echotime /N "%%b %%b.!guidlet!">>%2\FeatureComponents.idt
  1148. echotime /N "INSTDIR %%b.!guidlet!">>%2\CreateFolder.idt
  1149. echo %%b.!guidlet! {!ThisGuid!} INSTDIR 0 >>%2\Component.idt
  1150. )
  1151. )
  1152. call cscript.exe %TOOLPATH%\wiimport.vbs //nologo %1 %2 FeatureComponents.idt
  1153. call cscript.exe %TOOLPATH%\wiimport.vbs //nologo %1 %2 Component.idt
  1154. call cscript.exe %TOOLPATH%\wiimport.vbs //nologo %1 %2 CreateFolder.idt
  1155. goto :EOF
  1156. :DbgFinished
  1157. if /i "%DbgErrors%" == "yes" goto errend
  1158. if NOT EXIST %DESTDIR%\%MSINAME%.msi (
  1159. call errmsg "%DESTDIR%\%MSINAME%.msi is missing"
  1160. goto errend
  1161. )
  1162. goto end
  1163. REM **************************************************************************
  1164. REM Usage
  1165. REM
  1166. REM **************************************************************************
  1167. :Usage
  1168. echo Usage:
  1169. echo debuggers.cmd ^[ template ^| full ^| update ^]
  1170. echo.
  1171. echo template Builds the package without cabs
  1172. echo full Builds the full package (default)
  1173. echo update Does an incremental build of the cabs
  1174. echo.
  1175. goto errend
  1176. REM *********************
  1177. REM End of debugger code
  1178. REM *********************
  1179. REM **********************************************************
  1180. REM
  1181. REM Template
  1182. REM
  1183. REM **********************************************************
  1184. :MAIN
  1185. REM
  1186. REM Define SCRIPT_NAME. Used by the logging scripts.
  1187. REM
  1188. for %%i in (%0) do set script_name=%%~ni.cmd
  1189. REM
  1190. REM Save the command line.
  1191. REM
  1192. set cmdline=%script_name% %*
  1193. REM
  1194. REM Define LOGFILE, to be used by the logging scripts.
  1195. REM As the build rule scripts are typically invoked from wrappers (congeal.cmd),
  1196. REM LOGFILE is already defined.
  1197. REM
  1198. REM Do not redefine LOGFILE if already defined.
  1199. REM
  1200. if defined LOGFILE goto logfile_defined
  1201. if not exist %tmp% md %tmp%
  1202. for %%i in (%script_name%) do (
  1203. set LOGFILE=%tmp%\%%~ni.log
  1204. )
  1205. if exist %LOGFILE% del /f %LOGFILE%
  1206. :logfile_defined
  1207. REM
  1208. REM Create a temporary file, to be deleted when the script finishes its execution.
  1209. REM The existence of the temporary file tells congeal.cmd that this script is still running.
  1210. REM Before the temporary file is deleted, its contents are appended to LOGFILE.
  1211. REM International builds define tmpfile based on language prior to calling the US build
  1212. REM rule script, so that multiple languages can run the same build rule script concurrently.
  1213. REM
  1214. REM Do not redefine tmpfile if already defined.
  1215. REM
  1216. if defined tmpfile goto tmpfile_defined
  1217. if not exist %tmp% md %tmp%
  1218. for %%i in (%script_name%) do (
  1219. set tmpfile=%tmp%\%%~ni.tmp
  1220. )
  1221. if exist %tmpfile% del /f %tmpfile%
  1222. :tmpfile_defined
  1223. set LOGFILE_BAK=%LOGFILE%
  1224. set LOGFILE=%tmpfile%
  1225. REM
  1226. REM Mark the beginning of script's execution.
  1227. REM
  1228. call logmsg.cmd /t "START %cmdline%"
  1229. REM
  1230. REM Execute the build rule option.
  1231. REM
  1232. call :BeginBuildPackage
  1233. if errorlevel 1 (set /A ERRORS=%errorlevel%) else (set /A ERRORS=0)
  1234. REM
  1235. REM Mark the end of script's execution.
  1236. REM
  1237. call logmsg.cmd /t "END %cmdline% (%ERRORS% errors)"
  1238. set LOGFILE=%LOGFILE_BAK%
  1239. REM
  1240. REM Append the contents of tmpfile to logfile, then delete tmpfile.
  1241. REM
  1242. type %tmpfile% >> %LOGFILE%
  1243. del /f %tmpfile%
  1244. echo.& echo %script_name% : %ERRORS% errors : see %LOGFILE%.
  1245. if "%ERRORS%" == "0" goto end_main
  1246. goto errend_main
  1247. :end_main
  1248. endlocal
  1249. goto end
  1250. :errend_main
  1251. endlocal
  1252. goto errend
  1253. :ExecuteCmd
  1254. REM Do not use setlocal/endlocal:
  1255. REM for ex., if the command itself is "pushd",
  1256. REM a "popd" will be executed automatically at the end.
  1257. set cmd_bak=cmd
  1258. set cmd=%1
  1259. REM Remove the quotes
  1260. set cmd=%cmd:~1,-1%
  1261. if "%cmd%" == "" (
  1262. call errmsg.cmd "internal error: no parameters for ExecuteCmd %1."
  1263. set cmd=cmd_bak& goto errend
  1264. )
  1265. REM Run the command.
  1266. call logmsg.cmd "Running %cmd%."
  1267. %cmd%
  1268. if not "%errorlevel%" == "0" (
  1269. call errmsg.cmd "%cmd% failed."
  1270. set cmd=%cmd_bak%& goto errend
  1271. )
  1272. set cmd=cmd_bak
  1273. goto end
  1274. :errend
  1275. seterror.exe 1
  1276. goto :EOF
  1277. :end
  1278. seterror.exe 0
  1279. goto :EOF
  1280. REM END