|
1 #!/usr/bin/perl |
|
2 |
|
3 =head1 NAME |
|
4 |
|
5 Getlatestrel.pl |
|
6 |
|
7 =head1 SYNOPSIS |
|
8 |
|
9 Getlatestrel.pl |
|
10 |
|
11 =head1 DESCRIPTION |
|
12 |
|
13 This script is designed to use latestver from the CBR tools to find at get the |
|
14 latest version of a component. |
|
15 |
|
16 If a baseline version is provided, then it will install the version of the component |
|
17 released as part of that specified baseline. |
|
18 |
|
19 =head1 COPYRIGHT |
|
20 |
|
21 Copyright (c) 2008 Symbian Ltd. All rights reserved |
|
22 |
|
23 =cut |
|
24 |
|
25 use strict; |
|
26 |
|
27 use Getopt::Long; |
|
28 |
|
29 my ($iComp, $iSource, $iVersion, $iBaselineComponent, $iBaselineVersion) = ProcessCommandLine(); |
|
30 |
|
31 if ($iSource) |
|
32 { |
|
33 $iSource = "-s"; |
|
34 } else { |
|
35 $iSource = ""; |
|
36 } |
|
37 if (!defined $iVersion) |
|
38 { |
|
39 if (defined $iBaselineVersion) { |
|
40 |
|
41 if (!defined $iBaselineComponent) { |
|
42 $iBaselineComponent = "gt_techview_baseline"; |
|
43 } |
|
44 my $envout= `envsize -v $iBaselineComponent $iBaselineVersion 2>&1`; |
|
45 |
|
46 # match component |
|
47 if ($envout =~ m/(Adding up size of )$iComp (.*)/) { |
|
48 print "INFO: Component $iComp version $2 found for baseline $iBaselineComponent $iBaselineVersion\n"; |
|
49 $iVersion = $2; |
|
50 }elsif ($envout =~ m/(didn't exist)/) { |
|
51 print "WARNING: Baseline $iBaselineVersion didn't exist, unable to check $iBaselineComponent, geting latest version\n"; |
|
52 $iVersion = `latestver $iComp`; |
|
53 } |
|
54 } else { |
|
55 $iVersion = `latestver $iComp`; |
|
56 } |
|
57 } |
|
58 |
|
59 chomp($iVersion); |
|
60 |
|
61 my $getreloutput = `getrel -vv $iSource -o $iComp $iVersion`; |
|
62 |
|
63 if (($getreloutput =~ /^Installing $iComp $iVersion/) || |
|
64 ($getreloutput =~ /^Switching $iComp/) || |
|
65 ($getreloutput =~ /already installed and clean/)) { |
|
66 |
|
67 print $getreloutput; |
|
68 } else { |
|
69 print "ERROR: could not getrel $iComp $iVersion - $getreloutput\n"; |
|
70 } |
|
71 |
|
72 |
|
73 |
|
74 # ProcessCommandLine |
|
75 # |
|
76 # Inputs |
|
77 # |
|
78 # Outputs |
|
79 # $ilog - logfile location |
|
80 # |
|
81 # Description |
|
82 # This function processes the commandline |
|
83 sub ProcessCommandLine { |
|
84 my ($iHelp, $iComp, $iSource, $iVersion, $iBaselineComponent, $iBaselineVersion); |
|
85 |
|
86 GetOptions('h' => \$iHelp, 'c=s' => \$iComp, 's' => \$iSource, 'v=s' => \$iVersion, 'bc=s' => \$iBaselineComponent, 'bv=s' => \$iBaselineVersion); |
|
87 |
|
88 if (($iHelp) || (!defined $iComp)) |
|
89 { |
|
90 &Usage(); |
|
91 } else { |
|
92 return($iComp, $iSource, $iVersion, $iBaselineComponent, $iBaselineVersion); |
|
93 } |
|
94 } |
|
95 |
|
96 # Usage |
|
97 # |
|
98 # Output Usage Information. |
|
99 # |
|
100 |
|
101 sub Usage { |
|
102 print <<USAGE_EOF; |
|
103 |
|
104 Usage: getlatestrel.pl [Args/options] |
|
105 |
|
106 Args: (required) |
|
107 |
|
108 -c [Component name] Name of component to get |
|
109 |
|
110 options: |
|
111 |
|
112 -h help |
|
113 -s install (and overwrite) source code |
|
114 -v [version string] Optional version to get instead of latest available. |
|
115 |
|
116 -bc [component str ] Optional baseline component [default is gt_techview_baseline] |
|
117 -bv [version str ] Optional baseline version |
|
118 |
|
119 Example Commandline |
|
120 getlatestrel.pl -c tools_testexecute |
|
121 |
|
122 USAGE_EOF |
|
123 exit 1; |
|
124 } |