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.

193 lines
4.3 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM
  4. REM makewinpeimg.cmd
  5. REM
  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. use Logmsg;
  20. sub Usage { print<<USAGE; exit(1) }
  21. makewinpeimg.cmd
  22. USAGE
  23. sub Dependencies {
  24. if ( !open DEPEND, ">>$ENV{_NTPOSTBLD}\\..\\build_logs\\dependencies.txt" ) {
  25. errmsg("Unable to open dependency list file.");
  26. die;
  27. }
  28. print DEPEND<<DEPENDENCIES;
  29. \[$0\]
  30. IF {...} ADD {
  31. opk\\...
  32. }
  33. DEPENDENCIES
  34. close DEPEND;
  35. exit;
  36. }
  37. my $qfe;
  38. parseargs('?' => \&Usage,
  39. 'plan' => \&Dependencies,
  40. 'qfe:' => \$qfe);
  41. if ( -f "$ENV{_NTPOSTBLD}\\..\\build_logs\\skip.txt" ) {
  42. if ( !open SKIP, "$ENV{_NTPOSTBLD}\\..\\build_logs\\skip.txt" ) {
  43. errmsg("Unable to open skip list file.");
  44. die;
  45. }
  46. while (<SKIP>) {
  47. chomp;
  48. exit if lc$_ eq lc$0;
  49. }
  50. close SKIP;
  51. }
  52. # *** NEXT FEW LINES ARE TEMPLATE ***
  53. $ENV{"_CPCMAGIC"}++;exit(system($0)>>8);
  54. __END__
  55. :CPCBegin
  56. set _CPCMAGIC=
  57. setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
  58. REM
  59. REM *** BEGIN YOUR CMD SCRIPT BELOW ***
  60. REM
  61. @echo off
  62. REM
  63. REM Set local variable's state
  64. REM
  65. set WINPEBUILDERROR=0
  66. set OldCurrentDirectory=%cd%
  67. REM
  68. REM We only create winpe images on fre builds
  69. REM
  70. if /i "%_BuildType%" == "chk" (
  71. goto :winpe_done
  72. )
  73. echo.
  74. echo ---------------------------------------
  75. echo Beginning WinPE image generation
  76. echo ---------------------------------------
  77. echo.
  78. call logmsg.cmd /t "Beginning WinPE image generation"
  79. REM
  80. REM Create the temporary build directory
  81. REM
  82. call logmsg.cmd "Copying the required WinPE build tools..."
  83. if exist %_NTPOSTBLD%\winpe.build (
  84. rd %_NTPOSTBLD%\winpe.build /s /q
  85. )
  86. md %_NTPOSTBLD%\winpe.build
  87. cd %_NTPOSTBLD%\winpe.build
  88. if errorlevel 1 (
  89. call logmsg.cmd "Error in setting up WinPE build directory"
  90. goto :winpe_error
  91. )
  92. REM
  93. REM Copy the required tools to build WinPE in the temporaray
  94. REM build directory
  95. REM
  96. copy %_NTPOSTBLD%\opk\winpe\* 2>1>nul
  97. if not errorlevel 1 (
  98. copy %_NTPOSTBLD%\opk\tools\%_BUILDARCH%\* 2>1>nul
  99. )
  100. if errorlevel 1 (
  101. call logmsg.cmd "Error in copying the WinPE build tools"
  102. goto :winpe_error
  103. )
  104. REM
  105. REM Make sure we are using the tools\x86 tools
  106. REM on Win64 WinPE image creation
  107. REM
  108. if /i "%_BuildArch%" == "amd64" (
  109. del bldhives.exe
  110. del oemmint.exe
  111. )
  112. if /i "%_BuildArch%" == "ia64" (
  113. del bldhives.exe
  114. del oemmint.exe
  115. )
  116. REM
  117. REM Now go ahead and create the WinPE image
  118. REM
  119. call logmsg.cmd "Creating the WinPE image..."
  120. call mkimg.cmd "%_NTPOSTBLD%\slp\pro" "%_NTPOSTBLD%\WINPE" > "%_NTPOSTBLD%\build_logs\winpebuild.log"
  121. REM
  122. REM Link back the WinPE folder under OPK folder so that we have a self sufficient
  123. REM OPK CD with WinPE.
  124. REM
  125. if not errorlevel 1 (
  126. call logmsg.cmd "Linking the WinPE image to OPK CD..."
  127. call compdir.exe /deklnstuw "%_NTPOSTBLD%\WINPE" "%_NTPOSTBLD%\opk" >> "%_NTPOSTBLD%\build_logs\winpebuild.log"
  128. REM
  129. REM Rename startopk.cmd as startnet.cmd for OPK WinPE CD.
  130. REM
  131. if not errorlevel 1 (
  132. if /i "%_BuildArch%" == "ia64" (
  133. del "%_NTPOSTBLD%\opk\ia64\system32\startnet.cmd" 2>1>nul
  134. copy "%_NTPOSTBLD%\opk\winpe\startopk.cmd" "%_NTPOSTBLD%\opk\ia64\system32\startnet.cmd" 2>1>nul
  135. ) else if /i "%_BuildArch%" == "amd64" (
  136. del "%_NTPOSTBLD%\opk\amd64\system32\startnet.cmd" 2>1>nul
  137. copy "%_NTPOSTBLD%\opk\winpe\startopk.cmd" "%_NTPOSTBLD%\opk\amd64\system32\startnet.cmd" 2>1>nul
  138. ) else if /i "%_BuildArch%" == "x86" (
  139. del "%_NTPOSTBLD%\opk\i386\system32\startnet.cmd" 2>1>nul
  140. copy "%_NTPOSTBLD%\opk\winpe\startopk.cmd" "%_NTPOSTBLD%\opk\i386\system32\startnet.cmd" 2>1>nul
  141. )
  142. )
  143. )
  144. :winpe_error
  145. set WINPEBUILDERROR=%errorlevel%
  146. REM
  147. REM Remove the build directory
  148. REM
  149. call logmsg.cmd "Removing WinPE build directory..."
  150. cd /d %OldCurrentDirectory%
  151. if exist %_NTPOSTBLD%\winpe.build (
  152. rd %_NTPOSTBLD%\winpe.build /s /q
  153. )
  154. call logmsg.cmd /t "Done with WinPE image generation"
  155. echo.
  156. echo ---------------------------------------
  157. echo Done with WinPE image generation
  158. echo ---------------------------------------
  159. echo.
  160. :winpe_done
  161. seterror.exe "%WINPEBUILDERROR%"