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.

271 lines
7.2 KiB

  1. @REM
  2. @REM Copyright (c) Microsoft Corporation 2001
  3. @REM
  4. @REM Description:
  5. @REM Generate the Timewarp Client MSI from twcliXX_.msi
  6. @REM Adds the latest version of twclient.chm twclient.hlp and twext.dll
  7. @REM
  8. @REM Usage:
  9. @REM Called by twclient.cmd during the automatic PostBuild phase.
  10. @REM
  11. @REM Author:
  12. @REM Adi Oltean [aoltean] - 10/09/2001
  13. @REM
  14. @REM Revisions:
  15. @REM 10/09/2001 - created original script for x86 and USA only.
  16. @REM
  17. @rem
  18. @rem 0) Set up environment variables
  19. @rem
  20. @echo off
  21. @if defined verbose echo on
  22. setlocal ENABLEEXTENSIONS
  23. set TW_ERR=0
  24. set TWCLI_ROOT=%~dp0
  25. set TWCLI_MSI_GEN_DIR=%~dp0\gen_msi
  26. set TWCLI_CAB_GEN_DIR=%~dp0\gen_cab
  27. set TWCLI_HELP_SRC=%~dp0\help\usa
  28. set TWCLI_MSI_SRC=%~dp0\usa
  29. set TWCLI_FINAL_MSI_DIR=%TWCLI_ROOT%\usa
  30. @rem
  31. @rem 1) Set the platform-dependent file names
  32. @rem
  33. call :SET_PLATFORM_DEPENDENT_VAR
  34. set TWCLI_CHM_FILE=%TWCLI_HELP_SRC%\twclient.chm
  35. set TWCLI_HLP_FILE=%TWCLI_HELP_SRC%\twclient.hlp
  36. set TWCLI_DLL_FILE=%TWCLI_ROOT%\twext.dll
  37. set TWCLI_INITIAL_MSI_FILE=%TWCLI_MSI_SRC%\%TWCLI_INITIAL_MSI_FILE_NAME%
  38. set TWCLI_TMP_MSI_FILE=%TWCLI_MSI_GEN_DIR%\%TWCLI_INITIAL_MSI_FILE_NAME%
  39. set TWCLI_ALMOST_FINAL_MSI_FILE=%TWCLI_MSI_GEN_DIR%\%TWCLI_FINAL_MSI_FILE_NAME%
  40. set TWCLI_FINAL_MSI_FILE=%TWCLI_FINAL_MSI_DIR%\%TWCLI_FINAL_MSI_FILE_NAME%
  41. set TWCLI_TOOLS_DIR=%NTMAKEENV%\%PROCESSOR_ARCHITECTURE%
  42. @rem
  43. @rem 2) Testing if all files exists
  44. @rem
  45. @rem BUGBUG: Due to an ugly bug in the Enduser\HelpContents\i386\dirs
  46. @rem we need to ignore the Timewarp Help absence for now
  47. @rem This is a hack that must be fixed as soon as the dirs is fixed across depots
  48. if not exist %TWCLI_HELP_SRC% md %TWCLI_HELP_SRC%
  49. if not exist %TWCLI_CHM_FILE% copy %~df0 %TWCLI_CHM_FILE%
  50. if not exist %TWCLI_HLP_FILE% copy %~df0 %TWCLI_HLP_FILE%
  51. if not exist %TWCLI_DLL_FILE% copy %~df0 %TWCLI_DLL_FILE%
  52. @rem call :IF_NOT_EXIST %TWCLI_CHM_FILE%
  53. @rem call :IF_NOT_EXIST %TWCLI_HLP_FILE%
  54. @rem END BUGBUG
  55. call :IF_NOT_EXIST %TWCLI_DLL_FILE%
  56. call :IF_NOT_EXIST %TWCLI_INITIAL_MSI_FILE%
  57. call :IF_NOT_EXIST %NTMAKEENV%\WiStream.vbs
  58. call :IF_NOT_EXIST %TWCLI_ROOT%\WiMakTwClientCab.vbs
  59. call :IF_NOT_EXIST %TWCLI_TOOLS_DIR%\msifiler.exe
  60. @rem
  61. @rem 3) Deleting previous temporary folders and files
  62. @rem
  63. call :CLEANUP_FOLDER %TWCLI_CAB_GEN_DIR%
  64. call :CLEANUP_FOLDER %TWCLI_MSI_GEN_DIR%
  65. call :DELETE_FILE %TWCLI_FINAL_MSI_FILE%
  66. @rem
  67. @rem 4) Copying files to the temporary location. Also, copy the MSI to the
  68. @rem temporary location and double-check that we have the right file
  69. @rem
  70. call :COPY_INTO %TWCLI_CHM_FILE% %TWCLI_MSI_GEN_DIR%
  71. call :COPY_INTO %TWCLI_HLP_FILE% %TWCLI_MSI_GEN_DIR%
  72. call :COPY_INTO %TWCLI_DLL_FILE% %TWCLI_MSI_GEN_DIR%
  73. call :COPY_INTO %TWCLI_INITIAL_MSI_FILE% %TWCLI_MSI_GEN_DIR%
  74. call :IF_NOT_EXIST %TWCLI_TMP_MSI_FILE%
  75. @rem
  76. @rem 5) Deleting the old CAB from the MSI
  77. @rem
  78. call :EXEC_CMD_IN_FOLDER %TWCLI_CAB_GEN_DIR% cscript.exe %NTMAKEENV%\WiStream.vbs %TWCLI_TMP_MSI_FILE% /D Cabs.w1.cab //B
  79. @rem
  80. @rem 6) Packing new files into the new cab and add it to the MSI
  81. @rem
  82. call :EXEC_CMD_IN_FOLDER %TWCLI_CAB_GEN_DIR% cscript.exe %TWCLI_ROOT%\WiMakTwClientCab.vbs %TWCLI_TMP_MSI_FILE% Cabs.w1 %TWCLI_MSI_GEN_DIR% /c /u /e //B
  83. @rem
  84. @rem 7) Updating the MSI Version information
  85. @rem
  86. @rem [BUGBUG] msifiler.exe does not set the errorlevel! Use other tool.
  87. @rem We cannot reliably detect if it failed. But this doesn't corrupt the MSI.
  88. call :EXEC_CMD_IN_FOLDER %TWCLI_CAB_GEN_DIR% %TWCLI_TOOLS_DIR%\msifiler.exe -d %TWCLI_TMP_MSI_FILE% -s %TWCLI_MSI_GEN_DIR%\
  89. @rem
  90. @rem 8) Give the MSI the final name
  91. @rem
  92. call :RENAME_FILE %TWCLI_TMP_MSI_FILE% %TWCLI_FINAL_MSI_FILE_NAME%
  93. @rem
  94. @rem 9) Copy the updated MSI to the final location
  95. @rem
  96. call :COPY_INTO %TWCLI_ALMOST_FINAL_MSI_FILE% %TWCLI_FINAL_MSI_DIR%
  97. @rem
  98. @rem 10) Verify the correct file was generated.
  99. @rem
  100. call :IF_NOT_EXIST %TWCLI_FINAL_MSI_FILE%
  101. @rem
  102. @rem 10) We are done! Set the script return code
  103. @rem
  104. %TWCLI_TOOLS_DIR%\seterror %TW_ERR%
  105. goto :EOF
  106. rem /////////////////////////////////////////////////////////////////////
  107. rem // Routines
  108. rem /////////////////////////////////////////////////////////////////////
  109. rem /////////////////////////////////////////////////////////////////////
  110. rem // Sets the platform-dependent variables
  111. :SET_PLATFORM_DEPENDENT_VAR
  112. if %TW_ERR% == 1 goto :EOF
  113. if defined ia64 set MSI_POSTFIX=64
  114. if defined 386 set MSI_POSTFIX=32
  115. if "%MSI_POSTFIX%"=="" (
  116. call errmsg.cmd "Unknown platform: ia64 and 386 not defined."
  117. set TW_ERR=1 & goto :EOF
  118. )
  119. set TWCLI_INITIAL_MSI_FILE_NAME=twcli%MSI_POSTFIX%_.msi
  120. set TWCLI_FINAL_MSI_FILE_NAME=twcli%MSI_POSTFIX%.msi
  121. goto :EOF
  122. rem /////////////////////////////////////////////////////////////////////
  123. rem // Executes a shell command in a specific folder
  124. :EXEC_CMD_IN_FOLDER
  125. if %TW_ERR% == 1 goto :EOF
  126. if not exist %1 call errmsg.cmd "%1 is missing" & set TW_ERR=1 & goto :EOF
  127. pushd %1
  128. if errorlevel 1 (
  129. call errmsg.cmd "cd %1 failed [%errorlevel%]"
  130. set TW_ERR=1 & goto :EOF
  131. )
  132. %2 %3 %4 %5 %6 %7 %8 %9
  133. if errorlevel 1 (
  134. call errmsg.cmd "Command %2 %3 %4 %5 %6 %7 %8 %9 failed [%errorlevel%]"
  135. set TW_ERR=1 & popd & goto :EOF
  136. )
  137. popd
  138. goto :EOF
  139. rem /////////////////////////////////////////////////////////////////////
  140. rem // Test the existence of a file/directory
  141. :IF_NOT_EXIST
  142. if %TW_ERR% == 1 goto :EOF
  143. if not exist %1 call errmsg.cmd "%1 is missing" & set TW_ERR=1
  144. goto :EOF
  145. rem /////////////////////////////////////////////////////////////////////
  146. rem // Recursively deletes a directory
  147. :CLEANUP_FOLDER
  148. if %TW_ERR% == 1 goto :EOF
  149. if exist %1 rd /s/q %1
  150. if errorlevel 1 (
  151. call errmsg.cmd "Folder %1 cannot be deleted [%errorlevel%]"
  152. set TW_ERR=1 & goto :EOF
  153. )
  154. md %1
  155. if errorlevel 1 (
  156. call errmsg.cmd "Folder %1 cannot be created [%errorlevel%]"
  157. set TW_ERR=1 & goto :EOF
  158. )
  159. goto :EOF
  160. rem /////////////////////////////////////////////////////////////////////
  161. rem // Copies a file in a directory
  162. :COPY_INTO
  163. if %TW_ERR% == 1 goto :EOF
  164. if not exist %1 (
  165. call errmsg.cmd "File %1 does not exist"
  166. set TW_ERR=1 & goto :EOF
  167. )
  168. if not exist %2 (
  169. call errmsg.cmd "Folder %2 does not exist"
  170. set TW_ERR=1 & goto :EOF
  171. )
  172. copy %1 %2
  173. if errorlevel 1 (
  174. call errmsg.cmd "COPY %1 to folder %2 cannot be performed [%errorlevel%]"
  175. set TW_ERR=1 & goto :EOF
  176. )
  177. goto :EOF
  178. rem /////////////////////////////////////////////////////////////////////
  179. rem // Renames a file
  180. :RENAME_FILE
  181. if %TW_ERR% == 1 goto :EOF
  182. if not exist %1 (
  183. call errmsg.cmd "%1 does not exist"
  184. set TW_ERR=1 & goto :EOF
  185. )
  186. ren %1 %2
  187. if errorlevel 1 (
  188. call errmsg.cmd "ren %1 %2 cannot be performed [%errorlevel%]"
  189. set TW_ERR=1 & goto :EOF
  190. )
  191. goto :EOF
  192. rem /////////////////////////////////////////////////////////////////////
  193. rem // Deletes a file
  194. :DELETE_FILE
  195. if %TW_ERR% == 1 goto :EOF
  196. if not exist %1 goto :EOF
  197. del %1
  198. if errorlevel 1 (
  199. call errmsg.cmd "del %1 cannot be performed [%errorlevel%]"
  200. set TW_ERR=1 & goto :EOF
  201. )
  202. goto :EOF