2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
24 sub readIncVersions
($);
27 sub incrementNewVersion
($);
28 sub incrementOldVersion
($);
29 sub incrementPolicyVersion
($);
31 "The tool increments the minor version of assemblies and the major version of ".
32 "the respective policy files. This is only done if new uno types have been added since".
33 "the last product update. This information is obtained from the file which is passed as ".
34 "argument changedTypes. The names in the version file must have a particular form. ".
35 "They must end on one of following terms: NEW_VERSION, OLD_VERSION, POLICY_VERSION\n".
36 "If no new published types have been added then no output, argument newVersions, is written".
37 "Usage is: \n increment_version.pl oldVersions incVersions newVersions changedTypes\n\n".
38 "oldVersion: Contains name value pairs, which are used for forming the config files of ".
39 "the policy assemblies, for building the assemblies. \n\n".
40 "incVersions: File containing the names of which the versions are to be incremented. ".
41 "Every line may only contain one name. The names must exactly match those from the ".
42 "oldVersion file.\n\n".
43 "newVersions: Contains all entries from oldVersions, but the values of the names,".
44 "which occur in selection, have been incremented.\n\n".
45 "changedTypes: File that contains the information if new published types have been added ".
46 "since the last product update.\n\n" ;
49 "The names must end on one of these names: NEW_VERSION, OLD_VERSION, POLICY_VERSION\n".
50 "For example, valid names are: \n".
51 "CLI_URETYPES_NEW_VERSION\nCLI_URETYPES_OLD_VERSION\nCLI_URETYPES_POLICY_VERSION\n";
53 if (scalar @ARGV < 3) {
58 -e
"$ARGV[0]" or die "Error: wrong arguments. \n".$usage;
59 -e
"$ARGV[1]" or die "Error: wrong arguments. \n".$usage;
60 #-e "$ARGV[3]" or die "Error: wrong arguments. \n".$usage;
62 # DISABLED: always increment
63 #check if new types have been added since last release.
64 #If not, then there is nothing to be done.
65 #read in oldVersions line by line and apply the increment operation
66 #open TYPES, "$ARGV[3]" or die "Cannot open to $ARGV[3] $!";
70 #We look for the line that contains the number of new types
73 # if (/New and published types/i)
78 # print "\n###$ARGV[3] contains an invalid entry for 'New and published types'. \n\n";
85 #Check if changeTypes contained the line we are looking for
86 #if (! defined $newTypes)
88 # print "\n###$ARGV[3] does not contain entry about the new types ".
89 # "or we are looking for the wrong string! \n\n";
95 # print "\nNo new UNO types since las product update.\n";
100 # print "\nNew UNO types were added since last release. The version will be increased.\n\n";
103 #read in incVersions in a list
104 my @incVersions = readIncVersions
($ARGV[1]);
105 #print "@incVersions";
107 #read in oldVersions line by line and apply the increment operation
108 open OLDVERSION
, "$ARGV[0]" or die "Cannot open to $ARGV[0] $!";
110 #open file we want to write to
111 open NEWVERSION
, "> $ARGV[2]" or die "Cannot write to $ARGV[2] $!";
113 print NEWVERSION processLine
($_, @incVersions) while(<OLDVERSION
>);
125 return $line if (length($trimmed = trim
($line)) == 0);
126 #Skip comment symbol: #
127 return $line if ($trimmed =~ /^#/);
129 #Get the left part of '='
130 my $i = index($line, "=");
133 print "Error: No '=' found in line:,: \n $line \n";
136 my $name = substr($line, 0, $i);
138 #We do not check the names here because the file can contain
139 #other names, e.g. CLI_URETYPES_POLICY_ASSEMBLY
140 if (length($name) == 0) {
141 print "Wrong line in $ARGV[0]\n", $sNameForm;
144 my $value = substr($line, $i + 1);
145 $value = trim
($value);
147 #Check if the entry shall be incremented, this information is in the second
156 if ( ! defined($found)) {
160 #Check if the name represents a version we need to change
161 if ($name =~ /NEW_VERSION$/)
163 $value = incrementNewVersion
($value);
165 elsif ($name =~ /OLD_VERSION$/)
167 $value = incrementOldVersion
($value);
169 elsif ($name =~ /POLICY_VERSION$/)
171 $value = incrementPolicyVersion
($value);
175 #other name which we ignore
178 return "${name}=${value}\n";
181 #The value of a new version has the form x.x.x.x
182 #We increment the third position from the left.
183 #Te argument must already be trimmed.
184 sub incrementNewVersion
($)
186 my @parts = split /\./,$_[0];
187 if (scalar @parts != 4)
189 print "Error, no valid version given in $ARGV[0]\n. A 'new version' has four parts.";
193 #build the version string and return
194 return "$parts[0].$parts[1].$parts[2].$parts[3]";
197 #The value of a new version has the form x.x.x.x-x.x.x.x
198 #We increment the third position of the second part.
199 #Te argument must already be trimmed.
200 sub incrementOldVersion
($)
202 my @parts = split /[\.-]/,$_[0];
203 if (scalar @parts != 8)
205 print "Error, no valid version given in $ARGV[0]\n. A 'old version' has the form
210 return "$parts[0].$parts[1].$parts[2].$parts[3]-$parts[4].$parts[5].$parts[6].$parts[7]";
214 sub incrementPolicyVersion
($)
216 my @parts = split /\./,$_[0];
217 if (scalar @parts != 4)
219 print "Error, no valid version given in $ARGV[0]\n. A 'policy version' has four parts.";
223 #build the version string and return
224 return "$parts[0].$parts[1].$parts[2].$parts[3]";
228 sub readIncVersions
($)
230 open INC
, $_[0] or die "Could not open $_[0] $!";
239 if (length($line = trim
($_)) == 0) {
242 #Skip comment symbol: #
246 if (!checkName
($line)) {
247 print "Wrong entry in file $_[0]\n", $sNameForm;
252 print "No entries found in $arg\n" if(scalar @names == 0);
256 #The argument must already be trimmed
261 if ( $name !~/NEW_VERSION$|OLD_VERSION$|POLICY_VERSION$/) {