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.

164 lines
4.9 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.1 (Whistler) by default.
  51. if not defined osattr (
  52. set osattr=2:5.1
  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 -n %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. call ExecuteCmd.cmd "setreg -q 1 TRUE"
  94. if errorlevel 1 (
  95. popd& goto :EOF
  96. )
  97. popd
  98. if defined SIGNTOOL_SIGN (
  99. signtool sign /q %SIGNTOOL_SIGN% "%tmp_catfile%"
  100. if errorlevel 1 (
  101. call errmsg.cmd "signtool failed."
  102. goto :EOF
  103. )
  104. ) else (
  105. REM if %tempdir% is the current directory, signcode.exe will fail without setting the errorlevel
  106. if not "%NT_CERTHASH%" == "" (
  107. signcode -sha1 %NT_CERTHASH% -n "Microsoft Windows NT Driver Catalog TEST" -i "http://ntbld" %tmp_catfile%
  108. ) else (
  109. signcode -v %RazzleToolPath%\driver.pvk -spc %RazzleToolPath%\driver.spc -n "Microsoft Windows NT Driver Catalog TEST" -i "http://ntbld" %tmp_catfile%
  110. )
  111. if errorlevel 1 (
  112. call errmsg.cmd "signcode failed."
  113. goto :EOF
  114. )
  115. )
  116. REM ---------------------------------------------------
  117. REM Move CAT file to the output directory
  118. REM ---------------------------------------------------
  119. if /i "%tempdir%" == "%binout%" goto move_done
  120. if /i NOT exist %binout% md %binout%
  121. if errorlevel 1 (
  122. call errmsg.cmd "Unable to make the output directory %binout%."
  123. goto :EOF
  124. )
  125. call logmsg.cmd "Copying %tmp_catfile% to %binout%..."
  126. call ExecuteCmd.cmd "xcopy /yf %tmp_catfile% %binout%\"
  127. if errorlevel 1 (
  128. goto :EOF
  129. )
  130. REM Need the CDF file for testing purposes
  131. call logmsg.cmd "Copying %tmp_cdffile% to %binout%..."
  132. call ExecuteCmd.cmd "xcopy /yf %tmp_cdffile% %binout%\"
  133. if errorlevel 1 (
  134. goto :EOF
  135. )
  136. :move_done
  137. call logmsg.cmd "%binout%\%catfile%.cat and %binout%\%catfile%.cdf generated successfully."