Debian Bug report logs - #41642
debhelper: dh_diversions script?

version graph

Package: debhelper; Maintainer for debhelper is Debhelper Maintainers <debhelper-devel@lists.alioth.debian.org>; Source for debhelper is src:debhelper (PTS, buildd, popcon).

Reported by: Julian Gilbey <jdg@debian.org>

Date: Mon, 19 Jul 1999 22:03:00 UTC

Severity: wishlist

Tags: patch

Merged with 384807, 444029

Found in version 2.0.14

Reply or subscribe to this bug.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Joey Hess <joeyh@master.debian.org>:
Bug#41642; Package debhelper. (full text, mbox, link).


Acknowledgement sent to Julian Gilbey <J.D.Gilbey@qmw.ac.uk>:
New bug report received and forwarded. Copy sent to Joey Hess <joeyh@master.debian.org>. (full text, mbox, link).


Message #5 received at submit@bugs.debian.org (full text, mbox, reply):

From: Julian Gilbey <J.D.Gilbey@qmw.ac.uk>
To: submit@bugs.debian.org ( Debian bug reports)
Subject: debhelper: dh_diversions script?
Date: Mon, 19 Jul 1999 13:54:37 +0100 (BST)
Package: debhelper
Version: 2.0.14
Severity: wishlist

It might be nice to have a dh_diversions script to automatically write
any wanted dpkg-divert commands for the preinst/postrm scripts.

   Julian

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  Julian Gilbey, Dept of Maths, QMW, Univ. of London. J.D.Gilbey@qmw.ac.uk
        Debian GNU/Linux Developer,  see http://www.debian.org/~jdg


Bug closed, send any further explanations to Julian Gilbey <J.D.Gilbey@qmw.ac.uk> Request was from Julian Gilbey <jdg@debian.org> to control@bugs.debian.org. (full text, mbox, link).


Bug reopened, originator set to Julian Gilbey <jdg@debian.org>. Request was from Julian Gilbey <jdg@debian.org> to control@bugs.debian.org. (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org:
Bug#41642; Package debhelper. (full text, mbox, link).


Acknowledgement sent to Joey Hess <joeyh@debian.org>:
Extra info received and forwarded to list. (full text, mbox, link).


Message #14 received at 41642@bugs.debian.org (full text, mbox, reply):

From: Joey Hess <joeyh@debian.org>
To: 41642@bugs.debian.org
Subject: dh_diversions
Date: Thu, 21 Aug 2003 17:56:15 -0400
[Message part 1 (text/plain, inline)]
The problem with this idea is much the same as the problem with
a dh_alternatives: dpkg-divert and update-alternatives are complicated
and have many options that might need to be passed in, and adding a
debhelper command just adds a layer of complexity with no real gain.

Also of course, use of diversions should not be encouraged..

-- 
see shy jo
[Message part 2 (application/pgp-signature, inline)]

Information forwarded to debian-bugs-dist@lists.debian.org:
Bug#41642; Package debhelper. (full text, mbox, link).


Acknowledgement sent to Joey Hess <joeyh@debian.org>:
Extra info received and forwarded to list. (full text, mbox, link).


Message #19 received at 41642@bugs.debian.org (full text, mbox, reply):

From: Joey Hess <joeyh@debian.org>
To: 41642@bugs.debian.org
Subject: FWD: Re: Patch Submission for Debhelper
Date: Mon, 20 Aug 2007 15:13:13 -0400
[Message part 1 (text/plain, inline)]
----- Forwarded message from "Matt T. Proud" <khanreaper@nerp.net> -----

From: "Matt T. Proud" <khanreaper@nerp.net>
Date: Sat, 26 Aug 2006 21:22:23 -0500 (CDT)
To: Joey Hess <joey@kitenet.net>
Subject: Re: Patch Submission for Debhelper
Reply-To: khanreaper@nerp.net
User-Agent: SquirrelMail/1.4.5

Joey,

I appreciate your reviewing what I have written here; it makes a
contributor feel worthwhile.

Regarding the split between the calls in postinst and preinst, it should
be possible to modify what I have submitted by telling dh_diverts (Or was
it dh_divert?) to look for the presence of another file postinst-diverts,
or something to that effect. If you would like, I could modify my patch to
be more extensible against all of these {post,pre}{inst,rm} possibilities.
Would you like that? Out of curiosity, what would "$1" be under postinst
when the dpkg-divert would be called? I would guess configure. I have to
admit that I do not use postinst as much as I do other maintenance
scripts. If I were to make my patch more extensible, could it be a
candidate for inclusion?

Again, thank you for taking your time.

Best,

Matt

> Matt T. Proud wrote:
>> Please let me know what you think. If it seems unlikely for you to
>> incorporate this, please tell me; but it would certainly make my life a
>> lot easier if you were to, as that would remove my need for maintaining
>> a
>> custom , in-house version of Debhelper to use with my organization's
>> development tool set.
>
> Thanks for the contribution. I'm suprised noone has filed a bug before
> asking for diversion support in debhelper.
>
> The only problem I can see is that the choice to run dpkg-divert in the
> preinst seems a bit arbitrary. About half the packages using dpkg-divert
> do use the preinst, the other half add the diversion in the postinst.
> I'm not sure if there's one choice that works well in all situations.
>
> --
> see shy jo
>



----- End forwarded message -----

-- 
see shy jo
[signature.asc (application/pgp-signature, inline)]

Information forwarded to debian-bugs-dist@lists.debian.org:
Bug#41642; Package debhelper. (full text, mbox, link).


Acknowledgement sent to Joey Hess <joeyh@debian.org>:
Extra info received and forwarded to list. (full text, mbox, link).


Message #24 received at 41642@bugs.debian.org (full text, mbox, reply):

From: Joey Hess <joeyh@debian.org>
To: 41642@bugs.debian.org
Subject: FWD: New Debhelper patch
Date: Mon, 20 Aug 2007 15:13:26 -0400
[Message part 1 (text/plain, inline)]
----- Forwarded message from "Matt T. Proud" <khanreaper@nerp.net> -----

From: "Matt T. Proud" <khanreaper@nerp.net>
Date: Sun, 27 Aug 2006 02:01:51 -0500 (CDT)
To: joey@kitenet.net
Cc: khanreaper@nerp.net
Subject: New Debhelper patch
Reply-To: khanreaper@nerp.net
User-Agent: SquirrelMail/1.4.5

Joey,

Attached is a new patch file. It supports creating diversions in
preinst::install, postinst::configure, postrm::remove, and postrm::purge.
While it is plausible for one to manipulate diversions in other areas, I
think that these are the places where we will get the most utility for the
patch.

Do keep in mind, that I have written this with the following in mind:
http://www.debian.org/doc/debian-policy/ap-pkg-diversions.html

Best,

Matt
Index: autoscripts/postinst-configure-diverts
===================================================================
--- autoscripts/postinst-configure-diverts	(revision 0)
+++ autoscripts/postinst-configure-diverts	(revision 0)
@@ -0,0 +1,3 @@
+if [ "$1" == "configure" ]; then
+	dpkg-divert --package #PACKAGE# --add --rename --divert #DIVERSION#.original #DIVERSION#
+fi
Index: autoscripts/postrm-purge-diverts
===================================================================
--- autoscripts/postrm-purge-diverts	(revision 0)
+++ autoscripts/postrm-purge-diverts	(revision 0)
@@ -0,0 +1,3 @@
+if [ "$1" == "purge" ]; then
+	dpkg-divert --package #PACKAGE#  --remove --rename --divert #DIVERSION#.original #DIVERSION#
+fi
Index: autoscripts/postrm-remove-diverts
===================================================================
--- autoscripts/postrm-remove-diverts	(revision 0)
+++ autoscripts/postrm-remove-diverts	(revision 0)
@@ -0,0 +1,3 @@
+if [ "$1" == "remove" ]; then
+	dpkg-divert --package #PACKAGE#  --remove --rename --divert #DIVERSION#.original #DIVERSION#
+fi
Index: autoscripts/preinst-install-diverts
===================================================================
--- autoscripts/preinst-install-diverts	(revision 0)
+++ autoscripts/preinst-install-diverts	(revision 0)
@@ -0,0 +1,3 @@
+if [ "$1" == "install" ]; then
+	dpkg-divert --package #PACKAGE# --add --rename --divert #DIVERSION#.original #DIVERSION#
+fi
Index: debian/changelog
===================================================================
--- debian/changelog	(revision 1939)
+++ debian/changelog	(working copy)
@@ -10,6 +10,8 @@
   * move po4a to Build-Depends as it's run in clean.
   * Add size test, which fails on any debhelper program of more than 150
     lines. This is not a joke, and 100 lines would be better.
+  * Added support for package file diversions via dh_divert from a patch by
+    Matt T. Proud <khanreaper@nerp.net>.
 
  -- Joey Hess <joeyh@debian.org>  Sun,  2 Jul 2006 18:11:49 -0400
 
Index: dh_divert
===================================================================
--- dh_divert	(revision 0)
+++ dh_divert	(revision 0)
@@ -0,0 +1,100 @@
+#!/usr/bin/perl -w
+
+=head1 NAME
+
+dh_divert - Create and manage package file diversions.
+
+=cut
+
+use strict;
+use Debian::Debhelper::Dh_Lib;
+
+=head1 SYNOPSIS
+
+B<dh_divert> [S<I<debhelper options>>] [B<-p<package>>]
+
+=head1 DESCRIPTION
+
+dh_divert is a debhelper program that manages package file diversions.
+It works by using dpkg-divert with real package files.
+
+Depending upon when a file is to be diverted, there are several places a file
+should be listed in order to notify dh_divert when this should occur. Files that
+will need to be diverted prior to package installation should be noted in the 
+debian/install-diverts file. Files that will have their contents diverted upon
+package configuration in the post-installation phase should be listed in the
+debian/configure-diverts file.
+
+Likewise, depending upon when a diversion is to be removed, there are several
+possibilities. For files that will have their contents undiverted upon package 
+removal, place a list of these files in the debian/remove-diverts file. Packages
+that want removal of a diversion upon purging will want their files placed in
+the debian/purge-diverts file.
+
+dh_divert is subject to the same limitations of dpkg-divert, so it will not work
+with directories.
+
+=cut
+
+init();
+
+foreach my $package (@{$dh{DOPACKAGES}}) {
+	my $tmp=tmpdir($package);
+
+	my $installfile=pkgfile($package,"install-diverts");
+	my $configurediverts=pkgfile($package,"configure-diverts");
+	my $removefile=pkgfile($package,"remove-diverts");
+	my $purgefile=pkgfile($package,"purge-diverts");
+	
+	my @installdiverts;
+	if ($installfile) {
+		@installdiverts=filearray($installfile, '.');
+	}
+	
+	my @configurediverts;
+	if ($configurefile) {
+		@configurediverts=filearray($configurefile, '.');
+	}
+
+	my @removediverts;
+	if ($removefile) {
+		@removediverts=filearray($removefile, '.');
+	}
+
+	my @purgediverts;
+	if ($purgefile) {
+		@purgediverts=filearray($purgefile, '.');
+	}
+
+# I haven't implemented command line arguments yet.
+	#if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
+	#	push @diversions, @ARGV; 
+	#}
+	
+	if ( ! $dh{NOSCRIPTS}) {
+		foreach (@installdiverts) {
+			autoscript($package,"preinst", "preinst-install-diverts", "s:#DIVERSION#:$_:;:#PACKAGE#:$package:");
+		}
+		foreach (@configurediverts) {
+			autoscript($package,"postinst", "postinst-configure-diverts", "s:#DIVERSION#:$_:;:#PACKAGE#:$package:");
+		}
+		foreach (@removediverts) {
+			autoscript($package,"postrm", "postrm-remove-diverts", "s:#DIVERSION#:$_:;:#PACKAGE#:$package:");
+		}
+		foreach (@purgediverts) {
+			autoscript($package,"postrm", "postrm-purge-diverts","s:#DIVERSION#:$_:;:#PACKAGE#:$package:");
+		}
+	}
+}
+
+=head1 SEE ALSO
+
+L<debhelper> L<dpkg-divert>
+
+This program is a part of debhelper.
+
+=head1 AUTHOR
+
+Matt T. Proud <khanreaper@nerp.net>
+
+=cut

----- End forwarded message -----

-- 
see shy jo
[debhelper.patch (text/x-diff, attachment)]
[signature.asc (application/pgp-signature, inline)]

Information forwarded to debian-bugs-dist@lists.debian.org:
Bug#41642; Package debhelper. (full text, mbox, link).


Acknowledgement sent to Joey Hess <joeyh@debian.org>:
Extra info received and forwarded to list. (full text, mbox, link).


Message #29 received at 41642@bugs.debian.org (full text, mbox, reply):

From: Joey Hess <joeyh@debian.org>
To: 41642@bugs.debian.org
Subject: FWD: Newer Debhelper Patch
Date: Mon, 20 Aug 2007 15:13:43 -0400
[Message part 1 (text/plain, inline)]
----- Forwarded message from "Matt T. Proud" <khanreaper@nerp.net> -----

From: "Matt T. Proud" <khanreaper@nerp.net>
Date: Sun, 27 Aug 2006 13:14:34 -0500
To: joey@kitenet.net
Subject: Newer Debhelper Patch
User-Agent: Thunderbird 1.5.0.5 (X11/20060728)

Joey,

I apologize for spamming the inbox, but here is an improved patch.
Apparently some things did not work as expected.

Best,

Matt

Index: autoscripts/postinst-configure-diverts
===================================================================
--- autoscripts/postinst-configure-diverts	(revision 0)
+++ autoscripts/postinst-configure-diverts	(revision 0)
@@ -0,0 +1,3 @@
+if [ "$1" == "configure" ]; then
+	dpkg-divert --package #PACKAGE# --add --rename --divert #DIVERSION#.original #DIVERSION#
+fi
Index: autoscripts/postrm-purge-diverts
===================================================================
--- autoscripts/postrm-purge-diverts	(revision 0)
+++ autoscripts/postrm-purge-diverts	(revision 0)
@@ -0,0 +1,3 @@
+if [ "$1" == "purge" ]; then
+	dpkg-divert --package #PACKAGE#  --remove --rename --divert #DIVERSION#.original #DIVERSION#
+fi
Index: autoscripts/postrm-remove-diverts
===================================================================
--- autoscripts/postrm-remove-diverts	(revision 0)
+++ autoscripts/postrm-remove-diverts	(revision 0)
@@ -0,0 +1,3 @@
+if [ "$1" == "remove" ]; then
+	dpkg-divert --package #PACKAGE#  --remove --rename --divert #DIVERSION#.original #DIVERSION#
+fi
Index: autoscripts/preinst-install-diverts
===================================================================
--- autoscripts/preinst-install-diverts	(revision 0)
+++ autoscripts/preinst-install-diverts	(revision 0)
@@ -0,0 +1,3 @@
+if [ "$1" == "install" ]; then
+	dpkg-divert --package #PACKAGE# --add --rename --divert #DIVERSION#.original #DIVERSION#
+fi
Index: debian/changelog
===================================================================
--- debian/changelog	(revision 1939)
+++ debian/changelog	(working copy)
@@ -10,6 +10,8 @@
   * move po4a to Build-Depends as it's run in clean.
   * Add size test, which fails on any debhelper program of more than 150
     lines. This is not a joke, and 100 lines would be better.
+  * Added support for package file diversions via dh_divert from a patch by
+    Matt T. Proud <khanreaper@nerp.net>.
 
  -- Joey Hess <joeyh@debian.org>  Sun,  2 Jul 2006 18:11:49 -0400
 
Index: dh_divert
===================================================================
--- dh_divert	(revision 0)
+++ dh_divert	(revision 0)
@@ -0,0 +1,100 @@
+#!/usr/bin/perl -w
+
+=head1 NAME
+
+dh_divert - Create and manage package file diversions.
+
+=cut
+
+use strict;
+use Debian::Debhelper::Dh_Lib;
+
+=head1 SYNOPSIS
+
+B<dh_divert> [S<I<debhelper options>>] [B<-p<package>>]
+
+=head1 DESCRIPTION
+
+dh_divert is a debhelper program that manages package file diversions.
+It works by using dpkg-divert with real package files.
+
+Depending upon when a file is to be diverted, there are several places a file
+should be listed in order to notify dh_divert when this should occur. Files that
+will need to be diverted prior to package installation should be noted in the 
+debian/install-diverts file. Files that will have their contents diverted upon
+package configuration in the post-installation phase should be listed in the
+debian/configure-diverts file.
+
+Likewise, depending upon when a diversion is to be removed, there are several
+possibilities. For files that will have their contents undiverted upon package 
+removal, place a list of these files in the debian/remove-diverts file. Packages
+that want removal of a diversion upon purging will want their files placed in
+the debian/purge-diverts file.
+
+dh_divert is subject to the same limitations of dpkg-divert, so it will not work
+with directories.
+
+=cut
+
+init();
+
+foreach my $package (@{$dh{DOPACKAGES}}) {
+	my $tmp=tmpdir($package);
+
+	my $installfile=pkgfile($package,"install-diverts");
+	my $configurefile=pkgfile($package,"configure-diverts");
+	my $removefile=pkgfile($package,"remove-diverts");
+	my $purgefile=pkgfile($package,"purge-diverts");
+	
+	my @installdiverts;
+	if ($installfile) {
+		@installdiverts=filearray($installfile, '.');
+	}
+	
+	my @configurediverts;
+	if ($configurefile) {
+		@configurediverts=filearray($configurefile, '.');
+	}
+
+	my @removediverts;
+	if ($removefile) {
+		@removediverts=filearray($removefile, '.');
+	}
+
+	my @purgediverts;
+	if ($purgefile) {
+		@purgediverts=filearray($purgefile, '.');
+	}
+
+# I haven't implemented command line arguments yet.
+	#if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
+	#	push @diversions, @ARGV; 
+	#}
+	
+	if ( ! $dh{NOSCRIPTS}) {
+		foreach (@installdiverts) {
+			autoscript($package,"preinst", "preinst-install-diverts", "s%#DIVERSION#%$_%g; s%#PACKAGE#%$package%g");
+		}
+		foreach (@configurediverts) {
+			autoscript($package,"postinst", "postinst-configure-diverts", "s%#DIVERSION#%$_%g; s%#PACKAGE#%$package%g");
+		}
+		foreach (@removediverts) {
+			autoscript($package,"postrm", "postrm-remove-diverts", "s%#DIVERSION#%$_%g; s%#PACKAGE#%$package%g");
+		}
+		foreach (@purgediverts) {
+			autoscript($package,"postrm", "postrm-purge-diverts","s%#DIVERSION#%$_%g; s%#PACKAGE#%$package%g");
+		}
+	}
+}
+
+=head1 SEE ALSO
+
+L<debhelper> L<dpkg-divert>
+
+This program is a part of debhelper.
+
+=head1 AUTHOR
+
+Matt T. Proud <khanreaper@nerp.net>
+
+=cut


----- End forwarded message -----

-- 
see shy jo
[debhelper.patch (text/x-diff, attachment)]
[signature.asc (application/pgp-signature, inline)]

Tags added: patch Request was from Joey Hess <joeyh@debian.org> to control@bugs.debian.org. (Mon, 20 Aug 2007 19:21:05 GMT) (full text, mbox, link).


Merged 41642 444029. Request was from Joey Hess <joeyh@debian.org> to control@bugs.debian.org. (Tue, 25 Sep 2007 16:42:04 GMT) (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, Joey Hess <joeyh@debian.org>:
Bug#41642; Package debhelper. (Thu, 25 Jun 2009 11:09:03 GMT) (full text, mbox, link).


Acknowledgement sent to Marco Amadori <amadorim@vdavda.com>:
Extra info received and forwarded to list. Copy sent to Joey Hess <joeyh@debian.org>. (Thu, 25 Jun 2009 11:09:04 GMT) (full text, mbox, link).


Message #38 received at 41642@bugs.debian.org (full text, mbox, reply):

From: Marco Amadori <amadorim@vdavda.com>
To: Joey Hess <joeyh@debian.org>
Cc: 41642@bugs.debian.org
Subject: Diversions should not be encouraged?
Date: Thu, 25 Jun 2009 12:36:29 +0200
On  Thu, 21 Aug 2003 17:56:15 -0400, Joey Hess said:

> The problem with this idea is much the same as the problem with
> a dh_alternatives: dpkg-divert and update-alternatives are complicated
> and have many options that might need to be passed in, and adding a
> debhelper command just adds a layer of complexity with no real gain.

> Also of course, use of diversions should not be encouraged..

Could you please explain better this point ?

How a package which should configure or extend another one (think of a company 
custom "config-bind*.deb" package which setup a standard dns service for 
company's servers) should do it in a polite way?

Providing directly other packages configuration files does not work, since they 
wil conflict with other package's files.

Copying files over in postinst is suboptimal since you will lose modification in 
upgrades, or duplicate dpkg's work on handling condifuration files.

Diversions in /etc seemed the right thing to do, so both are configuration files 
and dpkg will know of the diversion.

What you would suggest, for better addressing both this example use case, and 
the general use cases handled by dpkg-divert ?

-- 
ESC:wq

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.





Merged 384807 41642 444029 Request was from Niels Thykier <niels@thykier.net> to control@bugs.debian.org. (Mon, 31 Aug 2015 19:51:12 GMT) (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, Debhelper Maintainers <debhelper-devel@lists.alioth.debian.org>:
Bug#41642; Package debhelper. (Tue, 24 Jan 2017 01:18:02 GMT) (full text, mbox, link).


Acknowledgement sent to "USPS Priority Solutions" <bill.hardin@kovacslaci.com>:
Extra info received and forwarded to list. Copy sent to Debhelper Maintainers <debhelper-devel@lists.alioth.debian.org>. (Tue, 24 Jan 2017 01:18:02 GMT) (full text, mbox, link).


Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Fri Jan 5 15:37:10 2018; Machine Name: beach

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.