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.

1176 lines
36 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM
  4. REM chgkeyinf.cmd
  5. REM Change txtsetup.sif, layout.inf, dosnet.inf file for the adding mui resource files
  6. REM
  7. REM
  8. REM Copyright (c) Microsoft Corporation. All rights reserved.
  9. REM
  10. REM ------------------------------------------------------------------
  11. perl -x "%~f0" %*
  12. goto :EOF
  13. #!perl
  14. use strict;
  15. use File::Basename;
  16. use IO::File;
  17. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  18. use lib $ENV{RAZZLETOOLPATH};
  19. use PbuildEnv;
  20. use ParseArgs;
  21. use Logmsg;
  22. use cksku;
  23. require Exporter;
  24. BEGIN {
  25. $ENV{SCRIPT_NAME} = 'chgkeyinf.cmd';
  26. }
  27. sub Usage { print<<USAGE; exit(1) }
  28. chgkeyinf [-l lang]
  29. Change txtsetup.sif, layout.inf, dosnet.inf file for the adding mui resource files
  30. Read nttree\\build_logs\\LgNeutral\\lgnbuildlist.txt, which generated by lgndata.cmd, to
  31. get the list of binaries to be added to the said INFs.
  32. USAGE
  33. # Global variables
  34. my ($lang);
  35. my (%CDDataSKUs, %INFPathSKUs, $Neutral_LogDir, $LGNBuildList, $LGNCMFList, $LGNDirs, $LGNDirs_Localized);
  36. my (@ItemsList, $LGNTagStart, $LGNTagEnd, $LGNItemEntry, $LGNDirs_Tag, $LGNDirs_TagReg);
  37. my( $LogFilename );
  38. my( $TempDir );
  39. my( $nttree, $razpath, $TempDir);
  40. my($fNeedGenerateCMF);
  41. ##################
  42. #
  43. # parse command line
  44. #
  45. ##################
  46. parseargs( '?' => \&Usage,
  47. 'l:' => \$lang
  48. );
  49. &Main();
  50. #
  51. # Check if Language Neutral is enabled or not
  52. #
  53. sub IsLGNActivated()
  54. {
  55. my ($MUI_MAGIC, $Result);
  56. $Result = 0;
  57. $MUI_MAGIC= $ENV{ "MUI_MAGIC" };
  58. if ( defined($MUI_MAGIC))
  59. {
  60. $Result=1;
  61. }
  62. return $Result
  63. }
  64. sub IsCMFActivated()
  65. {
  66. my ($MUI_MAGIC_CMF, $Result);
  67. $Result = 0;
  68. $MUI_MAGIC_CMF= $ENV{ "MUI_MAGIC_CMF" };
  69. if ( defined($MUI_MAGIC_CMF))
  70. {
  71. $Result=1;
  72. }
  73. return $Result
  74. }
  75. sub Main
  76. {
  77. # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  78. # Begin Main code section
  79. # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  80. # Return when you want to exit on error
  81. #
  82. my ($Mylang, $MyError, $Sku, $MyLCID);
  83. my ($Path_Dosnet, $Path_Txtsetup, $Path_Layout, $Path_Dir);
  84. my ($Path_Dosnet_sign, $Path_Txtsetup_sign, $Path_Layout_sign, $Path_Dir_sign);
  85. my ($Backup_Path, $ErrCnt);
  86. if (! &IsLGNActivated())
  87. {
  88. return 0;
  89. }
  90. #
  91. # $lang must be set. Default is usa
  92. #
  93. if ( ! defined($lang))
  94. {
  95. $lang = $ENV{LANG};
  96. if (! defined($lang))
  97. {
  98. $lang="usa";
  99. }
  100. }
  101. $Mylang="\L$lang";
  102. if ( ($Mylang ne "usa" ) && ($Mylang ne "psu" ) )
  103. {
  104. return 0;
  105. }
  106. #
  107. # Check If CMF is enabled
  108. #
  109. $fNeedGenerateCMF=&IsCMFActivated();
  110. #
  111. # Set important path
  112. #
  113. $nttree = $ENV{ "_NTPostBld" };
  114. $razpath= $ENV{ "RazzleToolPath" };
  115. $TempDir = $ENV{ "TMP" };
  116. $Logmsg::DEBUG = 0; # set to 1 to activate logging of dbgmsg's
  117. $LogFilename = $ENV{ "LOGFILE" };
  118. if ( ! defined( $LogFilename ) )
  119. {
  120. $TempDir = $ENV{ "TMP" };
  121. $LogFilename = "$TempDir\\$0.log";
  122. }
  123. $Neutral_LogDir = $nttree."\\build_logs\\LgNeutral";
  124. $LGNBuildList = $Neutral_LogDir."\\lgnbuildlist.txt";
  125. $LGNCMFList = $Neutral_LogDir."\\lgnCMFlist.txt";
  126. $LGNTagStart = "; Following are entries added for Language neutral resource files:\$\$\$ ";
  127. $LGNTagEnd = "; End of entries for Language neutral resource files: \$\$\$";
  128. $LGNDirs_Tag = "190 = mui\\fallback\\";
  129. $LGNDirs_TagReg ="190 = mui\\\\fallback\\\\";
  130. $LGNDirs = $LGNDirs_Tag."0409";
  131. $LGNItemEntry = " = 1,,2048,,,,,190,0,0";
  132. if (! GetLCIDofLang($lang,\$MyLCID))
  133. {
  134. errmsg("Fatal: can't get LCID for $lang");
  135. return 0;
  136. }
  137. $LGNDirs_Localized="$LGNDirs_Tag$MyLCID";
  138. $MyError=0;
  139. #
  140. # Check Language Neutral working directory
  141. #
  142. unless (-d $Neutral_LogDir)
  143. {
  144. errmsg("Fatal: Directory $Neutral_LogDir does not exist");
  145. $MyError=1;
  146. }
  147. if ($fNeedGenerateCMF)
  148. {
  149. unless (-e $LGNCMFList)
  150. {
  151. errmsg("Fatal: Language Neutral CMF list not found : $LGNCMFList");
  152. $MyError=1;
  153. }
  154. }
  155. else
  156. {
  157. unless (-e $LGNBuildList)
  158. {
  159. errmsg("Fatal: Language Neutral build list not found : $LGNBuildList");
  160. $MyError=1;
  161. }
  162. }
  163. if ($MyError != 0)
  164. {
  165. exit(1);
  166. }
  167. if ($fNeedGenerateCMF)
  168. {
  169. #
  170. # Read CMF binaries into @ItemsList
  171. #
  172. unless ( open(INFILE, $LGNCMFList))
  173. {
  174. errmag("Fatal: Can't open $LGNCMFList");
  175. $MyError=1;
  176. exit(1);
  177. }
  178. @ItemsList=<INFILE>;
  179. close(INFFILE);
  180. }
  181. else
  182. {
  183. #
  184. # Read LGN binaries into @ItemsList
  185. #
  186. unless ( open(INFILE, $LGNBuildList))
  187. {
  188. errmag("Fatal: Can't open $LGNBuildList");
  189. $MyError=1;
  190. exit(1);
  191. }
  192. @ItemsList=<INFILE>;
  193. close(INFFILE);
  194. }
  195. #
  196. # Build path of INFs for SKUs
  197. #
  198. BuildArray();
  199. #
  200. # For Each SKUs, update the KEY INFS
  201. #
  202. $ErrCnt=0;
  203. foreach $Sku ( keys(%CDDataSKUs))
  204. {
  205. # SKU populated ?
  206. if ($CDDataSKUs{$Sku})
  207. {
  208. if ( !defined($INFPathSKUs{$Sku} ))
  209. {
  210. errmag("Fatal: $Sku has no corr. entry in INFPathSKUs");
  211. exit(1);
  212. }
  213. #
  214. # Read the INFs path for the SKU
  215. #
  216. ($Path_Dosnet,$Path_Txtsetup,$Path_Layout,$Path_Dir, $Path_Dosnet_sign,$Path_Txtsetup_sign,$Path_Layout_sign,$Path_Dir_sign)=@{$INFPathSKUs{$Sku}};
  217. $Backup_Path="$Neutral_LogDir\\$Path_Dir";
  218. #
  219. #Change for DosNet
  220. #
  221. if (! DoDosNetChange($Path_Dosnet, \@ItemsList, $Backup_Path))
  222. {
  223. $ErrCnt++;
  224. errmsg("Fatal: Update Dosnet.inf faild for $Sku");
  225. }
  226. #Change for Txtsetup
  227. if (! DoTxtsetupNLayoutChange($Path_Txtsetup, \@ItemsList, $Backup_Path))
  228. {
  229. $ErrCnt++;
  230. errmsg("Fatal: Update Txtsetup.sif faild for $Sku");
  231. }
  232. # Change for Layout
  233. if (! DoTxtsetupNLayoutChange($Path_Layout, \@ItemsList, $Backup_Path))
  234. {
  235. $ErrCnt++;
  236. errmsg("Fatal: Update layout.inf faild for $Sku");
  237. }
  238. #
  239. #
  240. #
  241. $Backup_Path="$Neutral_LogDir\\$Path_Dir_sign";
  242. #
  243. #Change for DosNet
  244. #
  245. if (! DoDosNetChange($Path_Dosnet_sign, \@ItemsList, $Backup_Path))
  246. {
  247. $ErrCnt++;
  248. errmsg("Fatal: Update Dosnet.inf faild for $Sku");
  249. }
  250. #Change for Txtsetup
  251. if (! DoTxtsetupNLayoutChange($Path_Txtsetup_sign, \@ItemsList, $Backup_Path))
  252. {
  253. $ErrCnt++;
  254. errmsg("Fatal: Update Txtsetup.sif faild for $Sku");
  255. }
  256. # Change for Layout
  257. if (! DoTxtsetupNLayoutChange($Path_Layout_sign, \@ItemsList, $Backup_Path))
  258. {
  259. $ErrCnt++;
  260. errmsg("Fatal: Update layout.inf faild for $Sku");
  261. }
  262. }
  263. }
  264. if ( !$ErrCnt)
  265. {
  266. timemsg( "Update KEY INFs successfully");
  267. }
  268. else
  269. {
  270. timemsg( "Update KEY INFs Failed with $ErrCnt errors, please check Log");
  271. }
  272. # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  273. # End Main code section
  274. # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  275. }
  276. #
  277. # Get LCID of a given language
  278. #
  279. sub GetLCIDofLang
  280. {
  281. my($Mylang, $LCID) = @_;
  282. my ($CODEFILE,@data, $Result, $LCIDShort);
  283. $CODEFILE = $ENV{RAZZLETOOLPATH} ."\\codes.txt";
  284. $Result = 0;
  285. $Mylang="\L$Mylang";
  286. if ( $Mylang eq "usa")
  287. {
  288. $$LCID="0409";
  289. $Result =1;
  290. return $Result;
  291. }
  292. #
  293. # Search CODEFILE for $Special_Lang, $LCID, $LANG_ISO, etc.
  294. #
  295. if(!open(CODEFILE, "$CODEFILE"))
  296. {
  297. errmsg ("Can't open lcid file $CODEFILE for reading.");
  298. return $Result;
  299. }
  300. CODES_LOOP: while (<CODEFILE>)
  301. {
  302. if (/^$Mylang\s+/i)
  303. {
  304. @data = split(/\s+/,$_);
  305. last CODES_LOOP;
  306. }
  307. }
  308. close(CODEFILE);
  309. if(!@data)
  310. {
  311. errmsg("fatal: can't find LCID for $Mylang");
  312. return $Result;
  313. }
  314. $LCIDShort = $data[2];
  315. $LCIDShort =~ s/^0x//;
  316. $$LCID=$LCIDShort;
  317. $Result =1;
  318. return $Result;
  319. } # GetLCIDofLang
  320. #
  321. # Add LGN binaries to dosnet.inf
  322. #
  323. sub DoDosNetChange
  324. {
  325. my ($FilePath, $pItemsList, $BackupPath) = @_;
  326. my (@Items, @ItemsInSection, $Section, $Result, $nStart, $nEnd, $nStartTag1, $nStartTag2);
  327. my ($Replace, $Line, $Entry);
  328. my (@AddedItems, $FileName, $Path, $Idx, $Item_no);
  329. $Result = 0;
  330. # Open he dosnet.inf
  331. unless ( open(INFILE, $FilePath) )
  332. {
  333. errmsg ("Can't open $FilePath");
  334. return $Result;
  335. }
  336. # Read into @Items
  337. @Items=<INFILE>;
  338. close(INFILE);
  339. $Section="Files";
  340. $nStartTag1=0;
  341. $nStartTag2=0;
  342. #
  343. # Read [Files] Section, position in nStart, nEnd
  344. # Find LGN tag, position in nStartTag1, nStartTag2
  345. #
  346. # [Note] There are multiply [Files] in Dosnet.inf. We are looking the one which notepad.exe exists
  347. #
  348. if (!ReadSectionDosNet($Section,\@Items, \$nStart, \$nEnd, \$nStartTag1, \$nStartTag2,
  349. $LGNTagStart,$LGNTagEnd))
  350. {
  351. errmsg("Fatal: Can't find $Section in $FilePath");
  352. return $Result;
  353. }
  354. #
  355. # Search the LGN Tag
  356. #
  357. $nStartTag1=-1;
  358. $nStartTag2=-1;
  359. $Replace="FALSE";
  360. $Idx=-1;
  361. foreach (@Items)
  362. {
  363. chomp($_);
  364. $Idx++;
  365. # Find$ LGN tag, position in nStartTag1, nStartTag2
  366. if ( $_ eq $LGNTagStart)
  367. {
  368. $nStartTag1 = $Idx;
  369. }
  370. if ( $_ eq $LGNTagEnd)
  371. {
  372. $nStartTag2 = $Idx;
  373. }
  374. }
  375. if ( ($nStartTag1 != -1) && ($nStartTag2 != -1))
  376. {
  377. $Replace = "TRUE";
  378. }
  379. else
  380. {
  381. logmsg("StartTag/EndTag not found in $FilePath, it may be a fresh one");
  382. }
  383. #
  384. # LGN resource files list in @$pItemsList
  385. # Let's add items in @$pItemsList to @AddedItems
  386. #
  387. foreach $Line (@$pItemsList)
  388. {
  389. chomp($Line);
  390. if (! $fNeedGenerateCMF)
  391. {
  392. $Entry = "d1,$Line.mui";
  393. }
  394. else
  395. {
  396. $Entry = "d1,$Line";
  397. }
  398. push(@AddedItems,$Entry);
  399. }
  400. #
  401. # backup the dosnet.inf before the modification
  402. #
  403. if ( ! -d $BackupPath)
  404. {
  405. system("md $BackupPath");
  406. }
  407. unless ( -d $BackupPath)
  408. {
  409. errmsg("Fatal: Can't open backup path $BackupPath");
  410. }
  411. #
  412. # Get File name from path
  413. #
  414. ($FileName, $Path ) = fileparse($FilePath);
  415. if ( system("copy/y $FilePath $BackupPath\\$FileName.Bak") != 0)
  416. {
  417. errmsg("Fatal: Can't backup $FilePath to $BackupPath\\$FileName.Bak");
  418. return $Result;
  419. }
  420. #
  421. # Generate the dosnet.inf with added LGN resource files
  422. #
  423. system ("attrib -r $FilePath 2>null");
  424. unless ( open(OUTFILE, ">$FilePath") )
  425. {
  426. errmsg("Fatal: Can't open output for $FilePath");
  427. return $Result;
  428. }
  429. $Item_no=scalar(@Items);
  430. if ( $Replace eq "TRUE")
  431. {
  432. for ($Idx=0; $Idx <= $nStartTag1; $Idx++)
  433. {
  434. chomp($Items[$Idx]);
  435. print (OUTFILE "$Items[$Idx]\n");
  436. }
  437. foreach $Line (@AddedItems)
  438. {
  439. print (OUTFILE "$Line\n");
  440. }
  441. for ($Idx=$nStartTag2; $Idx < $Item_no; $Idx++)
  442. {
  443. chomp($Items[$Idx]);
  444. print (OUTFILE "$Items[$Idx]\n");
  445. }
  446. }
  447. else
  448. {
  449. for ($Idx=0; $Idx <= $nEnd; $Idx++)
  450. {
  451. chomp($Items[$Idx]);
  452. print (OUTFILE "$Items[$Idx]\n");
  453. }
  454. #
  455. # Add LGN resource files, enclosed them with Tag
  456. #
  457. print (OUTFILE "$LGNTagStart\n");
  458. foreach $Line (@AddedItems)
  459. {
  460. print (OUTFILE "$Line\n");
  461. }
  462. print (OUTFILE "$LGNTagEnd\n\n");
  463. for ($Idx=$nEnd+1; $Idx < $Item_no; $Idx++)
  464. {
  465. chomp($Items[$Idx]);
  466. print (OUTFILE "$Items[$Idx]\n");
  467. }
  468. }
  469. close(OUTFILE);
  470. $Result = 1;
  471. logmsg("Success: Update $FilePath");
  472. return $Result;
  473. }
  474. #
  475. # Add LGN binaries to txtsetup.sif/layout.inf
  476. #
  477. sub DoTxtsetupNLayoutChange
  478. {
  479. my ($FilePath, $pItemsList, $BackupPath) = @_;
  480. my (@Items, @ItemsInSection, $Section, $Result, $nStart, $nEnd, $nStartTag1, $nStartTag2,$nStartDirs,$nEndDirs);
  481. my ($nStart_Dir,$nEnd_Dir);
  482. my ($ReplaceDirs, $Replace, $Line, $Entry);
  483. my (@AddedItems, $FileName, $Path, $Idx, $Item_no);
  484. my (%RenameTable, $FileRenamed, $nUppbound);
  485. my ($NoAlt, $BldArch, $AltSection,$nAltStart,$nAltEnd, $bLGNDirs);
  486. $Result = 0;
  487. # Open he dosnet.inf
  488. unless ( open(INFILE, $FilePath) )
  489. {
  490. errmsg ("Can't open $FilePath");
  491. return $Result;
  492. }
  493. # Read into @Items
  494. @Items=<INFILE>;
  495. close(INFILE);
  496. #
  497. # First, we have to read [WinntDirectories] section to see if '190 = mui\fallback\0409' is there
  498. #
  499. $Section="WinntDirectories";
  500. $nStartDirs=0;
  501. $nEndDirs=0;
  502. #
  503. # Read [WinntDirectories] Section, position in nStart, nEnd
  504. #
  505. if (!ReadSection($Section,\@Items, \@ItemsInSection, \$nStart_Dir, \$nEnd_Dir, \$nStartDirs, \$nEndDirs,
  506. $LGNDirs,"Nothing"))
  507. {
  508. errmsg("Fatal: Can't find $Section in $FilePath");
  509. return $Result;
  510. }
  511. $Section="SourceDisksFiles";
  512. $nStartTag1=0;
  513. $nStartTag2=0;
  514. #
  515. # Read [SourceDisksFiles] Section, position in nStart, nEnd
  516. #
  517. if (!ReadSection($Section,\@Items, \@ItemsInSection, \$nStart, \$nEnd, \$nStartTag1, \$nStartTag2,
  518. $LGNTagStart,$LGNTagEnd))
  519. {
  520. errmsg("Fatal: Can't find $Section in $FilePath");
  521. return $Result;
  522. }
  523. #
  524. # Read [SourceDisksFiles.<BldArch>] Section. This section contains platform specific files
  525. #
  526. my ($NoAlt, $BldArch, $AltSection);
  527. $NoAlt=0;
  528. $BldArch = $ENV{ "\_BuildArch" };
  529. if ( $BldArch =~ /x86/i )
  530. {
  531. $AltSection= "$Section.x86";
  532. }
  533. elsif ( $BldArch =~ /amd64/i)
  534. {
  535. $AltSection= "$Section.amd64";
  536. }
  537. elsif ( $BldArch =~ /ia64/i )
  538. {
  539. $AltSection= "$Section.ia64";
  540. }
  541. else
  542. {
  543. $AltSection= "$Section.x86";
  544. }
  545. if (!ReadSection($AltSection,\@Items, \@ItemsInSection, \$nAltStart, \$nAltEnd, \$nStartTag1, \$nStartTag2,
  546. $LGNTagStart,$LGNTagEnd))
  547. {
  548. errmsg(" Can't find $AltSection in $FilePath");
  549. $NoAlt=1;
  550. }
  551. #
  552. # Search Tag here
  553. #
  554. $nStartDirs=-1;
  555. $nEndDirs=-1;
  556. $nStartTag1=-1;
  557. $nStartTag2=-1;
  558. $ReplaceDirs="FALSE";
  559. $Replace="FALSE";
  560. $Idx=-1;
  561. foreach (@Items)
  562. {
  563. chomp($_);
  564. $Idx++;
  565. # Find $LGNDirs, position in nStartDirs
  566. if ( $_ eq $LGNDirs)
  567. {
  568. $nStartDirs = $Idx;
  569. }
  570. # Find$ LGN tag, position in nStartTag1, nStartTag2
  571. if ( $_ eq $LGNTagStart)
  572. {
  573. $nStartTag1 = $Idx;
  574. }
  575. if ( $_ eq $LGNTagEnd)
  576. {
  577. $nStartTag2 = $Idx;
  578. }
  579. }
  580. if ($nStartDirs != -1)
  581. {
  582. $ReplaceDirs = "TRUE";
  583. }
  584. if ( ($nStartTag1 != -1) && ($nStartTag2 != -1))
  585. {
  586. $Replace = "TRUE";
  587. }
  588. #
  589. # Build up rename table here !
  590. # Windows sepcify the renaming in txtsetup.txt and layout.inf
  591. #
  592. %RenameTable={};
  593. if ($Replace eq "TRUE")
  594. {
  595. $nUppbound = $nStartTag1;
  596. }
  597. else
  598. {
  599. $nUppbound = $nEnd;
  600. }
  601. if (! &BuildRenameTable(\@Items,$nStart, $nUppbound,\%RenameTable))
  602. {
  603. errmsg("Can't build File Rename Table");
  604. return $Result;
  605. }
  606. if ( ! $NoAlt )
  607. {
  608. if (! &BuildRenameTable(\@Items,$nAltStart, $nAltEnd,\%RenameTable))
  609. {
  610. errmsg("Can't build File Rename Table from $AltSection");
  611. }
  612. }
  613. #
  614. # LGN resource files list in @$pItemsList
  615. # Let's add LGN binaries to @AddedItems
  616. #
  617. foreach $Line (@$pItemsList)
  618. {
  619. chomp($Line);
  620. if (! $fNeedGenerateCMF)
  621. {
  622. $Entry = "$Line.mui$LGNItemEntry";
  623. #
  624. # If file exists in rename table, append rename entry
  625. #
  626. $FileRenamed=$RenameTable{$Line};
  627. if ( defined($FileRenamed) )
  628. {
  629. $Entry="$Entry,$FileRenamed.mui";
  630. }
  631. }
  632. else
  633. {
  634. $Entry = "$Line$LGNItemEntry";
  635. }
  636. push(@AddedItems,$Entry);
  637. }
  638. #
  639. # backup the txtsetup.sif / layout.inf before the modification
  640. #
  641. if ( ! -d $BackupPath)
  642. {
  643. system("md $BackupPath");
  644. }
  645. unless ( -d $BackupPath)
  646. {
  647. errmsg("Fatal: Can't open backup path $BackupPath");
  648. }
  649. #
  650. # Get File name from path
  651. #
  652. ($FileName, $Path ) = fileparse($FilePath);
  653. if (system("copy/y $FilePath $BackupPath\\$FileName.Bak") != 0)
  654. {
  655. errmsg("Fatal: Can't backup $FilePath to $BackupPath\\$FileName.Bak");
  656. return $Result;
  657. }
  658. #
  659. # Generate the txtsetup.sif / layout.inf with added LGN resource files
  660. #
  661. system ("attrib -r $FilePath");
  662. unless ( open(OUTFILE, ">$FilePath") )
  663. {
  664. errmsg("Fatal: Can't open output for $FilePath");
  665. return $Result;
  666. }
  667. $Item_no=scalar(@Items);
  668. $bLGNDirs=0;
  669. for ($Idx=0; $Idx <= $nEnd_Dir; $Idx++)
  670. {
  671. chomp($Items[$Idx]);
  672. if ( ($Idx > $nStart_Dir) && ( $Items[$Idx] =~ /^$LGNDirs_TagReg/) )
  673. {
  674. $Items[$Idx] = $LGNDirs_Localized;
  675. $bLGNDirs=1;
  676. }
  677. print (OUTFILE "$Items[$Idx]\n");
  678. }
  679. #if ($ReplaceDirs eq "FALSE")
  680. if ( ! $bLGNDirs)
  681. {
  682. print (OUTFILE "$LGNDirs_Localized\n\n");
  683. }
  684. #
  685. # Add/Replace items in [SourceDisksFiles] Section
  686. #
  687. if ( $Replace eq "TRUE")
  688. {
  689. for ($Idx=$nEnd_Dir + 1 ; $Idx <= $nStartTag1; $Idx++)
  690. {
  691. chomp($Items[$Idx]);
  692. print (OUTFILE "$Items[$Idx]\n");
  693. }
  694. foreach $Line (@AddedItems)
  695. {
  696. print (OUTFILE "$Line\n");
  697. }
  698. for ($Idx=$nStartTag2; $Idx < $Item_no; $Idx++)
  699. {
  700. chomp($Items[$Idx]);
  701. print (OUTFILE "$Items[$Idx]\n");
  702. }
  703. }
  704. else
  705. {
  706. for ($Idx=$nEnd_Dir + 1; $Idx <= $nEnd; $Idx++)
  707. {
  708. chomp($Items[$Idx]);
  709. print (OUTFILE "$Items[$Idx]\n");
  710. }
  711. #
  712. # Add LGN resource files, enclosed them with Tag
  713. #
  714. print (OUTFILE "$LGNTagStart\n");
  715. foreach $Line (@AddedItems)
  716. {
  717. print (OUTFILE "$Line\n");
  718. }
  719. print (OUTFILE "$LGNTagEnd\n\n");
  720. for ($Idx=$nEnd+1; $Idx < $Item_no; $Idx++)
  721. {
  722. chomp($Items[$Idx]);
  723. print (OUTFILE "$Items[$Idx]\n");
  724. }
  725. }
  726. close(OUTFILE);
  727. $Result = 1;
  728. logmsg("Success: Update $FilePath");
  729. return $Result;
  730. }
  731. #
  732. #
  733. # Scan the entries of txtsetup.sif/layout.inf to find the files to be renamed
  734. #
  735. # If a file is renamed, then its associated mui file should be renamed also
  736. #
  737. sub BuildRenameTable
  738. {
  739. my ($pItems,$nStart, $nEnd,$pRenameTable)= @_;
  740. my ($Line, $Trash, $Idx,$OldName,$NewName);
  741. for ($Idx = $nStart; $Idx <= $nEnd; $Idx++)
  742. {
  743. $Line=$$pItems[$Idx];
  744. chomp($Line);
  745. if ( length($Line) == 0)
  746. {
  747. next;
  748. }
  749. if (substr($Line,0,1) eq ";")
  750. {
  751. next;
  752. }
  753. if ($Line =~ /=\s*[^,]*,[^,]*,[^,]*,[^,]*,[^,]*,[^,]*,[^,]*,[^,]*,[^,]*,[^,]*,([^,]+)/ )
  754. {
  755. $NewName=$1;
  756. ($OldName,$Trash) = split ( /=+/, $Line);
  757. $OldName =~ s/\s//g;
  758. $NewName=~ s/\s//g;
  759. $$pRenameTable{$OldName}=$NewName;
  760. }
  761. }
  762. return 1;
  763. }
  764. #
  765. # Search a Section of a INFs. INFs stored in @$pItemsList
  766. #
  767. sub ReadSection
  768. {
  769. my ($Section, $pItemsList, $pItemsInSection, $pnStart, $pnEnd, $pnStartTag1, $pnStartTag2, $Tag1,$Tag2) = @_;
  770. my ($Index, $SectionStart, $SectionEnd, $Line, $Line_Org, $ReadFlag, $Result);
  771. $ReadFlag = "FALSE";
  772. $Index= -1;
  773. $SectionStart = -1;
  774. $SectionEnd = -1;
  775. $Result = 0;
  776. #
  777. # Read The section
  778. #
  779. LINE: foreach $Line_Org (@$pItemsList)
  780. {
  781. $Line = $Line_Org;
  782. chomp($Line);
  783. $Index++;
  784. if ( (length($Line) == 0) || (substr($Line,0,1) eq ";") || (substr($Line,0,1) eq "#") )
  785. {
  786. if ( $ReadFlag eq "TRUE" )
  787. {
  788. push (@$pItemsInSection, $Line_Org);
  789. }
  790. next;
  791. }
  792. if ( $Line =~ /^\[/ )
  793. {
  794. if ( $ReadFlag eq "TRUE")
  795. {
  796. $ReadFlag = "FALSE";
  797. if ( $SectionStart != -1)
  798. {
  799. if ($SectionEnd == -1)
  800. {
  801. $SectionEnd = $Index-1;
  802. }
  803. }
  804. last LINE;
  805. }
  806. }
  807. if ( $Line =~ /^\[$Section\]/ ) # pattern in $Section !!!
  808. {
  809. $ReadFlag = "TRUE";
  810. $SectionStart=$Index;
  811. }
  812. if ($ReadFlag eq "TRUE")
  813. {
  814. # Check if it's a LGN starting Tag
  815. if ( $$pnStartTag1 != 0)
  816. {
  817. if ($Line eq $Tag1)
  818. {
  819. $$pnStartTag1 = $Index;
  820. }
  821. }
  822. # Check if it's a LGN ending Tag
  823. if ( $$pnStartTag2 != 0)
  824. {
  825. if ($Line eq $Tag2)
  826. {
  827. $$pnStartTag2 = $Index;
  828. }
  829. }
  830. push(@$pItemsInSection, $Line_Org);
  831. }
  832. }
  833. if ( $SectionStart != -1)
  834. {
  835. if ( $SectionEnd == -1)
  836. {
  837. $SectionEnd = $Index;
  838. }
  839. $Result = 1;
  840. $$pnStart = $SectionStart;
  841. $$pnEnd = $SectionEnd;
  842. }
  843. return $Result;
  844. }
  845. #
  846. # Search a Section of a INFs. INFs stored in @$pItemsList
  847. #
  848. sub ReadSectionDosNet
  849. {
  850. my ($Section, $pItemsList, $pnStart, $pnEnd, $pnStartTag1, $pnStartTag2, $Tag1,$Tag2) = @_;
  851. my ($Index, $SectionStart, $SectionEnd, $Line, $ReadFlag, $Result, $NotepadFound, $NotepadTag);
  852. $ReadFlag = 0;
  853. $NotepadFound=0;
  854. $Index= -1;
  855. $SectionStart = -1;
  856. $SectionEnd = -1;
  857. $Result = 0;
  858. $NotepadTag="d1,notepad.exe";
  859. #
  860. # Read The section
  861. #
  862. LINE: foreach $Line (@$pItemsList)
  863. {
  864. chomp($Line);
  865. $Index++;
  866. if ( (length($Line) == 0) || (substr($Line,0,1) eq ";") || (substr($Line,0,1) eq "#") )
  867. {
  868. next;
  869. }
  870. #
  871. # A start of section
  872. #
  873. if ( $Line =~ /^\[/ )
  874. {
  875. if ( $ReadFlag)
  876. {
  877. $ReadFlag = 0;
  878. #
  879. # Is it the section we want ?
  880. #
  881. if ($NotepadFound)
  882. {
  883. if ( $SectionStart != -1)
  884. {
  885. if ($SectionEnd == -1)
  886. {
  887. $SectionEnd = $Index-1;
  888. }
  889. }
  890. # Done ! and Exit the loop
  891. last LINE;
  892. }
  893. else
  894. {
  895. $SectionStart= -1;
  896. $SectionEnd = -1;
  897. }
  898. }
  899. }
  900. if ( $Line =~ /^\[$Section\]/ ) # pattern in $Section !!!
  901. {
  902. $ReadFlag = 1;
  903. $SectionStart=$Index;
  904. }
  905. if ($ReadFlag)
  906. {
  907. if ( $Line =~ /$NotepadTag/ )
  908. {
  909. $NotepadFound=1;
  910. }
  911. }
  912. }
  913. if ( ($SectionStart != -1) && $NotepadFound )
  914. {
  915. if ( $SectionEnd == -1)
  916. {
  917. $SectionEnd = $Index;
  918. }
  919. $Result = 1;
  920. $$pnStart = $SectionStart;
  921. $$pnEnd = $SectionEnd;
  922. }
  923. return $Result;
  924. }
  925. #
  926. # Build hash of array which contians path of KEY INFS
  927. #
  928. sub BuildArray
  929. {
  930. my ($BigDosnet, $PerDosnet, $BlaDosnet, $SbsDosnet, $SrvDosnet , $EntDosnet , $DtcDosnet);
  931. my ($BigDosnet_sign, $PerDosnet_sign, $BlaDosnet_sign, $SbsDosnet_sign, $SrvDosnet_sign , $EntDosnet_sign , $DtcDosnet_sign);
  932. my ($BigTxtsetup, $PerTxtsetup, $BlaTxtsetup, $SbsTxtsetup, $SrvTxtsetup, $EntTxtsetup, $DtcTxtsetup);
  933. my ($BigTxtsetup_sign, $PerTxtsetup_sign, $BlaTxtsetup_sign, $SbsTxtsetup_sign, $SrvTxtsetup_sign, $EntTxtsetup_sign, $DtcTxtsetup_sign);
  934. my ($BigLayout, $PerLayout, $BlaLayout, $SbsLayout, $SrvLayout , $EntLayout, $DtcLayout);
  935. my ($BigLayout_sign, $PerLayout_sign, $BlaLayout_sign, $SbsLayout_sign, $SrvLayout_sign , $EntLayout_sign, $DtcLayout_sign);
  936. my ($Path_Dosnet, $Path_Txtsetup, $Path_Layout, $Path_Dir);
  937. my ($Path_Dosnet_sign, $Path_Txtsetup_sign, $Path_Layout_sign, $Path_Dir_sign);
  938. #
  939. # Get SKUs
  940. #
  941. %CDDataSKUs = map({uc$_ => cksku::CkSku($_, $lang, $ENV{_BuildArch})} qw(PRO PER SRV BLA SBS ADS DTC));
  942. #
  943. # Build Key INFs for SKUs
  944. #
  945. $BigDosnet = $nttree . "\\dosnet.inf";
  946. $PerDosnet = $nttree . "\\perinf\\dosnet.inf";
  947. $BlaDosnet = $nttree . "\\blainf\\dosnet.inf";
  948. $SbsDosnet = $nttree . "\\sbsinf\\dosnet.inf";
  949. $SrvDosnet = $nttree . "\\srvinf\\dosnet.inf";
  950. $EntDosnet = $nttree . "\\entinf\\dosnet.inf";
  951. $DtcDosnet = $nttree . "\\dtcinf\\dosnet.inf";
  952. $BigTxtsetup = $nttree . "\\txtsetup.sif";
  953. $PerTxtsetup = $nttree . "\\perinf\\txtsetup.sif";
  954. $BlaTxtsetup = $nttree . "\\blainf\\txtsetup.sif";
  955. $SbsTxtsetup = $nttree . "\\sbsinf\\txtsetup.sif";
  956. $SrvTxtsetup = $nttree . "\\srvinf\\txtsetup.sif";
  957. $EntTxtsetup = $nttree . "\\entinf\\txtsetup.sif";
  958. $DtcTxtsetup = $nttree . "\\dtcinf\\txtsetup.sif";
  959. $BigLayout = $nttree . "\\layout.inf";
  960. $PerLayout = $nttree . "\\perinf\\layout.inf";
  961. $BlaLayout = $nttree . "\\blainf\\layout.inf";
  962. $SbsLayout = $nttree . "\\sbsinf\\layout.inf";
  963. $SrvLayout = $nttree . "\\srvinf\\layout.inf";
  964. $EntLayout = $nttree . "\\entinf\\layout.inf";
  965. $DtcLayout = $nttree . "\\dtcinf\\layout.inf";
  966. $BigDosnet_sign = $nttree . "\\realsign\\dosnet.inf";
  967. $PerDosnet_sign = $nttree . "\\perinf\\realsign\\dosnet.inf";
  968. $BlaDosnet_sign = $nttree . "\\blainf\\realsign\\dosnet.inf";
  969. $SbsDosnet_sign = $nttree . "\\sbsinf\\realsign\\dosnet.inf";
  970. $SrvDosnet_sign = $nttree . "\\srvinf\\realsign\\dosnet.inf";
  971. $EntDosnet_sign = $nttree . "\\entinf\\realsign\\dosnet.inf";
  972. $DtcDosnet_sign = $nttree . "\\dtcinf\\realsign\\dosnet.inf";
  973. $BigTxtsetup_sign = $nttree . "\\realsign\\txtsetup.sif";
  974. $PerTxtsetup_sign = $nttree . "\\perinf\\realsign\\txtsetup.sif";
  975. $BlaTxtsetup_sign = $nttree . "\\blainf\\realsign\\txtsetup.sif";
  976. $SbsTxtsetup_sign = $nttree . "\\sbsinf\\realsign\\txtsetup.sif";
  977. $SrvTxtsetup_sign = $nttree . "\\srvinf\\realsign\\txtsetup.sif";
  978. $EntTxtsetup_sign = $nttree . "\\entinf\\realsign\\txtsetup.sif";
  979. $DtcTxtsetup_sign = $nttree . "\\dtcinf\\realsign\\txtsetup.sif";
  980. $BigLayout_sign = $nttree . "\\realsign\\layout.inf";
  981. $PerLayout_sign = $nttree . "\\perinf\\realsign\\layout.inf";
  982. $BlaLayout_sign = $nttree . "\\blainf\\realsign\\layout.inf";
  983. $SbsLayout_sign = $nttree . "\\sbsinf\\realsign\\layout.inf";
  984. $SrvLayout_sign = $nttree . "\\srvinf\\realsign\\layout.inf";
  985. $EntLayout_sign = $nttree . "\\entinf\\realsign\\layout.inf";
  986. $DtcLayout_sign = $nttree . "\\dtcinf\\realsign\\layout.inf";
  987. # PRO
  988. $Path_Dosnet =$BigDosnet;
  989. $Path_Txtsetup =$BigTxtsetup;
  990. $Path_Layout =$BigLayout;
  991. $Path_Dir ="ProInf";
  992. $Path_Dosnet_sign =$BigDosnet_sign;
  993. $Path_Txtsetup_sign =$BigTxtsetup_sign;
  994. $Path_Layout_sign =$BigLayout_sign;
  995. $Path_Dir_sign ="ProInf\\realsign";
  996. $INFPathSKUs{"PRO"} = [ ($Path_Dosnet,$Path_Txtsetup,$Path_Layout,$Path_Dir, $Path_Dosnet_sign,$Path_Txtsetup_sign,$Path_Layout_sign,$Path_Dir_sign) ];
  997. #PER
  998. $Path_Dosnet =$PerDosnet;
  999. $Path_Txtsetup =$PerTxtsetup;
  1000. $Path_Layout =$PerLayout;
  1001. $Path_Dir ="PerInf";
  1002. $Path_Dosnet_sign =$PerDosnet_sign;
  1003. $Path_Txtsetup_sign =$PerTxtsetup_sign;
  1004. $Path_Layout_sign =$PerLayout_sign;
  1005. $Path_Dir_sign ="PerInf\\realsign";
  1006. $INFPathSKUs{"PER"} = [ ($Path_Dosnet,$Path_Txtsetup,$Path_Layout,$Path_Dir, $Path_Dosnet_sign,$Path_Txtsetup_sign,$Path_Layout_sign,$Path_Dir_sign) ];
  1007. #SRV
  1008. $Path_Dosnet =$SrvDosnet;
  1009. $Path_Txtsetup =$SrvTxtsetup;
  1010. $Path_Layout =$SrvLayout;
  1011. $Path_Dir ="SrvInf";
  1012. $Path_Dosnet_sign =$SrvDosnet_sign;
  1013. $Path_Txtsetup_sign =$SrvTxtsetup_sign;
  1014. $Path_Layout_sign =$SrvLayout_sign;
  1015. $Path_Dir_sign ="SrvInf\\realsign";
  1016. $INFPathSKUs{"SRV"} = [ ($Path_Dosnet,$Path_Txtsetup,$Path_Layout,$Path_Dir, $Path_Dosnet_sign,$Path_Txtsetup_sign,$Path_Layout_sign,$Path_Dir_sign) ];
  1017. #BLA
  1018. $Path_Dosnet =$BlaDosnet;
  1019. $Path_Txtsetup =$BlaTxtsetup;
  1020. $Path_Layout =$BlaLayout;
  1021. $Path_Dir ="BlaInf";
  1022. $Path_Dosnet_sign =$BlaDosnet_sign;
  1023. $Path_Txtsetup_sign =$BlaTxtsetup_sign;
  1024. $Path_Layout_sign =$BlaLayout_sign;
  1025. $Path_Dir_sign ="BlaInf\\realsign";
  1026. $INFPathSKUs{"BLA"} = [ ($Path_Dosnet,$Path_Txtsetup,$Path_Layout,$Path_Dir, $Path_Dosnet_sign,$Path_Txtsetup_sign,$Path_Layout_sign,$Path_Dir_sign) ];
  1027. #SBS
  1028. $Path_Dosnet =$SbsDosnet;
  1029. $Path_Txtsetup =$SbsTxtsetup;
  1030. $Path_Layout =$SbsLayout;
  1031. $Path_Dir ="SbsInf";
  1032. $Path_Dosnet_sign =$SbsDosnet_sign ;
  1033. $Path_Txtsetup_sign =$SbsTxtsetup_sign ;
  1034. $Path_Layout_sign =$SbsLayout_sign ;
  1035. $Path_Dir_sign ="SbsInf\\realsign";
  1036. $INFPathSKUs{"SBS"} = [ ($Path_Dosnet,$Path_Txtsetup,$Path_Layout,$Path_Dir, $Path_Dosnet_sign,$Path_Txtsetup_sign,$Path_Layout_sign,$Path_Dir_sign) ];
  1037. #ADS (ENT)
  1038. $Path_Dosnet =$EntDosnet;
  1039. $Path_Txtsetup =$EntTxtsetup;
  1040. $Path_Layout =$EntLayout;
  1041. $Path_Dir ="EntInf";
  1042. $Path_Dosnet_sign =$EntDosnet_sign;
  1043. $Path_Txtsetup_sign =$EntTxtsetup_sign;
  1044. $Path_Layout_sign =$EntLayout_sign;
  1045. $Path_Dir_sign ="EntInf\\realsign";
  1046. $INFPathSKUs{"ADS"} = [ ($Path_Dosnet,$Path_Txtsetup,$Path_Layout,$Path_Dir, $Path_Dosnet_sign,$Path_Txtsetup_sign,$Path_Layout_sign,$Path_Dir_sign) ];
  1047. #DTC
  1048. $Path_Dosnet =$DtcDosnet;
  1049. $Path_Txtsetup =$DtcTxtsetup;
  1050. $Path_Layout =$DtcLayout;
  1051. $Path_Dir ="DtcInf";
  1052. $Path_Dosnet_sign =$DtcDosnet_sign;
  1053. $Path_Txtsetup_sign =$DtcTxtsetup_sign;
  1054. $Path_Layout_sign =$DtcLayout_sign;
  1055. $Path_Dir_sign ="DtcInf\\realsign";
  1056. $INFPathSKUs{"DTC"} = [ ($Path_Dosnet,$Path_Txtsetup,$Path_Layout,$Path_Dir, $Path_Dosnet_sign,$Path_Txtsetup_sign,$Path_Layout_sign,$Path_Dir_sign) ];
  1057. return 1;
  1058. }