Package: debhelper

Recording this in the BTS so it doesn't get lost.

----- Forwarded message from "Matt T. Proud" <[EMAIL PROTECTED]> -----

From: "Matt T. Proud" <[EMAIL PROTECTED]>
Date: Sat, 26 Aug 2006 12:56:24 -0500 (CDT)
To: [EMAIL PROTECTED], [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED], [EMAIL PROTECTED]
Subject: Patch Submission for Debhelper
Reply-To: [EMAIL PROTECTED]
User-Agent: SquirrelMail/1.4.5

Hello Joey,

I have taken a liking to your Debhelper build tools, so I wrote a little
patch for it that reflects some further needs of a place where I work. It
probably won't have too much use with mainstream package developers, but
it proves to be incredibly useful in custom situations, particularly where
one is writing a package to override a lot of things provided by other
packages, such as custom settings propagation, etc.

Given how harmless this extension is and how much I use it, I would
request that you incorporate it into Debhelper. Even though we are using
Ubuntu, I requested that you include this instead of Ubuntu based upon
<http://kitenet.net/~joey/blog/entry/on_forking_debhelper.html>.

The long and short of what it provides is this: A new script called
dh_divert. What dh_divert is that it looks at the contents of
debian/diverts and debian/purgediverts and instructs the preinst and
postrm scripts to create and remove diversions. Debian/diverts' diversions
are removed upon "postrm remove," and debian/purgediverts are removed upon
"postrm purge."

I am not a Perl guru, but I based what I wrote off of other Debhelper
utilities, so the code shouldn't be too foul.

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.

Attached is a patch of my work against the Subversion checkout from 20060826

Best,

Matt


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

-- 
see shy jo
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-diverts
===================================================================
--- autoscripts/preinst-diverts (revision 0)
+++ autoscripts/preinst-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 <[EMAIL PROTECTED]>.
 
  -- Joey Hess <[EMAIL PROTECTED]>  Sun,  2 Jul 2006 18:11:49 -0400
 
Index: dh_divert
===================================================================
--- dh_divert   (revision 0)
+++ dh_divert   (revision 0)
@@ -0,0 +1,72 @@
+#!/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.
+
+For files that will have their contents undiverted upon package removal,
+place a list of these files in debian/diverts. Packages that want removal of
+a diversion upon purging will want their files placed in debian/purgediverts.
+
+=cut
+
+init();
+
+foreach my $package (@{$dh{DOPACKAGES}}) {
+       my $tmp=tmpdir($package);
+       my $removefile=pkgfile($package,"diverts");
+       my $purgefile=pkgfile($package,"purgediverts");
+
+       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 (@removediverts) {
+                       autoscript($package,"preinst", "preinst-diverts", 
"s:#DIVERSION#:$_:;s:#PACKAGE#:$package:");
+                       autoscript($package,"postrm", "postrm-remove-diverts", 
"s:#DIVERSION#:$_:;:#PACKAGE#:$package:");
+               }
+               foreach (@purgediverts) {
+                       autoscript($package,"preinst", "preinst-diverts", 
"s:#DIVERSION#:$_:;s:#PACKAGE#:$package:");
+                       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. It is based off of dh_desktop and
+dh_installwm.
+
+=head1 AUTHOR
+
+Matt T. Proud <[EMAIL PROTECTED]>
+
+=cut

Property changes on: dh_divert
___________________________________________________________________
Name: svn:executable
   + *

Reply via email to