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.

146 lines
4.4 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM
  4. REM createcat.cmd
  5. REM Create an NT 5 catalog file from a list
  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. createcat -f <filelist> -c <catfile> -t <tempdir> -o <outdir> [-a <osattr>] [-l <language>]
  21. Creates a CAT file signed with the test certificate
  22. given a file with the proper list format for a CDF.
  23. -f <filelist> Specifies the file listing the files to be put
  24. into the CAT file. Each file needs to be listed
  25. on a separate line as follows:
  26. <hash>path\\filename=path\\filename
  27. -c <catfile> Specifies the name of the catalog file, with
  28. no extension.
  29. -t <tempdir> Specifies the temporary directory to use when
  30. creating the CAT and CDF files.
  31. -o <outdir> Specifies the directory to place the final
  32. CAT and CDF files.
  33. -a <osattr> Specifies the OSAttr used in CDF's CATATTR1 entry.
  34. 2:5.0 is the default value, correct for Win2k files.
  35. Use 1:4.0 for Win98 files, and 2:4.x for NT4 SP files.
  36. USAGE
  37. parseargs('?' => \&Usage,
  38. 'f:'=> \$ENV{LIST},
  39. 'c:'=> \$ENV{CATFILE},
  40. 't:'=> \$ENV{TEMPDIR},
  41. 'o:'=> \$ENV{BINOUT},
  42. 'a:'=> \$ENV{OSATTR});
  43. # *** NEXT FEW LINES ARE TEMPLATE ***
  44. $ENV{"_CPCMAGIC"}++;exit(system($0)>>8);
  45. __END__
  46. :CPCBegin
  47. set _CPCMAGIC=
  48. setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
  49. REM *** BEGIN YOUR CMD SCRIPT BELOW ***
  50. REM OSAttr is 2:5.2 (.NET) by default.
  51. if not defined osattr (
  52. set osattr=2:5.2
  53. )
  54. REM --------------------------------------------------
  55. REM Create the CDF file
  56. REM --------------------------------------------------
  57. set tmp_catfile=%tempdir%\%catfile%.cat
  58. set tmp_cdffile=%tempdir%\%catfile%.cdf
  59. if /i NOT exist %tempdir% md %tempdir%
  60. if errorlevel 1 (
  61. call errmsg.cmd "Unable to create the temporary directory %tempdir%."
  62. goto :EOF
  63. )
  64. REM Put the header on and output it as a CDF
  65. call logmsg.cmd "Creating %tmp_cdffile%..."
  66. echo ^[CatalogHeader^]> %tmp_cdffile%
  67. echo Name=%catfile%>> %tmp_cdffile%
  68. echo PublicVersion=0x0000001>> %tmp_cdffile%
  69. echo EncodingType=0x00010001>> %tmp_cdffile%
  70. echo CATATTR1=0x10010001:OSAttr:%osattr%>> %tmp_cdffile%
  71. echo ^[CatalogFiles^]>> %tmp_cdffile%
  72. type %list%>> %tmp_cdffile%
  73. if exist %tmp_cdffile% call logmsg.cmd "Creating %tmp_cdffile% succeeded"
  74. REM ---------------------------------------------------
  75. REM Create the CAT file
  76. REM ---------------------------------------------------
  77. set cmd=pushd %tempdir%
  78. %cmd%
  79. if errorlevel 1 (
  80. call errmsg.cmd "%cmd% failed."
  81. goto :EOF
  82. )
  83. call logmsg.cmd "Creating %tmp_catfile%..."
  84. call ExecuteCmd.cmd "makecat %tmp_cdffile%"
  85. if errorlevel 1 (
  86. popd& goto :EOF
  87. )
  88. if exist %tmp_catfile% call logmsg.cmd "Creating %tmp_catfile% succeeded"
  89. REM ---------------------------------------------------
  90. REM Sign the CAT file with the test signature
  91. REM ---------------------------------------------------
  92. call logmsg.cmd "Signing %tmp_catfile% with the test signature..."
  93. popd
  94. signtool sign /q %SIGNTOOL_SIGN% "%tmp_catfile%"
  95. if errorlevel 1 (
  96. call errmsg.cmd "signtool failed."
  97. goto :EOF
  98. )
  99. REM ---------------------------------------------------
  100. REM Move CAT file to the output directory
  101. REM ---------------------------------------------------
  102. if /i "%tempdir%" == "%binout%" goto move_done
  103. if /i NOT exist %binout% md %binout%
  104. if errorlevel 1 (
  105. call errmsg.cmd "Unable to make the output directory %binout%."
  106. goto :EOF
  107. )
  108. call logmsg.cmd "Copying %tmp_catfile% to %binout%..."
  109. call ExecuteCmd.cmd "xcopy /yf %tmp_catfile% %binout%\"
  110. if errorlevel 1 (
  111. goto :EOF
  112. )
  113. REM Need the CDF file for testing purposes
  114. call logmsg.cmd "Copying %tmp_cdffile% to %binout%..."
  115. call ExecuteCmd.cmd "xcopy /yf %tmp_cdffile% %binout%\"
  116. if errorlevel 1 (
  117. goto :EOF
  118. )
  119. :move_done
  120. call logmsg.cmd "%binout%\%catfile%.cat and %binout%\%catfile%.cdf generated successfully."