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.

132 lines
3.6 KiB

  1. @echo off
  2. setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
  3. if DEFINED _echo echo on
  4. if DEFINED verbose echo on
  5. REM first, parse command line
  6. :SwitchLoop
  7. for %%a in (./ .- .) do if ".%1." == "%%a?." goto :Usage
  8. if "%1" == "" goto :EndSwitchLoop
  9. for /f "tokens=1,2 delims=:" %%a in ('echo %1') do (
  10. set Switch=%%a
  11. set Arg=%%b
  12. for %%c in (./ .-) do (
  13. if ".!Switch!." == "%%cl." (set Language=!Arg!&&goto :ShiftArg)
  14. if ".!Switch!." == "%%cf." (set ForceMove=TRUE&&goto :ShiftArg)
  15. )
  16. REM if we're here, we didn't encounter any switches and thus we have
  17. REM an unrecognized argument
  18. goto :Usage
  19. )
  20. :ShiftArg
  21. shift
  22. goto :SwitchLoop
  23. :EndSwitchLoop
  24. if not defined Language set Language=usa
  25. REM get name of release share from ini file
  26. set ReleaseDir=
  27. set IniCmd=perl %RazzleToolPath%\PostBuildScripts\CmdIniSetting.pl
  28. set IniCmd=!IniCmd! -l:%Language%
  29. set IniCmd=!IniCmd! -b:%_BuildBranch%
  30. set IniCmd=!IniCmd! -f:AlternateReleaseDir
  31. for /f %%a in ('!IniCmd!') do (
  32. set ReleaseDir=%%a
  33. )
  34. if not defined ReleaseDir set ReleaseDir=release
  35. REM because we're attempting to move the lastest build around, let's
  36. REM lower the latest share. this also helps with "access is denied" on
  37. REM the move, as people are always going through the latest share to a
  38. REM build.
  39. net share latest /d /y >nul 2>nul
  40. REM Get the latest release
  41. for /f %%a in ('!RazzleToolPath!\PostBuildScripts\GetLatestRelease.cmd -l:!Language!') do (
  42. REM Abort if no release directory
  43. if /i "%%a" == "none" (
  44. echo No latest release found
  45. echo Aborting
  46. goto errend
  47. ) else (
  48. set BuildName=%%a
  49. set MyDrive=!_NTTREE:~0,2!
  50. if /i "!Language!" NEQ "usa" (
  51. set LatestBuild=!MyDrive!\!ReleaseDir!\!Language!\!BuildName!
  52. ) else (
  53. set LatestBuild=!MyDrive!\!ReleaseDir!\!BuildName!
  54. )
  55. )
  56. )
  57. REM Set the destination directory
  58. set BinDirectory=%_NTPOSTBLD%
  59. if /i "!Language!" NEQ "usa" (
  60. if /i "!Language!" NEQ "cov" (
  61. set BinDirectory=!BinDirectory!\!Language!
  62. )
  63. )
  64. REM Abort if destination already exists
  65. if exist !BinDirectory! (
  66. echo You have a !BinDirectory! directory already.
  67. echo If you don't want it, remove it and rerun this script
  68. echo Aborting
  69. goto errend
  70. )
  71. REM Move it
  72. move !LatestBuild! !BinDirectory!
  73. REM Abort if move failed
  74. if /i not "!ErrorLevel!" == "0" (
  75. if "!ForceMove!" == "TRUE" (
  76. net stop server
  77. if "!ErrorLevel!" NEQ "0" (
  78. echo Failed to stop server service, exiting ...
  79. goto :ErrEnd
  80. )
  81. move !LatestBuild! !BinDirectory!
  82. if "!ErrorLevel!" == "0" (
  83. net start server
  84. if "!ErrorLevel!" == "0" goto :MovedBuild
  85. echo Move succeeded, but failed to restart server service ...
  86. goto :ErrEnd
  87. )
  88. )
  89. echo Error attempting to move !LatestBuild! to !BinDirectory! --
  90. echo Please use the -f switch to net stop server and restart after
  91. echo the move attempt.
  92. echo Aborting
  93. goto errend
  94. )
  95. :MovedBuild
  96. echo !LatestBuild! moved to !BinDirectory!
  97. goto end
  98. :Usage
  99. echo %0 [-l:^<lang^>][-f]
  100. echo.
  101. echo -l:^<lang^> language; default is usa.
  102. echo -f issues net stop server, performs move, and restarts service
  103. echo.
  104. echo MoveLatest.cmd moves the latest release directory to a binaries directory.
  105. echo This needs to be done before taking an incremental fix after running
  106. echo postbuild.cmd. If MoveLatest.cmd fails, try again using the -f switch.
  107. echo.
  108. goto end
  109. :errend
  110. echo MoveLatest.cmd finished with errors.
  111. echo.
  112. goto end
  113. :end
  114. endlocal