Subject: Bug#564917: deb-reversion: update strict versioned dependencies to match new version

From: Piotr Engelking <[email-masked]>
Date: Tue, 12 Jan 2010 19:28:52 +0100

Package: devscripts
Version: 2.10.61
Severity: wishlist
Tags: patch

Please consider adding an option to update versioned dependencies to
match the new version in case the package depends on another package
with exactly the same version. It would be useful for preserving strict
versioned dependencies between binary packages generated from the same
source.

The attached patch adds such an option and accompanying documentation.

-- Package-specific info:

--- /etc/devscripts.conf ---

--- ~/.devscripts ---
Not present

-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (500, 'testing'), (400, 'unstable'), (300, 'experimental')
Architecture: i386 (x86_64)

Kernel: Linux 2.6.32 (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=pl_PL.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages devscripts depends on:
ii  dpkg-dev                      1.15.3.1   Debian package development tools
ii  libc6                         2.10.2-2   GNU C Library: Shared libraries
ii  perl                          5.10.1-8   Larry Wall's Practical Extraction

Versions of packages devscripts recommends:
ii  at                 3.1.12-1              Delayed job execution and batch pr
ii  bsd-mailx [mailx]  8.1.2-0.20090911cvs-2 simple mail user agent
ii  bzr                2.0.3-1               easy to use distributed version co
ii  curl               7.19.7-1              Get a file from an HTTP, HTTPS or
ii  cvs                1:1.12.13-12          Concurrent Versions System
ii  dctrl-tools        2.14                  Command-line tools to process Debi
ii  debian-keyring [de 2009.11.04            GnuPG (and obsolete PGP) keys of D
pn  dput | dupload     <none>                (no description available)
ii  elinks [www-browse 0.12~pre5-1+b1        advanced text-mode WWW browser
ii  epiphany-browser [ 2.29.3-1              Intuitive GNOME web browser
pn  equivs             <none>                (no description available)
ii  fakeroot           1.14.4-1              Gives a fake root environment
ii  git-core           1:1.6.5-1             fast, scalable, distributed revisi
ii  gnupg              1.4.10-2              GNU privacy guard - a free PGP rep
ii  iceweasel [www-bro 3.5.6-1               lightweight web browser based on M
pn  libauthen-sasl-per <none>                (no description available)
pn  libcrypt-ssleay-pe <none>                (no description available)
ii  libparse-debcontro 2.005-2               Easy OO parsing of Debian control-
pn  libsoap-lite-perl  <none>                (no description available)
ii  libterm-size-perl  0.2-4+b1              Perl extension for retrieving term
ii  libtimedate-perl   1.1900-1              Time and date functions for Perl
ii  liburi-perl        1.50-1                module to manipulate and access UR
ii  libwww-perl        5.834-1               Perl HTTP/WWW client/server librar
pn  libyaml-syck-perl  <none>                (no description available)
ii  links [www-browser 2.2-1+b1              Web browser running in text mode
ii  links2 [www-browse 2.2-1+b1              Web browser running in both graphi
ii  lintian            2.2.18                Debian package checker
ii  lsb-release        3.2-23                Linux Standard Base version report
ii  lynx-cur [www-brow 2.8.8dev.2-1          Text-mode WWW Browser with NLS sup
ii  lzma               4.43-14               Compression method of 7z format in
ii  man-db             2.5.6-5               on-line manual pager
ii  mercurial          1.4.1-1               scalable distributed version contr
ii  openssh-client [ss 1:5.1p1-8             secure shell client, an rlogin/rsh
ii  opera [www-browser 10.10.4742.gcc4.qt3   The Opera Web Browser
ii  patch              2.6-2                 Apply a diff file to an original
ii  patchutils         0.3.1-2               Utilities to work with patches
ii  sensible-utils     0.0.2                 Utilities for sensible alternative
ii  strace             4.5.19-1              A system call tracer
ii  subversion         1.6.3dfsg-1           Advanced version control system
ii  unzip              6.0-1                 De-archiver for .zip files
ii  w3m [www-browser]  0.5.2-2.1             WWW browsable pager with excellent
ii  wdiff              0.5-19                Compares two files word by word
ii  wget               1.12-1.1              retrieves files from the web

Versions of packages devscripts suggests:
ii  build-essential               11.4       Informational list of build-essent
pn  cvs-buildpackage              <none>     (no description available)
pn  devscripts-el                 <none>     (no description available)
ii  gnuplot                       4.2.6-1    A command-line driven interactive
ii  libfile-desktopentry-perl     0.04-2     Perl module to handle freedesktop
pn  libnet-smtp-ssl-perl          <none>     (no description available)
pn  mutt                          <none>     (no description available)
pn  svn-buildpackage              <none>     (no description available)
ii  w3m                           0.5.2-2.1  WWW browsable pager with excellent

-- no debconf information
diff -ur devscripts-2.10.61/scripts/deb-reversion.dbk devscripts/scripts/deb-reversion.dbk
--- devscripts-2.10.61/scripts/deb-reversion.dbk	2010-01-03 04:20:42.000000000 +0100
+++ devscripts/scripts/deb-reversion.dbk	2010-01-12 18:44:23.618261523 +0100
@@ -166,6 +166,18 @@
       </varlistentry>
 
       <varlistentry>
+	<term><option>-d</option></term>
+	<term><option>--update-dependencies</option></term>
+	<listitem>
+	  <para>
+            If the package depends on another package with exactly the
+            same version, update the dependency to match the new
+            version number.
+          </para>
+	</listitem>
+      </varlistentry>
+
+      <varlistentry>
 	<term><option>-s</option> <replaceable class="parameter">string</replaceable></term>
 	<term><option>--string</option> <replaceable class="parameter">string</replaceable></term>
 	<listitem>
@@ -277,7 +289,8 @@
       it works fine in most cases, it may just not in yours. Especially,
       please consider that it changes binary packages (only!) and hence can
       break strict versioned dependencies between binary packages generated
-      from the same source. </para>
+      from the same source (in which case <option>-d</option> may help).
+    </para>
 
     <para>
       You are using this tool at your own risk and I shall not shed a tear if
diff -ur devscripts-2.10.61/scripts/deb-reversion.sh devscripts/scripts/deb-reversion.sh
--- devscripts-2.10.61/scripts/deb-reversion.sh	2010-01-03 04:20:42.000000000 +0100
+++ devscripts/scripts/deb-reversion.sh	2010-01-12 18:19:54.628811670 +0100
@@ -39,6 +39,7 @@
 	-v ver|--new-version=ver & use this as new version number
 	-o old|--old-version=ver & calculate new version number based on this old one
 	-c|--calculate-only & only calculate (and print) the augmented version
+	-d|--update-dependencies & update strict versioned dependencies
 	-s str|--string=str & append this string instead of '$VERSTR' to
 	                    & calculate new version number
 	-k script|--hook=script & call this script before repacking
@@ -61,11 +62,12 @@
 }
 
 CURDIR="$(pwd)"
-SHORTOPTS=hVo:v:ck:Ds:b
-LONGOPTS=help,version,old-version:new-version:,calculate-only,hook:,debug,string:,force-bad-version
+SHORTOPTS=hVo:v:cdk:Ds:b
+LONGOPTS=help,version,old-version:new-version:,calculate-only,update-dependencies,hook:,debug,string:,force-bad-version
 set -- $(getopt -s bash -o $SHORTOPTS -l $LONGOPTS --n $PROGNAME -- "$@")
 
 CALCULATE=0
+DEPENDENCIES=0
 DPKGDEB_DEBUG=
 DEB=
 DCH_OPTIONS=
@@ -83,6 +85,7 @@
     -v|--new-version) OPT_STATE=SET_NEW_VERSION;;
     -o|--old-version) OPT_STATE=SET_OLD_VERSION;;
     -c|--calculate-only|--print-only) CALCULATE=1;;
+    -d|--update-dependencies) DEPENDENCIES=1;;
     -s|--string) OPT_STATE=SET_STRING;;
     -k|--hook) OPT_STATE=SET_HOOK;;
     -D|--debug) DPKGDEB_DEBUG=--debug;;
@@ -181,6 +184,10 @@
   call_hook
   gzip -9 -c debian/changelog >| $LOGFILE
   sed -i -e "s,^Version: .*,Version: $VERSION," DEBIAN/control
+  if [ $DEPENDENCIES -eq 1 ]; then
+    ESC_OLD_VERSION=$(echo "$OLD_VERSION" | sed -e 's,\.,\\&,g')
+    sed -i -e "/^Depends: / s,(= $ESC_OLD_VERSION),(= $VERSION),g" DEBIAN/control
+  fi
   rm -rf debian
 }