Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
dd9f644851b10bf435993b86fb12cdf851b48776
[xestiaab/.git] / source / tools / updateversion.pl
1 #!/usr/bin/perl
3 #############################################################################
4 # Xestia Address Book: Version Updater                                      #
5 # (c) 2017 Xestia Address Book                                              #
6 #############################################################################
7 # This file is part of Xestia Address Book.                                 #
8 #                                                                           #
9 # Xestia Address Book is free software: you can redistribute it and/or      #
10 # modify it under the terms of the GNU General Public License as published  #
11 # by the Free Software Foundation, version 3 of the license.                #
12 #                                                                           #
13 # Xestia Address Book is distributed in the hope that it will be useful,    #
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of            #
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the              #
16 # GNU General Public License for more details.                              #
17 #                                                                           #
18 # You should have received a copy of the GNU General Public License along   #
19 # with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>      #
20 #############################################################################
22 use strict;
23 use warnings;
24 use Tie::File;
26 # Get the version number.
28 if (!$ARGV[0]){
29         print "Error: No version specified!\n";
30         exit;
31 }
33 my $version = $ARGV[0];
35 my $filename;
36 my $file_handle;
37 my @file_data;
39 # Split the version information down.
41 my @version_split = split(/(\.)/, $version);
43 my $version_major = $version_split[0];
44 my $version_minor = $version_split[2];
46 # Update source/version.h
48 $filename = "../version.h";
50 tie(@file_data, 'Tie::File', $filename);
51 foreach my $file_data_line(@file_data) {
53         # Look for XSDAB_VERSION
55         if ($file_data_line =~ /^\#define\ XSDAB_VERSION/){
56                 my $line_output = "#define XSDAB_VERSION \"";
57                 $line_output .= $version;
58                 $line_output .= "\"";
59                 $file_data_line = $line_output;
60         }       
62         # Look for XSDAB_USERAGENT
64         if ($file_data_line =~ /^\#define\ XSDAB_USERAGENT/){
65                 my $line_output = "#define XSDAB_USERAGENT \"XestiaAddressBook/";
66                 $line_output .= $version;
67                 $line_output .= "\"";
68                 $file_data_line = $line_output;
69         }       
71 }
73 # Update source/os/msw/xestiaab.rc
75 $filename = "../os/msw/xestiaab.rc";
76 tie(@file_data, 'Tie::File', $filename);
77 foreach my $file_data_line(@file_data) {
79         # Look for FILEVERSION
81         if ($file_data_line =~ /^    FILEVERSION/){
82                 my $line_output = "    FILEVERSION     ";
83                 $line_output .= $version_major;
84                 $line_output .= ",";
85                 $line_output .= $version_minor;
86                 $line_output .= ",0,0";
87                 $file_data_line = $line_output;
88         }       
90         # Look for PRODUCTVERSION
92         if ($file_data_line =~ /^    PRODUCTVERSION/){
93                 my $line_output = "    PRODUCTVERSION  ";
94                 $line_output .= $version_major;
95                 $line_output .= ",";
96                 $line_output .= $version_minor;
97                 $line_output .= ",0,0";
98                 $file_data_line = $line_output;
99         }       
102 # Update source/os/osx/Info.plist
104 $filename = "../os/osx/Info.plist";
105 open($file_handle, '+<', $filename);
106 my $line_found = 0;
107 my $new_file = "";
108 while(<$file_handle>)
110         if ($line_found eq 1)
111         {
112                 my $new_line = "\t<string>" . $version_major . "." . $version_minor . "</string>\n";
113                 $new_file .= $new_line;
114                 $line_found = 0;
115                 next;
116         }
118         if (/.*<key>CFBundleVersion<\/key>/)
119         {
120                 $line_found = 1;
121         }
122         $new_file .= $_;
124 close($file_handle);
126 open($file_handle, '>', $filename);
127 print $file_handle $new_file;
128 close($file_handle);
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy