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.

142 lines
4.0 KiB

  1. @rem Name: Submit_new_public_files.cmd
  2. @rem
  3. @rem Usage: Submit_new_public_files.cmd Delete|Add
  4. @rem
  5. @rem Purpose: This is the script that adds new files and deletes old files
  6. @rem for the public directories in the build.
  7. @rem
  8. @rem The script is driven off the %RazzleToolPath%\public_changes.txt.
  9. @rem See that file for more info.
  10. @if "%_echo%"=="" echo off
  11. setlocal
  12. if "%BUILD_OFFLINE%"=="1" goto :eof
  13. set __DO_ADDS=
  14. set __DO_DELETES=
  15. if /i "%1" == "" (
  16. set __DO_ADDS=1
  17. set __DO_DELETES=1
  18. )
  19. if /i "%1" == "delete" (
  20. set __DO_DELETES=1
  21. )
  22. if /i "%1" == "add" (
  23. set __DO_ADDS=1
  24. )
  25. @rem
  26. @rem Build up the list of files we should checkin.
  27. @rem
  28. set _Submit_Rules_AddDel=%temp%\SubmitRulesAddDel%RANDOM%
  29. set _SD_results=%temp%\SubmitRulesAddDel2%RANDOM%
  30. set _AddList=%temp%\AddList%RANDOM%
  31. set _DelList=%temp%\DelList%RANDOM%
  32. set _tmp1=%temp%\AddDelTemp1_%RANDOM%
  33. set _tmp2=%temp%\AddDelTemp2_%RANDOM%
  34. if "%_BUILDARCH%" == "x86" set _LIBARCH=i386&& goto LibArchSet
  35. set _LIBARCH=%_BUILDARCH%
  36. :LibArchSet
  37. @rem First eliminate comments
  38. set ConvertMacro={s/\;.*//g
  39. @rem Then replace * with the appropriate architecture and remove extra spaces.
  40. set ConvertMacro=%ConvertMacro%;s/\*/%_LIBARCH%/;s/\,[ \t]*/\,/g
  41. @rem and print out the results if non-zero.
  42. set ConvertMacro=%ConvertMacro%;if (length gt 1) {print $_;}}
  43. perl -e "while (<>) %ConvertMacro%" < %RazzleToolPath%\PublicChanges.txt > %_Submit_Rules_AddDel%
  44. @rem
  45. @rem Verify that there's the correct number of columns in the output file.
  46. @rem
  47. for /f "tokens=1-4 delims=," %%i in (%_Submit_Rules_AddDel%) do (
  48. @if "%%l" == "" (
  49. echo BUILDMSG: Error: %RazzleToolPath%\PublicChanges.txt ^(%%i,%%j,%%k,%%l^) is malformed - forget a comma?
  50. )
  51. )
  52. @rem
  53. @rem do the work.
  54. @rem
  55. pushd %_NTDRIVE%%_NTROOT%\public
  56. @rem
  57. @rem public_AddDel.log will be appended to the checkin report. Don't delete when done.
  58. @rem
  59. if not exist %_NTDRIVE%%_NTROOT%\public\PUBLIC_CHANGENUM.SD (
  60. echo.
  61. echo BUILDMSG: Error: %_NTDRIVE%%_NTROOT%\public\PUBLIC_CHANGENUM.SD is missing.
  62. echo BUILDMSG: Error: Open a new razzle window and redo your build.
  63. echo.
  64. goto TheEnd
  65. )
  66. for /f "tokens=2" %%x in (PUBLIC_CHANGENUM.SD) do (
  67. set _PublicChangeNum=%%x
  68. )
  69. @rem
  70. @rem Now query SD and see if it knows about this file already.
  71. @rem
  72. @rem In the case of an add operation, we check to see if the file's not known
  73. @rem (ie: "sd files filename" reports "no such file"). This is a clear case
  74. @rem for an add (file never existed before). So is "delete change(some number)"
  75. @rem since this indicates the file was deleted sometime in the past and we
  76. @rem want to add it back.
  77. @rem
  78. @rem In the case of a delete, the exact inverse is true. If the file doesn't exist
  79. @rem or has already been deleted, there's nothing to delete. Otherwise, it needs
  80. @rem to be added to the delete list.
  81. @rem
  82. for /f "tokens=1,2,3,4 delims=," %%i in (%_Submit_Rules_AddDel%) do (
  83. @if defined __DO_ADDS (
  84. @if "%%j" == "add" (
  85. @if exist %%i (
  86. echo %%i>> %_AddList%
  87. )
  88. )
  89. )
  90. if defined __DO_DELETES (
  91. if "%%j" == "del" (
  92. echo %%i>> %_DelList%
  93. )
  94. )
  95. )
  96. if exist %_AddList% (
  97. sd -s -x %_AddList% files > %_tmp1%
  98. findstr /c:"no such file" %_tmp1% > %_tmp2%
  99. findstr /c:"delete change" %_tmp1% >> %_tmp2%
  100. for /f "tokens=2 delims=# " %%i in (%_tmp2%) do sd add -c %_PublicChangeNum% %%i
  101. del %_tmp1%
  102. del %_tmp2%
  103. del %_AddList%
  104. )
  105. if exist %_DelList% (
  106. sd -s -x %_DelList% files > %_tmp1%
  107. findstr /v /c:"no such file" %_tmp1% | findstr /v /c:"delete change" | findstr /v /c:"exit:" > %_tmp2%
  108. for /f "tokens=2 delims=# " %%i in (%_tmp2%) do sd delete -c %_PublicChangeNum% %%i
  109. del %_tmp1%
  110. del %_tmp2%
  111. del %_DelList%
  112. )
  113. :TheEnd
  114. if exist %_Submit_Rules_AddDel% del %_Submit_Rules_AddDel%
  115. if exist %_SD_results% del %_SD_results%
  116. popd
  117. endlocal