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.

263 lines
7.1 KiB

  1. @REM -----------------------------------------------------------------
  2. @REM
  3. @REM mkmedctr.cmd - Terrye
  4. @REM Generate Media Center Cabinet File.
  5. @REM
  6. @REM Leveraged from:
  7. @REM MkTabCab.cmd - dougpa
  8. @REM Generate TabletPC.cab file.
  9. @REM
  10. @REM Copyright (c) Microsoft Corporation. All rights reserved.
  11. @REM
  12. @REM -----------------------------------------------------------------
  13. @if defined _CPCMAGIC goto CPCBegin
  14. @perl -x "%~f0" %*
  15. @goto :EOF
  16. #!perl
  17. use strict;
  18. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  19. use lib $ENV{RAZZLETOOLPATH};
  20. use PbuildEnv;
  21. use ParseArgs;
  22. use Logmsg;
  23. sub Usage { print<<USAGE; exit(1) }
  24. mkmedctr.cmd [-l <language>]
  25. This sript creates medctr.cab. This cabinet contains files which
  26. are only installed on Windows XP TabletPC edition.
  27. USAGE
  28. sub Dependencies {
  29. if ( !open DEPEND, ">>$ENV{_NTPOSTBLD}\\..\\build_logs\\dependencies.txt" ) {
  30. errmsg("Unable to open dependency list file.");
  31. die;
  32. }
  33. print DEPEND<<DEPENDENCIES;
  34. \[$0\]
  35. IF { mediactr.cab mediactr.cat }
  36. ADD {
  37. ehepgdat.exe
  38. medctr.sed
  39. DEPENDENCIES
  40. my $file;
  41. $file = "$ENV{_NTTREE}\\medctr.sed";
  42. $file = "$ENV{_NTFILTER}\\medctr.sed" if !-f $file;
  43. sys("copy $file $ENV{TEMP}\\medctr.sed >nul 2>nul");
  44. if (!open SED, "$ENV{TEMp}\\medctr.sed") {
  45. errmsg("Unable to open medctr.sed");
  46. die;
  47. }
  48. my @files = <SED>;
  49. close SED;
  50. while ( (shift @files) !~ /\[SourceFiles0\]/i ) {}
  51. for (@files) {
  52. s/\s*\=\s*$/\n/;
  53. print DEPEND if !/^\s*$/;
  54. }
  55. print DEPEND "}\n\n";
  56. close DEPEND;
  57. exit;
  58. }
  59. sub sys {
  60. my $cmd = shift;
  61. logmsg("Running: $cmd");
  62. system($cmd);
  63. if ($?) {
  64. errmsg "$cmd ($?)";
  65. die;
  66. }
  67. }
  68. sub NoPrejit {
  69. $ENV{"_NOPREJIT"} = "SquelchPrejit";
  70. }
  71. my $qfe;
  72. parseargs('?' => \&Usage,
  73. 'plan' => \&Dependencies,
  74. 'qfe:' => \$qfe,
  75. 'noprejit' => \&NoPrejit );
  76. if ( -f "$ENV{_NTPOSTBLD}\\..\\build_logs\\skip.txt" ) {
  77. if ( !open SKIP, "$ENV{_NTPOSTBLD}\\..\\build_logs\\skip.txt" ) {
  78. errmsg("Unable to open skip list file.");
  79. die;
  80. }
  81. while (<SKIP>) {
  82. chomp;
  83. exit if lc$_ eq lc$0;
  84. }
  85. close SKIP;
  86. }
  87. # *** TEMPLATE CODE ***
  88. $ENV{"_CPCMAGIC"}++;exit(system($0)>>8);
  89. __END__
  90. @:CPCBegin
  91. @set _CPCMAGIC=
  92. @setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
  93. @if not defined DEBUG echo off
  94. @REM Only build this .cab for x86
  95. if not defined x86 goto :End
  96. call logmsg.cmd "MkMedCtr: Start Media Center postbuild..."
  97. if NOT "%_NOPREJIT%" == "" goto noprejit
  98. if "%OFFICIAL_BUILD_MACHINE%%PREJIT%" == "" goto noprejit
  99. if NOT "%_BUILDARCH%%_BUILDTYPE%" == "x86fre" goto noprejit
  100. @REM Just in case LANG is not set
  101. if NOT DEFINED lang goto :do_prejit
  102. @REM Only USA and KOR are supported right now
  103. if /i NOT "%lang%"=="usa" if /i NOT "%lang%"=="kor" goto :End
  104. :do_prejit
  105. set files=custsat.dll DebugSvc.dll ehCIR.dll ehCIR.ird EhCM.dll EhDebug.dll ehdrop.dll ehentt.dll ehepg.dll ehepgdat.dll ehepgdec.dll ehepgnet.dll ehiPlay.dll ehiProxy.dll ehiTuner.dll ehiuserxp.dll ehiVidCtl.dll ehiwmp.dll ehPlayer.dll ehProxy.dll e
  106. hRec.exe ehRecObj.dll ehres.dll ehSched.exe ehshell.exe ehtray.exe ehui.dll ehuihlp.dll medctrro.exe snchk.exe
  107. call logmsg.cmd "MkMedCtr: Copying files to Prejit machine and waiting up to 32 minutes"
  108. @rem Copy binaries up to prejit machine
  109. for %%a in (%files%) do (
  110. copy %_NTTREE%\%%a %PREJIT_DROP_SITE%\%%a
  111. )
  112. @rem Create the file which triggers the prejit process
  113. echo %_NTTREE% >%PREJIT_DROP_SITE%\new_bins.here
  114. sleep 120
  115. set sleep_count=2
  116. :sleep_loop
  117. sleep 60
  118. if exist %PREJIT_LDO_PICKUP%\ehshell.ldo goto :prejit_done
  119. set /a sleep_count+=1
  120. if %sleep_count% GEQ 32 goto :prejit_too_long
  121. call logmsg.cmd "MkMedCtr: Waited %sleep_count% minute(s) so far"
  122. goto :sleep_loop
  123. :prejit_too_long
  124. call logmsg.cmd "MkMedCtr: .LDO generation took too long, using placeholders"
  125. goto :prejit_continue
  126. :prejit_done
  127. call logmsg.cmd "MkMedCtr: Getting .LDO files from Prejit machine"
  128. sleep 60
  129. @REM Copy prejit results from %PREJIT_LDO_PICKUP% to bin folder, replacing placeholder .ldo files
  130. call %_NTROOT%\tools\sp\PlaceLdo.cmd %PREJIT_LDO_PICKUP%
  131. goto :prejit_continue
  132. :prejit_continue
  133. :noprejit
  134. @REM
  135. @REM Use Iexpress.exe to generate the .cab
  136. @REM
  137. @REM First, update the sed with the correct PostBuild directory.
  138. REM
  139. set DoubledPath=%_NTPostBld:\=\\%
  140. set NewSedFile=%temp%\mediactr.sed
  141. if EXIST %NewSedFile% del /f %NewSedFile%
  142. perl -n -e "s/_NTPOSTBLD/%DoubledPath%/g;print $_;" < %_NTPostBld%\medctr.sed > %NewSedFile%
  143. if not exist %NewSedFile% (
  144. call errmsg.cmd "File %NewSedFile% not found."
  145. goto :End
  146. )
  147. @REM
  148. @REM Generate MediaCtr.cat
  149. REM
  150. set MediaCtrTmp=%_NTPostBld%\MediaCtr.tmp
  151. if EXIST %MediaCtrTmp% rd /s /q %MediaCtrTmp%
  152. md %MediaCtrTmp%
  153. set SourceFiles0=%_NTPOSTBLD%
  154. set SourceFiles1=%_NTPOSTBLD%
  155. if defined LANG if /i not "%LANG%"=="usa" set SourceFiles1=%_NTPOSTBLD%\%LANG%
  156. if defined LANGUAGE if /i not "%LANGUAGE%"=="usa" set SourceFiles1=%_NTPOSTBLD%\%LANGUAGE%
  157. set set SourceDir=%SourceFiles0%
  158. set CopyFile=
  159. for /f "tokens=1" %%a in (%NewSedFile%) do (
  160. if /i "%%a"=="[SourceFiles0]" (
  161. set CopyFile=1
  162. set SourceDir=%SourceFiles0%
  163. ) else (
  164. if /i "%%a"=="[SourceFiles1]" (
  165. set CopyFile=1
  166. set SourceDir=%SourceFiles1%
  167. ) else (
  168. if /i "!copyFile!"=="1" (
  169. set File=%%a
  170. copy /y !SourceDir!\!File! %MediaCtrTmp%\!File!
  171. if errorlevel 1 (
  172. call errmsg.cmd "Could not copy %_NTPostBld%\!File!"
  173. set CopyErrors=1
  174. )
  175. )
  176. )
  177. )
  178. )
  179. if defined CopyErrors goto :End
  180. sleep 10
  181. call logmsg.cmd "MkMedCtr: Creating Catalog"
  182. call deltacat %MediaCtrTmp%
  183. if not exist %MediaCtrTmp%\delta.cat (
  184. call errmsg.cmd "Could not find %MediaCtrTmp%\delta.cat> Deltacat failed."
  185. goto :End
  186. )
  187. if exist %MediaCtrTmp%\MediaCtr.cat del /f /q %MediaCtrTmp%\MediaCtr.cat
  188. ren %MediaCtrTmp%\Delta.cat MediaCtr.cat
  189. if errorlevel 1 (
  190. call errmsg.cmd "Could not rename delta.cat to MediaCtr.cat"
  191. goto :End
  192. )
  193. copy %MediaCtrTmp%\MediaCtr.cat %_NTPostBld%\MediaCtr.cat
  194. if errorlevel 1 (
  195. call errmsg.cmd "Could not copy %MediaCtrTmp%\MediaCtr.cat to %_NTPostBld%"
  196. goto :End
  197. )
  198. REM
  199. REM Now generated MediaCtr.cab
  200. REM
  201. if exist %_NTPostBld%\mediactr.cab del /f %_NTPostBld%\mediactr.cab
  202. REM
  203. REM Munge the path so we use the correct wextract.exe to build the package with...
  204. REM NOTE: We *want* to use the one we just built (and for Intl localized)!
  205. REM
  206. set _NEW_PATH_TO_PREPEND=%RazzleToolPath%\%PROCESSOR_ARCHITECTURE%\loc\%LANG%
  207. set _OLD_PATH_BEFORE_PREPENDING=%PATH%
  208. set PATH=%_NEW_PATH_TO_PREPEND%;%PATH%
  209. call logmsg.cmd "MkMedCtr: Creating CAB"
  210. call ExecuteCmd.cmd "start /min /wait iexpress.exe /M /N /Q %NewSedFile%"
  211. REM
  212. REM Return the path to what it was before...
  213. REM
  214. set PATH=%_OLD_PATH_BEFORE_PREPENDING%
  215. if not exist %_NtPostBld%\mediactr.cab (
  216. call errmsg.cmd "IExpress.exe failed on %NewSedFile%. One or more files may be missing."
  217. goto :End
  218. )
  219. :End
  220. if defined MediaCtrTmp if exist %MediaCtrTmp% rd /s /q %MediaCtrTmp%
  221. if "%errors%" == "" set errors=0
  222. seterror.exe %errors%& goto :EOF