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.

223 lines
5.8 KiB

  1. #-----------------------------------------------------------------//
  2. # Script: cksku.pm
  3. #
  4. # (c) 2000 Microsoft Corporation. All rights reserved.
  5. #
  6. # Purpose: This script Checks if the given SKU is valid for the given
  7. # language and architechture per %RazzleToolPath%\\codes.txt
  8. # and prodskus.txt.
  9. #
  10. # Version: <1.00> 06/28/2000 : Suemiao Rossognol
  11. #-----------------------------------------------------------------//
  12. ###-----Set current script Name/Version.----------------//
  13. package cksku;
  14. $VERSION = '1.00';
  15. ###-----Require section and extern modual.---------------//
  16. require 5.003;
  17. use strict;
  18. use lib $ENV{ "RazzleToolPath" };
  19. use lib $ENV{ "RazzleToolPath" }."\\PostBuildScripts";
  20. no strict 'vars';
  21. no strict 'subs';
  22. no strict 'refs';
  23. use GetParams;
  24. use Logmsg;
  25. use ParseTable;
  26. use cklang;
  27. ###-----Fields function.----------------------------------//
  28. sub Fields{
  29. my ( $pLang, $pArch, $pSku ) = @_;
  30. my %skus = &cksku::GetSkus(uc($lang), lc($arch));
  31. join(" ", keys(%skus));
  32. }
  33. ###-----CkSku function.------------------------------------//
  34. ### Return value:
  35. ### 1 = SKU verifies ok
  36. ### 0 = SKU does not verify
  37. sub CkSku
  38. {
  39. my ( $pSku, $pLang, $pArch ) = @_;
  40. $pSku = lc( $pSku );
  41. my %validSkus = &GetSkus( $pLang, $pArch );
  42. if ($pSku =~ /\;/) {
  43. my @sku = split/\;/,$pSku;
  44. # Returning false if even 1 of the given skus is not valid
  45. foreach (@sku) {
  46. return 0 if (!$validSkus{$_}) ;
  47. }
  48. return 1;
  49. }
  50. if( $validSkus{ $pSku } ){ return 1; }
  51. return 0;
  52. }
  53. sub GetSkus
  54. {
  55. my ( $pLang, $pArch ) = @_;
  56. my (%validSkus, @skus, $theSku);
  57. $pLang = "USA" if( $ENV{_COVERAGE_BUILD} && uc $pLang eq "COV" );
  58. if ( !&ValidateParams( \$pLang, \$pArch ) ) {
  59. return;
  60. }
  61. $pLang = uc( $pLang );
  62. $pArch = lc( $pArch );
  63. ###(1)Validate Architechtue by prodskus.txt file.---------//
  64. my %skuHash=();
  65. parse_table_file("$ENV{\"RazzleToolPath\"}\\prodskus.txt", \%skuHash );
  66. if( !exists( $skuHash{$pLang}->{ $pArch } ) ){
  67. wrnmsg("Language $pLang and architecture $pArch combination not listed in prodskus.txt.");
  68. }
  69. # Override language variable if _BuildSku is set
  70. my (@sku,%sku);
  71. if ( $ENV{_BuildSku} ) {
  72. #$pLang=uc( $ENV{_BuildSku} );
  73. @sku = split/\;/ , $ENV{_BuildSku};
  74. %sku = map { $_=>1 } @sku ;
  75. }
  76. ###(2)Get Skus.--------------------------------------//
  77. @skus= split( /\;/, $skuHash{$pLang}->{ $pArch } );
  78. (%validSkus)=();
  79. for $theSku( @skus )
  80. {
  81. next if( $theSku eq "-" );
  82. if (%sku) {
  83. if ( $sku{$theSku} ) {
  84. $validSkus{ lc($theSku) }=1;
  85. }
  86. } else {
  87. $validSkus{ lc($theSku) }=1;
  88. }
  89. }
  90. return(%validSkus);
  91. }
  92. #--------------------------------------------------------------//
  93. #Function Usage
  94. #--------------------------------------------------------------//
  95. sub Usage
  96. {
  97. print <<USAGE;
  98. Checks if the given SKU is valid for the given language and
  99. architechture per %RazzleToolPath%\\codes.txt and prodskus.txt.
  100. Usage: $0 -t:sku [ -l:lang ] [ -a:arch ]
  101. -t Product SKU. SKU is one of per, pro, srv, ads.
  102. -l Language. Default value is USA. Overridden if _BuildSku is set.
  103. -a Architecture. Default value is %_BuildArch%.
  104. /? Displays usage
  105. Examples:
  106. perl $0 -t:pro -l:jpn -a:x86 ->>>> returns 0 (valid)
  107. perl $0 -t:ads -l:ara -a:ia64 ->>>> returns 1 (invalid)
  108. Example script usage (cmd):
  109. 1. perl \%RAZZLETOOLPATH\%\\cksku.pm -t:\%SKU\% -l:\%LANG\%
  110. if \%errorlevel\% EQU 0 (set prods=\%prods\% \%SKU\%)
  111. REM With SKU=srv, LANG=RU prods will be set to srv
  112. REM With SKU=ads, LANG=RU prods will be empty
  113. 2.
  114. set prods=
  115. for /F \"tokens=*\" \%\%. in ('perl \%RAZZLETOOLPATH\%\\cksku.pm -l:\%LANG\% -o') do set prods=\%\%.
  116. REM the prods will be equal to "per pro srv" for LANG=RU.
  117. USAGE
  118. exit(1);
  119. }
  120. ###-----Cmd entry point for script.-------------------------------//
  121. if (eval("\$0 =~ /" . __PACKAGE__ . "\\.pm\$/i"))
  122. {
  123. # <run perl.exe GetParams.pm /? to get the complete usage for GetParams.pm>
  124. &GetParams ('-n', '','-o', 't:l:a:o', '-p', 'sku lang arch field', @ARGV);
  125. #Validate or Set default
  126. if( !&ValidateParams( \$lang, \$arch ) ) {exit(1); }
  127. if ($field){
  128. print &cksku::Fields(uc($lang), lc($arch), $sku);
  129. }
  130. $rtno = &cksku::CkSku( lc($sku), uc($lang), lc($arch) );
  131. exit( !$rtno );
  132. }
  133. ###---------------------------------------------------------------//
  134. sub GetParams
  135. {
  136. #Call pm getparams with specified arguments
  137. &GetParams::getparams(@_);
  138. #Call the usage if specified by /?
  139. if ($HELP) {
  140. &Usage();
  141. }
  142. }
  143. ###--------------------------------------------------------------//
  144. sub ValidateParams
  145. {
  146. my ( $pLang, $pArch ) = @_;
  147. if( !${$pLang} ){
  148. $$pLang = "USA";
  149. } else {
  150. if ( !&cklang::CkLang( $$pLang ) ) {
  151. return 0;
  152. }
  153. }
  154. if( !${$pArch} ){ ${$pArch} = $ENV{ '_BuildArch' }; }
  155. if ( lc($$pArch) ne "x86" && lc($$pArch) ne "amd64" && lc($$pArch) ne "ia64" )
  156. {
  157. errmsg("Invalid architecture $$pArch.");
  158. return 0;
  159. }
  160. return 1;
  161. }
  162. ###-------------------------------------------------------------//
  163. =head1 NAME
  164. B<cksku> - Check SKU
  165. =head1 SYNOPSIS
  166. perl cksku.pm -t:ads [-l:jpn] [-a x86]
  167. =head1 DESCRIPTION
  168. Check sku ads with language jpn and architechture x86
  169. =head1 INSTANCES
  170. =head2 <myinstances>
  171. <Description of myinstances>
  172. =head1 METHODS
  173. =head2 <mymathods>
  174. <Description of mymathods>
  175. =head1 SEE ALSO
  176. =head1 AUTHOR
  177. <Suemiao Rossignol <[email protected]>>
  178. =cut
  179. 1;