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.

160 lines
3.4 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM
  4. REM <<template_script.cmd>>
  5. REM <<purpose of this script>>
  6. REM
  7. REM Copyright (c) Microsoft Corporation. All rights reserved.
  8. REM
  9. REM ------------------------------------------------------------------
  10. if defined _CPCMAGIC goto CPCBegin
  11. perl -x "%~f0" %*
  12. goto :EOF
  13. #!perl
  14. use strict;
  15. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  16. use lib $ENV{RAZZLETOOLPATH};
  17. use PbuildEnv;
  18. use ParseArgs;
  19. sub Usage { print<<USAGE; exit(1) }
  20. deletesym -l:<lang>
  21. USAGE
  22. parseargs('?' => \&Usage,
  23. 'l:'=> \$ENV{LNG});
  24. # *** NEXT FEW LINES ARE TEMPLATE ***
  25. $ENV{"_CPCMAGIC"}++;exit(system($0)>>8);
  26. __END__
  27. :CPCBegin
  28. set _CPCMAGIC=
  29. setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
  30. REM *** BEGIN YOUR CMD SCRIPT BELOW ***
  31. REM Get Free Space Requirements
  32. set DefaultFreeSpaceReq=11
  33. set CmdIni=perl %RazzleToolPath%\PostBuildScripts\CmdIniSetting.pl
  34. set param=SymFarmFreeSpace::%COMPUTERNAME%
  35. set ThisCommandLine=%CmdIni% -l:%Lang% -f:%param%
  36. %ThisCommandLine% >nul 2>nul
  37. if !ERRORLEVEL! NEQ 0 (
  38. call logmsg.cmd "%param% is not defined in the ini file"
  39. set FreeSpaceReq=%DefaultFreeSpaceReq%
  40. ) else (
  41. for /f %%a in ('%ThisCommandLine%') do (
  42. set FreeSpaceReq=%%a
  43. )
  44. )
  45. :Loop
  46. echo free space required is %FreeSpaceReq% GB
  47. REM Find Free Space available
  48. set symDir=\symfarm\%lang%
  49. call :GetFreeSpace %SymDir%
  50. echo free space is %FreeSpace% GB
  51. REM see if we need to delete
  52. if %FreeSpace% GEQ %FreeSpaceReq% (
  53. echo "Current free space = %FreeSpace% GB ... No delete required"
  54. goto Done
  55. )
  56. set BuildToDelete=
  57. for /f %%a in ('dir %symDir%\*.* /b /o:n') do (
  58. if NOT DEFINED BuildToDelete (
  59. set save=
  60. if EXIST %SymDir%\%%a\build_logs\sav.qly set save=yes
  61. if EXIST %SymDir%\%%a\build_logs\ids.qly set save=yes
  62. if EXIST %SymDir%\%%a\build_logs\idw.qly set save=yes
  63. if EXIST %SymDir%\%%a\build_logs\idc.qly set save=yes
  64. if NOT DEFINED save (
  65. set BuildToDelete=%%a
  66. )
  67. )
  68. )
  69. if DEFINED BuildToDelete (
  70. echo deleting %SymDir%\%BuildToDelete%
  71. pushd %symdir%
  72. rd /s /q %BuildToDelete%
  73. popd
  74. )
  75. goto :Loop
  76. :Done
  77. goto :EOF
  78. REM ************************************************************************
  79. REM GetFreeSpace
  80. REM
  81. REM Set %FreeSpace% equal to the amount of free disk for the drive for the
  82. REM path passed in as %1. The free space is reported in GB. If the
  83. REM number of bytes free is less than 1 GB, %FreeSpace% is set to 0.
  84. REM
  85. REM Result - %ThereWereErrors% is set to "yes" if there are errors in the function.
  86. REM %ThereWereErrors% is not defined if the function finishes
  87. REM successfully.
  88. REM
  89. REM ************************************************************************
  90. :GetFreeSpace %1
  91. set ThereWereErrors=
  92. set FreeSpace=
  93. if not exist %1 (
  94. call errmsg.cmd "Cannot determine free disk space for %1"
  95. set ThereWereErrors=yes
  96. goto :EOF
  97. )
  98. REM This is cheesey, but the third token of the last line of the dir command
  99. REM is the free disk space
  100. for /f "tokens=3 delims= " %%a in ('dir %1') do (
  101. set DiskSpace=%%a
  102. )
  103. REM Now, make it a number in gigabytes
  104. set /a FreeSpace=0
  105. for /f "tokens=1,2,3,4,5 delims=," %%a in ("%DiskSpace%") do (
  106. if /i not "%%d" == "" set /a FreeSpace=%%a
  107. if /i not "%%e" == "" set /a FreeSpace="!FreeSpace!*1000+%%b"
  108. )
  109. :EndGetFreeSpace
  110. goto :EOF
  111. )