forked from mbaltaks/doublecommand
-
Notifications
You must be signed in to change notification settings - Fork 1
/
update_plist_versions.pl
executable file
·78 lines (63 loc) · 1.13 KB
/
update_plist_versions.pl
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
#!/usr/bin/perl
use strict;
my $numargs = @ARGV;
if ( @ARGV < 1 ) {
die "Usage: $0 version-file-path < source > dest\n";
}
my $VersionFile = shift( @ARGV );
my $Version;
if ( @ARGV ) {
die "Usage: $0 version-file-path < source > dest\n";
}
if ( ! open( VERSION, "< $VersionFile" ) ) {
die "Couldn't open $VersionFile for reading: $!\n";
}
while ( <VERSION> ) {
if ( /^#/ ) {
next;
}
chomp;
if ( !length ) {
next;
}
s/^\s*//;
s/\s*$//;
$Version = $_;
last;
}
if ( !defined( $Version ) ) {
die "No version defined in $VersionFile\n";
}
my $change = 0;
my $long_version = 0;
while ( <> ) {
if (/CFBundleVersion/)
{
$change = 1;
print;
next;
}
if (/CFBundleShortVersionString/)
{
$change = 1;
print;
next;
}
if (/CFBundleGetInfoString/)
{
$long_version = 1;
print;
next;
}
if ($change == 1)
{
s/(<string>).+(<\/string>)/\1$Version\2/g;
$change = 0;
}
if ($long_version == 1)
{
s/(<string>).+(<\/string>)/\1DoubleCommand $Version\2/g;
$long_version = 0;
}
print;
}