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.

1736 lines
50 KiB

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