Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / third_party / lcov / bin / updateversion.pl
blob55f2bc1dd9a0dead1d8d3ff7216ac8827ec96758
1 #!/usr/bin/perl -w
3 use strict;
5 sub update_man_page($);
6 sub update_bin_tool($);
7 sub update_txt_file($);
8 sub update_spec_file($);
9 sub get_file_info($);
11 our $directory = $ARGV[0];
12 our $version = $ARGV[1];
13 our $release = $ARGV[2];
15 our @man_pages = ("man/gendesc.1", "man/genhtml.1", "man/geninfo.1",
16 "man/genpng.1", "man/lcov.1", "man/lcovrc.5");
17 our @bin_tools = ("bin/gendesc", "bin/genhtml", "bin/geninfo",
18 "bin/genpng", "bin/lcov");
19 our @txt_files = ("README");
20 our @spec_files = ("rpm/lcov.spec");
22 if (!defined($directory) || !defined($version) || !defined($release)) {
23 die("Usage: $0 <directory> <version string> <release string>\n");
26 foreach (@man_pages) {
27 print("Updating man page $_\n");
28 update_man_page($directory."/".$_);
30 foreach (@bin_tools) {
31 print("Updating bin tool $_\n");
32 update_bin_tool($directory."/".$_);
34 foreach (@txt_files) {
35 print("Updating text file $_\n");
36 update_txt_file($directory."/".$_);
38 foreach (@spec_files) {
39 print("Updating spec file $_\n");
40 update_spec_file($directory."/".$_);
42 print("Done.\n");
44 sub get_file_info($)
46 my ($filename) = @_;
47 my ($sec, $min, $hour, $year, $month, $day);
48 my @stat;
50 @stat = stat($filename);
51 ($sec, $min, $hour, $day, $month, $year) = localtime($stat[9]);
52 $year += 1900;
53 $month += 1;
55 return (sprintf("%04d-%02d-%02d", $year, $month, $day),
56 sprintf("%04d%02d%02d%02d%02d.%02d", $year, $month, $day,
57 $hour, $min, $sec),
58 sprintf("%o", $stat[2] & 07777));
61 sub update_man_page($)
63 my ($filename) = @_;
64 my @date = get_file_info($filename);
65 my $date_string = $date[0];
66 local *IN;
67 local *OUT;
69 $date_string =~ s/-/\\-/g;
70 open(IN, "<$filename") || die ("Error: cannot open $filename\n");
71 open(OUT, ">$filename.new") ||
72 die("Error: cannot create $filename.new\n");
73 while (<IN>) {
74 s/\"LCOV\s+\d+\.\d+\"/\"LCOV $version\"/g;
75 s/\d\d\d\d\\\-\d\d\\\-\d\d/$date_string/g;
76 print(OUT $_);
78 close(OUT);
79 close(IN);
80 chmod(oct($date[2]), "$filename.new");
81 system("mv", "-f", "$filename.new", "$filename");
82 system("touch", "$filename", "-t", $date[1]);
85 sub update_bin_tool($)
87 my ($filename) = @_;
88 my @date = get_file_info($filename);
89 local *IN;
90 local *OUT;
92 open(IN, "<$filename") || die ("Error: cannot open $filename\n");
93 open(OUT, ">$filename.new") ||
94 die("Error: cannot create $filename.new\n");
95 while (<IN>) {
96 s/(our\s+\$lcov_version\s*=\s*["']).*(["'].*)$/$1LCOV version $version$2/g;
97 print(OUT $_);
99 close(OUT);
100 close(IN);
101 chmod(oct($date[2]), "$filename.new");
102 system("mv", "-f", "$filename.new", "$filename");
103 system("touch", "$filename", "-t", $date[1]);
106 sub update_txt_file($)
108 my ($filename) = @_;
109 my @date = get_file_info($filename);
110 local *IN;
111 local *OUT;
113 open(IN, "<$filename") || die ("Error: cannot open $filename\n");
114 open(OUT, ">$filename.new") ||
115 die("Error: cannot create $filename.new\n");
116 while (<IN>) {
117 s/(Last\s+changes:\s+)\d\d\d\d-\d\d-\d\d/$1$date[0]/g;
118 print(OUT $_);
120 close(OUT);
121 close(IN);
122 chmod(oct($date[2]), "$filename.new");
123 system("mv", "-f", "$filename.new", "$filename");
124 system("touch", "$filename", "-t", $date[1]);
127 sub update_spec_file($)
129 my ($filename) = @_;
130 my @date = get_file_info($filename);
131 local *IN;
132 local *OUT;
134 open(IN, "<$filename") || die ("Error: cannot open $filename\n");
135 open(OUT, ">$filename.new") ||
136 die("Error: cannot create $filename.new\n");
137 while (<IN>) {
138 s/^(Version:\s*)\d+\.\d+.*$/$1$version/;
139 s/^(Release:\s*).*$/$1$release/;
140 print(OUT $_);
142 close(OUT);
143 close(IN);
144 system("mv", "-f", "$filename.new", "$filename");
145 system("touch", "$filename", "-t", $date[1]);