14
14
-D Compare files (cvs diff)
15
15
-f FILE Just do a particular file
16
16
-t TYPE Just do a particular type of file
17
-P Print resulting modified lines
23
getopts("v:T:RCMDhnf:t:V",\%opts) || usage();
23
getopts("Pv:T:RCMDhnf:t:V",\%opts) || usage();
24
24
if ($opts{'h'}) { usage(); }
26
26
if (!$opts{'v'} && $opts{'M'} && !$opts{'T'}) {
44
44
expr => 'Version: [\.0-9a-zA-Z]+' =>
45
45
repl => 'Version: $VERSION',
46
files => [qw(README FAQ dist/net-snmp.spec)]},
46
files => [qw(README FAQ dist/net-snmp.spec)],
47
not_required => {'dist/net-snmp.spec' => 1}
55
57
{ type => 'Makefile',
56
58
expr => 'VERSION = \'(.*)\'',
57
59
repl => 'VERSION = \'$VERSION\'',
58
files => [qw(dist/Makefile)]},
60
files => [qw(dist/Makefile)],
61
not_required => {'dist/Makefile' => 1}
61
65
{ type => 'doxygen',
62
66
expr => 'PROJECT_NUMBER(\s+)=(\s+)\'(.*)\'',
63
67
repl => 'PROJECT_NUMBER$1=$2\'$VERSION\'',
64
files => [qw(doxygen.conf)]},
68
files => [qw(doxygen.conf)]
68
73
expr => 'VERSION = \'(.*)\'',
69
repl => 'VERSION = \'$VERSION\'',
74
repl => 'VERSION = \'$VERSION_FLOAT\'',
70
75
files => [qw(perl/SNMP/SNMP.pm
71
76
perl/agent/agent.pm
77
perl/agent/Support/Support.pm
72
78
perl/agent/default_store/default_store.pm
73
79
perl/default_store/default_store.pm
76
82
perl/AnyData_SNMP/Storage.pm
77
83
perl/AnyData_SNMP/Format.pm
78
84
perl/TrapReceiver/TrapReceiver.pm
86
not_required => {'perl/agent/Support/Support.pm' => 1}
89
# configure script files
90
{ type => 'configure',
91
expr => 'AC_INIT\\(\\[Net-SNMP\\], \\[([^\\]]+)\\]',
92
repl => 'AC_INIT([Net-SNMP], [$VERSION]',
93
files => [qw(configure.in)],
95
exfiles => [qw(configure)],
98
# configure script files
100
expr => 'PROJECT_NUMBER\s*= (.*)',
101
repl => 'PROJECT_NUMBER = $VERSION',
102
files => [qw(doxygen.conf)],
107
# set up versioning information
82
109
if ($opts{'T'} && !$opts{'v'}) {
83
110
$opts{'v'} = $opts{'T'};
84
111
die "usage error: version tag must begin with Ext-" if ($opts{'T'} !~ /^Ext-/);
86
113
$opts{'v'} =~ s/-/./g;
88
115
$VERSION = $opts{'v'};
116
$VERSION_FLOAT = floatize_version($VERSION);
120
# loop through all the expression types
90
123
for ($i = 0; $i <= $#exprs; $i++) {
125
# drop other file types if only one was requested.
91
126
next if ($opts{'t'} && $exprs[$i]{'type'} ne $opts{'t'});
128
# loop through each file and process
92
129
foreach my $f (@{$exprs[$i]->{'files'}}) {
131
# skip files that weren't specifically in the todo list if need be
93
132
next if ($opts{'f'} && $f ne $opts{'f'});
134
# remove the changes and revert to CVS
95
136
print "removing changes and updating $f\n" if ($opts{'V'});
97
138
system("cvs update $f");
141
# make sure it exists
143
if (!exists($exprs[$i]->{'not_required'}{$f})) {
144
print STDERR "FAILED to find file $f\n";
147
print STDERR "SKIPPING file $f\n";
152
# modify the files with the version
100
154
rename ($f,"$f.bak");
101
155
open(I,"$f.bak");
104
eval "s/$exprs[$i]->{'expr'}/$exprs[$i]->{'repl'}/";
158
my $res = eval "s/$exprs[$i]->{'expr'}/$exprs[$i]->{'repl'}/";
159
if ($res && $opts{'P'}) {
161
$shortened =~ s/^\s*//;
162
printf("%s:\n %s", $f, $shortened);
109
168
unlink("$f.bak");
110
170
print "modified $f using s/$exprs[$i]->{'expr'}/$exprs[$i]->{'repl'}/\n" if ($opts{'V'});
173
# run CVS diff if requested.
112
174
if ($opts{'D'}) {
113
175
print "diffing $f\n" if ($opts{'V'});
114
176
system("cvs diff $f");
117
print "committing $f\n" if ($opts{'V'});
118
system("cvs commit -m \"- ($f): version tag ( $VERSION )\" $f");
179
system($exprs[$i]->{'exec'}) if ($exprs[$i]->{'exec'});
180
push @files, @{$exprs[$i]->{'exfiles'}} if ($exprs[$i]->{'exfiles'});
184
# CVS commit the modified files
187
my $files = join(" ",@files);
188
print "committing $files\n" if ($opts{'V'});
189
$ret = system("cvs commit -m \"- version tag ( $VERSION )\" $files");
193
sub floatize_version {
194
my ($major, $minor, $patch, $opps) = ($_[0] =~ /^(\d+)\.(\d+)\.?(\d*)\.?(\d*)/);
195
return $major + $minor/100 + $patch/10000 + $opps/100000;