From d7f3d277a8b20d7827278df05d6aeaaf59974300 Mon Sep 17 00:00:00 2001
From: Dominic Hargreaves <dom@earth.li>
Date: Thu, 31 Dec 2015 12:17:56 +0000
Subject: Extract the correct (Debian) version number in configure.ac

Also make clear in the web interface that this version number is from
Debian.

Patch-Name: debianize_version.diff
Forwarded: not-needed
---
 configure.ac                                  | 8 ++++----
 share/html/Admin/Tools/Config/Elements/Option | 3 +++
 share/html/Elements/Footer                    | 2 +-
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index b540d55e..7599ffa5 100755
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script
 
 dnl Setup autoconf
 AC_PREREQ([2.59])
-AC_INIT(RT, m4_esyscmd([( git describe --tags || cat ./.tag 2> /dev/null || echo "rt-5.0.EXPORTED" )| tr -d "\n"]), [rt-bugs@bestpractical.com])
+AC_INIT(RT, m4_esyscmd([( dpkg-parsechangelog -SVersion | sed -e 's/^[0-9]*://' )| tr -d "\n"]), [https://www.debian.org/Bugs/Reporting])
 AC_CONFIG_SRCDIR([lib/RT.pm])
 
 dnl Save our incant early since $@ gets overwritten by some macros.
@@ -14,11 +14,11 @@ AC_SUBST(CONFIGURE_INCANT, "$0 $@")
 
 dnl Extract RT version number components
 AC_SUBST([rt_version_major],
-	m4_bregexp(AC_PACKAGE_VERSION,[^rt-\(\w+\)\.\(\w+\)\.\(.+\)$],[\1]))
+	m4_bregexp(AC_PACKAGE_VERSION,[^\(\w+\)\.\(\w+\)\.\(.+\)$],[\1]))
 AC_SUBST([rt_version_minor],
-	m4_bregexp(AC_PACKAGE_VERSION,[^rt-\(\w+\)\.\(\w+\)\.\(.+\)$],[\2]))
+	m4_bregexp(AC_PACKAGE_VERSION,[^\(\w+\)\.\(\w+\)\.\(.+\)$],[\2]))
 AC_SUBST([rt_version_patch],
-	m4_bregexp(AC_PACKAGE_VERSION,[^rt-\(\w+\)\.\(\w+\)\.\(.+\)$],[\3]))
+	m4_bregexp(AC_PACKAGE_VERSION,[^\(\w+\)\.\(\w+\)\.\(.+\)$],[\3]))
 test "x$rt_version_major" = 'x' && rt_version_major=0
 test "x$rt_version_minor" = 'x' && rt_version_minor=0
 test "x$rt_version_patch" = 'x' && rt_version_patch=0
diff --git a/share/html/Admin/Tools/Config/Elements/Option b/share/html/Admin/Tools/Config/Elements/Option
index 17ad519f..5a629d1f 100644
--- a/share/html/Admin/Tools/Config/Elements/Option
+++ b/share/html/Admin/Tools/Config/Elements/Option
@@ -74,6 +74,9 @@ my $stringify = sub {
 };
 
 my $doc_version = $RT::VERSION;
+# Strip Debian version suffix first, since we add it as a suffix to upstream
+# version.
+$doc_version =~ s/\+dfsg-.*$//;       # 5.0.3+dfsg-1 -> 5.0.3
 $doc_version =~ s/\.\d+-\d+-g\w+$//;  # 4.4.3-1-g123 -> 4.4
 
 my $name = $option->{Name};
diff --git a/share/html/Elements/Footer b/share/html/Elements/Footer
index 9b69c944..dffb1c9c 100644
--- a/share/html/Elements/Footer
+++ b/share/html/Elements/Footer
@@ -58,7 +58,7 @@
 %     if ($m->{'rt_base_time'}) {
         <span id="time"><&|/l&>Time to display</&>: <%Time::HiRes::tv_interval( $m->{'rt_base_time'} )%> -</span>
 %     }
-      <span><&|/l_unsafe, $RT::VERSION, &>RT Version [_1]</&></span>
+      <span><&|/l_unsafe, $RT::VERSION . ' (Debian)', &>RT Version [_1]</&></span>
     </p>
   </div>
   <div class="col-<% $cols %>">
