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.

395 lines
12 KiB

  1. REM
  2. REM Generate msrdpcli.msi from msrdpcl_.msi
  3. REM 1) create data.cab for client bins and stream that in
  4. REM 2) stream in custom.dll (custom action)
  5. REM 3) Update file table with new version and size info (for this build)
  6. REM 4) Update product and package code for this build (every build is like a 'new product')
  7. REM
  8. REM Assumes i386 build env (we don't build tsclient MSI for any other archs)
  9. REM Contact: nadima
  10. REM
  11. REM (need this switch for the BuildNum stuff below to work)
  12. setlocal ENABLEDELAYEDEXPANSION
  13. set MSIIDTDIR=%_NTPOSTBLD%\tsclient\win32\i386\idtdir
  14. set MSINAME=.\msrdpcli.msi
  15. REM make tempdirs
  16. if exist .\tmpcab (
  17. rmdir /q /s .\tmpcab
  18. if errorlevel 1 call errmsg.cmd "err deleting tmpcab dir"& goto errend
  19. )
  20. if exist %MSIIDTDIR% (
  21. rmdir /q /s %MSIIDTDIR%
  22. if errorlevel 1 call errmsg.cmd "err deleting idtdir dir"& goto errend
  23. )
  24. mkdir .\tmpcab
  25. if errorlevel 1 call errmsg.cmd "err creating .\tmpcab dir"& goto errend
  26. mkdir %MSIIDTDIR%
  27. if errorlevel 1 call errmsg.cmd "err creating %MSIIDTDIR% dir"& goto errend
  28. REM verify source files
  29. if not exist .\mstscax.dll (
  30. call errmsg.cmd "mstscax.dll is missing for tscmsigen.cmd"
  31. goto errend
  32. )
  33. if not exist .\mstsc.exe (
  34. call errmsg.cmd "mstsc.exe is missing for tscmsigen.cmd"
  35. goto errend
  36. )
  37. if not exist %_NTPOSTBLD%\mstsc.chm (
  38. call errmsg.cmd "mstsc.chm is missing for tscmsigen.cmd"
  39. goto errend
  40. )
  41. copy %_NTPOSTBLD%\mstsc.chm .\mstsc.chm
  42. if errorlevel 1 call errmsg.cmd "err copying up help (mstsc.chm) from binaries root"& goto errend
  43. if not exist .\msrdpcl_.msi (
  44. call errmsg.cmd "msrdpcl_.msi is missing for tscmsigen.cmd"
  45. goto errend
  46. )
  47. if not exist .\custom.dll (
  48. call errmsg.cmd "custom.dll is missing for tscmsigen.cmd"
  49. goto errend
  50. )
  51. if not exist .\wistream.vbs (
  52. call errmsg.cmd "wistream.vbs is missing for tscmsigen.cmd"
  53. goto errend
  54. )
  55. if not exist .\media.idt (
  56. call errmsg.cmd "media.idt is missing for tscmsigen.cmd"
  57. goto errend
  58. )
  59. REM rename files
  60. copy .\mstsc.exe .\tmpcab\F1060_mstsc.exe
  61. if errorlevel 1 call errmsg.cmd "err copying files to .\tmpcab"& goto errend
  62. copy .\mstsc.chm .\tmpcab\F1061_mstsc.chm
  63. if errorlevel 1 call errmsg.cmd "err copying files to .\tmpcab"& goto errend
  64. copy .\mstscax.dll .\tmpcab\F1059_mstscax.dll
  65. if errorlevel 1 call errmsg.cmd "err copying files to .\tmpcab"& goto errend
  66. REM now generate the cab file
  67. if exist .\data.cab (
  68. del data.cab
  69. )
  70. REM Sequence of files MUST match Sequence field of MSI File table (see Sequence property in File table)
  71. cabarc -s 6144 -m MSZIP -i 1 n .\data.cab .\tmpcab\F1060_mstsc.exe .\tmpcab\F1059_mstscax.dll .\tmpcab\F1061_mstsc.chm
  72. if errorlevel 1 (
  73. call errmsg.cmd "cabarc failed to generate .\data.cab"
  74. goto errend
  75. )
  76. rmdir /q /s .\tmpcab
  77. if errorlevel 1 call errmsg.cmd "err deleting tmpcab dir"& goto errend
  78. REM *****************************************************
  79. REM * Update the MSI *
  80. REM *****************************************************
  81. if exist %MSINAME% del %MSINAME%
  82. copy .\msrdpcl_.msi msrdpcli.msi
  83. if errorlevel 1 call errmsg.cmd "err copying msrdpcl_.msi to %MSINAME%" & goto errend
  84. REM *****************************************************
  85. REM * Stream in the client binaries (in cab form) *
  86. REM *****************************************************
  87. cscript.exe .\wistream.vbs %MSINAME% .\data.cab
  88. if errorlevel 1 (
  89. call errmsg.cmd "wistream failed to stream in .\data.cab"
  90. goto errend
  91. )
  92. REM *****************************************************
  93. REM * Stream in the update custom.dll *
  94. REM *****************************************************
  95. cscript.exe .\wistream.vbs %MSINAME% .\custom.dll Binary.New_Binary
  96. if errorlevel 1 (
  97. call errmsg.cmd "wistream failed to stream in .\custom.dll"
  98. goto errend
  99. )
  100. REM *****************************************************
  101. REM * Give every package that gets generated, a new *
  102. REM * product and package code. MSI will always thing *
  103. REM * its upgrading. *
  104. REM *****************************************************
  105. call :UpdateProductCode %MSINAME% %MSIIDTDIR%
  106. call :UpdatePackageCode %MSINAME% %MSIIDTDIR%
  107. call :SetUpgradeCode %MSINAME% %MSIIDTDIR%
  108. REM *****************************************************
  109. REM * Update the product version property *
  110. REM *****************************************************
  111. call :SetVersion %MSINAME% %MSIIDTDIR%
  112. REM *****************************************************
  113. REM * Update the filetable with file size and ver info *
  114. REM * assumes the source files are in the same directory*
  115. REM *****************************************************
  116. call cscript.exe .\\wifilver.vbs /U %MSINAME%
  117. if errorlevel 1 (
  118. call errmsg.cmd "wifilver failed"
  119. goto errend
  120. )
  121. REM *****************************************************
  122. REM * Update the media table to reflect that the data.cab
  123. REM * is a streamed in archive *
  124. REM *****************************************************
  125. copy .\media.idt %MSIIDTDIR%\media.idt
  126. if errorlevel 1 call errmsg.cmd "err copying media.idt files to IDTDIR"& goto errend
  127. call cscript.exe .\wiimport.vbs %MSINAME% %MSIIDTDIR% media.idt
  128. if errorlevel 1 (
  129. call errmsg.cmd "Import update media table failed"
  130. goto errend
  131. )
  132. REM *****************************************************
  133. REM * Patch the Control table to fix dev src lock problems
  134. REM *****************************************************
  135. msiquery.exe "UPDATE Control Set Attributes = 3 WHERE Type = 'RadioButtonGroup'" %MSINAME%
  136. call logmsg.cmd "tscmsigen.cmd COMPLETED OK!"
  137. REM we're done
  138. endlocal
  139. goto end
  140. REM ******************SUBS START HERE********************
  141. REM *****************************************************
  142. REM * Update version sub *
  143. REM * (updates version in the property table *
  144. REM *****************************************************
  145. :SetVersion
  146. REM
  147. REM Update the version in the Property table
  148. REM and update the version in the Upgrade Table
  149. REM
  150. REM %1 is the msi file
  151. REM %2 is the msiidt directory
  152. set ntverp=%_NTBINDIR%\public\sdk\inc\ntverp.h
  153. if NOT EXIST %ntverp% (echo Can't find ntverp.h.&goto :ErrEnd)
  154. for /f "tokens=3 delims=, " %%i in ('findstr /c:"#define VER_PRODUCTMAJORVERSION " %ntverp%') do (
  155. set /a ProductMajor="%%i"
  156. set BuildNum=%%i
  157. )
  158. for /f "tokens=3 delims=, " %%i in ('findstr /c:"#define VER_PRODUCTMINORVERSION " %ntverp%') do (
  159. set /a ProductMinor="%%i"
  160. set BuildNum=!BuildNum!.%%i
  161. )
  162. for /f "tokens=6" %%i in ('findstr /c:"#define VER_PRODUCTBUILD " %ntverp%') do (
  163. set /a ProductBuild="%%i"
  164. set BuildNum=!BuildNum!.%%i
  165. )
  166. for /f "tokens=3" %%i in ('findstr /c:"#define VER_PRODUCTBUILD_QFE " %ntverp%') do (
  167. set /a ProductQfe="%%i"
  168. set BuildNum=!BuildNum!.%%i
  169. )
  170. call logmsg.cmd "Updating the msrdpcli.msi ProductVersion to !BuildNum! in prop table"
  171. call cscript.exe .\\wiexport.vbs %1 %2 Property
  172. copy %2\Property.idt %2\Property.idt.old > nul
  173. del /f %2\Property.idt
  174. for /f "tokens=1,2,* delims= " %%a in (%2\Property.idt.old) do (
  175. if /i "%%a" == "ProductVersion" (
  176. echo %%a !BuildNum!>>%2\Property.idt
  177. ) else (
  178. if "%%c"=="" (
  179. echo %%a %%b>>%2\Property.idt
  180. ) else (
  181. echo %%a %%b %%c>>%2\Property.idt
  182. )
  183. )
  184. )
  185. REM Set the property that says if this is an x86 or a 64-bit package
  186. if /i "%CurArch%" == "i386" (
  187. echo Install32 ^1>>%2\Property.idt
  188. )
  189. if /i "%CurArch%" == "ia64" (
  190. echo Install64 ^1>>%2\Property.idt
  191. )
  192. call cscript.exe .\\wiimport.vbs //nologo %1 %2 Property.idt
  193. if errorlevel 1 (
  194. call errmsg.cmd "Import of Property table in SetVersion back into msrdpcli.msi failed!"
  195. goto errend
  196. )
  197. REM call logmsg.cmd "Finished updating the ProductVersion in the property table"
  198. goto :EOF
  199. REM *****************************************************
  200. REM * Update product code sub *
  201. REM *****************************************************
  202. :UpdateProductCode
  203. REM Update the product code GUID in the property table
  204. REM
  205. REM %1 is the msi file
  206. REM %2 is the msi idt directory
  207. call logmsg.cmd "Updating the product code GUID in the property table"
  208. call cscript.exe .\\wiexport.vbs %1 %2 Property
  209. copy %2\Property.idt %2\Property.idt.old > nul
  210. del /f %2\Property.idt
  211. uuidgen.exe -c -o%2\productguid
  212. for /f "tokens=1" %%a in (%2\productguid) do (
  213. set NewGuid=%%a
  214. )
  215. call logmsg.cmd "ProductCode GUID = !NewGuid!"
  216. for /f "tokens=1,2,* delims= " %%a in (%2\Property.idt.old) do (
  217. if /i "%%a" == "ProductCode" (
  218. echo %%a {%NewGuid%}>>%2\Property.idt
  219. ) else (
  220. if "%%c"=="" (
  221. echo %%a %%b>>%2\Property.idt
  222. ) else (
  223. echo %%a %%b %%c>>%2\Property.idt
  224. )
  225. )
  226. )
  227. call cscript.exe .\wiimport.vbs //nologo %1 %2 Property.idt
  228. if errorlevel 1 (
  229. call errmsg.cmd "Import of Property table in UpdateProductCode back into msrdpcli.msi failed!"
  230. goto errend
  231. )
  232. call logmsg.cmd "Finished updating the product code GUID in the property table"
  233. goto :EOF
  234. REM *****************************************************
  235. REM * Update package code sub *
  236. REM *****************************************************
  237. :UpdatePackageCode
  238. REM
  239. REM Update the guid for the package code in the _SummaryInformation table
  240. REM %1 is the msi file
  241. REM %2 is the msiidt directory
  242. call logmsg.cmd "Updating the package code GUID in the _SummaryInformation table"
  243. call cscript.exe .\\wiexport.vbs //nologo %1 %2 _SummaryInformation
  244. copy %2\_SummaryInformation.idt %2\_SummaryInformation.idt.old > nul
  245. del /f %2\_SummaryInformation.idt
  246. uuidgen.exe -c -o%2\packageguid
  247. for /f "tokens=1" %%a in (%2\packageguid) do (
  248. set NewGuid=%%a
  249. )
  250. call logmsg.cmd "ProductCode GUID (package code) = !NewGuid!"
  251. for /f "tokens=1,2 delims= " %%a in (%2\_SummaryInformation.idt.old) do (
  252. if "%%a" == "9" (
  253. echo %%a {%NewGuid%}>>%2\_SummaryInformation.idt
  254. ) else (
  255. echo %%a %%b>>%2\_SummaryInformation.idt
  256. )
  257. )
  258. call cscript.exe .\\wiimport.vbs //nologo %1 %2 _SummaryInformation.idt
  259. goto :EOF
  260. REM *****************************************************
  261. REM * Set upgrade code to ease future upgrades *
  262. REM *****************************************************
  263. :SetUpgradeCode
  264. REM Update the upgrade code GUID in the property table
  265. REM
  266. REM %1 is the msi file
  267. REM %2 is the msi idt directory
  268. call logmsg.cmd "Setting the upgrade code GUID in the property table"
  269. call cscript.exe .\\wiexport.vbs //nologo %1 %2 Property
  270. copy %2\Property.idt %2\Property.idt.old > nul
  271. del /f %2\Property.idt
  272. set CurUpgradeGUID=17258378-2B69-4900-9754-1CAD4D0FB7CC
  273. call logmsg.cmd "!CurArch! Upgrade Code GUID = !CurUpgradeGUID!"
  274. for /f "tokens=1,2,* delims= " %%a in (%2\Property.idt.old) do (
  275. if /i "%%a" == "UpgradeCode" (
  276. echo %%a {!CurUpgradeGuid!}>>%2\Property.idt
  277. ) else (
  278. if "%%c"=="" (
  279. echo %%a %%b>>%2\Property.idt
  280. ) else (
  281. echo %%a %%b %%c>>%2\Property.idt
  282. )
  283. )
  284. )
  285. call cscript.exe .\\wiimport.vbs //nologo %1 %2 Property.idt
  286. if errorlevel 1 (
  287. call errmsg.cmd "Import of Property table in SetUpgradeCode back into msrdpcli.msi failed!"
  288. goto errend
  289. )
  290. call logmsg.cmd "Finished updating the product code GUID in the property table"
  291. REM Update the upgrade code GUID in the Upgrade table
  292. call logmsg.cmd "Updating the upgrade code in the Upgrade table
  293. call cscript.exe .\\wiexport.vbs //nologo %1 %2 Upgrade
  294. copy %2\Upgrade.idt %2\Upgrade.idt.old > nul
  295. del /f %2\Upgrade.idt
  296. REM
  297. REM Put the header to the file
  298. REM Echo the first three lines to the file
  299. set /a count=1
  300. for /f "tokens=*" %%a in (%2\upgrade.idt.old) do (
  301. if !count! LEQ 3 echo %%a>>%2\Upgrade.idt
  302. set /a count=!count!+1
  303. )
  304. for /f "skip=3 tokens=1,2,3,4,5,6* delims= " %%a in (%2\Upgrade.idt.old) do (
  305. echo {!CurUpgradeGuid!} %%b %%c %%d %%e %%f>>%2\Upgrade.idt
  306. )
  307. call cscript.exe .\\wiimport.vbs //nologo %1 %2 Upgrade.idt
  308. call logmsg.cmd "Finished updating the Upgrade code in the upgrade table"
  309. goto :EOF
  310. :errend
  311. goto :EOF
  312. :end
  313. seterror.exe 0
  314. goto :EOF