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.

113 lines
3.4 KiB

  1. @echo off
  2. setlocal EnableDelayedExpansion
  3. REM
  4. REM this file is intended to be called ONLY from drivercab.cmd
  5. REM
  6. REM
  7. REM the syntax is:
  8. REM
  9. REM a txt list of files to cab up
  10. REM the name of the cab to generate
  11. REM the name of the event to signal when finished
  12. REM
  13. set FileList=%1
  14. set CabName=%2
  15. set EventName=%3
  16. if not defined EventName (
  17. call errmsg.cmd "Incorrect command line passed to CabWrapper ..."
  18. endlocal
  19. goto :EOF
  20. )
  21. REM verify some args
  22. if not exist %FileList% (
  23. call errmsg.cmd "File list %FileList% passed to CabWrapper does not exist ..."
  24. goto :End
  25. )
  26. for %%a in (%FileList%) do set FileListName=%%~nxa
  27. REM delete old junk
  28. if exist %CabName% del /f /q %CabName%
  29. if exist %CabName% (
  30. call errmsg.cmd "Failed to delete %CabName% ..."
  31. goto :End
  32. )
  33. for %%a in (%CabName%) do (
  34. set CabDir=%%~dpa
  35. set CabNameOnly=%%~nxa
  36. )
  37. REM
  38. REM here we want to create the DDF and then send it to makecab.exe
  39. REM
  40. call logmsg.cmd "%FileListName%: Deleting old ddf ..."
  41. for %%a in (%CabName%) do set CabFileName=%%~nxa
  42. set MyDDFName=%TMP%\ddf_%CabFileName%.ddf
  43. if exist %MyDDFName% del /f /q %MyDDFName%
  44. if exist %MyDDFName% (
  45. call errmsg.cmd "Failed to delete %MyDDFName% ..."
  46. goto :End
  47. )
  48. REM create the DDF header
  49. call logmsg.cmd "%FileListName%: Creating DDF header ..."
  50. echo ^.Option Explicit>%MyDDFName%
  51. echo ^.Set DiskDirectoryTemplate=%CabDir%>>%MyDDFName%
  52. echo ^.Set CabinetName1=%CabNameOnly%>>%MyDDFName%
  53. echo ^.Set RptFilename=nul>>%MyDDFName%
  54. echo ^.Set InfFileName=nul>>%MyDDFName%
  55. echo ^.Set InfAttr=>>%MyDDFName%
  56. echo ^.Set MaxDiskSize=CDROM>>%MyDDFName%
  57. echo ^.Set CompressionType=LZX>>%MyDDFName%
  58. echo ^.Set CompressionMemory=21>>%MyDDFName%
  59. echo ^.Set CompressionLevel=1 >>%MyDDFName%
  60. if /i "%Comp%" == "No" (
  61. call logmsg.cmd "%FileListName%: Compression is turned off"
  62. echo ^.Set Compress=OFF>>%MyDDFName%
  63. ) else (
  64. call logmsg.cmd "%FileListName%: Compression is turned on"
  65. echo ^.Set Compress=ON>>%MyDDFName%
  66. )
  67. echo ^.Set Cabinet=ON>>%MyDDFName%
  68. echo ^.Set UniqueFiles=ON>>%MyDDFName%
  69. echo ^.Set FolderSizeThreshold=1000000>>%MyDDFName%
  70. echo ^.Set MaxErrors=300>>%MyDDFName%
  71. REM add the files to the DDF
  72. REM Sort them first since this makes compression better
  73. call logmsg.cmd "%FileListName%: Adding files to the DDF from %FileList% ..."
  74. sort %FileList% > %FileList%.sorted
  75. REM This is changed as the the ddf file sometimes misses entries from FileList caused by echoing in the for loop
  76. perl -n -e "s/^/$ENV{_NTPOSTBLD}\\/g;print $_"<%FileList%.sorted > %FileList%.sorted.ddf
  77. copy %MyDDFName% + %FileList%.sorted.ddf %MyDDFName%
  78. call logmsg.cmd "%FileListName%: Issuing makecab directive ..."
  79. set ThisErrFile=%MyDDFName%.Output
  80. call logmsg.cmd "Output is in %ThisErrFile% ..."
  81. call ExecuteCmd.cmd "makecab.exe /f %MyDDFName%" > %ThisErrFile%
  82. if %ErrorLevel% NEQ 0 (
  83. call errmsg.cmd "%FileListName%: Failed to create cab ... here's the errors ..."
  84. for /f "tokens=1 delims=" %%a in (%ThisErrFile%) do (
  85. call errmsg.cmd "%%a"
  86. )
  87. ) else (
  88. call logmsg.cmd "%FileListName%: Cab generation successful ..."
  89. )
  90. :End
  91. REM finishing up, just wait for someone to listen then send our event
  92. perl %RazzleToolPath%\PostBuildScripts\cmdevt.pl -ihv %EventName%
  93. perl %RazzleToolPath%\PostBuildScripts\cmdevt.pl -isv %EventName%
  94. endlocal
  95. goto :EOF