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.

230 lines
6.7 KiB

  1. @echo off
  2. setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
  3. if DEFINED _echo echo on
  4. if DEFINED verbose echo on
  5. REM --------------------------------------------------------------------
  6. REM realsgn.cmd - This is a utility to sign test binaries
  7. REM against a real signed build. It copies
  8. REM the correct "testsign" infs, testroot,
  9. REM and catalog file from \\ntbuilds\release;
  10. REM updates and signs the catalog; and checks
  11. REM that the files are signed.
  12. REM
  13. REM USAGE: WINSIGN buildnumber architecture dbgtype ostype directory
  14. REM
  15. REM E.G. - realsgn 2000 x86 fre wks c:\mydir
  16. REM
  17. REM buildnumber - must be a build number on DFS
  18. REM architecute - x86 | alpha
  19. REM debugtype - fre | chk
  20. REM ostype - wks | per | bla | sbs | srv | ent | dtc
  21. REM directory - the absolute path to the directory
  22. REM containing your test bits.
  23. REM
  24. REM THESE PARAMETERS MUST BE IN THE CORRECT ORDER
  25. REM
  26. REM PREREQUISITES - You must have the following files in your path:
  27. REM chktrust.exe
  28. REM signcode.exe
  29. REM updcat.exe
  30. REM driver.spc
  31. REM driver.pvk
  32. REM
  33. REM
  34. REM - Installed testroot.cer:
  35. REM To install the testroot, copy
  36. REM testroot.cer from the fre.pub\tools
  37. REM directory of \\ntbuilds\release\usa.
  38. REM Run it from a command prompt.
  39. REM A wizard will guide through a very quick
  40. REM installation. Once there, it will remain
  41. REM until you upgrade to a PRS signed build.
  42. REM
  43. REM ---------------------------------------------------------------------
  44. for %%a in (./ .- .) do if ".%1." == "%%a?." goto usage
  45. set bldno=%1
  46. set arc=%2
  47. set dbg=%3
  48. set ostype=%4
  49. set mydir=%5
  50. set arcchk=
  51. set dbgchk=
  52. set ostypechk=
  53. set files=
  54. set num=1
  55. REM check build number as well as we can.
  56. if /I "%bldno%"=="" goto usage
  57. REM check for architecture
  58. if /I "%arc%"=="x86" (
  59. set arcchk=1
  60. ) else (
  61. if /I "%arc%"=="alpha" (
  62. set arcchk=1
  63. )
  64. )
  65. if NOT "%arcchk%"=="1" echo.&echo The second argument should be x86 or alpha&goto usage
  66. REM check for Debug type
  67. if /I "%dbg%"=="fre" (
  68. set dbgchk=1
  69. ) else (
  70. if /I "%dbg%"=="chk" (
  71. set dbgchk=1
  72. )
  73. )
  74. if NOT "%dbgchk%"=="1" echo.&echo The third argument should be fre or chk&goto usage
  75. REM check for flavor
  76. if /I "%ostype%"=="wks" (
  77. set ostypechk=1
  78. ) else (
  79. if /I "%ostype%"=="srv" (
  80. set ostypechk=1
  81. ) else (
  82. if /I "%ostype%"=="ent" (
  83. set ostypechk=1
  84. ) else (
  85. If /I "%ostype%"=="dtc" (
  86. set ostypechk=1
  87. ) else (
  88. If /I "%ostype%"=="bla" (
  89. set ostypechk=1
  90. ) else (
  91. If /I "%ostype%"=="sbs" (
  92. set ostypechk=1
  93. ) else (
  94. If /I "%ostype%"=="per" (
  95. set ostypechk=1
  96. )
  97. )
  98. )
  99. )
  100. )
  101. if NOT "%ostypechk%"=="1" echo.&echo The fourth argument should be wks, per, srv, ent, or dtc&goto usage
  102. REM check target directory
  103. if NOT exist "%mydir%" echo.&echo Cannot find your test directory&goto usage
  104. REM check for existence of build
  105. if NOT exist \\ntbuilds\release\usa\%bldno%\%arc%\%dbg%.%ostype% echo.&echo Could not find \\ntbuilds\release\usa\%bldno%\%arc%\%dbg%.%ostype%&goto usage
  106. pushd %mydir%
  107. REM check path information
  108. for %%a in (driver.pvk driver.spc) do (
  109. if NOT exist %%~$PATH:a (
  110. echo.&echo You must have %%a in your path&goto usage
  111. ) else (
  112. set Drv!num!=%%~$PATH:a
  113. set /a num=!num! + 1
  114. )
  115. )
  116. for %%a in (signcode.exe chktrust.exe updcat.exe) do (
  117. if NOT exist %%~$PATH:a (
  118. echo.&echo You must have %%a in your path.&goto usage
  119. )
  120. )
  121. REM clean out %mydir%
  122. for %%a in (testroot.ce* nt5inf.ca* layout.inf dosnet.inf txtsetup.sif syssetup.in*) do (
  123. if exist %%a (
  124. del /f %%a
  125. )
  126. )
  127. REM This works for US builds. The path information for
  128. REM copies will have to be changed for international builds.
  129. for %%a in (nt5inf.ca_ testsign\layout.inf testsign\dosnet.inf testsign\txtsetup.sif syssetup.in_) do (
  130. copy /Y \\ntbuilds\release\usa\%bldno%\%arc%\%dbg%.%ostype%\%%a
  131. if errorlevel 1 echo.&echo error copying %%a from release shares&goto usage
  132. )
  133. copy /Y \\ntbuilds\release\usa\%bldno%\%arc%\%dbg%.pub\tools\testroot.cer
  134. if errorlevel 1 echo.&echo error copying %%a from release shares&goto usage
  135. if exist nt5inf.ca_ expand nt5inf.ca_ nt5inf.cat
  136. if exist syssetup.in_ expand syssetup.in_ syssetup.inf
  137. if exist nt5inf.ca_ del /f nt5inf.ca_
  138. if exist syssetup.in_ del /f syssetup.in_
  139. REM Make a list of all files in %mydir%
  140. REM which we need to sign
  141. for /F %%a in ('dir /b /a-d') do call :setfiles %%a
  142. echo %files%
  143. set files=%files:nt5inf.cat=%
  144. set files=%files:testroot.cer=%
  145. echo Will now sign %files% in nt5inf.cat
  146. REM Update nt5inf.cat
  147. for %%a in (%files%) do call :update %%a
  148. REM Sign nt5inf.cat
  149. setreg -q 1 TRUE
  150. echo signing updated nt5inf.cat ...
  151. call signcode -v %DrV1% -spc %Drv2% -n "Microsoft Windows NT Driver Catalog TEST" -i "http://ntbld" %mydir%\nt5inf.CAT
  152. REM check that files are signed
  153. for %%a in (%files%) do call chktrust -wd -c nt5inf.cat -t foo %%a
  154. goto end
  155. REM function to accumulate list of files to sign
  156. :setfiles
  157. set files=%files% %1
  158. goto :EOF
  159. REM function to update nt5inf.cat
  160. :update
  161. echo %1
  162. call updcat nt5inf.cat -a %1
  163. goto :EOF
  164. :usage
  165. echo.
  166. echo --------------------------------------------------------------------
  167. echo realsgn.cmd - This is a utility to sign test binaries
  168. echo against a real signed build. It copies
  169. echo the correct "testsign" infs, testroot,
  170. echo and catalog file from \\ntbuilds\release;
  171. echo updates and signs the catalog; and checks
  172. echo that the files are signed.
  173. echo.
  174. echo USAGE: realsgn buildnumber architecture dbgtype ostype directory
  175. echo.
  176. echo E.G. - realsgn 2000 x86 fre wks c:\mydir
  177. echo.
  178. echo buildnumber - must be a build number on DFS
  179. echo architecute - x86 or alpha
  180. echo debugtype - fre or chk
  181. echo ostype - wks or per or bla or sbs or srv or ent or dtc
  182. echo directory - the absolute path to the directory
  183. echo containing your test bits.
  184. echo.
  185. echo THESE PARAMETERS MUST BE IN THE CORRECT ORDER
  186. echo.
  187. echo PREREQUISITES - You must have the following tools in your path:
  188. echo chktrust.exe
  189. echo signcode.exe
  190. echo updcat.exe
  191. echo driver.spc
  192. echo driver.pvk
  193. echo
  194. echo.
  195. echo - Installed testroot.cer:
  196. echo To install the testroot, copy
  197. echo testroot.cer from the fre.pub\tools
  198. echo directory of \\ntbuilds\release\usa.
  199. echo Expand it. Run it from a command prompt.
  200. echo A wizard will guide through a very quick
  201. echo installation. Once there, it will remain
  202. echo until you upgrade to a PRS signed build.
  203. echo.
  204. REM ---------------------------------------------------------------------
  205. :end
  206. popd
  207. @endlocal