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.

130 lines
3.4 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. set BinDirectory=!BinDirectory!\!Language!
  61. )
  62. REM Abort if destination already exists
  63. if exist !BinDirectory! (
  64. echo You have a !BinDirectory! directory already.
  65. echo If you don't want it, remove it and rerun this script
  66. echo Aborting
  67. goto errend
  68. )
  69. REM Move it
  70. move !LatestBuild! !BinDirectory!
  71. REM Abort if move failed
  72. if /i not "!ErrorLevel!" == "0" (
  73. if "!ForceMove!" == "TRUE" (
  74. net stop server
  75. if "!ErrorLevel!" NEQ "0" (
  76. echo Failed to stop server service, exiting ...
  77. goto :ErrEnd
  78. )
  79. move !LatestBuild! !BinDirectory!
  80. if "!ErrorLevel!" == "0" (
  81. net start server
  82. if "!ErrorLevel!" == "0" goto :MovedBuild
  83. echo Move succeeded, but failed to restart server service ...
  84. goto :ErrEnd
  85. )
  86. )
  87. echo Error attempting to move !LatestBuild! to !BinDirectory! --
  88. echo Please use the -f switch to net stop server and restart after
  89. echo the move attempt.
  90. echo Aborting
  91. goto errend
  92. )
  93. :MovedBuild
  94. echo !LatestBuild! moved to !BinDirectory!
  95. goto end
  96. :Usage
  97. echo %0 [-l:^<lang^>][-f]
  98. echo.
  99. echo -l:^<lang^> language; default is usa.
  100. echo -f issues net stop server, performs move, and restarts service
  101. echo.
  102. echo MoveLatest.cmd moves the latest release directory to a binaries directory.
  103. echo This needs to be done before taking an incremental fix after running
  104. echo postbuild.cmd. If MoveLatest.cmd fails, try again using the -f switch.
  105. echo.
  106. goto end
  107. :errend
  108. echo MoveLatest.cmd finished with errors.
  109. echo.
  110. goto end
  111. :end
  112. endlocal