[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#650701: [PATCH] Check git and debian/changelog before showing dummy version number



Source: lintian
Version: 2.5.4
Severity: wishlist

Currently Lintian has a placeholder version number ("<VERSION>") which
gets replaced at build time. However, things like the lintian.d.o
harness run from source checkouts. Without manual cleanup, they will
keep showing the dummy number.

If the version number hasn't been substituted in, this patch checks
for a more authoritative version number, first trying git-describe,
and then the debian/changelog, and finally printing "<VERSION>" only
if neither of the other two pan out.

-- System Information:
Debian Release: wheezy/sid
  APT prefers oneiric-updates
  APT policy: (500, 'oneiric-updates'), (500, 'oneiric-security'), (500, 'oneiric'), (100, 'oneiric-backports')
Architecture: amd64 (x86_64)

Kernel: Linux 3.0.0-13-generic (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages lintian depends on:
ii  binutils       2.21.53.20110810-0ubuntu5 The GNU assembler, linker and bina
ii  bzip2          1.0.5-6ubuntu1            high-quality block-sorting file co
ii  diffstat       1.54-1                    produces graph of changes introduc
ii  file           5.04-5ubuntu3             Determines file type using "magic"
ii  gettext        0.18.1.1-3ubuntu1         GNU Internationalization utilities
ii  intltool-debia 0.35.0+20060710.1         Help i18n of RFC822 compliant conf
ii  libapt-pkg-per 0.1.24build3              Perl interface to libapt-pkg
ii  libclass-acces 0.34-1                    Perl module that automatically gen
ii  libdpkg-perl   1.16.0.3ubuntu5           Dpkg perl modules
ii  libemail-valid 0.184-1                   Perl module for checking the valid
ii  libipc-run-per 0.90-1                    Perl module for running processes
ii  libparse-debia 1.2.0-1ubuntu1            parse Debian changelogs and output
ii  libtimedate-pe 1.2000-1                  collection of modules to manipulat
ii  liburi-perl    1.58-1                    module to manipulate and access UR
ii  locales        2.13+git20110622-2        common files for locale support
ii  man-db         2.6.0.2-2                 on-line manual pager
ii  patchutils     0.3.2-1                   Utilities to work with patches
ii  perl [libdiges 5.12.4-4                  Larry Wall's Practical Extraction 
ii  unzip          6.0-4ubuntu1              De-archiver for .zip files

lintian recommends no packages.

Versions of packages lintian suggests:
pn  binutils-multiarch       <none>          (no description available)
ii  dpkg-dev                 1.16.0.3ubuntu5 Debian package development tools
ii  libhtml-parser-perl      3.68-1build1    collection of modules that parse H
ii  libtext-template-perl    1.45-2          Text::Template perl module
ii  man-db                   2.6.0.2-2       on-line manual pager
ii  xz-utils                 5.0.0-2         XZ-format compression utilities

-- no debconf information
>From 4332ec8f449562df13079f0b8f408a90a0b7d1bc Mon Sep 17 00:00:00 2001
From: Evan Broder <evan@ebroder.net>
Date: Thu, 1 Dec 2011 20:59:57 -0800
Subject: [PATCH] Check git and debian/changelog before showing dummy version
 number

This should ensure that lintian --version prints out something
reasonable if it's run from a source tree.

Signed-off-by: Evan Broder <evan@ebroder.net>
---
 debian/rules     |    2 +-
 frontend/lintian |   15 ++++++++++++++-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/debian/rules b/debian/rules
index feaaf11..a1aafb9 100755
--- a/debian/rules
+++ b/debian/rules
@@ -97,7 +97,7 @@ binary-indep: $(neededfiles) build
 
 	dh_install
 # some manual work
-	sed -i 's/<VERSION>/$(VER)/' $(tmp)/usr/bin/lintian
+	sed -i 's/my $$LINTIAN_VERSION = ""/my $$LINTIAN_VERSION = "$(VER)"/' $(tmp)/usr/bin/lintian
 	install -m 644 doc/lintianrc.example $(tmp)/etc/lintianrc
 	dh_installdocs
 	dh_installchangelogs
diff --git a/frontend/lintian b/frontend/lintian
index 8e2b64c..f054618 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -26,6 +26,9 @@ use strict;
 use warnings;
 
 use Getopt::Long;
+use File::Basename;
+use IPC::Run;
+use Parse::DebianChangelog;
 
 # }}}
 
@@ -73,7 +76,17 @@ qw(
 ### "Normal" application variables
 
 # Version number - Is replaced during build with sed, see d/rules
-my $LINTIAN_VERSION = '<VERSION>';      #External Version number
+my $LINTIAN_VERSION = "";      #External Version number
+if ( $LINTIAN_VERSION eq '' && -d dirname(__FILE__) . "/../.git" ) {
+    IPC::Run::run ["git", "--git-dir=" . dirname(__FILE__) . "/../.git", "describe"], \
+        undef, \$LINTIAN_VERSION;
+    chomp $LINTIAN_VERSION;
+}
+if ( $LINTIAN_VERSION eq '' && -f dirname(__FILE__) . "/../debian/changelog" ) {
+    my $changelog = Parse::DebianChangelog->init({ infile => dirname(__FILE__) . "/../debian/changelog" });
+    $LINTIAN_VERSION = $changelog->dpkg()->{'Version'} if $changelog;
+}
+$LINTIAN_VERSION = '<VERSION>' if $LINTIAN_VERSION eq '';
 my $BANNER = "Lintian v$LINTIAN_VERSION"; #Version Banner - text form
 
 # Variables used to record commandline options
-- 
1.7.5.4


Reply to: