bldsystemtools/commonbldutils/BuildLaunchChecks.pm
branchRCL_3
changeset 24 d90029decf65
parent 20 a9d4531388d0
child 33 54aa4a06a075
child 34 5e522efbae7b
equal deleted inserted replaced
20:a9d4531388d0 24:d90029decf65
     1 #
       
     2 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 # All rights reserved.
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of "Eclipse Public License v1.0"
       
     6 # which accompanies this distribution, and is available
       
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 #
       
     9 # Initial Contributors:
       
    10 # Nokia Corporation - initial contribution.
       
    11 #
       
    12 # Contributors:
       
    13 #
       
    14 # Description: 
       
    15 #
       
    16 #This module is used by startbuild.pl
       
    17 #It asks for some BuildLaunch data from the user and performs some checks on this data
       
    18 #This is then input to the BuildLaunch.xml file and then opens the file for the user to verify before launching the build.
       
    19 
       
    20 package BuildLaunchChecks;
       
    21 use strict;
       
    22 
       
    23 sub GetUserInput
       
    24 {
       
    25   # Ask for Snapshot, Previous Snapshot and ChangeList numbers
       
    26   
       
    27   my $Product;
       
    28   print "Enter Product number (e.g 9.1/9.5/tb91sf/tb92sf/tb101sf) >";
       
    29   chomp($Product = <STDIN>);
       
    30   $Product =~ s/\s+//g;
       
    31   
       
    32   my $Snapshot;
       
    33   print "Enter Snapshot number >";
       
    34   chomp($Snapshot = <STDIN>);
       
    35   $Snapshot =~ s/\s+//g;
       
    36   
       
    37   my $PrevSnapshot;
       
    38   print "Enter Previous Snapshot number >";
       
    39   chomp($PrevSnapshot = <STDIN>);
       
    40   $PrevSnapshot =~ s/\s+//g;
       
    41   
       
    42   my $Changelist;
       
    43   print "Enter ChangeList number >";
       
    44   chomp($Changelist = <STDIN>);
       
    45   $Changelist =~ s/\s+//g;
       
    46   print "\n";
       
    47   
       
    48   my $CurrentCodeline;
       
    49   print "Enter Codeline (e.g. //epoc/master //EPOC/Release/sf/symtb91 //EPOC/master/sf) >";
       
    50   chomp($CurrentCodeline = <STDIN>);
       
    51   $CurrentCodeline =~ s/\s+//g;
       
    52   print "\n";
       
    53   
       
    54   my $Platform;
       
    55   print "Enter Platform (e.g. beech/cedar/SF) >";
       
    56   chomp($Platform = <STDIN>);
       
    57   $Platform =~ s/\s+//g;
       
    58   print "\n";
       
    59   
       
    60   my $Type;
       
    61   print "Enter Type (e.g Master/MasterSF/Symbian_OS_v9.1/Symbian_OS_vTB91SF) >";
       
    62   chomp($Type = <STDIN>);
       
    63   $Type =~ s/\s+//g;
       
    64   print "\n";
       
    65   
       
    66   
       
    67   
       
    68   return $Product,
       
    69          $Snapshot,
       
    70          $PrevSnapshot,
       
    71          $Changelist,
       
    72          $CurrentCodeline,
       
    73          $Platform,
       
    74          $Type;
       
    75 }
       
    76 
       
    77 sub GetBCValue
       
    78 {
       
    79   my($BuildData) = @_;
       
    80   $BuildData->{CurrentCodeline} =~ s/\/$//;  #drop any trailing /
       
    81   my $cmd = "p4 print -q $BuildData->{CurrentCodeline}/os/buildtools/bldsystemtools/commonbldutils/BCValues.xml\@$BuildData->{ChangelistNumber}";
       
    82   my $BCValues = `$cmd`;
       
    83   warn "WARNING: Could not open BCValues file" if $?;
       
    84   
       
    85   my @BCValues = split /\n/m, $BCValues;
       
    86   
       
    87   my $BCToolsBaseBuildNo;
       
    88   
       
    89   my $Product_Found = 0;
       
    90   foreach my $line (@BCValues)
       
    91   {
       
    92     $Product_Found = 1 if ($line =~ m/Product name=\"$BuildData->{Product}\"/i);
       
    93     
       
    94     if (($line =~ m/\"BCToolsBaseBuildNo\" Value=\"(.*)\"/i)&&($Product_Found == 1))
       
    95     {
       
    96       $BCToolsBaseBuildNo = $1;
       
    97       $BCToolsBaseBuildNo =~ s/\s+//g;
       
    98       last;
       
    99     }
       
   100   }
       
   101   
       
   102   return $BCToolsBaseBuildNo;
       
   103 }
       
   104 
       
   105 sub CheckData
       
   106 {
       
   107   my($BuildData) = @_;
       
   108   
       
   109   my @change;
       
   110   my $Error;
       
   111   my $BCBaseBuild = "$BuildData->{PreviousBuildPublishLocation}\\$BuildData->{Type}\\$BuildData->{BCToolsBaseBuildNo}"."_Symbian_OS_v$BuildData->{Product}"
       
   112          if ((defined $BuildData->{BCToolsBaseBuildNo})&&(defined $BuildData->{Type})&&(defined $BuildData->{Product}));
       
   113   my $warnings = 0;
       
   114  
       
   115   #Check that the Changelist number entered at prebuild is the same as the Changelist entered at startbuild
       
   116   if (($ENV{CHANGELIST} != $BuildData->{ChangelistNumber})&&(defined $ENV{CHANGELIST})&&(defined $BuildData->{ChangelistNumber}))
       
   117   {
       
   118      warn "Warning: Changelist numbers entered at prebuild and startbuild are different\n";
       
   119      $warnings++;
       
   120   }
       
   121   
       
   122   #Check that the Changelist number entered is on the CodeLine
       
   123   if(defined $BuildData->{ChangelistNumber})
       
   124   {
       
   125     my $describe = "p4 -s describe $BuildData->{ChangelistNumber} 2>&1";
       
   126     push @change, `$describe`;
       
   127     warn "ERROR: Could not execute: $describe\n" if $?;
       
   128     
       
   129     foreach my $line(@change)
       
   130     {
       
   131      if ($line =~ m/$BuildData->{CurrentCodeline}/i)
       
   132      {
       
   133        $Error = 0;
       
   134        last;
       
   135      }
       
   136     }
       
   137     if (!defined $Error)
       
   138     {
       
   139      warn "Warning: Change $BuildData->{ChangelistNumber} does not exist on $BuildData->{CurrentCodeline}\n";
       
   140      $warnings++;
       
   141     }
       
   142   }
       
   143   
       
   144   #Check that the Previous Snapshot is less than the Current Snapshot
       
   145   if (($BuildData->{SnapshotNumber} lt $BuildData->{PreviousSnapshotNumber})&&(defined $BuildData->{SnapshotNumber})&&(defined $BuildData->{PreviousSnapshotNumber}))
       
   146   {
       
   147      warn "Warning: Current snapshot is less than the Previous snapshot\n";
       
   148      $warnings++;
       
   149   }
       
   150   
       
   151   #Check that the Previous Snapshot Number exists
       
   152   if ((!-e "$BuildData->{PreviousBuildPublishLocation}\\$BuildData->{Type}\\$BuildData->{PreviousSnapshotNumber}"."_Symbian_OS_v$BuildData->{Product}")&&(defined $BuildData->{PreviousSnapshotNumber})&&(defined $BuildData->{Product})&&(defined $BuildData->{Type}))
       
   153   {
       
   154      warn "Warning: Previous snapshot number does not exist on $BuildData->{PreviousBuildPublishLocation}\\$BuildData->{Type}\n";
       
   155      $warnings++;
       
   156   }
       
   157   
       
   158   #Check that CBR exists for the Previous Snapshot
       
   159   if ((!-e "$BuildData->{PreviousBuildPublishLocation}\\ComponentisedReleases\\DailyBuildArchive\\Symbian_OS_v$BuildData->{Product}\\gt_techview_baseline\\$BuildData->{PreviousSnapshotNumber}"."_Symbian_OS_v$BuildData->{Product}")&&(defined $BuildData->{PreviousSnapshotNumber})&&(defined $BuildData->{Product}))
       
   160   {
       
   161      warn "Warning: CBR does not exist for build $BuildData->{PreviousSnapshotNumber}\n";
       
   162      $warnings++;
       
   163   }
       
   164   
       
   165   #Check that the BCToolsBaseBuildNo exists on devbuilds
       
   166   if ((!-e $BCBaseBuild)&&(defined $BCBaseBuild)&&(defined $BuildData->{BCToolsBaseBuildNo}))
       
   167   {
       
   168     warn "Warning: $BuildData->{BCToolsBaseBuildNo}"."_"."Symbian_OS_v$BuildData->{Product} does not exist on \\\\Builds01\\devbuilds\\$BuildData->{Type}\n";
       
   169     $warnings++;
       
   170   }
       
   171  return $warnings;
       
   172 }
       
   173 
       
   174 sub UpdateXML
       
   175 {
       
   176   my($xmlfile, $BuildData, $Sync) = @_;
       
   177   open(XMLFILE, '+<', $xmlfile) || warn "Warning: can't open $xmlfile for append: $!";
       
   178   my @initarray = <XMLFILE>;
       
   179   
       
   180   my $Left;
       
   181   my $Right;
       
   182   
       
   183   foreach my $line (@initarray)
       
   184   {
       
   185     if (($line =~ m/\"SnapshotNumber\" Value=\"([^\"]+)\"/)&&(defined $BuildData->{SnapshotNumber}))
       
   186     {
       
   187       $Left  = $`;
       
   188       $Right = $';
       
   189       $line= $Left . "\"SnapshotNumber\" Value=\"" . $BuildData->{SnapshotNumber} ."\"" . $Right;
       
   190       next;
       
   191     }
       
   192     
       
   193     if (($line =~ m/\"PreviousSnapshotNumber\" Value=\"([^\"]+)\"/)&&(defined $BuildData->{PreviousSnapshotNumber}))
       
   194     {
       
   195       $Left  = $`;
       
   196       $Right = $';
       
   197       $line= $Left . "\"PreviousSnapshotNumber\" Value=\"" . $BuildData->{PreviousSnapshotNumber} ."\"" . $Right;
       
   198       next;
       
   199     }
       
   200     
       
   201     if (($line =~ m/\"ChangelistNumber\" Value=\"([^\"]+)\"/)&&(defined $BuildData->{ChangelistNumber}))
       
   202     {
       
   203       $Left  = $`;
       
   204       $Right = $';
       
   205       $line= $Left . "\"ChangelistNumber\" Value=\"" . $BuildData->{ChangelistNumber} ."\"" . $Right;
       
   206       next;
       
   207     }
       
   208     
       
   209     if (($line =~ m/\"Platform\" Value=\"([^\"]+)\"/)&&(defined $BuildData->{Platform}))
       
   210     {
       
   211       $Left  = $`;
       
   212       $Right = $';
       
   213       $line= $Left . "\"Platform\" Value=\"" . $BuildData->{Platform} ."\"" . $Right;
       
   214       next;
       
   215     }
       
   216     
       
   217     if (($line =~ m/\"Product\" Value=\"([^\"]+)\"/)&&(defined $BuildData->{Product}))
       
   218     {
       
   219       $Left  = $`;
       
   220       $Right = $';
       
   221       $line= $Left . "\"Product\" Value=\"" . $BuildData->{Product} ."\"" . $Right;
       
   222       next;
       
   223     }
       
   224     
       
   225     if (($line =~ m/\"PublishLocation\" Value=\"([^\"]+)\"/)&& (defined $BuildData->{PublishLocation}))
       
   226     {
       
   227       $Left  = $`;
       
   228       $Right = $';
       
   229       $line= $Left . "\"PublishLocation\" Value=\"$BuildData->{PublishLocation}\"" . $Right;
       
   230       next;
       
   231     }
       
   232     
       
   233     if (($line =~ m/\"CurrentCodeline\" Value=\"([^\"]+)\"/)&&(defined $BuildData->{CurrentCodeline}))
       
   234     {
       
   235       $Left  = $`;
       
   236       $Right = $';
       
   237       $line= $Left . "\"CurrentCodeline\" Value=\"$BuildData->{CurrentCodeline}\"" . $Right;
       
   238       next;
       
   239     }
       
   240 
       
   241     if (($line =~ m/\"Type\" Value=\"([^\"]+)\"/)&&(defined $BuildData->{Type}))
       
   242     {
       
   243       $Left  = $`;
       
   244       $Right = $';
       
   245       $line= $Left . "\"Type\" Value=\"$BuildData->{Type}\"" . $Right;
       
   246       
       
   247       next;
       
   248     }
       
   249     
       
   250     if (($line =~ m/\"BuildSubType\" Value=\"([^\"]+)\"/)&&(defined $BuildData->{BuildSubType}))
       
   251     {
       
   252       $Left  = $`;
       
   253       $Right = $';
       
   254       $line= $Left . "\"BuildSubType\" Value=\"$BuildData->{BuildSubType}\"" . $Right;
       
   255       
       
   256       next;
       
   257     }
       
   258     
       
   259     if (($line =~ m/\"BCToolsBaseBuildNo\" Value=\"([^\"]+)\"/)&&(defined $BuildData->{BCToolsBaseBuildNo}))
       
   260     {
       
   261       $Left  = $`;
       
   262       $Right = $';
       
   263       $line= $Left . "\"BCToolsBaseBuildNo\" Value=\"" . $BuildData->{BCToolsBaseBuildNo} ."\"" . $Right;
       
   264       next;
       
   265     }
       
   266     
       
   267     if (($line =~ m/\"BuildsDirect\" Value=\"([^\"]+)\"/)&&(defined $BuildData->{BuildsDirect}))
       
   268     {
       
   269       $Left  = $`;
       
   270       $Right = $';
       
   271       $line= $Left . "\"BuildsDirect\" Value=\"$BuildData->{BuildsDirect}\"" . $Right;
       
   272       
       
   273       last;
       
   274     }
       
   275   }
       
   276   
       
   277   # output the changes to the original file
       
   278   seek(XMLFILE,0,0);
       
   279   print XMLFILE @initarray;
       
   280   truncate(XMLFILE,tell(XMLFILE));
       
   281   
       
   282   close(XMLFILE);
       
   283 }
       
   284 
       
   285 1;
       
   286 
       
   287 __END__