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.

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