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.

413 lines
12 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM
  4. REM propbuild.cmd
  5. REM Propgate the build to the release server.
  6. REM
  7. REM Copyright (c) Microsoft Corporation. All rights reserved.
  8. REM Version: < 1.0 > 04/26/2002 Suemiao Rossignol
  9. REM ------------------------------------------------------------------
  10. perl -x "%~f0" %*
  11. goto :EOF
  12. #!perl
  13. use strict;
  14. use lib "$ENV{RAZZLETOOLPATH}\\PostBuildScripts";
  15. use lib $ENV{RAZZLETOOLPATH};
  16. use Logmsg;
  17. use ParseArgs;
  18. use File::Basename;
  19. use comlib;
  20. use GetIniSetting;
  21. use WaitProc;
  22. $ENV{script_name} = basename( $0 );
  23. sub Usage {
  24. print<<USAGE;
  25. Pull XPSP1 build to release servers.
  26. Usage:
  27. $ENV{script_name} -n:<Build Number> [-s:<Source Server>] [-d:<Target Server>]
  28. [-a:<Build Architecture>] [-t:<Build Debug Type>]
  29. [-mail][-d] [-p]
  30. -n: Build Number.
  31. -s: Source Server.
  32. Default is %computername%.
  33. -d: Target Server.
  34. Default is %computername%.
  35. -c: Conglomeration Server.
  36. Default is defined in the xpsp1.ini.
  37. -a: Build Architecture. x86 or ia64.
  38. Default is $ENV{_BuildArch}.
  39. -t: Build Debug Type. fre or chk.
  40. Default is $ENV{_BuildType}.
  41. -mail Send notification mail to BVT.
  42. -p: Powerless.
  43. -qfe qfe number
  44. -? Display Usage.
  45. USAGE
  46. exit(1)
  47. }
  48. my ( $buildNo, $relPath, $srcServer, $relServer, @aggServers );
  49. my ( $isThinRelease );
  50. my ( $buildArch, $buildType, $sendMail, $isPowerLess );
  51. my ( $qfe);
  52. if( !&GetParams() ) { &ExitWithStatus(1); }
  53. timemsg( "Start $ENV{script_name}" );
  54. if( !&InitVars() ) { &ExitWithStatus(1); }
  55. if( !&PushRelease() ){ &ExitWithStatus(1); }
  56. &ExitWithStatus(0);
  57. #-----------------------------------------------------------------------------
  58. sub ExitWithStatus
  59. {
  60. my ( $pStatus ) = @_;
  61. if( $pStatus == 0 )
  62. {
  63. timemsg( "Complete $ENV{script_name} - NO ERRORS ENCOUNTERED" );
  64. }
  65. else
  66. {
  67. timemsg( "Complete $ENV{script_name} - ERRORS ENCOUNTERED" );
  68. }
  69. # Copy log file over the rlease server
  70. my $temp = $ENV{temp};
  71. $temp =~ s/\:/\$/;
  72. &comlib::ExecuteSystemX( "copy $ENV{LOGFILE} \\\\$relServer\\$temp", $isPowerLess ) if( -e $ENV{LOGFILE} );
  73. &comlib::ExecuteSystemX( "copy $ENV{ERRFILE} \\\\$relServer\\$temp", $isPowerLess ) if( -e $ENV{ERRFILE} );
  74. # repeat this for allrel.cmd to be able to parse status correctly
  75. if( $pStatus == 0 )
  76. {
  77. timemsg( "Complete $ENV{script_name} - NO ERRORS ENCOUNTERED" );
  78. }
  79. else
  80. {
  81. timemsg( "Complete $ENV{script_name} - ERRORS ENCOUNTERED" );
  82. }
  83. exit($pStatus);
  84. }
  85. #-----------------------------------------------------------------------------
  86. sub GetParams
  87. {
  88. parseargs('?' => \&Usage, 'l:' =>\$ENV{lang}, 'n:' => \$buildNo,
  89. 's:' =>\$srcServer, 'd:' =>\$relServer, 'c:' =>\@aggServers,
  90. 'a:' =>\$buildArch, 't:' =>\$buildType,
  91. 'p'=>\$isPowerLess, 'mail'=>\$sendMail ,'-qfe:' => \$qfe);
  92. $ENV{lang}="usa" if( !$ENV{lang} );
  93. if( !$buildNo && !$qfe )
  94. {
  95. errmsg( "Please enter build number or qfe num." );
  96. return 0;
  97. }
  98. $srcServer = $ENV{computername} if( !$srcServer );
  99. $relServer = $ENV{computername} if( !$relServer );
  100. if( !$buildArch ) { $buildArch = $ENV{_BuildArch}; }
  101. elsif( lc $buildArch ne "x86" && lc $buildArch ne "ia64" )
  102. {
  103. errmsg( "Invalid Build Architecture." );
  104. return 0;
  105. }
  106. if( !$buildType ) { $buildType = $ENV{_BuildType}; }
  107. elsif( lc $buildType ne "fre" && lc $buildType ne "chk" )
  108. {
  109. errmsg( "Invalid Build Debug Type." );
  110. return 0;
  111. }
  112. if( $sendMail ){ $sendMail = 1; } else { $sendMail = 0; }
  113. &comlib::ResetLogErrFile("propbuild.$buildNo.$buildArch$buildType.$relServer");
  114. return 1;
  115. }
  116. #-----------------------------------------------------------------------------
  117. sub InitVars
  118. {
  119. # Check source server is available
  120. if( !&comlib::ExecuteSystem( "net view $srcServer >nul 2>nul") )
  121. {
  122. errmsg( "Failed to see [$srcServer] via net view, exit. ");
  123. return 0;
  124. }
  125. # Check source path is existing
  126. if (!$qfe) {
  127. $relPath = "\\release\\$buildNo\\$ENV{lang}\\$buildArch$buildType";
  128. } else {
  129. $relPath = "\\release\\Q$qfe\\$buildArch$buildType";
  130. }
  131. if( !(-e "\\\\$srcServer$relPath" ) )
  132. {
  133. errmsg( "[\\\\$srcServer$relPath] does not exist" );
  134. return 0;
  135. }
  136. # Verify access of the target server
  137. if( system( "net view $relServer >nul 2>nul") )
  138. {
  139. errmsg( "Failed to see [$relServer] via net view. ");
  140. return 0;
  141. }
  142. # Define Conglomeration Servers
  143. if( !@aggServers )
  144. {
  145. my $iniAggServers = &GetIniSetting::GetSetting( "ConglomerationServers::$ENV{lang}" );
  146. @aggServers = split( /\s+/, $iniAggServers );
  147. }
  148. # Check if runs for thin release
  149. my $iniThinServers = &GetIniSetting::GetSetting( "ThinRelease" );
  150. my @thinServers = split( /\s+/,$iniThinServers );
  151. for ( @thinServers ) { if( lc $relServer eq lc $_ ){ $isThinRelease = 1; last; } }
  152. # Check if the release server need to send BVT mail
  153. my $tmp = &GetIniSetting::GetSetting( "SendBVTMailServer" );
  154. my @mailBVTServers = split( /\s/, $tmp);
  155. if( $sendMail )
  156. {
  157. $sendMail = 0;
  158. for( @mailBVTServers ) { if( lc $relServer eq lc $_ ){ $sendMail = 1; last; } }
  159. }
  160. logmsg( "Lauguage .............[$ENV{lang}]" );
  161. logmsg( "Build No .............[$buildNo]" );
  162. logmsg( "Source Serevr. .......[$srcServer]" );
  163. logmsg( "Release Server .......[$relServer]" );
  164. logmsg( "Build Platform .......[$buildArch$buildType]" );
  165. logmsg( "Release Path .........[$relPath]" );
  166. logmsg( "Conglomeration Servers[@aggServers]" );
  167. logmsg( "Is Thin Release ......[$isThinRelease]" );
  168. logmsg( "Need Send mail to BVT.[$sendMail]" );
  169. logmsg( "Temp Log file ........[$ENV{LOGFILE}]" );
  170. logmsg( "Temp Error file ......[$ENV{ERRFILE}]" );
  171. logmsg( "PID ..................[$$]");
  172. return 1;
  173. }
  174. #-----------------------------------------------------------------------------
  175. sub ThinCopy
  176. {
  177. my $dash = '-' x 60;
  178. logmsg ( $dash );
  179. my $src = "\\\\$srcServer$relPath";
  180. my $dest = "\\\\$relServer$relPath";
  181. my @thinDirs = ( "netfx", "idw", "perinf\\idw", "setuptxt","support", "valueadd","OPK" ,"symbolcd", "ddk_cd", "hal_cd", "processor_cd", "ifs_cd", "mantis", "eval" );
  182. my @thinFiles = ( "xpsp1.exe" , "dump\\epidgen.dll" , "dump\\vpidgen.dll", "nt5inf.cat" );
  183. my @thinDirsx86 = ( "makeboot", "realsign", "perinf\\realsign","bootfloppy", "perinf\\bootfloppy", "eval.wpa.wksinf\\dpcdll.dll" );
  184. my @thinFilesx86 = ( "netfxocm\\netfx.cab", "bflics.txt", "tabletpc.cab", "mediactr.cab","bfcab.inf", "perinf\\bfcab.inf", "perinf\\nt5inf.cat" );
  185. my @thinDirsia64 = ( "EFIpart");
  186. # Copy upd folder under bin
  187. my $from = "$src\\upd";
  188. my $to = "$dest\\bin\\upd";
  189. &comlib::ExecuteSystemX( "md $to", $isPowerLess ) if( !(-e $to ) );
  190. return 0 if( !&comlib::ExecuteSystemX( "compdir /eknst $from $to", $isPowerLess ) );
  191. $src .= "\\bin";
  192. $dest .= "\\bin";
  193. # Copy dirs
  194. for my $theDir ( @thinDirs )
  195. {
  196. $from = "$src\\$theDir";
  197. $to = "$dest\\$theDir";
  198. next if( !(-e $from) );
  199. &comlib::ExecuteSystemX( "md $to", $isPowerLess ) if( !(-e $to ) );
  200. return 0 if( !&comlib::ExecuteSystemX( "compdir /eknst $from $to", $isPowerLess ) );
  201. }
  202. # Copy files
  203. for my $theFile ( @thinFiles )
  204. {
  205. $from = "$src\\$theFile";
  206. $to = "$dest\\$theFile";
  207. if( $to =~ /^(.+)\\[^\\]+$/ )
  208. {
  209. &comlib::ExecuteSystemX( "md $1", $isPowerLess ) if( !(-e $1 ) );
  210. }
  211. return 0 if( !&comlib::ExecuteSystemX( "copy $from $to", $isPowerLess ) );
  212. }
  213. if( lc $buildArch eq "x86" )
  214. {
  215. for my $theDir ( @thinDirsx86 )
  216. {
  217. $from = "$src\\$theDir";
  218. $to = "$dest\\$theDir";
  219. &comlib::ExecuteSystemX( "md $to", $isPowerLess ) if( !(-e $to ) );
  220. return 0 if( !&comlib::ExecuteSystemX( "compdir /eknst $from $to", $isPowerLess ) );
  221. }
  222. for my $theFile ( @thinFilesx86 )
  223. {
  224. $from = "$src\\$theFile";
  225. $to = "$dest\\$theFile";
  226. if( $to =~ /^(.+)\\[^\\]+$/ )
  227. {
  228. &comlib::ExecuteSystemX( "md $1", $isPowerLess ) if( !(-e $1 ) );
  229. }
  230. if( -e $from )
  231. {
  232. return 0 if( !&comlib::ExecuteSystemX( "copy $from $to", $isPowerLess ) );
  233. }
  234. }
  235. }
  236. elsif( lc $buildArch eq "ia64" )
  237. {
  238. for my $theDir ( @thinDirsia64 )
  239. {
  240. $from = "$src\\$theDir";
  241. $to = "$dest\\$theDir";
  242. &comlib::ExecuteSystemX( "md $to", $isPowerLess ) if( !(-e $to ) );
  243. return 0 if( !&comlib::ExecuteSystemX( "compdir /eknst $from $to", $isPowerLess ) );
  244. }
  245. }
  246. # Create SLP
  247. logmsg ( $dash );
  248. #my $cmdLine = "echo cd /d ^%^sdxroot%^\\tools\\sp ^& ";
  249. my $cmdLine = "echo pushd ^^%RazzleToolPath^^% ^& echo sd sync ... ^& echo popd ^&";
  250. $cmdLine .= " echo start /min cmd /c ^^%RazzleToolPath^^%\\sp\\BuildSlp.cmd ";
  251. $cmdLine .= "\-l:$ENV{lang} \-n:$buildNo \-a:$buildArch \-t:$buildType";
  252. $cmdLine .= " \| \@remote.exe /c $relServer xpsp1release /L 1";
  253. if( !&comlib::ExecuteSystemX( $cmdLine, $isPowerLess ))
  254. {
  255. errmsg( "Failed to start remote on [$relServer], please investigate." );
  256. return 0;
  257. }
  258. return 1;
  259. }
  260. #-----------------------------------------------------------------------------
  261. sub PushRelease
  262. {
  263. # If qfe mode
  264. if ($qfe) {
  265. return ( &QfeThinCopy );
  266. }
  267. # Thin Release
  268. if( $isThinRelease )
  269. {
  270. return ( &ThinCopy() );
  271. }
  272. # Full release
  273. my $dash = '-' x 60;
  274. logmsg ( $dash );
  275. my $src = "\\\\$srcServer$relPath";
  276. my $dest = "\\\\$relServer$relPath";
  277. my @copyDirs = `dir /ad /b $src`;
  278. chomp( @copyDirs );
  279. for my $theDir ( @copyDirs )
  280. {
  281. my $from = "$src\\$theDir";
  282. my $to = "$dest\\$theDir";
  283. &comlib::ExecuteSystemX( "md $to",$isPowerLess ) if( !(-e $to ) );
  284. return 0 if( !&comlib::ExecuteSystemX( "compdir /eknst $from $to", $isPowerLess ) );
  285. }
  286. my $cmdLine;
  287. # miscrel.cmd - Make a conglomerator dirs
  288. if( grep { $relServer eq $_} @aggServers )
  289. {
  290. logmsg ( $dash );
  291. $cmdLine = "$ENV{RazzleToolPath}\\sp\\miscrel.cmd -l:$ENV{lang} -n:$buildNo
  292. -d:$relServer -s:$relServer -a:$buildArch -t:$buildType";
  293. return 0 if( !&comlib::ExecuteSystemX( $cmdLine, $isPowerLess ));
  294. }
  295. # Raiseall.cmd - Make bvt dfs links
  296. if( lc $relServer ne "burnarch1" )
  297. {
  298. logmsg ( $dash );
  299. $cmdLine = "$ENV{RazzleToolPath}\\sp\\raiseall.cmd -l:$ENV{lang} -n:$buildNo -q:bvt
  300. -r:$relServer -a:$buildArch -t:$buildType";
  301. if( &comlib::ExecuteSystemX( $cmdLine, $isPowerLess ) && $sendMail )
  302. {
  303. # mailbvt.cmd - Send mail notification to BVT lab
  304. logmsg ( $dash );
  305. $cmdLine = "$ENV{RazzleToolPath}\\sp\\mailbvt.cmd -l:$ENV{lang} -n:$buildNo
  306. -a:$buildArch -t:$buildType";
  307. &comlib::ExecuteSystemX( $cmdLine, $isPowerLess );
  308. }
  309. }
  310. # copysym.cmd - Copy common symbols files from usa build
  311. logmsg ( $dash );
  312. $cmdLine = "$ENV{RazzleToolPath}\\sp\\copysym.cmd -l:$ENV{lang} -n:$buildNo
  313. -d:$relServer -a:$buildArch -t:$buildType";
  314. return 0 if( !&comlib::ExecuteSystemX( $cmdLine, $isPowerLess ));
  315. # delbuild.cmd - delete builds for build machine
  316. logmsg ( $dash );
  317. $cmdLine = "$ENV{RazzleToolPath}\\sp\\delbuild.cmd -l:$ENV{lang}";
  318. &comlib::ExecuteSystemX( $cmdLine, $isPowerLess );
  319. # Start remote to run delbuild in release server
  320. logmsg ( $dash );
  321. my $cmdLine = "echo cd /d ^%^sdxroot%^\\tools\\sp ^& ";
  322. $cmdLine .= "echo pushd ^^%RazzleToolPath^^% ^& echo sd sync ... ^& echo popd ^&";
  323. $cmdLine .= " echo start /min cmd /c ^^%RazzleToolPath^^%\\sp\\DelBuild.cmd ";
  324. $cmdLine .= "\-l:$ENV{lang} ";
  325. $cmdLine .= " \| \@remote.exe /c $relServer xpsp1release /L 1";
  326. &comlib::ExecuteSystemX( $cmdLine, $isPowerLess );
  327. return 1;
  328. }
  329. #-----------------------------------------------------------------------------
  330. sub QfeThinCopy
  331. {
  332. my $dash = '-' x 60;
  333. logmsg ( $dash );
  334. my $src = "\\\\$srcServer$relPath";
  335. my $dest = "\\\\$relServer$relPath";
  336. my $qfeName = "Q$qfe"."_"."$ENV{lang}.exe";
  337. &comlib::ExecuteSystemX ("copy $src\\$qfeName $dest");
  338. &comlib::ExecuteSystemX ("xcopy /eiyd $src\\bin_$ENV{lang} $dest\\bin_$ENV{lang}");
  339. }
  340. #-----------------------------------------------------------------------------
  341. 1;