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.

178 lines
4.8 KiB

  1. @REM -----------------------------------------------------------------
  2. @REM
  3. @REM GenSSIFile.cmd - bensont
  4. @REM Generate ssi file from the .pri, .pub, .bin to .ssi
  5. @REM
  6. @REM Copyright (c) Microsoft Corporation. All rights reserved.
  7. @REM
  8. @REM -----------------------------------------------------------------
  9. @perl -x "%~f0" %*
  10. @goto :EOF
  11. #!perl
  12. use strict;
  13. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  14. use lib $ENV{RAZZLETOOLPATH};
  15. use PbuildEnv;
  16. use ParseArgs;
  17. use GetIniSetting;
  18. use File::Basename;
  19. use BuildName;
  20. use Logmsg;
  21. my ($indexfile, $outputfile, $targetpath, $binpath);
  22. my ($buildnum, $buildname, $ext, $buildlabphone, $buildtype, $location,
  23. $binlocation, $contactpeople, $buildarch, $statusmail,
  24. $project, $username);
  25. sub Usage { print<<USAGE; exit(1) }
  26. $0 - Generate ssi file from the .pri, .pub or .bin
  27. ----------------------------------------------------------
  28. $0 -i inputfile -o outputfile -t targetpath -b binarypath
  29. USAGE
  30. parseargs(
  31. 'i:' => \$indexfile,
  32. 'o:' => \$outputfile,
  33. 't:' => \$targetpath,
  34. 'b:' => \$binpath,
  35. '?' => \&Usage
  36. );
  37. my %itemdriven = (
  38. Bug => '',
  39. Build => build_number(@_),
  40. BuildID => build_name(@_),
  41. BuildLabPhone => &getinisetting('SymSrvBuildLabPhone'),
  42. BuildRemark => &getbuildremark,
  43. BuildType => $ENV{_BuildType},
  44. ContactPeople => &getinisetting('SymSrvContactPeople'),
  45. Directory => &getlocation,
  46. DontShipList => &getdontshiplist,
  47. DontStripDoShip => &getdonstripdoship,
  48. Hotfix => '',
  49. LocaleCode => $ENV{Lang},
  50. 'MSonly.YYMMDD-HHMM' => '',
  51. Platform => $ENV{_BuildArch},
  52. PrefixToStrip => &getlocation,
  53. ProductGroup => 'Windows',
  54. ProductName => 'WindowsXP',
  55. Project => &getproject,
  56. Recursive => 'no',
  57. Release => 'tst',
  58. StatusMail => &getinisetting('SymSrvStatusMail'),
  59. SubmitForDownload => '',
  60. SubmitToArchive => '',
  61. SubmitToInternet => '',
  62. UNCPath => &getlocation,
  63. UserName => $ENV{UserName},
  64. Vendor => 'MS'
  65. );
  66. &main;
  67. sub main {
  68. my (%info, @text);
  69. &ReadSSIFile( $indexfile, \%info, [keys %itemdriven], \@text );
  70. for (keys %itemdriven) {
  71. if ((!exists $info{$_}) || ($info{$_} eq '')) {
  72. $info{$_}=$itemdriven{$_};
  73. }
  74. }
  75. if ($outputfile !~ /$itemdriven{'Project'}/i) {
  76. my ($path, $filename);
  77. $outputfile =~ /\\([^\\]+)$/;
  78. ($path, $filename) = ($`, $1);
  79. $filename=~s/^windows\_//i;
  80. $outputfile = "$path\\$itemdriven{'Project'}\_$filename";
  81. }
  82. if ($outputfile !~ /\.ssi$/i) {
  83. $outputfile .= ".ssi";
  84. }
  85. &WriteSSIFile( $outputfile, \%info, [sort keys %itemdriven], \@text);
  86. }
  87. sub ReadSSIFile {
  88. my ($filename, $infohptr, $keylptr, $itemlptr) = @_;
  89. my ($var, $value, $keyword);
  90. @{$itemlptr}=();
  91. open(FILEHANDLE, $filename);
  92. while (<FILEHANDLE>) {
  93. chomp;
  94. if (/^[^\;].+\,.+\,.+\,/) {
  95. push @{$itemlptr}, $_;
  96. } elsif (/^\;([^\=]+)\s*\=\s*(\S[^\=]+)?$/) {
  97. ($var, $value) = (lc($1), $2);
  98. ($keyword) = grep {lc($_) eq $var} @$keylptr;
  99. $infohptr->{$keyword} = $value if (defined $keyword);
  100. }
  101. }
  102. close(FILEHANDLE);
  103. }
  104. sub WriteSSIFile {
  105. my ($filename, $infohptr, $keylptr, $itemlptr) = @_;
  106. my ($var, $value, $keyword);
  107. open(FILEHANDLE, ">$filename");
  108. for (@$keylptr) {
  109. if (exists $infohptr->{$_}) {
  110. print FILEHANDLE "\;$_\=$infohptr->{$_}\n";
  111. }
  112. }
  113. for (@$itemlptr) {
  114. print FILEHANDLE $_ . "\n" if (/\S/);
  115. }
  116. close(FILEHANDLE);
  117. }
  118. sub getinisetting {
  119. my $item = shift;
  120. my %knowledge = (
  121. SymSrvBuildLabPhone => "36167",
  122. SymSrvContactPeople => "bensont",
  123. SymSrvStatusMail => "bensont"
  124. );
  125. my $r = GetIniSetting::GetSettingQuietEx($ENV{_BuildBranch}, $ENV{Lang}, $item);
  126. if (!defined $r) {
  127. if (exists $knowledge{$item}) {
  128. return $knowledge{$item};
  129. }
  130. errmsg( "Cannot find $item in ini file." );
  131. $r = '';
  132. }
  133. return $r;
  134. }
  135. sub getbuildremark {
  136. $indexfile=~ /(pri|bin|pub)(\.ssi)?$/i;
  137. return $1;
  138. }
  139. sub getlocation {
  140. return $targetpath;
  141. }
  142. sub getbinlocation {
  143. return $binpath;
  144. }
  145. sub getdontshiplist {
  146. my $loc = &getbinlocation();
  147. return (defined $loc)?"$loc\\symbolcd\\cd\\usa\\dontship.txt":'';
  148. }
  149. sub getdonstripdoship {
  150. my $loc = &getbinlocation();
  151. return (defined $loc)?"$loc\\symbolcd\\cd\\usa\\symbolswithtypes.txt":'';
  152. }
  153. sub getproject {
  154. my $value;
  155. $value = &GetIniSetting::GetSettingQuietEx($ENV{_BuildBranch}, $ENV{Lang}, 'DFSAlternateBranchName');
  156. $value = $ENV{_BuildBranch} if (!defined $value);
  157. $value =~ s/\_.+//;
  158. return "Win" . $value;
  159. }
  160. 1;