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.

153 lines
4.7 KiB

  1. @REM standard cmd script intro lines ...
  2. @echo off
  3. setlocal EnableDelayedExpansion
  4. REM octopus.cmd
  5. REM
  6. REM intended to run on the machine which is
  7. REM creating the build.inc file. this script
  8. REM is called via remote when the x86fre build
  9. REM finished postbuild.cmd
  10. REM set up env vars needed
  11. for %%a in (%0) do set SCRIPT_NAME=%%~na
  12. set LOGFILE=%SDXROOT%\!SCRIPT_NAME!.log
  13. set /a ExitCode=0
  14. set SemaphoreName=octopus
  15. set SemaphoreRaised=
  16. REM startup
  17. call logmsg.cmd /t "Beginning ..."
  18. REM validate we're on an enlisted machine
  19. if not defined SDXROOT (
  20. call errmsg.cmd "SDXROOT is not defined! Exiting ..."
  21. set /a ExitCode=!ExitCode! + 1
  22. goto :ErrEnd
  23. )
  24. REM check the semaphore
  25. pushd %RazzleToolPath%\PostBuildScripts
  26. if "!ErrorLevel!" NEQ "0" (
  27. call errmsg.cmd "Can't find %%RazzleToolPath%%\PostBuildScripts!"
  28. set /a ExitCode=!ExitCode! + 1
  29. goto :ErrEnd
  30. )
  31. perl cmdevt.pl -q %SemaphoreName% >nul 2>nul
  32. if "!ErrorLevel!" == "0" (
  33. REM there is already an octopus event, so octopus is running.
  34. call errmsg.cmd "Octopus already running, won't start new process"
  35. set /a ExitCode=!ExitCode! + 1
  36. goto :ErrEnd
  37. )
  38. REM otherwise, start up octopus
  39. REM first, raise the semaphore
  40. start "Octopus running ..." /min perl cmdevt.pl -w %SemaphoreName%
  41. set SemaphoreRaised=TRUE
  42. popd &REM matches pushd %RazzleToolPath%\PostBuildScripts
  43. set MailFileName=%TMP%\octomail.txt
  44. if exist !MailFileName! del !MailFileName!
  45. if exist !MailFileName! call logmsg.cmd "Mail not deleted, will append ..."
  46. echo This is an automated message from octopus. >> !MailFileName!
  47. echo. >> !MailFileName!
  48. echo For build: >> !MailFileName!
  49. REM all we need to do is build a build.inc file,
  50. REM so no need to use timebuild, just build.exe
  51. pushd %SDXROOT%
  52. REM run scorch just so we don't get certain clobber errors
  53. REM hide our log file from this temporarily
  54. if exist %TMP%\templog.tmp del /f /q %TMP%\templog.tmp >nul 2>nul
  55. copy %LOGFILE% %TMP%\templog.tmp >nul 2>nul
  56. nmake -f makefil0 scorch_source
  57. if not exist %LOGFILE% copy %TMP%\templog.tmp %LOGFILE% >nul 2>nul
  58. call %RazzleToolPath%\PostBuildScripts\fullsync.cmd
  59. if "!ErrorLevel!" NEQ "0" (
  60. call errmsg.cmd "Failed to sync tree, exiting."
  61. set /a ExitCode=!ExitCode! + 1
  62. REM for now, just keep going like nothing happened.
  63. REM goto :ErrEnd
  64. REM instead of exiting, let's log the files that weren't syncable
  65. echo Sync errors occured, here's the output of sdx sync: >> %LOGFILE%
  66. sdx sync -n >>%LOGFILE% 2>>%LOGFILE%
  67. )
  68. REM now move old build.inc file in case we're overwritting something
  69. if exist build.inc (
  70. call logmsg.cmd "Moving build.inc to build.inc.old ..."
  71. if exist build.inc.old del build.inc.old
  72. ren build.inc build.inc.old
  73. if "!ErrorLevel!" NEQ "0" (
  74. call errmsg.cmd "Failed to rename build.inc to build.inc.old"
  75. call errmsg.cmd "Will continue ..."
  76. set /a ExitCode=!ExitCode! + 1
  77. )
  78. )
  79. set BuildErrors=
  80. build.exe -cDP#
  81. if "!ErrorLevel!" NEQ "0" (
  82. call errmsg.cmd "build finished with errors!"
  83. set BuildErrors=TRUE
  84. set /a ExitCode=!ExitCode! + 1
  85. REM comment out the next line as we want to go on with postbuild
  86. REM regardless of the outcome of the build
  87. REM goto :ErrEnd
  88. ) else (
  89. call logmsg.cmd "Build finished with no errors."
  90. )
  91. type %SDXROOT%\__blddate__ >> !MailFileName!
  92. echo. >> !MailFileName!
  93. if defined BuildErrors (
  94. echo There were build errors: >> !MailFileName!
  95. type %SDXROOT%\build.err >> !MailFileName!
  96. echo. >> !MailFileName!
  97. )
  98. REM uniqify the build.inc file
  99. perl %RazzleToolPath%\PostBuildScripts\unique.pl -i:%SDXROOT%\build.inc -o:%SDXROOT%\unique.inc
  100. REM now postbuild
  101. postbuild.cmd
  102. REM let's just run release.pl for run since primecdixf will never
  103. REM be an official_build_machine. use -nd so we don't propagate builds
  104. perl %RazzleToolPath%\PostBuildScripts\release.pl -nd
  105. if exist \\%COMPUTERNAME%\latest\build_logs\postbuild.err (
  106. echo There were postbuild errors: >> !MailFileName!
  107. type \\%COMPUTERNAME%\latest\build_logs\postbuild.err >> !MailFileName!
  108. echo. >> !MailFileName!
  109. )
  110. echo Have a nice day! >> !MailFileName!
  111. REM now send the mail
  112. perl %RazzleToolPath%\PostBuildScripts\octomail.pl
  113. popd &REM matches pushd %SDXROOT%
  114. goto :End
  115. :End
  116. call logmsg.cmd /t "Finished."
  117. REM drop the semaphore if we raised it
  118. if defined SemaphoreRaised (
  119. pushd %RazzleToolPath%\PostBuildScripts
  120. perl cmdevt.pl -s %SemaphoreName%
  121. popd &REM matches %RazzleToolPath%\PostBuildScripts
  122. )
  123. endlocal & seterror.exe "!ExitCode!"
  124. goto :EOF
  125. :ErrEnd
  126. call logmsg.cmd /t "Encountered !ExitCode! logged error(s)."
  127. call errmsg.cmd "See %LOGFILE% for errors."
  128. call :End
  129. if "!ExitCode!" == "0" set /a ExitCode=1
  130. endlocal & seterror.exe "!ExitCode!"