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.

777 lines
22 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM <<intlsdop.cmd>>
  4. REM Perform sd operations for international builds.
  5. REM Copyright (c) Microsoft Corporation. All rights reserved.
  6. REM Version: < 1.0 > 02/02/2001 Suemiao Rossignol
  7. REM ------------------------------------------------------------------
  8. perl -x "%~f0" %*
  9. goto :EOF
  10. #!perl
  11. use strict;
  12. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  13. use lib $ENV{RAZZLETOOLPATH};
  14. use Logmsg;
  15. use ParseArgs;
  16. use File::Basename;
  17. use BuildName;
  18. use GetIniSetting;
  19. use comlib;
  20. use cklang;
  21. use cktarg;
  22. use filestat;
  23. use vars (qw($LOCPART $MAIN));
  24. my $LOCDIRS = {"locpart"=>"lp",
  25. "dnsrv_dev"=>"dnsrvdev"};
  26. my $scriptname = basename( $0 );
  27. sub Usage {
  28. my $SELF = $0;
  29. $SELF =~ s/.*\\//g;
  30. print<<USAGE;
  31. Perform Integrate, reverse integrate or sync for internatioanl builds steps.
  32. Usage:
  33. $SELF [-l:<lang> | -d:<location>] -o:<op> [-t:<timestamp>][-pf] [-y:<branch>] [-c]
  34. -l Language. Default is "usa".
  35. The operation $SELF performs is language dependent.
  36. Not all op/lang combinations are allowed.
  37. If "usa", sync the source projects under SDXROOT.
  38. If <lang>, RI or sync the localization projects for the given <lang>.
  39. -d: Location.
  40. This could be %sdxroot% or %RazzleToolPath%
  41. Perform sd <operation> on <location>.
  42. -o: SD operation.
  43. if "r", perform loc RI.
  44. if "s", perform sync.
  45. if "v", perform verification.
  46. if "u", perform updates. This option is not yet functional.
  47. -t Timestamp. Used for Integrate/RI/syncing the SD files.
  48. Default is the latest time.
  49. -f: Force operation
  50. -i: Interactive mode (prompts for user input)
  51. -p Powerless.
  52. Do not perform sd operation.
  53. -y <branch> the branch parameter which defaults to "locpart".
  54. -c Force sync to current, It only works when used with -d:%RazzleToolPath%
  55. /? Displays usage.
  56. Examples:
  57. $SELF -d:%sdxroot% -t:2000/10/01:18:00 -o:s
  58. Sync the source tree at the given timestamp.
  59. $SELF -l:ger -t:2000/09/09:12:34 -o:r
  60. Reverse integrate German localization projects at the given timestamp.
  61. $SELF -l:JPN -t:2000/09/09:12:34 -o:r -y:dnsrv_dev
  62. Reverse integrate Japanese localization projects from dnsrv_dev
  63. to dnsrv at the given timestamp.
  64. $SELF -l:ger -o:s
  65. Sync the German localization projects at the latest time.
  66. $SELF -l:ger -o:u
  67. Open, edit and submit files from German localization projects to the
  68. destination needed by the build. This option is not yet functional.
  69. USAGE
  70. exit(1);
  71. }
  72. my( $lang, $destDir, $syncTime, $operation, $powerLess, $force, $intact);
  73. my( $isFake, $sdxroot, $toolDir, $pbsDir, $isCurrent );
  74. if( !&GetParams ) { exit(1);}
  75. exit(&main);
  76. #-----------------------------------------------------------------------------
  77. # GetParams - parse & validate command line
  78. #-----------------------------------------------------------------------------
  79. sub GetParams
  80. {
  81. parseargs('?' => \&Usage, 'l:' =>\$ENV{lang}, 'd:' => \$destDir,'t:' =>\$syncTime, 'o:' =>\$operation
  82. ,"y:" => \$LOCPART,
  83. 'p' =>\$powerLess, 'f' => \$force, 'i' => \$intact, 'c' => \$isCurrent );
  84. $LOCPART = "locpart" unless $LOCPART;
  85. $MAIN = "main" unless $MAIN ;
  86. $ENV{lang} = "USA" if( !$ENV{lang} );
  87. $lang = $ENV{lang};
  88. #####The lang not usa, but template default it got to be, so verify with destDir
  89. if ($operation eq "u"){
  90. errmsg("This option is not yet functional.");
  91. return 0;
  92. }
  93. return 1 if( lc($lang) eq "usa" && !$destDir );
  94. if( lc($lang) eq "usa" && $destDir )
  95. {
  96. if( $destDir eq $ENV{sdxroot} )
  97. {
  98. if( $operation ne "s" )
  99. {
  100. errmsg("Invalid operation $operation for $destDir" );
  101. return 0;
  102. }
  103. }
  104. elsif( $destDir eq $ENV{RazzleToolPath} )
  105. {
  106. if( !( $operation eq "r" || $operation eq "s" ) )
  107. {
  108. errmsg("Invalid operation $operation for $destDir" );
  109. return 0;
  110. }
  111. }
  112. else
  113. {
  114. errmsg( "Invalid location $destDir" );
  115. return 0;
  116. }
  117. }
  118. else
  119. {
  120. if( !( $operation eq "r" || $operation eq "s" || $operation eq "v") )
  121. {
  122. errmsg("Invalid operation $operation for $lang" );
  123. return 0;
  124. }
  125. }
  126. return 1;
  127. }
  128. #-----------------------------------------------------------------------------
  129. sub main
  130. {
  131. #####Set LogFile & ErrFile
  132. my $curTime = &CurTime();
  133. $ENV{temp} = "$ENV{temp}\\$lang";
  134. system( "md $ENV{temp}" ) if( !(-e $ENV{temp} ) );
  135. $ENV{LOGFILE} = "$ENV{temp}\\$scriptname.log.$curTime";
  136. $ENV{ERRFILE} = "$ENV{temp}\\$scriptname.err.$curTime";
  137. timemsg( "Start [$scriptname]" );
  138. if( $syncTime && ( $syncTime !~ /^([@#].+)$/ )){ $syncTime = "\@".$syncTime; }
  139. if( $powerLess ) { $isFake = "-n"; } else { $isFake="";}
  140. if( $force ) { $force = "-f"; } else { $force="";}
  141. $sdxroot = $ENV{SDXROOT};
  142. $toolDir = $ENV{RazzleToolPath};
  143. $pbsDir = "$toolDir\\PostBuildScripts";
  144. if( uc($lang) eq "USA" && !$destDir ) #sync source tree#
  145. {
  146. &comlib::ExecuteSystem( "cd /d $ENV{SDXROOT} & sdx sync $force $isFake ...$syncTime -q -h" ); #added $force switch
  147. #if timestamp specified, sync tools & pbs to latest
  148. if($syncTime){ &SyncTools;}
  149. return 0;
  150. }
  151. if ( $destDir )
  152. {
  153. if( $destDir eq $sdxroot )
  154. {
  155. &SyncSourceTree;
  156. }
  157. else
  158. {
  159. &IorRIorSyncTools;
  160. }
  161. }
  162. elsif( $lang )
  163. {
  164. if(!&CheckOpened("$sdxroot\\loc\\res\\TOOLS",
  165. "$sdxroot\\loc\\res\\$lang",
  166. "$sdxroot\\loc\\bin\\$lang") ||
  167. !&VryFieZs("writable", "$sdxroot\\loc\\res\\$lang",
  168. "$sdxroot\\loc\\res\\TOOLS")
  169. )
  170. # do not check write bit for loc bin drop path files
  171. {
  172. return 0 if( !$intact );
  173. }
  174. if( $intact && &PromptAction("sd client") == 1 ) #only do sd client in interactive mode
  175. { #we'll assume its right in automated case#
  176. &comlib::ExecuteSystem( "cd $sdxroot\\loc\\res\\TOOLS& sd client -o");
  177. &comlib::ExecuteSystem( "cd $sdxroot\\loc\\res\\$lang& sd client -o");
  178. &comlib::ExecuteSystem( "cd $sdxroot\\loc\\bin\\$lang& sd client -o");
  179. }
  180. if( $operation eq "v" )
  181. {
  182. &CompMainLocpart;
  183. }
  184. else
  185. {
  186. &RIorSyncLocTree;
  187. if( $operation eq "r")
  188. {
  189. return 0 unless &VryFieZs("zerosize",
  190. "$sdxroot\\loc\\res\\$lang",
  191. "$sdxroot\\loc\\bin\\$lang");
  192. &CompMainLocpart;
  193. }
  194. if( $operation eq "s")
  195. {
  196. &addsyncInt();
  197. }
  198. }
  199. }
  200. return 1;
  201. }
  202. #----------------------------------------------------------------------------
  203. # VryFieZs - verify files in directories
  204. # usage VryFieZs(test, dirname,dirname,...)
  205. # currently as "test" the "writeable" or "zerosize" may be used.
  206. #----------------------------------------------------------------------------
  207. sub VryFieZs(){
  208. my $test = shift;
  209. my $GOOD = 1;
  210. foreach my $path (@_)
  211. {
  212. chdir $path;
  213. my @res = (qx(cd $path &dir /s/b/a-d .) =~ /.+\n/mig);
  214. map {chomp} @res;
  215. my @bad = &filestat($test, @res);
  216. next unless scalar(@bad);
  217. @bad = map {qx(sd.exe have $_ 2>NUL)} @bad;
  218. map {errmsg $_} @bad ;
  219. $GOOD=0 if scalar(@bad);
  220. }
  221. $GOOD;
  222. }
  223. #----------------------------------------------------------------------------
  224. # SyncTools() - Syncs tools & PBS to latest - all others to timestamp
  225. #----------------------------------------------------------------------------
  226. sub SyncTools()
  227. {
  228. my ($d, @dirs);
  229. my $sTs = "";
  230. if(!$isCurrent)
  231. {
  232. $sTs = $syncTime;
  233. }
  234. @dirs = `cd $sdxroot\\tools &dir /ad /b`;
  235. for $d (@dirs)
  236. {
  237. if( $d !~ /postbuildscripts/i)
  238. {
  239. chomp $d;
  240. &comlib::ExecuteSystem("cd $sdxroot\\tools\\$d &sd sync $force $isFake ...$syncTime");
  241. &comlib::ExecuteSystem("cd $sdxroot\\tools\\$d &sd diff -f -sadeE ...$syncTime");
  242. }
  243. }
  244. &comlib::ExecuteSystem("cd $sdxroot\\tools &sd sync $force $isFake *$sTs");
  245. &comlib::ExecuteSystem("cd $sdxroot\\tools &sd diff -f -sadeE *$sTs");
  246. &comlib::ExecuteSystem("cd $sdxroot\\tools\\postbuildscripts &sd sync $force $isFake ...$sTs");
  247. &comlib::ExecuteSystem("cd $sdxroot\\tools\\postbuildscripts &sd diff -f -sadeE ...$sTs");
  248. &comlib::ExecuteSystem("cd $sdxroot\\tools\\ploc &sd sync $force $isFake ...");
  249. &comlib::ExecuteSystem("cd $sdxroot\\tools\\ploc &sd diff -f -sadeE ...");
  250. return 0 if (!CheckOpened("$sdxroot\\tools"));
  251. # || !&VryFieZs("writable","$sdxroot\\tools") ;
  252. # //depot/dnsrv/root/tools/x86/managed/urt/v1.1.4322/config/... is often read-write.
  253. # Ignore that for now.
  254. return 1;
  255. }
  256. #----------------------------------------------------------------------------
  257. # SDSubmit($) - Automates Submittals w/ arg:comment
  258. #----------------------------------------------------------------------------
  259. sub SDSubmit($$)
  260. {
  261. my(@chglist, $fout, $l);
  262. my($comment, $dir) = @_;
  263. @chglist = `cd $dir &sd change -o`;
  264. my $res = 0;
  265. $l = 0;
  266. while( $l < @chglist && $chglist[$l++] !~ /^Files:/ ){}
  267. while( $l < @chglist && $chglist[$l++] =~ /\/\/depot.*/ ){
  268. $res = 1;
  269. last;
  270. }
  271. if ($res == 0){
  272. logmsg("No files to submit.\n");
  273. return 1;
  274. }
  275. open fout, ">$ENV{TMP}\\_sdchglst.$lang.tmp" || return 0;
  276. for $l (@chglist) {
  277. $l =~ s/\<enter description here\>/$comment/;
  278. print fout $l;
  279. }
  280. close fout;
  281. print `cd $dir &type $ENV{TMP}\\_sdchglst.$lang.tmp | sd submit -i`;
  282. `del /f $ENV{TMP}\\_sdchglst.$lang.tmp`;
  283. return 1;
  284. }
  285. #----------------------------------------------------------------------------
  286. # CheckOpened(@) - validate no opened files in $arg:tree
  287. #----------------------------------------------------------------------------
  288. sub CheckOpened(@)
  289. {
  290. my @path = @_;
  291. my $res;
  292. foreach my $path (@path){
  293. logmsg("cd $path &sd opened ...");
  294. $res = `cd $path &sd opened ...`;
  295. if($res ne ''){
  296. print $res;
  297. return 0;
  298. }
  299. }
  300. return 1;
  301. }
  302. #----------------------------------------------------------------------------
  303. # RIorSyncLocTree - RI's or syncs loc tree
  304. #----------------------------------------------------------------------------
  305. sub RIorSyncLocTree
  306. {
  307. my( $cmdLine, $action, $res, $bldno );
  308. my %myCmds = ( "1"=>"sd sync $force $isFake ...", #added $force switch
  309. "2"=>"sd integrate -b $LOCPART -d -r -i $force $isFake ...$syncTime",
  310. "3"=>"sd resolve $isFake -ab ...",
  311. "4"=>"sd resolve $isFake -at ...",
  312. "5"=>"sd resolve -n ...",
  313. "6"=>"sd submit ...",
  314. "7"=>"sd diff -f -sadeE ...$syncTime" );
  315. if( $operation eq "s" ) { $myCmds{"1"} = "sd sync $force $isFake ...$syncTime";}
  316. my %myDirs = ( "1"=>"$sdxroot\\loc\\res\\$lang",
  317. "2"=>"$sdxroot\\loc\\bin\\$lang");
  318. if( $operation =~ /[rs]/i) { $myDirs{"3"} = "$sdxroot\\loc\\res\\TOOLS";}
  319. for my $dirKey ( sort keys %myDirs )
  320. {
  321. for my $theKey ( sort { $a <=> $b } keys %myCmds )
  322. {
  323. last if( $theKey eq "5" && !$intact );
  324. $action = 1;
  325. $cmdLine="cd $myDirs{$dirKey}& $myCmds{$theKey}";
  326. if($intact){ $action = &PromptAction( $cmdLine );}
  327. $res = &comlib::ExecuteSystem( $cmdLine ) if( $action == 1);
  328. if(!$intact && $res == 0 )
  329. {
  330. errmsg("Errors encountered... exiting\n");
  331. return 0;
  332. }
  333. #####Stop here, if sync or automation
  334. if( $operation eq "s" )
  335. {
  336. &comlib::ExecuteSystem("cd $myDirs{$dirKey}& $myCmds{7}" );
  337. last;
  338. }
  339. }
  340. #perform submit here - since 2nd case isnt a system call, can't add to myCmds hash
  341. if($operation eq "r" && !$isFake && !$intact)
  342. {
  343. $MAIN = undef;
  344. &getMainBranchName();
  345. if(!SDSubmit("RI: [ntdev\\ntbuild] $lang $LOCPART->$MAIN", $myDirs{$dirKey}))
  346. {
  347. errmsg("Errors encountered submitting changes... exiting\n");
  348. return 0;
  349. }
  350. }
  351. }
  352. }
  353. #----------------------------------------------------------------------------
  354. # CompmainLocpart - compares RI & LP branches
  355. #----------------------------------------------------------------------------
  356. sub CompMainLocpart
  357. {
  358. my( $cmdLine, $action, $res );
  359. my %myCmds = ( "1"=>"sd sync $force $isFake ...$syncTime",
  360. "2"=>"sd sync $force $isFake ...$syncTime");
  361. my $LocDir = $LOCDIRS -> {lc($LOCPART)};
  362. my %myDirs = ( "1"=>"\\$LocDir\\loc\\res\\$lang",
  363. "2"=>"\\$LocDir\\loc\\bin\\$lang");
  364. for my $theKey ( sort keys %myCmds )
  365. {
  366. $cmdLine="cd $myDirs{$theKey}& $myCmds{$theKey}";
  367. if($intact)
  368. {
  369. $action = &PromptAction( $cmdLine );
  370. next if( $action == 2 );
  371. }
  372. $res = &comlib::ExecuteSystem( $cmdLine );
  373. if(!$intact && $res == 0 )
  374. {
  375. errmsg("Differences found during: $cmdLine\n");
  376. }
  377. }
  378. #do comparison
  379. if($intact) #if interactive use windiff / else compdir
  380. {
  381. for $cmdLine ("start windiff $sdxroot\\loc\\res\\$lang \\$LocDir\\loc\\res\\$lang",
  382. "start windiff $sdxroot\\loc\\bin\\$lang \\$LocDir\\loc\\bin\\$lang")
  383. {
  384. $action = &PromptAction( $cmdLine );
  385. &comlib::ExecuteSystem( $cmdLine );
  386. }
  387. }
  388. else
  389. {
  390. for $cmdLine (" compdir $sdxroot\\loc\\res\\$lang \\$LocDir\\loc\\res\\$lang",
  391. " compdir $sdxroot\\loc\\bin\\$lang \\$LocDir\\loc\\bin\\$lang")
  392. {
  393. logmsg("$cmdLine");
  394. my @res = `$cmdLine`;
  395. if( $? )
  396. {
  397. errmsg( "Errors found during comparison:\n@res" );
  398. }
  399. }
  400. }
  401. }
  402. #----------------------------------------------------------------------------//
  403. sub IorRIorSyncTools
  404. {
  405. my( $cmdLine, $action, $IorRI, $res );
  406. $IorRI = "";
  407. $IorRI = "-r -i" if( $operation eq "r" );
  408. if($operation eq "s")
  409. {
  410. &SyncTools();
  411. }
  412. # else
  413. # {
  414. # my %myCmds = ( "1" => "sd opened ...",
  415. # "2"=>"sd sync $force $isFake *",
  416. # "3"=>"sd sync $force $isFake ...",
  417. # "4"=>"sd integrate -b intlred $IorRI $force $isFake *$syncTime",
  418. # "5"=>"sd integrate -b intlred $IorRI $force $isFake ...$syncTime",
  419. # "6"=>"sd resolve $isFake -ab ...",
  420. # "7"=>"sd resolve $isFake -am ...",
  421. # "8"=>"sd resolve ...",
  422. # "9"=>"sd resolve -n ...",
  423. # "10"=>"sd submit ..." );
  424. # my %myDirs = ( "1"=>"$toolDir", "2"=>"$toolDir","3"=>"$pbsDir", "4"=>"$toolDir", "5"=>"$pbsDir",
  425. # "6"=>"$toolDir","7"=>"$toolDir", "8"=>"$toolDir", "9"=>"$toolDir", "10" =>"$toolDir" );
  426. #
  427. # for my $theKey ( sort { $a <=> $b } keys %myCmds )
  428. # {
  429. # $action = 1;
  430. # $cmdLine="cd $myDirs{$theKey}& $myCmds{$theKey}";
  431. # if($intact){$action = &PromptAction( $cmdLine ); }
  432. #
  433. # $res = &comlib::ExecuteSystem( $cmdLine )if( $action == 1 );
  434. # if(!$intact && $res == 0 )
  435. # {
  436. # errmsg("**** Errors encountered executing $cmdLine... exiting ****\n");
  437. # return 0;
  438. # }
  439. # }
  440. # }
  441. }
  442. sub addsyncInt
  443. {
  444. # This code is pasted from copylang.pl
  445. # The eventual goal is migration and separation.
  446. my @theHashKey;
  447. my $line;
  448. my $curKey;
  449. my $LCID;
  450. my $priLangID;
  451. my %tmp;
  452. my $theFromFile;
  453. my $theToFile;
  454. my $theFromRoot;
  455. my $theToRoot;
  456. my $theFromTree;
  457. my $theToTree;
  458. my $from;
  459. my $to;
  460. my $res;
  461. my %hashCodes=();
  462. my $pLocRoot = "$ENV{_NTBINDIR}\\loc\\res\\$lang\\windows\\sources";
  463. my $pSrcRoot = $ENV{"SDXROOT"};
  464. my $theFromTree = "LocTree";
  465. my $theFromRoot = $pLocRoot;
  466. my $theFromFile = "LocTreeFilename";
  467. my $theToTree = "SourceTree";
  468. my $theToRoot = $pSrcRoot;
  469. my $theToFile = "SourceFilename";
  470. &HashText::Read_Text_Hash( 0, $ENV{RazzleToolPath}."\\Codes.txt", \%hashCodes );
  471. # Delete everything that's not international
  472. delete $hashCodes{RO};
  473. delete $hashCodes{CA};
  474. delete $hashCodes{CHP};
  475. delete $hashCodes{PSU};
  476. delete $hashCodes{MIR};
  477. delete $hashCodes{TST};
  478. ###---Get Hash value from intlsrc.txt file.----------//
  479. my @srcHash=();
  480. &HashText::Read_Text_Hash( 1, "$ENV{\"RazzleToolPath\"}\\intlsrc.txt", \@srcHash );
  481. @theHashKey = ("Target", "SourceFilename", "SourceTree", "LocTree","LocTreeFilename","Comments");
  482. %tmp=();
  483. for $line( @srcHash)
  484. {
  485. for $curKey ( @theHashKey )
  486. {
  487. if( $line->{ $curKey } =~ /^(.*)(\$\(LANG\))(.*)$/ )
  488. {
  489. $line->{ $curKey } = $1 . lc($lang) .$3;
  490. }
  491. if( $line->{ $curKey } =~ /^(.*)([c|h])(\$\(PRIMARY_LANG_ID\))(.*)$/ )
  492. {
  493. if( $lang eq "CHT" || $lang eq "CHS" )
  494. {
  495. $LCID = substr( $hashCodes{uc($lang)}->{LCID}, 2, length($hashCodes{uc($lang)}->{LCID})-2);
  496. $line->{ $curKey } = "prf" . $2 . $LCID .$4;
  497. }
  498. else
  499. {
  500. $priLangID = "0". substr( $hashCodes{uc($lang)}->{PriLangID}, 2, length($hashCodes{uc($lang)}->{PriLangID})-2);
  501. $line->{ $curKey } = $1 . $2. $priLangID .$4;
  502. }
  503. }
  504. }
  505. $to = $theToRoot."\\". $line->{ $theToTree };
  506. if( !exists $tmp{$to} ){ $tmp{$to}=(); }
  507. my $todir = "$theToRoot\\$line->{ $theToTree }";
  508. my $cmdLine = "md $todir 2\>NUL&pushd $todir&sd sync $force $to";
  509. $intact and
  510. $res = &PromptAction( $cmdLine );
  511. &comlib::ExecuteSystem( $cmdLine );
  512. }
  513. ###---Perform Copy now.------------------------------//
  514. &dbgmsg("Read targets from intlsrc.txt: \n");
  515. for $line ( @srcHash )
  516. {
  517. &dbgmsg($line->{ $theFromTree },"\n");
  518. if( $lang ne "USA" )
  519. {
  520. next if( !&cktarg::CkTarg( $line->{'Target'}, uc($lang) ) );
  521. }
  522. if( $lang ne "USA" )
  523. {
  524. if( $line->{ $theFromFile } eq ".")
  525. {
  526. $from = $theFromRoot ."\\". $line->{ $theFromTree }."\\".$line->{ $theToFile };
  527. }
  528. }
  529. $to = $theToRoot."\\". $line->{ $theToTree }. "\\".$line->{ $theToFile };
  530. my $todir = "$theToRoot\\$line->{ $theToTree }";
  531. my $cmdLine = "md $todir 2\>NUL&pushd $todir&sd sync $force $to";
  532. $intact and
  533. $res = &PromptAction( $cmdLine );
  534. &comlib::ExecuteSystem( $cmdLine );
  535. }
  536. }
  537. #----------------------------------------------------------------------------
  538. # SyncSourceTree - syncs sdx projects
  539. #----------------------------------------------------------------------------
  540. sub SyncSourceTree
  541. {
  542. my( @sdMap, @sdProject, $cmdLine, $action, $res, $sdCmd, @opened );
  543. if( !open( SDMAP, "$sdxroot\\sd.map") )
  544. {
  545. errmsg( "Fail to read $sdxroot\\s.map, exit.");
  546. return 0;
  547. }
  548. @sdMap = <SDMAP>;
  549. close( SDMAP );
  550. my $validLine = 0;
  551. @sdProject=();
  552. for my $curLine ( @sdMap )
  553. {
  554. chomp $curLine;
  555. my @tmpLine = split( /\s+/, $curLine );
  556. if( $tmpLine[1] !~ "---" )
  557. {
  558. next if ( !$validLine );
  559. last if( $tmpLine[0] =~ "#" );
  560. }
  561. else
  562. {
  563. $validLine = 1;
  564. next;
  565. }
  566. next if( !$tmpLine[1] || $tmpLine[1] =~ "(.*)_(.*)" );
  567. next if( $tmpLine[1] eq "root" );
  568. push ( @sdProject, $tmpLine[3] );
  569. }
  570. push ( @sdProject,"developer" );
  571. push ( @sdProject,"Mergedcomponents" );
  572. push ( @sdProject,"public" );
  573. push ( @sdProject,"published" );
  574. $sdCmd = "sd sync $force $isFake ...$syncTime";
  575. $cmdLine = "cd $sdxroot\\@sdProject& $sdCmd";
  576. if($intact) {return 1 if( &PromptAction( $cmdLine ) !=1 );}
  577. for my $theDir( @sdProject )
  578. {
  579. return 0 if !&VryFieZs("writable", "$sdxroot\\$theDir");
  580. $res = CheckOpened("$sdxroot\\$theDir" );
  581. if(!$intact && $res == 0 ){ push (@opened, $theDir); }
  582. $res = &comlib::ExecuteSystem( "cd $sdxroot\\$theDir& sd sync $force $isFake ...$syncTime" );
  583. if(!$intact && $res == 0 ){
  584. errmsg("**** Errors encountered during sync. Exiting... ****\n");
  585. return 0;
  586. }
  587. $res = &comlib::ExecuteSystem( "cd $sdxroot\\$theDir& sd diff -f -sadeE ...$syncTime" );
  588. if(!$intact && $res == 0 ){
  589. errmsg("**** Errors encountered during sd diff. Exiting... ****\n");
  590. return 0;
  591. }
  592. }
  593. if(!&SyncTools) #added SynclatestTools here since we'll always want latest tools
  594. {
  595. push (@opened, "tools");
  596. }
  597. for my $i(@opened) #report opened files
  598. {
  599. errmsg(" - Files opened in $i ");
  600. }
  601. return 1;
  602. }
  603. #----------------------------------------------------------------------------//
  604. sub PromptAction
  605. {
  606. my ( $pCmdLine ) = @_;
  607. my ( $choice ) = -1;
  608. my ($theDot) = '.' x ( length( $pCmdLine ) + 10);
  609. print ( "\nAbout to [$pCmdLine]\n$theDot\n") if( $pCmdLine );
  610. while ( $choice > 3 || $choice < 1 )
  611. {
  612. print( "\nPlease choose (1) Continue? (2) Skip (3) Quit? ");
  613. chop( $choice=<STDIN> );
  614. }
  615. print "\n\n";
  616. exit(0) if( $choice == 3 );
  617. return $choice;
  618. }
  619. #----------------------------------------------------------------------------//
  620. sub CurTime
  621. {
  622. my ($sec,$min,$hour,$day,$mon,$year) = localtime;
  623. $year %= 100;
  624. $mon++;
  625. return sprintf("%02d%02d%02d-%02d%02d%02d",
  626. $mon, $day, $year, $hour, $min, $sec);
  627. }
  628. sub getMainBranchName{
  629. last if $MAIN;
  630. my $HomeBranch = qx("sd have ... | head -1");
  631. $HomeBranch =~ s/\/\/depot\/(\w+)\/.*$/$1/g;
  632. print STDERR $HomeBranch;
  633. $MAIN = $HomeBranch;
  634. }
  635. 1;
  636. __END__
  637. =head1 INITIAL DESIGN
  638. <Suemiao Rossignol <[email protected]>
  639. =head1 CHANGES
  640. <Serguei Kouzmine <[email protected]>
  641. Rearranging the logic to separate sd update - sd sync - no sd.
  642. This rearrangement will involve intlbld.pl, copylang.pl, intlsdop.cmd
  643. Please read the usage for all these.
  644. Q: Is there the way to do it safe and incremental?
  645. A: Yes. Possibly.
  646. Step 1.
  647. add copylang.pl "sync only" functionality to intlsdop.cmd
  648. Step 2.
  649. add intlmap.pl "selective enlist" functionality to intlsdop.cmd
  650. and copylang/intlbld
  651. add intlsdop.cmd "sync" functionality to copylang/intlbld
  652. Step 3.
  653. do a cleanup of redundant code. Define logic in mapping files