Leaked source code of windows server 2003
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.

154 lines
3.8 KiB

  1. @REM -----------------------------------------------------------------
  2. @REM
  3. @REM makewinpeimg.cmd - VijayJ
  4. @REM Create the images for the WinPE CD
  5. @REM
  6. @REM Copyright (c) Microsoft Corporation. All rights reserved.
  7. @REM
  8. @REM -----------------------------------------------------------------
  9. @if defined _CPCMAGIC goto CPCBegin
  10. @perl -x "%~f0" %*
  11. @goto :EOF
  12. #!perl
  13. use strict;
  14. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  15. use lib $ENV{RAZZLETOOLPATH};
  16. use PbuildEnv;
  17. use ParseArgs;
  18. sub Usage { print<<USAGE; exit(1) }
  19. makewinpeimg [-l <language>]
  20. Create the images for the WinPE CD
  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 /d %_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 from <root>\tools\<architecture>
  77. REM
  78. del bldhives.exe
  79. del oemmint.exe
  80. REM
  81. REM Now go ahead and create the WinPE image
  82. REM
  83. call logmsg.cmd "Creating the WinPE image..."
  84. call mkimg.cmd "%_NTPOSTBLD%\ads" "%_NTPOSTBLD%\WINPE" > "%_NTPOSTBLD%\build_logs\winpebuild.log"
  85. REM
  86. REM Link back the WinPE folder under OPK folder so that we have a self sufficient
  87. REM OPK CD with WinPE.
  88. REM
  89. if not errorlevel 1 (
  90. call logmsg.cmd "Linking the WinPE image to OPK CD..."
  91. call compdir.exe /deklnstuw "%_NTPOSTBLD%\WINPE" "%_NTPOSTBLD%\opk" >> "%_NTPOSTBLD%\build_logs\winpebuild.log"
  92. REM
  93. REM Rename startopk.cmd as startnet.cmd for OPK WinPE CD.
  94. REM
  95. if not errorlevel 1 (
  96. if /i "%_BuildArch%" == "ia64" (
  97. del "%_NTPOSTBLD%\opk\ia64\system32\startnet.cmd" 2>1>nul
  98. copy "%_NTPOSTBLD%\opk\winpe\startopk.cmd" "%_NTPOSTBLD%\opk\ia64\system32\startnet.cmd" 2>1>nul
  99. ) else if /i "%_BuildArch%" == "amd64" (
  100. del "%_NTPOSTBLD%\opk\amd64\system32\startnet.cmd" 2>1>nul
  101. copy "%_NTPOSTBLD%\opk\winpe\startopk.cmd" "%_NTPOSTBLD%\opk\amd64\system32\startnet.cmd" 2>1>nul
  102. ) else if /i "%_BuildArch%" == "x86" (
  103. del "%_NTPOSTBLD%\opk\i386\system32\startnet.cmd" 2>1>nul
  104. copy "%_NTPOSTBLD%\opk\winpe\startopk.cmd" "%_NTPOSTBLD%\opk\i386\system32\startnet.cmd" 2>1>nul
  105. )
  106. )
  107. )
  108. :winpe_error
  109. set WINPEBUILDERROR=%errorlevel%
  110. REM
  111. REM Remove the build directory
  112. REM
  113. call logmsg.cmd "Removing WinPE build directory..."
  114. cd /d %OldCurrentDirectory%
  115. if exist %_NTPOSTBLD%\winpe.build (
  116. rd %_NTPOSTBLD%\winpe.build /s /q
  117. )
  118. call logmsg.cmd /t "Done with WinPE image generation"
  119. echo.
  120. echo ---------------------------------------
  121. echo Done with WinPE image generation
  122. echo ---------------------------------------
  123. echo.
  124. :winpe_done
  125. seterror.exe "%WINPEBUILDERROR%"