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