5 sub update_man_page
($);
6 sub update_bin_tool
($);
7 sub update_txt_file
($);
8 sub update_spec_file
($);
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."/".$_);
47 my ($sec, $min, $hour, $year, $month, $day);
50 @stat = stat($filename);
51 ($sec, $min, $hour, $day, $month, $year) = localtime($stat[9]);
55 return (sprintf("%04d-%02d-%02d", $year, $month, $day),
56 sprintf("%04d%02d%02d%02d%02d.%02d", $year, $month, $day,
58 sprintf("%o", $stat[2] & 07777));
61 sub update_man_page
($)
64 my @date = get_file_info
($filename);
65 my $date_string = $date[0];
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");
74 s/\"LCOV\s+\d+\.\d+\"/\"LCOV $version\"/g;
75 s/\d\d\d\d\\\-\d\d\\\-\d\d/$date_string/g;
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
($)
88 my @date = get_file_info
($filename);
92 open(IN
, "<$filename") || die ("Error: cannot open $filename\n");
93 open(OUT
, ">$filename.new") ||
94 die("Error: cannot create $filename.new\n");
96 s/(our\s+\$lcov_version\s*=\s*["']).*(["'].*)$/$1LCOV version $version$2/g;
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
($)
109 my @date = get_file_info
($filename);
113 open(IN
, "<$filename") || die ("Error: cannot open $filename\n");
114 open(OUT
, ">$filename.new") ||
115 die("Error: cannot create $filename.new\n");
117 s/(Last\s+changes:\s+)\d\d\d\d-\d\d-\d\d/$1$date[0]/g;
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
($)
130 my @date = get_file_info
($filename);
134 open(IN
, "<$filename") || die ("Error: cannot open $filename\n");
135 open(OUT
, ">$filename.new") ||
136 die("Error: cannot create $filename.new\n");
138 s/^(Version:\s*)\d+\.\d+.*$/$1$version/;
139 s/^(Release:\s*).*$/$1$release/;
144 system("mv", "-f", "$filename.new", "$filename");
145 system("touch", "$filename", "-t", $date[1]);