# enables.
# svn_client - Use svn client i.s.o. ugly internal SVN file hack
# format - A strftime() formatted string to use as a template for
-# the version string. The sequence "%#" will substitute
+# the version string. The sequence "%#" will substitute
# the SVN revision number.
-# pkg_enable - Enable or disable package versioning.
-# pkg_format - Like "format", but used for the package version.
+# pkg_enable - Enable or disable local package versioning.
+# pkg_format - Like "format", but used for the local package version.
#
-# If run with the "-p" or "--package-version" argument, the
-# AC_INIT macro in configure.in and the VERSION macro in
-# config.nmake will have the pkg_format template appended to the
-# version number. svnversion.h will _not_ be generated if either
-# argument is present (it will also not be generated if 'is_release' is set
-# in version.conf).
+# If run with the "-r" or "--set-release" argument the AC_INIT macro in
+# configure.ac and the VERSION macro in config.nmake will have the
+# pkg_format template appended to the version number. svnversion.h will
+# _not_ be generated if either argument is present.
#
# Default configuration:
#
my $revision = 0;
my $repo_path = "unknown";
my $get_svn = 0;
+my $set_svn = 0;
my $set_version = 0;
my $set_release = 0;
my %version_pref = (
"version_major" => 1,
- "version_minor" => 7,
+ "version_minor" => 11,
"version_micro" => 1,
"version_build" => 0,
#"pkg_format" => "",
);
my $srcdir = ".";
-my $svn_info_cmd = "";
+my $info_cmd = "";
-$ENV{LANG} = "C"; # Ensure we run with correct locale
+# Ensure we run with correct locale
+$ENV{LANG} = "C";
+$ENV{LC_ALL} = "C";
# Run "svn info". Parse out the most recent modification time and the
# revision number.
$package_format = $version_pref{"pkg_format"};
}
- if (-d "$srcdir/.svn") {
+ if (-d "$srcdir/.svn" or -d "$srcdir/../.svn") {
$info_source = "Command line (svn info)";
- $svn_info_cmd = "svn info $srcdir";
+ $info_cmd = "svn info $srcdir";
} elsif (-d "$srcdir/.git/svn") {
$info_source = "Command line (git-svn)";
- $svn_info_cmd = "(cd $srcdir; git svn info)";
+ $info_cmd = "(cd $srcdir; git svn info)";
}
if ($version_pref{"svn_client"}) {
eval {
use warnings "all";
no warnings "all";
- $line = qx{$svn_info_cmd};
+ $line = qx{$info_cmd};
if (defined($line)) {
if ($line =~ /Last Changed Date: (\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/) {
$last_change = timegm($6, $5, $4, $3, $2 - 1, $1);
close(TORTOISE);
$info_source = "Command line (SubWCRev)";
- $svn_info_cmd = "SubWCRev $srcdir $tortoise_file $version_file";
- my $tortoise = system($svn_info_cmd);
+ $info_cmd = "SubWCRev $srcdir $tortoise_file $version_file";
+ my $tortoise = system($info_cmd);
if ($tortoise == 0) {
$do_hack = 0;
}
if ($revision == 0) {
# Fall back to config.nmake
$info_source = "Prodding config.nmake";
- my $filepath = "config.nmake";
+ my $filepath = "$srcdir/config.nmake";
open(CFGNMAKE, "< $filepath") || die "Can't read $filepath!";
while ($line = <CFGNMAKE>) {
if ($line =~ /^SVN_REVISION=(\d+)/) {
}
close (CFGNMAKE);
}
+ if ($revision == 0 and -d "$srcdir/.git") {
+
+ # Try git...
+ eval {
+ use warnings "all";
+ no warnings "all";
+ # If someone had properly tagged 1.9.0 we could also use
+ # "git describe --abbrev=1 --tags HEAD"
+
+ $info_cmd = "(cd $srcdir; git log --format='%b' -n 1)";
+ $line = qx{$info_cmd};
+ if (defined($line)) {
+ if ($line =~ /svn path=.*; revision=(\d+)/) {
+ $revision = $1;
+ }
+ }
+ $info_cmd = "(cd $srcdir; git log --format='%ad' -n 1 --date=iso)";
+ $line = qx{$info_cmd};
+ if (defined($line)) {
+ if ($line =~ /(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/) {
+ $last_change = timegm($6, $5, $4, $3, $2 - 1, $1);
+ }
+ }
+ $info_cmd = "(cd $srcdir; git branch)";
+ $line = qx{$info_cmd};
+ if (defined($line)) {
+ if ($line =~ /\* (\S+)/) {
+ $repo_path = $1;
+ }
+ }
+ 1;
+ };
+ }
+ if ($revision == 0 and -d "$srcdir/.bzr") {
+
+ # Try bzr...
+ eval {
+ use warnings "all";
+ no warnings "all";
+ $info_cmd = "(cd $srcdir; bzr log -l 1)";
+ $line = qx{$info_cmd};
+ if (defined($line)) {
+ if ($line =~ /timestamp: \S+ (\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/) {
+ $last_change = timegm($6, $5, $4, $3, $2 - 1, $1);
+ }
+ if ($line =~ /svn revno: (\d+) \(on (\S+)\)/) {
+ $revision = $1;
+ $repo_path = $2;
+ }
+ }
+ 1;
+ };
+ }
+
# 'svn info' failed or the user really wants us to dig around in .svn/entries
if ($do_hack) {
}
-# Read configure.in, then write it back out with an updated
+# Read configure.ac, then write it back out with an updated
# "AC_INIT" line.
-sub update_configure_in
+sub update_configure_ac
{
my $line;
my $contents = "";
my $version = "";
- my $filepath = "configure.in";
+ my $filepath = "$srcdir/configure.ac";
return if (!$set_version && $package_string eq "");
open(CFGIN, "< $filepath") || die "Can't read $filepath!";
while ($line = <CFGIN>) {
- if ($line =~ /^AC_INIT\(wireshark, (\d+)\.(\d+).(\d+)/) {
- $line = sprintf("AC_INIT\(wireshark, %d.%d.%d%s)\n",
- $set_version ? $version_pref{"version_major"} : $1,
- $set_version ? $version_pref{"version_minor"} : $2,
- $set_version ? $version_pref{"version_micro"} : $3,
- $set_release ? $package_string : ""
- );
-
+ if ($line =~ /^m4_define\( *\[?version_major\]? *,.*([\r\n]+)$/) {
+ $line = sprintf("m4_define([version_major], [%d])$1", $version_pref{"version_major"});
+ } elsif ($line =~ /^m4_define\( *\[?version_minor\]? *,.*([\r\n]+)$/) {
+ $line = sprintf("m4_define([version_minor], [%d])$1", $version_pref{"version_minor"});
+ } elsif ($line =~ /^m4_define\( *\[?version_micro\]? *,.*([\r\n]+)$/) {
+ $line = sprintf("m4_define([version_micro], [%d])$1", $version_pref{"version_micro"});
+ } elsif ($line =~ /^m4_append\( *\[?version_micro_extra\]? *,.*([\r\n]+)$/) {
+ $line = sprintf("m4_append([version_micro_extra], [%s])$1", $package_string);
}
$contents .= $line
}
my $line;
my $contents = "";
my $version = "";
- my $filepath = "config.nmake";
+ my $filepath = "$srcdir/config.nmake";
open(CFGNMAKE, "< $filepath") || die "Can't read $filepath!";
while ($line = <CFGNMAKE>) {
- if ($line =~ /^SVN_REVISION=/) {
- $line = sprintf("SVN_REVISION=%d\n", $revision);
- } elsif ($set_version && $line =~ /^VERSION_MAJOR=/) {
- $line = sprintf("VERSION_MAJOR=%d\n", $version_pref{"version_major"});
- } elsif ($set_version && $line =~ /^VERSION_MINOR=/) {
- $line = sprintf("VERSION_MINOR=%d\n", $version_pref{"version_minor"});
- } elsif ($set_version && $line =~ /^VERSION_MICRO=/) {
- $line = sprintf("VERSION_MICRO=%d\n", $version_pref{"version_micro"});
- } elsif ($line =~ /^VERSION_EXTRA=/) {
- $line = "VERSION_EXTRA=$package_string\n";
+ if ($line =~ /^SVN_REVISION=.*([\r\n]+)$/) {
+ $line = sprintf("SVN_REVISION=%d$1", $revision);
+ } elsif ($set_version && $line =~ /^VERSION_MAJOR=.*([\r\n]+)$/) {
+ $line = sprintf("VERSION_MAJOR=%d$1", $version_pref{"version_major"});
+ } elsif ($set_version && $line =~ /^VERSION_MINOR=.*([\r\n]+)$/) {
+ $line = sprintf("VERSION_MINOR=%d$1", $version_pref{"version_minor"});
+ } elsif ($set_version && $line =~ /^VERSION_MICRO=.*([\r\n]+)$/) {
+ $line = sprintf("VERSION_MICRO=%d$1", $version_pref{"version_micro"});
+ } elsif ($line =~ /^VERSION_EXTRA=.*([\r\n]+)$/) {
+ $line = "VERSION_EXTRA=$package_string$1";
}
$contents .= $line
}
print "$filepath has been updated.\n";
}
-# Read docbook/release_notes.xml, then write it back out with an updated
-# "WiresharkCurrentVersion" line.
+# Read docbook/asciidoc.conf, then write it back out with an updated
+# wireshark-version replacement line.
sub update_release_notes
{
my $line;
my $contents = "";
my $version = "";
- my $filepath = "docbook/release-notes.xml";
+ my $filepath = "$srcdir/docbook/asciidoc.conf";
return if (!$set_version);
- open(RELNOTES, "< $filepath") || die "Can't read $filepath!";
- while ($line = <RELNOTES>) {
- # <!ENTITY WiresharkCurrentVersion "1.7.1">
+ open(ADOC_CONF, "< $filepath") || die "Can't read $filepath!";
+ while ($line = <ADOC_CONF>) {
+ # wireshark-version:\[\]=1.9.1
- if ($line =~ /<\!ENTITY\s+WiresharkCurrentVersion\s+/) {
- $line = sprintf("<!ENTITY WiresharkCurrentVersion \"%d.%d.%d\"\n",
+ if ($line =~ /^wireshark-version:\\\[\\\]=.*([\r\n]+)$/) {
+ $line = sprintf("wireshark-version:\\\[\\\]=%d.%d.%d$1",
$version_pref{"version_major"},
$version_pref{"version_minor"},
$version_pref{"version_micro"},
$contents .= $line
}
- open(RELNOTES, "> $filepath") || die "Can't write $filepath!";
- print(RELNOTES $contents);
- close(RELNOTES);
+ open(ADOC_CONF, "> $filepath") || die "Can't write $filepath!";
+ print(ADOC_CONF $contents);
+ close(ADOC_CONF);
print "$filepath has been updated.\n";
}
my $line;
my $contents = "";
my $version = "";
- my $filepath = "debian/changelog";
+ my $filepath = "$srcdir/debian/changelog";
return if ($set_version == 0);
print "$filepath has been updated.\n";
}
+# Read debian/wireshark-common.files, then write back out an updated version.
+# The libraries updated here MUST match the updates made by update_lib_releases
+# below. We should do this automatically.
+sub update_debian_wcf
+{
+ my $line;
+ my $contents = "";
+ my $version = "";
+ my $filepath = "$srcdir/debian/wireshark-common.files";
+
+ return if (!$set_version);
+
+ open(DWCF, "< $filepath") || die "Can't read $filepath!";
+ while ($line = <DWCF>) {
+ # /usr/lib/wireshark/libwireshark.so.1.1.0
+
+ if ($line =~ qr{^(/usr/lib/wireshark/lib(wireshark|wiretap).so\.\d+\.\d+\.)\d+$}) {
+ $line = sprintf("$1%d\n", $version_pref{"version_micro"});
+ }
+ $contents .= $line
+ }
+
+ open(DWCF, "> $filepath") || die "Can't write $filepath!";
+ print(DWCF $contents);
+ close(DWCF);
+ print "$filepath has been updated.\n";
+}
+
+# Read Makefile.am for each library, then write back out an updated version.
+sub update_lib_releases
+{
+ my $line;
+ my $contents = "";
+ my $version = "";
+ my $filedir;
+ my $filepath;
+
+ return if (!$set_version);
+
+ # The Libtool manual says
+ # "If the library source code has changed at all since the last
+ # update, then increment revision (‘c:r:a’ becomes ‘c:r+1:a’)."
+ # epan changes with each minor release, almost by definition. wiretap
+ # changes with *most* releases.
+ #
+ # http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
+ for $filedir ("epan", "wiretap") { # "wsutil"
+ $contents = "";
+ $filepath = $filedir . "/Makefile.am";
+ open(MAKEFILE_AM, "< $filepath") || die "Can't read $filepath!";
+ while ($line = <MAKEFILE_AM>) {
+ # libwireshark_la_LDFLAGS = -version-info 2:1:1 -export-symbols
+
+ if ($line =~ /^(lib\w+_la_LDFLAGS.*version-info\s+\d+:)\d+(:\d+.*)/) {
+ $line = sprintf("$1%d$2\n", $version_pref{"version_micro"});
+ }
+ $contents .= $line
+ }
+
+ open(MAKEFILE_AM, "> $filepath") || die "Can't write $filepath!";
+ print(MAKEFILE_AM $contents);
+ close(MAKEFILE_AM);
+ print "$filepath has been updated.\n";
+ }
+}
+
# Update distributed files that contain any version information
sub update_versioned_files
{
- &update_configure_in;
+ &update_configure_ac;
&update_config_nmake;
&update_release_notes;
&update_debian_changelog;
+ &update_debian_wcf;
+ &update_lib_releases;
}
# Print the SVN version to $version_file.
close OLDREV;
}
- if (! $set_version && ! $set_release) { return; }
+ if (! $set_svn) { return; }
if ($needs_update) {
# print "Updating $version_file so it contains:\n$svn_revision";
my $show_help = 0;
# Get our command-line args
+ # XXX - Do we need an option to undo --set-release?
GetOptions(
"help|h", \$show_help,
"get-svn|g", \$get_svn,
+ "set-svn|s", \$set_svn,
"set-version|v", \$set_version,
"set-release|r|package-version|p", \$set_release
) || pod2usage(2);
if ($show_help) { pod2usage(1); }
- if ( !( $show_help || $get_svn || $set_release ) ) {
- $set_version = 1;
+ if ( !( $show_help || $get_svn || $set_svn || $set_version || $set_release ) ) {
+ $set_svn = 1;
}
if ($#ARGV >= 0) {
if ($set_release) {
print "Generating release information\n";
} else {
- print "Clobbering release information\n";
+ print "Resetting release information\n";
$revision = 0;
$package_string = "";
}
--help, -h This help message
--get-svn, -g Print the SVN revision and source.
- --set-version, -v Set the major, minor, and micro versions.
+ --set-svn, -s Set the information in svnversion.h
+ --set-version, -v Set the major, minor, and micro versions in
+ configure.ac, config.nmake, debian/changelog,
+ and docbook/asciidoc.conf.
Resets the release information when used by
itself.
- --set-release, -r Set the release information.
+ --set-release, -r Set the release information in configure.ac
+ and config.nmake
--package-version, -p Deprecated. Same as --set-release.
-Options can be used in any combination. If none are specified B<--set-version>
+Options can be used in any combination. If none are specified B<--set-svn>
is assumed.
+
+#
+# Editor modelines - http://www.wireshark.org/tools/modelines.html
+#
+# Local variables:
+# c-basic-offset: 8
+# tab-width: 8
+# indent-tabs-mode: t
+# End:
+#
+# vi: set shiftwidth=8 tabstop=8 noexpandtab:
+# :indentSize=8:tabSize=8:noTabs=false:
+#
+#