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.

178 lines
4.2 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. ###-----CkSku function.------------------------------------//
  28. ### Return value:
  29. ### 1 = SKU verifies ok
  30. ### 0 = SKU does not verify
  31. sub CkSku
  32. {
  33. my ( $pSku, $pLang, $pArch, ) = @_;
  34. $pSku = lc( $pSku );
  35. my %validSkus = &GetSkus( $pLang, $pArch );
  36. if( $validSkus{ $pSku } ){ return 1; }
  37. return 0;
  38. }
  39. sub GetSkus
  40. {
  41. my ( $pLang, $pArch ) = @_;
  42. my (%validSkus, @skus, $theSku);
  43. if ( !&ValidateParams( \$pLang, \$pArch ) ) {
  44. return;
  45. }
  46. $pLang = uc( $pLang );
  47. $pArch = lc( $pArch );
  48. ###(1)Validate Architechtue by prodskus.txt file.---------//
  49. my %skuHash=();
  50. parse_table_file("$ENV{\"RazzleToolPath\"}\\prodskus.txt", \%skuHash );
  51. if( !exists( $skuHash{$pLang}->{ $pArch } ) ){
  52. wrnmsg("Language $pLang and architecture $pArch combination not listed in prodskus.txt.");
  53. }
  54. ###(2)Get Skus.--------------------------------------//
  55. @skus= split( /\;/, $skuHash{$pLang}->{ $pArch } );
  56. (%validSkus)=();
  57. for $theSku( @skus )
  58. {
  59. next if( $theSku eq "-" );
  60. $validSkus{ lc($theSku) }=1;
  61. }
  62. return(%validSkus);
  63. }
  64. #--------------------------------------------------------------//
  65. #Function Usage
  66. #--------------------------------------------------------------//
  67. sub Usage
  68. {
  69. print <<USAGE;
  70. Checks if the given SKU is valid for the given language and
  71. architechture per %RazzleToolPath%\\codes.txt and prodskus.txt.
  72. Usage: $0 -t:sku [ -l:lang ] [ -a:arch ]
  73. -t Product SKU. SKU is one of per, pro, srv, ads.
  74. -l Language. Default value is USA.
  75. -a Architecture. Default value is %_BuildArch%.
  76. /? Displays usage
  77. Examples:
  78. perl $0 -t:pro -l:jpn -a:x86 ->>>> returns 0 (valid)
  79. perl $0 -t:ads -l:ara -a:ia64 ->>>> returns 1 (invalid)
  80. USAGE
  81. exit(1);
  82. }
  83. ###-----Cmd entry point for script.-------------------------------//
  84. if (eval("\$0 =~ /" . __PACKAGE__ . "\\.pm\$/i"))
  85. {
  86. # <run perl.exe GetParams.pm /? to get the complete usage for GetParams.pm>
  87. &GetParams ('-n', 't:','-o', 'l:a:', '-p', 'sku lang arch', @ARGV);
  88. #Validate or Set default
  89. if( !&ValidateParams( \$lang, \$arch ) ) {exit(1); }
  90. $rtno = &cksku::CkSku( lc($sku), uc($lang), lc($arch) );
  91. exit( !$rtno );
  92. }
  93. ###---------------------------------------------------------------//
  94. sub GetParams
  95. {
  96. #Call pm getparams with specified arguments
  97. &GetParams::getparams(@_);
  98. #Call the usage if specified by /?
  99. if ($HELP) {
  100. &Usage();
  101. }
  102. }
  103. ###--------------------------------------------------------------//
  104. sub ValidateParams
  105. {
  106. my ( $pLang, $pArch ) = @_;
  107. if( !${$pLang} ){
  108. $$pLang = "USA";
  109. } else {
  110. if ( !&cklang::CkLang( $$pLang ) ) {
  111. return 0;
  112. }
  113. }
  114. if( !${$pArch} ){ ${$pArch} = $ENV{ '_BuildArch' }; }
  115. if ( lc($$pArch) ne "x86" && lc($$pArch) ne "amd64" && lc($$pArch) ne "ia64" )
  116. {
  117. errmsg("Invalid architecture $$pArch.");
  118. return 0;
  119. }
  120. return 1;
  121. }
  122. ###-------------------------------------------------------------//
  123. =head1 NAME
  124. B<cksku> - Check SKU
  125. =head1 SYNOPSIS
  126. perl cksku.pm -t:ads [-l:jpn] [-a x86]
  127. =head1 DESCRIPTION
  128. Check sku ads with language jpn and architechture x86
  129. =head1 INSTANCES
  130. =head2 <myinstances>
  131. <Description of myinstances>
  132. =head1 METHODS
  133. =head2 <mymathods>
  134. <Description of mymathods>
  135. =head1 SEE ALSO
  136. =head1 AUTHOR
  137. <Suemiao Rossignol <[email protected]>>
  138. =cut
  139. 1;