Convert make-version.pl and the associated cvsversion.h and CVSVERSION
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 15 Jul 2004 21:09:33 +0000 (21:09 +0000)
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 15 Jul 2004 21:09:33 +0000 (21:09 +0000)
definition to Subversion.  "svn info" prints out the last changed date
of the repository, so we don't have to go hunting through "CVS/Entries"
files anymore.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@11379 f5534014-38df-0310-8fa8-9805f1628bb7

Makefile.am
Makefile.common
Makefile.nmake
gtk/about_dlg.c
gtk/main.c
make-version.pl
mergecap.c
tethereal.c

index 599b1bdc6b0ad2fdc1af203ab1cb26a87f35957a..d8a7f41a41c3d48e96ea5ef636b9f16b7734d2c3 100644 (file)
@@ -288,7 +288,7 @@ AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/wiretap
 # FORCE is the portable version of .PHONY
 FORCE:
 
-cvsversion.h: FORCE
+svnversion.h: FORCE
        $(PERL) $(srcdir)/make-version.pl
 
 #
@@ -364,7 +364,7 @@ dftest_LDADD = \
 dftest_LDFLAGS = -export-dynamic
 
 CLEANFILES =   \
-       cvsversion.h \
+       svnversion.h \
        @rdps_bin@ \
        idl2eth
 
index 0b6a5dea8445588e43ff56ea4d319eef6c826266..0ccb1a9e4904c8e9cb0ff3969572494315f53e64 100644 (file)
@@ -262,7 +262,7 @@ DISSECTOR_SUPPORT_INCLUDES =        \
 
 # "BUILT_SOURCES" are built before any "make all" or "make check" targets.
 BUILT_SOURCES =                \
-       cvsversion.h \
+       svnversion.h \
        ps.c
 
 # sources common for ethereal and tethereal
@@ -379,7 +379,7 @@ text2pcap_SOURCES = \
 mergecap_SOURCES = \
        mergecap.c \
        merge.c \
-       cvsversion.h
+       svnversion.h
 
 # editcap specifics
 editcap_SOURCES = \
index 05b3edb4de187cfebeef2db9df4ff765916b2cd0..926e86ea27cb561499a2f5e3437e59485f285f61 100644 (file)
@@ -30,7 +30,7 @@ include Makefile.common
 include epan\Makefile.common
 
 BUILT_SOURCES =        $(BUILT_SOURCES) \
-       cvsversion.h
+       svnversion.h
 
 DISSECTOR_SRC = $(DISSECTOR_SRC:../=)
 DISSECTOR_OBJECTS = $(DISSECTOR_SRC:.c=.obj)
@@ -144,7 +144,7 @@ wiretap\wiretap-$(WTAP_VERSION).lib: wiretap
 !IFNDEF GTK1_DIR
 ethereal.exe   : 
 !ELSE
-ethereal.exe   : config.h cvsversion.h $(ethereal_OBJECTS) $(EXTRA_OBJECTS) epan gtk image\ethereal.res wiretap\wiretap-$(WTAP_VERSION).lib gtk\libui.lib dissectors.lib plugins
+ethereal.exe   : config.h svnversion.h $(ethereal_OBJECTS) $(EXTRA_OBJECTS) epan gtk image\ethereal.res wiretap\wiretap-$(WTAP_VERSION).lib gtk\libui.lib dissectors.lib plugins
        @echo Linking $@
        $(LINK) @<<
                /OUT:ethereal.exe $(guiflags) $(guilibsdll) $(LDFLAGS) /SUBSYSTEM:windows $(ethereal_LIBS) $(GTK1_LIBS) gtk\libui.lib $(ethereal_OBJECTS) $(EXTRA_OBJECTS) image\ethereal.res
@@ -154,14 +154,14 @@ ethereal.exe      : config.h cvsversion.h $(ethereal_OBJECTS) $(EXTRA_OBJECTS) epan g
 !IFNDEF GTK2_DIR
 ethereal-gtk2.exe      : 
 !ELSE
-ethereal-gtk2.exe      : config.h cvsversion.h $(ethereal_OBJECTS) $(EXTRA_OBJECTS) epan gtk2 image\ethereal.res wiretap\wiretap-$(WTAP_VERSION).lib gtk2.tmp\libui.lib dissectors.lib plugins
+ethereal-gtk2.exe      : config.h svnversion.h $(ethereal_OBJECTS) $(EXTRA_OBJECTS) epan gtk2 image\ethereal.res wiretap\wiretap-$(WTAP_VERSION).lib gtk2.tmp\libui.lib dissectors.lib plugins
        @echo Linking $@
        $(LINK) @<<
                /OUT:ethereal-gtk2.exe $(guiflags) $(guilibsdll) $(LDFLAGS) /SUBSYSTEM:windows $(ethereal_LIBS) $(GTK2_LIBS) gtk2.tmp\libui.lib $(ethereal_OBJECTS) $(EXTRA_OBJECTS) image\ethereal.res
 <<
 !ENDIF
 
-tethereal.exe  : config.h cvsversion.h $(tethereal_OBJECTS) $(EXTRA_OBJECTS) epan image\tethereal.res wiretap\wiretap-$(WTAP_VERSION).lib dissectors.lib plugins
+tethereal.exe  : config.h svnversion.h $(tethereal_OBJECTS) $(EXTRA_OBJECTS) epan image\tethereal.res wiretap\wiretap-$(WTAP_VERSION).lib dissectors.lib plugins
        @echo Linking $@
        $(LINK) @<<
                /OUT:tethereal.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console $(tethereal_LIBS) $(tethereal_OBJECTS) $(EXTRA_OBJECTS) image\tethereal.res
@@ -173,7 +173,7 @@ editcap.exe : config.h editcap.obj getopt.obj wiretap\wiretap-$(WTAP_VERSION).li
                /OUT:editcap.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console editcap.obj getopt.obj $(editcap_LIBS) image\editcap.res
 <<
 
-mergecap.exe   : config.h cvsversion.h mergecap.obj merge.obj getopt.obj wiretap\wiretap-$(WTAP_VERSION).lib image\mergecap.res
+mergecap.exe   : config.h svnversion.h mergecap.obj merge.obj getopt.obj wiretap\wiretap-$(WTAP_VERSION).lib image\mergecap.res
        @echo Linking $@
        $(LINK) @<<
                /OUT:mergecap.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console mergecap.obj merge.obj getopt.obj $(mergecap_LIBS) image\mergecap.res
@@ -217,7 +217,7 @@ ps.c        : rdps.exe print.ps
 #
 # Build the version string
 #
-cvsversion.h:
+svnversion.h:
        $(PERL) make-version.pl
 
 #
@@ -346,13 +346,13 @@ wiretap::
        $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
        cd ..
 
-gtk:: help config.h cvsversion.h AUTHORS-SHORT doxygen
+gtk:: help config.h svnversion.h AUTHORS-SHORT doxygen
        cd gtk
        $(MAKE) /$(MAKEFLAGS) /f Makefile.nmake GTK_CFLAGS="$(GTK1_CFLAGS)" GTK_LIBS="$(GTK1_LIBS)" libui.lib
        cd ..
 
 # copy all required files to gtk2.tmp (but only when newer than existing) and compile in that dir
-gtk2:: help config.h cvsversion.h AUTHORS-SHORT
+gtk2:: help config.h svnversion.h AUTHORS-SHORT
        if not exist gtk2.tmp mkdir gtk2.tmp
        cd gtk
        cp --update --preserve Makefile.* *.c *.h ..\gtk2.tmp
index 94783d2512569762ff1913e8f33b34f0ed7ce146..4c99412519b1b9173154c9a013d7e87e8c7860da 100644 (file)
@@ -41,7 +41,7 @@
 #endif
 #include "webbrowser.h"
 
-#include "cvsversion.h"
+#include "svnversion.h"
 
 #include "../image/eicon3d64.xpm"
 #include "gtkglobals.h"
@@ -156,8 +156,8 @@ about_ethereal_page_new(void)
   about_ethereal(top_level, main_vb, title);
 
   msg_label = gtk_label_new("Version " VERSION
-#ifdef CVSVERSION
-          " (" CVSVERSION ")"
+#ifdef SVNVERSION
+          " (" SVNVERSION ")"
 #endif
           " (C) 1998-2004 Gerald Combs <gerald@ethereal.com>\n\n");
   gtk_container_add(GTK_CONTAINER(main_vb), msg_label);
index cd5c8cd804cd04f3cdcb0b5b1162155cfcba814a..d0a3744d024fa1b79f920ab4402e8b0fc0840244 100644 (file)
@@ -80,7 +80,7 @@
 #include <epan/resolv.h>
 
 /* general (not GTK specific) */
-#include "cvsversion.h"
+#include "svnversion.h"
 #include "file.h"
 #include "summary.h"
 #include "filters.h"
@@ -957,8 +957,8 @@ print_usage(gboolean print_ver) {
   if (print_ver) {
     output = stdout;
     fprintf(output, "This is GNU " PACKAGE " " VERSION
-#ifdef CVSVERSION
-       " (" CVSVERSION ")"
+#ifdef SVNVERSION
+       " (" SVNVERSION ")"
 #endif
        "\n%s\n\n%s\n",
        comp_info_str->str, runtime_info_str->str);
@@ -994,8 +994,8 @@ show_version(void)
 #endif
 
   printf(PACKAGE " " VERSION
-#ifdef CVSVERSION
-      " (" CVSVERSION ")"
+#ifdef SVNVERSION
+      " (" SVNVERSION ")"
 #endif
       "\n%s\n\n%s\n",
       comp_info_str->str, runtime_info_str->str);
index b3deda66eac40a2503da6bb4579385b7cb1f7311..58b5fd34df7ad080fc5f61ae6591524895893c11 100755 (executable)
 # Default configuration:
 #
 # enable: 1
-# format: CVS %Y%m%d%H%M%S
+# format: SVN %Y%m%d%H%M%S
 
 use strict;
 
 use Time::Local;
 use POSIX qw(strftime);
 
-my $version_file = 'cvsversion.h';
+my $version_file = 'svnversion.h';
 my $vconf_file = 'version.conf';
-my %monthnum = ( "Jan" => "0", "Feb" => "1", "Mar" => "2", "Apr" => "3",
-               "May" => "4", "Jun" => "5", "Jul" => "6", "Aug" => "7",
-               "Sep" => "8", "Oct" => "9", "Nov" => "10", "Dec" => "11" );
 my $last = 0;
-my $last_file = undef;
-my %version_pref = ("enable" => 1, "format" => "CVS %Y%m%d%H%M%S");
+my %version_pref = ("enable" => 1, "format" => "SVN %Y%m%d%H%M%S");
 
 
-# Recursively find all CVS Entries files starting from the given directory,
+# Recursively find all SVN Entries files starting from the given directory,
 # and compute the modification time of the most recently modified Entries file.
-sub find_last_CVS_Entries {
-       my $dir = shift;
-       my $d;
-
-       opendir(DIR, "$dir") || print STDERR "Can't open directory $dir ($!)\n" && next;
-       foreach $d (readdir(DIR)) {
-               if (-d "$dir/$d" && $d !~ /^\.(|.)$/) {
-                       if ($d =~ /^CVS$/) {
-                               if (-f "$dir/CVS/Entries") {
-                                       &lastentry("$dir/CVS/Entries");
-                               }
-                       } else { # Recurse in directory
-                               &find_last_CVS_Entries("$dir/$d");
-                       }
-               }
-       }
-       closedir DIR;
-}
-
-
-# Check all entries in $file. In case they are newer, update $last accordingly
-# Args: Entries file
-sub lastentry {
-       my $date;
-       my ($wdayascii, $monthascii, $day, $time, $year);
-       my $file = shift;
-       my $current;
+sub read_svn_info {
+       my $line;
 
-       open(FILE, "<$file") || print STDERR "Open $file for reading failed ($!)\n" && return 1;
-
-       while (<FILE>) {
-               chomp;
-               # Regular lines look like this: /ethereal_be.py/1.6/Fri Aug  2 22:55:19 2002//
-               next if (/^D/);
-               $date = (split(/\//, $_, 5))[3];
-               #                        Month   Day   Hour   Minute Second Year
-               next if ($date !~ /\w{3} (\w{3}) (.\d) (\d\d):(\d\d):(\d\d) (\d{4})/);
-               $current = timegm($5, $4, $3, $2, $monthnum{$1}, $6);
-
-               if ($current > $last) {
-                       $last = $current;
+       open(SVNINFO, "svn info |") || return;
+       while ($line = <SVNINFO>) {
+               if ($line =~ /^Last Changed Date: (\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/) {
+                       $last = timegm($6, $5, $4, $3, $2 - 1, $1);
                }
        }
-       close FILE;
-       return 1;
+       close SVNINFO;
 }
 
 
-# Print the CVS version to $version_file.
+# Print the SVN version to $version_file.
 # Don't change the file if it is not needed.
-sub print_cvs_version
+sub print_svn_version
 {
-       my $cvs_version;
+       my $svn_version;
        my $needs_update = 1;
 
        if ($last) {
-               $cvs_version = "#define CVSVERSION \"" . 
+               $svn_version = "#define SVNVERSION \"" . 
                        strftime($version_pref{"format"}, gmtime($last)) .
                        "\"\n";
        } else {
-               $cvs_version = "/* #define CVSVERSION \"\" */\n";
+               $svn_version = "/* #define SVNVERSION \"\" */\n";
        }
        if (open(OLDVER, "<$version_file")) {
-               if (<OLDVER> eq $cvs_version) {
+               if (<OLDVER> eq $svn_version) {
                        print "$version_file is up-to-date.\n";
                        $needs_update = 0;
                }
@@ -125,9 +86,9 @@ sub print_cvs_version
        }
 
        if ($needs_update == 1) {
-               # print "Updating $version_file so it contains:\n$cvs_version";
+               # print "Updating $version_file so it contains:\n$svn_version";
                open(VER, ">$version_file") || die ("Cannot write to $version_file ($!)\n");
-               print VER "$cvs_version";
+               print VER "$svn_version";
                close VER;
                print "$version_file has been updated.\n";
        }
@@ -155,15 +116,15 @@ sub get_config {
 
 if ($version_pref{"enable"} == 0) {
        print "Version tag disabled in $vconf_file.\n";
-} elsif (-d "./CVS") {
-       print "This is a build from CVS (or a CVS snapshot), "
-       . "CVS version tag will be computed.\n";
-       &find_last_CVS_Entries(".");
+} elsif (-d "./.svn") {
+       print "This is a build from SVN (or a SVN snapshot), "
+       . "SVN version tag will be computed.\n";
+       &read_svn_info(".");
 } else {
-       print "This is not a CVS build.\n";
+       print "This is not a SVN build.\n";
 }
 
-# Now that we've computed everything, print the CVS version to $version_file
-&print_cvs_version;
+# Now that we've computed everything, print the SVN version to $version_file
+&print_svn_version;
 
 __END__
index 6a798e4e3e0d93f79f99eb2adfd692e214dff526..88f7c732a4d51b6a81beeb6c7f0fc226e2225615 100644 (file)
@@ -31,7 +31,7 @@
 #include "getopt.h"
 #endif
 
-#include "cvsversion.h"
+#include "svnversion.h"
 #include "merge.h"
 
 #ifdef HAVE_IO_H
@@ -152,8 +152,8 @@ main(int argc, char *argv[])
 
     case 'h':
       printf("mergecap version %s"
-#ifdef CVSVERSION
-         " (" CVSVERSION ")"
+#ifdef SVNVERSION
+         " (" SVNVERSION ")"
 #endif
          "\n", VERSION);
       usage();
index 2e3a2672580e7d5d50f02dd84936dba2353b4ad0..2c1bfeb0ea458dc20d8d8646bbdaffe90bbcf739 100644 (file)
@@ -72,7 +72,7 @@
 #include "getopt.h"
 #endif
 
-#include "cvsversion.h"
+#include "svnversion.h"
 
 #include <glib.h>
 #include <epan/epan.h>
@@ -260,8 +260,8 @@ print_usage(gboolean print_ver)
   if (print_ver) {
     output = stdout;
     fprintf(output, "This is GNU t" PACKAGE " " VERSION
-#ifdef CVSVERSION
-       " (" CVSVERSION ")"
+#ifdef SVNVERSION
+       " (" SVNVERSION ")"
 #endif
         "\n (C) 1998-2004 Gerald Combs <gerald@ethereal.com>"
        "\n%s\n%s\n",
@@ -1243,8 +1243,8 @@ main(int argc, char *argv[])
        break;
       case 'v':        /* Show version and exit */
         printf("t" PACKAGE " " VERSION
-#ifdef CVSVERSION
-           " (" CVSVERSION ")"
+#ifdef SVNVERSION
+           " (" SVNVERSION ")"
 #endif
            "\n%s\n%s\n",
            comp_info_str->str, runtime_info_str->str);