1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 # Copyright 2000, 2010 Oracle and/or its affiliates.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # This file is part of OpenOffice.org.
11 # OpenOffice.org is free software: you can redistribute it and/or modify
12 # it under the terms of the GNU Lesser General Public License version 3
13 # only, as published by the Free Software Foundation.
15 # OpenOffice.org is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU Lesser General Public License version 3 for more details
19 # (a copy is included in the LICENSE file that accompanied this code).
21 # You should have received a copy of the GNU Lesser General Public License
22 # version 3 along with OpenOffice.org. If not, see
23 # <http://www.openoffice.org/license.html>
24 # for a copy of the LGPLv3 License.
26 #*************************************************************************
33 sub readIncVersions
($);
36 sub incrementNewVersion
($);
37 sub incrementOldVersion
($);
38 sub incrementPolicyVersion
($);
40 "The tool increments the minor version of assemblies and the major version of ".
41 "the respective policy files. This is only done if new uno types have been added since".
42 "the last product upate. This information is obtained from the file which is passed as ".
43 "argument changedTypes. The names in the version file must have a particular form. ".
44 "They must end on one of folling terms: NEW_VERSION, OLD_VERSION, POLICY_VERSION\n".
45 "If no new published types habe been added then no output, argument newVersions, is written".
46 "Usage is: \n increment_version.pl oldVersions incVersions newVersions changedTypes\n\n".
47 "oldVersion: Contains name value pairs, which are used for forming the config files of ".
48 "the policy assemblies, for building the assemblies. \n\n".
49 "incVersions: File containing the names of which the versions are to be incremented. ".
50 "Every line may only contain one name. The names must exactly match those from the ".
51 "oldVersion file.\n\n".
52 "newVersions: Contains all entries from oldVersions, but the values of the names,".
53 "which occur in selection, have been incremented.\n\n".
54 "changedTypes: File that contains the information if new published types have been added ".
55 "since the last product update.\n\n" ;
58 "The names must end on one of these names: NEW_VERSION, OLD_VERSION, POLICY_VERSION\n".
59 "For example, valid names are: \n".
60 "CLI_URETYPES_NEW_VERSION\nCLI_URETYPES_OLD_VERSION\nCLI_URETYPES_POLICY_VERSION\n";
62 if (scalar @ARGV < 4) {
67 -e
"$ARGV[0]" or die "Error: wrong arguments. \n".$usage;
68 -e
"$ARGV[1]" or die "Error: wrong arguments. \n".$usage;
69 -e
"$ARGV[3]" or die "Error: wrong arguments. \n".$usage;
71 #check if new types have been added since last release.
72 #If not, then there is nothing to be done.
73 #read in oldVersions line by line and apply the increment operation
74 open TYPES
, "$ARGV[3]" or die "Cannot open to $ARGV[3] $!";
78 #We look for the line that contains the number of new types
81 if (/New and published types/i)
86 print "\n###$ARGV[3] contains an invalid entry for 'New and published types'. \n\n";
93 #Check if changeTypes contained the line we are looking for
94 if (! defined $newTypes)
96 print "\n###$ARGV[3] does not contain entry about the new types ".
97 "or we are looking for the wrong string! \n\n";
103 print "\nNo new UNO types since las product update.\n";
108 print "\nNew UNO types were addes since last release. The version will be increased.\n\n";
111 #read in incVersions in a list
112 my @incVersions = readIncVersions
($ARGV[1]);
113 #print "@incVersions";
115 #read in oldVersions line by line and apply the increment operation
116 open OLDVERSION
, "$ARGV[0]" or die "Cannot open to $ARGV[0] $!";
118 #open file we want to write to
119 open NEWVERSION
, "> $ARGV[2]" or die "Cannot write to $ARGV[2] $!";
121 print NEWVERSION processLine
($_, @incVersions) while(<OLDVERSION
>);
133 return $line if (length($trimmed = trim
($line)) == 0);
134 #Skip comment symbol: #
135 return $line if ($trimmed =~ /^#/);
137 #Get the left part of '='
138 my $i = index($line, "=");
141 print "Error: No '=' found in line:,: \n $line \n";
144 my $name = substr($line, 0, $i);
146 #We do not check the names here because the file can contain
147 #other names, e.g. CLI_URETYPES_POLICY_ASSEMBLY
148 if (length($name) == 0) {
149 print "Wrong line in $ARGV[0]\n", $sNameForm;
152 my $value = substr($line, $i + 1);
153 $value = trim
($value);
155 #Check if the entry shall be incremented, this information is in the second
164 if ( ! defined($found)) {
168 #Check if the name represents a version we need to change
169 if ($name =~ /NEW_VERSION$/)
171 $value = incrementNewVersion
($value);
173 elsif ($name =~ /OLD_VERSION$/)
175 $value = incrementOldVersion
($value);
177 elsif ($name =~ /POLICY_VERSION$/)
179 $value = incrementPolicyVersion
($value);
183 #other name which we ignore
186 return "${name}=${value}\n";
189 #The value of a new version has the form x.x.x.x
190 #We increment the third position from the left.
191 #Te argument must already be trimmed.
192 sub incrementNewVersion
($)
194 my @parts = split /\./,$_[0];
195 if (scalar @parts != 4)
197 print "Error, no valid version given in $ARGV[0]\n. A 'new version' has four parts.";
201 #build the version string and return
202 return "$parts[0].$parts[1].$parts[2].$parts[3]";
205 #The value of a new version has the form x.x.x.x-x.x.x.x
206 #We increment the third position of the second part.
207 #Te argument must already be trimmed.
208 sub incrementOldVersion
($)
210 my @parts = split /[\.-]/,$_[0];
211 if (scalar @parts != 8)
213 print "Error, no valid version given in $ARGV[0]\n. A 'old version' has the form
218 return "$parts[0].$parts[1].$parts[2].$parts[3]-$parts[4].$parts[5].$parts[6].$parts[7]";
222 sub incrementPolicyVersion
($)
224 my @parts = split /\./,$_[0];
225 if (scalar @parts != 4)
227 print "Error, no valid version given in $ARGV[0]\n. A 'policy version' has four parts.";
231 #build the version string and return
232 return "$parts[0].$parts[1].$parts[2].$parts[3]";
236 sub readIncVersions
($)
238 open INC
, $_[0] or die "Could not open $_[0] $!";
247 if (length($line = trim
($_)) == 0) {
250 #Skip comment symbol: #
254 if (!checkName
($line)) {
255 print "Wrong entry in file $_[0]\n", $sNameForm;
260 print "No entries found in $arg\n" if(scalar @names == 0);
264 #The argument must already be trimmed
269 if ( $name !~/NEW_VERSION$|OLD_VERSION$|POLICY_VERSION$/) {