File: propagate-version.pl

package info (click to toggle)
log4cplus 2.0.8-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,592 kB
  • sloc: cpp: 53,091; sh: 10,537; ansic: 1,845; python: 1,226; perl: 263; makefile: 209; xml: 85; objc: 59
file content (112 lines) | stat: -rwxr-xr-x 3,121 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!perl

# Enable in-place editing
BEGIN
{
    $^I = '.bak';
}

use strict;
use feature 'unicode_strings';

# parse line from include/log4cplus/version.h

open (my $fh, "<", "include/log4cplus/version.h")
    or die $!;

my ($major, $minor, $point, $version);
while (my $line = <$fh>)
{
    if ($line =~ m/\s* # \s* define \s+ LOG4CPLUS_VERSION \s+
          LOG4CPLUS_MAKE_VERSION \s* \(
          \s* (\d+) \s* , \s* (\d+) \s* , \s* (\d+) \s* \)/x)
    {
        ($major, $minor, $point) = ($1, $2, $3);
        $version = "$major.$minor.$point";
        print "version: ", $version, "\n";
        last;
    }
}

close $fh;

# parse SO version from configure.ac

open (my $fh2, "<", "configure.ac")
    or die $!;

my ($so_current, $so_revision, $so_age, $so_current_adjusted);
while (my $line = <$fh2>)
{
    if ($line =~ m/\s* LT_VERSION= \s*
          (\d+) \s* : \s* (\d+) \s* : \s* (\d+) \s*/x)
    {
        ($so_current, $so_revision, $so_age) = ($1, $2, $3);
        print +("SO version: ", $so_current, ".", $so_revision, ".", $so_age,
                "\n");
        $so_current_adjusted = $so_current - $so_age;
        print +("MingGW/Cygwin version: ", $major, "-", $minor, "-",
                $so_current_adjusted, "\n");
        last;
    }
}

close $fh2;

# edit configure.ac

{
    local $^I = ".bak";
    local @ARGV = ("configure.ac");
    while (my $line = <>)
    {
        $line =~ s/(.*AC_INIT\(.*\[)(\d+(?:\.\d+(?:\.\d+)?)?)(\].*)/$1$version$3/x;
        $line =~ s/(.*LT_RELEASE=)(.*)/$1$major.$minor/x;
        print $line;
    }

    local @ARGV = ("docs/doxygen.config");
    while (my $line = <>)
    {
        $line =~ s/(\s* PROJECT_NUMBER \s* = \s*)(.*)/$1$version/x;
        $line =~ s/(\s* OUTPUT_DIRECTORY \s* = \s*)(.*)/$1log4cplus-$version\/docs/x;
        print $line;
    }

    local @ARGV = ("docs/webpage_doxygen.config");
    while (my $line = <>)
    {
        $line =~ s/(\s* PROJECT_NUMBER \s* = \s*)(.*)/$1$version/x;
        $line =~ s/(\s* OUTPUT_DIRECTORY \s* = \s*)(.*)/$1webpage_docs-$version/x;
        print $line;
    }

    local @ARGV = ("log4cplus.spec", "mingw-log4cplus.spec");
    while (my $line = <>)
    {
        $line =~ s/(Version: \s*)(.*)/$1$version/x;
        if ($line =~ /Source\d*:/x)
        {
            $line =~ s/(\d+\.\d+\.\d+)/$version/gx;
        }
        print $line;
    }

    local @ARGV = ("cygport/log4cplus.cygport");
    while (my $line = <>)
    {
        $line =~ s/(\s* VERSION \s* = \s*)(\d+\.\d+\.\d+)(-.+)?/$1$version$3/x
            || $line =~ s/\d+ ([._\-]) \d+ ([._\-]) \d+
                         /$major$1$minor$2$so_current_adjusted/gx;
        print $line;
    }

    local @ARGV = ("CMakeLists.txt");
    while (my $line = <>)
    {
        $line =~ s/^(\s* set \s* \( \s* log4cplus_soversion \s*) (\d+)/$1$so_current_adjusted/x
            || $line =~ s/^(\s* set \s* \( \s* log4cplus_macho_current_version \s*) (\d+(?:\.\d+)+)/$1$so_current.0.0/x
            || $line =~ s/^(\s* set \s* \( \s* log4cplus_macho_compatibility_version \s*) (\d+(?:\.\d+)+)/$1$so_current_adjusted.0.0/x;
        print $line;
    }
}