xref: /AOO41X/main/solenv/bin/modules/installer/patch/Version.pm (revision c9b362f6b4b94fc79a706186f718dbfbc8ea72b0)
1*c9b362f6SAndre Fischer#**************************************************************
2*c9b362f6SAndre Fischer#
3*c9b362f6SAndre Fischer#  Licensed to the Apache Software Foundation (ASF) under one
4*c9b362f6SAndre Fischer#  or more contributor license agreements.  See the NOTICE file
5*c9b362f6SAndre Fischer#  distributed with this work for additional information
6*c9b362f6SAndre Fischer#  regarding copyright ownership.  The ASF licenses this file
7*c9b362f6SAndre Fischer#  to you under the Apache License, Version 2.0 (the
8*c9b362f6SAndre Fischer#  "License"); you may not use this file except in compliance
9*c9b362f6SAndre Fischer#  with the License.  You may obtain a copy of the License at
10*c9b362f6SAndre Fischer#
11*c9b362f6SAndre Fischer#    http://www.apache.org/licenses/LICENSE-2.0
12*c9b362f6SAndre Fischer#
13*c9b362f6SAndre Fischer#  Unless required by applicable law or agreed to in writing,
14*c9b362f6SAndre Fischer#  software distributed under the License is distributed on an
15*c9b362f6SAndre Fischer#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c9b362f6SAndre Fischer#  KIND, either express or implied.  See the License for the
17*c9b362f6SAndre Fischer#  specific language governing permissions and limitations
18*c9b362f6SAndre Fischer#  under the License.
19*c9b362f6SAndre Fischer#
20*c9b362f6SAndre Fischer#**************************************************************
21*c9b362f6SAndre Fischer
22*c9b362f6SAndre Fischerpackage installer::patch::Version;
23*c9b362f6SAndre Fischer
24*c9b362f6SAndre Fischer
25*c9b362f6SAndre Fischer=head1 NAME
26*c9b362f6SAndre Fischer
27*c9b362f6SAndre Fischer    package installer::patch::Version - Functions for handling version numbers.
28*c9b362f6SAndre Fischer
29*c9b362f6SAndre Fischer=cut
30*c9b362f6SAndre Fischer
31*c9b362f6SAndre Fischer
32*c9b362f6SAndre Fischer
33*c9b362f6SAndre Fischer# We handle version numbers that consist of three parts: major, minor and micro version number.
34*c9b362f6SAndre Fischermy $VersionPartCount = 3;
35*c9b362f6SAndre Fischer
36*c9b362f6SAndre Fischer
37*c9b362f6SAndre Fischer
38*c9b362f6SAndre Fischer=head StringToNumberArray($version_string)
39*c9b362f6SAndre Fischer
40*c9b362f6SAndre Fischer    Convert a version string (where the individual parts are separated by '.') into an array of three numbers.
41*c9b362f6SAndre Fischer    Missing numbers are filled with 0.
42*c9b362f6SAndre Fischer
43*c9b362f6SAndre Fischer    Returns an array with three elements (major, minor, micro).
44*c9b362f6SAndre Fischer=cut
45*c9b362f6SAndre Fischersub StringToNumberArray ($)
46*c9b362f6SAndre Fischer{
47*c9b362f6SAndre Fischer    my ($version_string) = @_;
48*c9b362f6SAndre Fischer
49*c9b362f6SAndre Fischer    my @version_parts = split(/\./, $version_string);
50*c9b362f6SAndre Fischer    while (scalar @version_parts < $VersionPartCount)
51*c9b362f6SAndre Fischer    {
52*c9b362f6SAndre Fischer        push @version_parts, "0";
53*c9b362f6SAndre Fischer    }
54*c9b362f6SAndre Fischer    return @version_parts;
55*c9b362f6SAndre Fischer}
56*c9b362f6SAndre Fischer
57*c9b362f6SAndre Fischer
58*c9b362f6SAndre Fischer
59*c9b362f6SAndre Fischer
60*c9b362f6SAndre Fischer=head ArrayToDirectoryName (@)
61*c9b362f6SAndre Fischer
62*c9b362f6SAndre Fischer    Return a directory name (without any path) for the given array of version numbers.
63*c9b362f6SAndre Fischer
64*c9b362f6SAndre Fischer=cut
65*c9b362f6SAndre Fischersub ArrayToDirectoryName (@)
66*c9b362f6SAndre Fischer{
67*c9b362f6SAndre Fischer    return "v-".join("-", @_);
68*c9b362f6SAndre Fischer}
69*c9b362f6SAndre Fischer
70*c9b362f6SAndre Fischer
71*c9b362f6SAndre Fischer
72*c9b362f6SAndre Fischer
73*c9b362f6SAndre Fischer
74*c9b362f6SAndre Fischer1;
75