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
|
#!/usr/bin/perl
use strict;
use warnings;
use lib "../../lib";
use EB::Version;
my $vv = $EB::Version::VERSION;
my ( $maj, $min, $aux ) = $vv =~ /^(\d+)\.(\d+)(?:_(\d+))?/;
@ARGV = qw( innosetup.iss ) unless @ARGV;
$^I = ".bak";
if ( $ARGV[0] =~ /\.iss$/ ) {
my $resetbuildnum = 0;
while ( <> ) {
s/(^#\s+define\s+V_MAJ\s+)(\d+)/$1$maj/ and
$2 != $maj and $resetbuildnum++;
s/(^#\s+define\s+V_MIN\s+)(\d+)/$1$min/ and
$2 != $min and $resetbuildnum++;
if ( defined($aux) ) {
s/(^#\s+define\s+V_AUX\s+)(\d+)/$1$aux/ and
$2 != $aux and $resetbuildnum++;
}
s/(^\#\s+define\s+BuildNum\s+)(\d+).*
/sprintf("%s%d", $1, $resetbuildnum ? 1 : 1+$2)
/ex;
}
continue {
print;
}
}
elsif ( $ARGV[0] =~ /\.rc$/ ) {
my $resetbuildnum = 0;
while ( <> ) {
if ( /^((?:PRODUCT|FILE)VERSION\s+)(\d+),(\d+),(\d+),(\d+)/ ) {
$2 != $maj and $resetbuildnum++;
$3 != $min and $resetbuildnum++;
if ( defined($aux) ) {
$4 != $aux and $resetbuildnum++;
}
$_ = sprintf("%s%d,%d,%d,%d\n",
$1, $maj, $min, $aux//0, $resetbuildnum ? 1 : 1+$5);
next;
}
if ( /^(\s*VALUE\s+"(?:Product|File)Version",\s+)/ ) {
$_ = "$1 \"$vv\"\n";
next;
}
}
continue {
print;
}
}
|