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.

477 lines
14 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM
  4. REM copywow64.cmd
  5. REM Copy appropriate 32bit files from a release into a 64bit build
  6. REM
  7. REM Copyright (c) Microsoft Corporation. All rights reserved.
  8. REM
  9. REM ------------------------------------------------------------------
  10. if defined _CPCMAGIC goto CPCBegin
  11. perl -x "%~f0" %*
  12. goto :EOF
  13. #!perl
  14. use strict;
  15. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  16. use lib $ENV{RAZZLETOOLPATH};
  17. use PbuildEnv;
  18. use ParseArgs;
  19. sub Usage { print<<USAGE; exit(1) }
  20. copywow64 [-l <language>]
  21. Copy appropriate 32bit files from a release into a 64bit build.
  22. If _NTWOWBINSTREE is set that is the location 32bit files will be
  23. copied from.
  24. USAGE
  25. parseargs('?' => \&Usage);
  26. # *** NEXT FEW LINES ARE TEMPLATE ***
  27. $ENV{"_CPCMAGIC"}++;exit(system($0)>>8);
  28. __END__
  29. :CPCBegin
  30. set _CPCMAGIC=
  31. setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
  32. REM *** BEGIN YOUR CMD SCRIPT BELOW ***
  33. REM This script generates a list of wow32 binaries to be copied from
  34. REM a 32 bit machine. The list itself is generated on the 64 bit machine
  35. REM Bail if your not on a 64 bit machine
  36. if /i "%_BuildArch%" neq "ia64" (
  37. if /i "%_BuildArch%" neq "amd64" (
  38. call logmsg.cmd "Not Win64, exiting."
  39. goto :End
  40. )
  41. )
  42. REM define comp if it's not already defined
  43. if NOT defined Comp (
  44. set Comp=No
  45. if %NUMBER_OF_PROCESSORS% GEQ 4 set Comp=Yes
  46. if defined OFFICIAL_BUILD_MACHINE set Comp=Yes
  47. )
  48. REM First find the latest build from which to copy the binaries
  49. if defined _NTWoWBinsTREE (
  50. set SourceDir=%_NTWoWBinsTREE%
  51. goto :EndGetBuild
  52. )
  53. REM read the copy location from build_logs\CPLocation.txt
  54. set CPFile=%_NTPOSTBLD%\build_logs\CPLocation.txt
  55. if not exist %CPFile% (
  56. call logmsg.cmd "Copy Location file not found, will attempt to create ..."
  57. call %RazzleToolPath%\PostBuildScripts\CPLocation.cmd -l:%lang%
  58. if not exist %CPFile% (
  59. call errmsg.cmd "CPLocation.cmd failed, exiting ..."
  60. goto :End
  61. )
  62. )
  63. for /f "delims=" %%a in ('type %CPFile%') do set CPLocation=%%a
  64. if not exist %CPLocation% (
  65. call logmsg.cmd "Copy Location from %CPFile% does not exist, retry ..."
  66. call %RazzleToolPath%\PostBuildScripts\CPLocation.cmd -l:%lang%
  67. if not exist %CPFile% (
  68. call errmsg.cmd "CPLocation.cmd failed, exiting ..."
  69. goto :End
  70. )
  71. for /f "delims=" %%a in ('type %CPFile%') do set CPLocation=%%a
  72. if not exist !CPLocation! (
  73. call errmsg.cmd "Copy Location !CPLocation! does not exist ..."
  74. goto :End
  75. )
  76. )
  77. call logmsg.cmd "Copy Location is set to %CPLocation% ..."
  78. set SourceDir=%CPLocation%
  79. :EndGetBuild
  80. if not exist %SourceDir% (
  81. call errmsg.cmd "The source dir %SourceDir% does not exist ..."
  82. goto :End
  83. )
  84. REM Now compare the services.tab files from the 32-bit build and
  85. REM the 64-bit build and make sure they're identical
  86. call logmsg.cmd "Verifying services.tab..."
  87. if not exist %SourceDir%\ntsv6432\kesvc32.tab (
  88. call logmsg.cmd "%SourceDir%\ntsv6432\kesvc32.tab not found"
  89. goto :CompFailed
  90. )
  91. if not exist %_NTPOSTBLD%\ntsv6432\kesvc.tab (
  92. call logmsg.cmd "%_NTPOSTBLD%\ntsv6432\kesvc.tab not found"
  93. goto :CompFailed
  94. )
  95. fc /w %SourceDir%\ntsv6432\kesvc32.tab %_NTPOSTBLD%\ntsv6432\kesvc.tab >Nul
  96. if %ERRORLEVEL% NEQ 0 (
  97. call logmsg.cmd "services.tab [kernel] comparison failed"
  98. goto :CompFailed
  99. )
  100. if not exist %SourceDir%\ntsv6432\guisvc32.tab (
  101. call logmsg.cmd "%SourceDir%\ntsv6432\guisvc32.tab not found"
  102. goto :CompFailed
  103. )
  104. if not exist %_NTPOSTBLD%\ntsv6432\guisvc.tab (
  105. call logmsg.cmd "%_NTPOSTBLD%\ntsv6432\guisvc.tab not found"
  106. goto :CompFailed
  107. )
  108. fc /w %SourceDir%\ntsv6432\guisvc32.tab %_NTPOSTBLD%\ntsv6432\guisvc.tab >Nul
  109. if %ERRORLEVEL% == 0 (
  110. call logmsg.cmd "services.tab comparison successful"
  111. goto :CompSucceeded
  112. )
  113. :CompFailed
  114. if defined OFFICIAL_BUILD_MACHINE (
  115. call errmsg.cmd "services.tab [gui] comparison failed"
  116. goto :END
  117. ) else (
  118. echo.
  119. call logmsg.cmd "--------------- WARNING: ---------------------------
  120. call logmsg.cmd "This Win64 build has a services.tab that's "
  121. call logmsg.cmd "incompatible with the 32-bit build used by Wow64."
  122. call logmsg.cmd "If the new services.tab entry you added isn't"
  123. call logmsg.cmd "located at the end of the file, then don't expect"
  124. call logmsg.cmd "32-bit component registration during 64-bit GUI "
  125. call logmsg.cmd "setup to work. Basically, 32-bit apps won't work on "
  126. call logmsg.cmd "this build."
  127. echo.
  128. )
  129. : CompSucceeded
  130. REM Set the Destination directory
  131. set DestDir=!_NTPostBld!\wowbins
  132. set UnCompDestDir=!_NTPostBld!\wowbins_uncomp
  133. REM Set the rest
  134. set outputfile=%tmp%\copywowlist.txt
  135. REM set wowchar=w
  136. set WowMiss=%tmp%\MissingWowFiles.txt
  137. call logmsg.cmd "Copying files from %SourceDir%"
  138. REM Delete the output file if it already exists
  139. if exist %tmp%\copywowlist.txt del /f %tmp%\copywowlist.txt
  140. if exist %tmp%\copywowlist1 del /f %tmp%\copywowlist1
  141. pushd %_NTPostBld%\congeal_scripts
  142. REM File compare the x86 and 64-bit layout.inf
  143. REM If they are different log a warning
  144. fc %SourceDir%\congeal_scripts\layout.inx layout.inx 2>Nul 1>Nul
  145. if /i NOT "%ErrorLevel%" == "0" (
  146. call logmsg.cmd /t "WARNING: the x86 build machine's layout.inx is different than this machine's - continuing"
  147. )
  148. if /i "%Comp%" == "No" (
  149. if exist !DestDir! (
  150. if exist !UnCompDestDir! rd /s /q !UnCompDestDir!
  151. if exist !DestDir! move !DestDir! !UnCompDestDir!
  152. )
  153. )
  154. REM Make the dosnet.tmp1 list: file with filenames and Media IDs.
  155. copy /b layout.inx+layout.txt dosnet.tmp1
  156. prodfilt dosnet.tmp1 dosnet.tmp2 +@
  157. prodfilt dosnet.tmp2 dosnet.tmp1 +i
  158. wowlist -i dosnet.tmp1 -c wowlist.inf -o dosnet.tmp2 -ac 2>NUL
  159. copy /b dosnet.tmp2+wowexcp.txt dosnet.tmp1
  160. copy /b layout.inx+layout.txt layout64.tmp1
  161. prodfilt layout64.tmp1 layout64.tmp2 +w
  162. prodfilt layout64.tmp2 layout64.tmp1 +m
  163. REM Process dosnet.tmp1 using layout64.tmp1 to get appropriate
  164. REM folder relative to \i386 and prepend to the entry before writing out to the outputfile
  165. call ExecuteCmd "perl %RazzleToolPath%\postbuildscripts\Copywowlist.pl layout64.tmp2 dosnet.tmp1 %outputfile%"
  166. copy %outputfile% %_NTPostBld%\congeal_scripts\copywowlist.txt
  167. REM ren files back to original name so that incremental compdir works.
  168. REM First, create the list of files at UnCompDestDir without the "w" (WowUncompDest.txt)
  169. if exist %tmp%\WowUncompDest.txt del %tmp%\WowUncompDest.txt
  170. for /f %%a in (%outputfile%) do (
  171. echo %UnCompDestDir%\%%a >> %tmp%\WowUncompDest.txt
  172. )
  173. REM Now rename files back
  174. if not exist !UnCompDestDir! md !UnCompDestDir!
  175. if /i "%Comp%" == "Yes" (
  176. if not exist !DestDir! md !DestDir!
  177. )
  178. for /f %%a in (%tmp%\WowUncompDest.txt) do (
  179. if exist %%~dpaw%%~nxa (
  180. if exist %%a del /f %%a
  181. ren %%~dpaw%%~nxa %%~nxa
  182. )
  183. )
  184. for /f %%i in (%outputfile%) do (
  185. if exist %SourceDir%\%%i call ExecuteCmd.cmd "compdir /enrstd %SourceDir%\%%i %UnCompDestDir%\%%i"
  186. )
  187. if exist dosnet.tmp1 del dosnet.tmp1
  188. if exist dosnet.tmp2 del dosnet.tmp2
  189. popd
  190. REM copy special wow6432 files over top of the stock versions
  191. REM Can't use /d because the wow6432 files MUST be copied over the same named
  192. REM files from root.
  193. call ExecuteCmd.cmd "xcopy /cyi %SourceDir%\wow6432 %UnCompDestDir%"
  194. REM Rename the files prepending a 'w'
  195. set wowchar=w
  196. REM do this once for files that don't have another file
  197. REM with the same name except for a 'w' in front
  198. for /f %%a in (%tmp%\WowUncompDest.txt) do (
  199. if not exist %%~dpaw%%~nxa (
  200. if exist %%a ren %%a w%%~nxa
  201. ) else (
  202. if exist %%a echo %%a>> %tmp%\WowRen.txt
  203. )
  204. )
  205. REM now do it for the remaining files
  206. if exist %tmp%\wowren.txt (
  207. for /f %%a in (%tmp%\WowRen.txt) do (
  208. if exist %%a ren %%a w%%~nxa
  209. )
  210. )
  211. if exist %tmp%\wowren.txt del /f %tmp%\wowren.txt
  212. REM Sign it
  213. call ExecuteCmd "deltacat.cmd %UnCompDestDir%"
  214. if exist %UnCompDestDir%\..\wow64.cat (
  215. del %UnCompDestDir%\..\wow64.cat
  216. )
  217. move %UnCompDestDir%\delta.cat %UnCompDestDir%\..\wow64.cat
  218. REM And now sign lang
  219. call ExecuteCmd "deltacat.cmd %UnCompDestDir%\lang"
  220. if exist %UnCompDestDir%\..\wowlang.cat (
  221. del %UnCompDestDir%\..\wowlang.cat
  222. )
  223. move %UnCompDestDir%\lang\delta.cat %UnCompDestDir%\..\wowlang.cat
  224. REM Compress it
  225. if /i "%Comp%" == "Yes" (
  226. pushd %DestDir%
  227. call ExecuteCmd.cmd "compress -r -d -zx21 -s %UnCompDestDir%\*.* ."
  228. popd
  229. if not exist %DestDir%\lang md %DestDir%\lang
  230. pushd %DestDir%\lang
  231. for /f %%a in ('dir /b /a-d !UnCompDestDir!\lang') do call ExecuteCmd.cmd "compress -r -d -zx21 -s %UnCompDestDir%\lang\%%a ."
  232. popd
  233. ) else (
  234. call ExecuteCmd.cmd "if exist !DestDir! rd /s/q !DestDir!"
  235. call ExecuteCmd.cmd "move !UnCompDestDir! !DestDir!"
  236. )
  237. call ExecuteCmd.cmd "xcopy /cyied %SourceDir%\asms %DestDir%\asms"
  238. call ExecuteCmd.cmd "xcopy /cyied %SourceDir%\wow6432\asms %DestDir%\wasms"
  239. REM
  240. REM Delete asms that have corresponding wasms.
  241. REM
  242. for /f %%i in ('dir /s/b/a-d %DestDir%\wasms\*.man') do call :DelAsmOfWasm %%i
  243. REM
  244. REM Delete any resulting empty directories.
  245. REM
  246. for /f %%i in ('dir /s/b/ad %DestDir%\asms') do rmdir %%i
  247. goto :EndDelAsmOfWasm
  248. :DelAsmOfWasm
  249. setlocal
  250. set i=%~dp1
  251. set i=%i:\wasms\=\asms\%
  252. call ExecuteCmd.cmd "rmdir /q/s %i%"
  253. endlocal
  254. goto :eof
  255. :EndDelAsmOfWasm
  256. REM Check that we have all the wow files
  257. if exist !WowMiss! del /f !WowMiss!
  258. REM Create the list of files at DestDir (their uncompressed name)
  259. REM and without the "w" (WowDest.txt)
  260. if exist %tmp%\WowDest.txt del %tmp%\WowDest.txt
  261. for /f %%a in (%outputfile%) do (
  262. echo %DestDir%\%%a >> %tmp%\WowDest.txt
  263. )
  264. for /f %%a in (%tmp%\WowDest.txt) do (
  265. if NOT exist %%~dpaw%%~nxa (
  266. call :CompName w%%~nxa
  267. if NOT exist %%~dpa!CompFileName! (
  268. echo %%~nxa >> !WowMiss!
  269. )
  270. )
  271. )
  272. REM If we are missing files we have to wait for the x86 machine
  273. if NOT exist !WowMiss! goto SkipTryAgain
  274. echo Missing WowFiles :
  275. if exist !WowMiss! type !WowMiss!
  276. if defined OFFICIAL_BUILD_MACHINE (
  277. echo.
  278. call logmsg.cmd "This 64-bit build machine must now wait for the"
  279. call logmsg.cmd "for corresponding x86 build machine to complete"
  280. call logmsg.cmd "build and postbuild in order to copy wow64 files"
  281. call logmsg.cmd "that are required by setup."
  282. echo.
  283. ) else (
  284. echo.
  285. call logmsg.cmd "You are missing the files listed above."
  286. call logmsg.cmd "This means there will be missing files during setup."
  287. echo.
  288. call logmsg.cmd "This probably occurred because someone in your VBL"
  289. call logmsg.cmd "added new wow64 files to layout.inx, but the VBL x86"
  290. call logmsg.cmd "build machine has not finished it's build with"
  291. call logmsg.cmd "these changes."
  292. echo.
  293. call logmsg.cmd "You MUST UNDERSTAND these missing files"
  294. call logmsg.cmd "before checking in your changes."
  295. echo.
  296. call errmsg.cmd "Continuing with missing wow files."
  297. goto :SkipTryAgain
  298. )
  299. REM
  300. REM if there were failed file copies, then let's generate our copy location
  301. REM again and retry
  302. REM
  303. call %RazzleToolPath%\PostBuildScripts\CPLocation.cmd -l:%lang%
  304. set CPFile=%_NTPOSTBLD%\build_logs\CPLocation.txt
  305. if not exist %CPFile% (
  306. call errmsg.cmd "Failed to find %CPFile%, exiting ..."
  307. goto :End
  308. )
  309. for /f "delims=" %%a in ('type %CPFile%') do set CPLocation=%%a
  310. if not exist %CPLocation% (
  311. call errmsg.cmd "Copy location %CPLocation% not found, exiting ..."
  312. goto :End
  313. )
  314. call logmsg.cmd "Retrying, copying from %CPLocation% ..."
  315. set SourceDir=%CPLocation%
  316. REM Copy and compress the files one by one - there shouldn't be many
  317. REM Note that the file may have been removed so check for existence
  318. REM before attempting to copy
  319. if /i "%Comp%" == "Yes" (
  320. pushd !DestDir!
  321. for /f %%a in (!WowMiss!) do (
  322. if exist !SourceDir!\%%a (
  323. echo copying %%a from !SourceDir! ...
  324. call ExecuteCmd.cmd "copy !SourceDir!\%%a !UnCompDestDir!\w%%a"
  325. echo compressing w%%a ...
  326. call ExecuteCmd.cmd "compress -zx21 -r -d -s !UnCompDestDir!\w%%a ."
  327. )
  328. )
  329. for /f %%a in (!WowMiss!) do (
  330. if exist !SourceDir!\wow6432\%%a (
  331. echo copying %%a from !SourceDir!\wow6432 ...
  332. call ExecuteCmd.cmd "copy !SourceDir!\wow6432\%%a !UnCompDestDir!\w%%a"
  333. echo compressing w%%a ...
  334. call ExecuteCmd.cmd "compress -zx21 -r -d -s !UnCompDestDir!\w%%a ."
  335. )
  336. )
  337. popd
  338. ) else (
  339. pushd !DestDir!
  340. for /f %%a in (!WowMiss!) do (
  341. if exist !SourceDir!\%%a (
  342. echo copying %%a from !SourceDir! ...
  343. call ExecuteCmd.cmd "copy !SourceDir!\%%a !DestDir!\w%%a"
  344. )
  345. )
  346. for /f %%a in (!WowMiss!) do (
  347. if exist !SourceDir!\wow6432\%%a (
  348. echo copying %%a from !SourceDir!\wow6432 ...
  349. call ExecuteCmd.cmd "copy !SourceDir!\wow6432\%%a !DestDir!\w%%a"
  350. )
  351. )
  352. popd
  353. )
  354. REM Now make sure there are no missing files
  355. if exist !WowMiss! del /f !WowMiss!
  356. for /f %%a in (%outputfile%) do (
  357. if NOT exist %DestDir%\w%%a (
  358. call :CompName w%%a
  359. if NOT exist %DestDir%\!CompFileName! (
  360. echo %%a >> !WowMiss!
  361. )
  362. )
  363. )
  364. REM Now remake the catalog - It doesn't take very long
  365. REM Also note that catalog signing doesn't care if I compress
  366. REM first or sign first, so we can sign the uncompressed binaries now.
  367. if /i "%Comp%" == "Yes" (
  368. call deltacat.cmd %UnCompDestDir%
  369. if exist %UnCompDestDir%\..\wow64.cat (
  370. del %UnCompDestDir%\..\wow64.cat
  371. )
  372. move %UnCompDestDir%\delta.cat %UnCompDestDir%\..\wow64.cat
  373. copy %tmp%\cdf\delta.cdf %_ntpostbld%\build_logs\copywow64.cdf
  374. copy %tmp%\log\delta.log %_ntpostbld%\build_logs\copywow64.log
  375. ) else (
  376. call deltacat.cmd -d %DestDir%
  377. if exist %DestDir%\..\wow64.cat (
  378. del %DestDir%\..\wow64.cat
  379. )
  380. move %DestDir%\delta.cat %DestDir%\..\wow64.cat
  381. )
  382. REM If the files are missing now we're screwed - log an error
  383. if exist !WowMiss! (
  384. call errmsg.cmd "Missing Wow64 files after x86 build finished - you cannot boot this build."
  385. if exist !WowMiss! type !WowMiss!
  386. )
  387. :SkipTryAgain
  388. goto end
  389. REM
  390. REM Function :CompName
  391. REM Arguments : File Name Returns : Compressed File Name
  392. REM
  393. :CompName
  394. for %%a in (%1) do (
  395. set FileName=%%~na
  396. set FileExt=%%~xa
  397. )
  398. if NOT defined FileExt (
  399. set CompFileExt=._
  400. ) else (
  401. set FourthExtChar=!FileExt:~3,1!
  402. if defined FourthExtChar (
  403. set CompFileExt=!FileExt:~0,-1!_
  404. ) else (
  405. set CompFileExt=!FileExt!_
  406. )
  407. )
  408. set CompFileName=!FileName!!CompFileExt!
  409. goto :EOF
  410. :end
  411. seterror.exe "%errors%"& goto :EOF