----- Forwarded message from "Matt T. Proud" <[EMAIL PROTECTED]> -----
From: "Matt T. Proud" <[EMAIL PROTECTED]> Date: Sun, 27 Aug 2006 02:01:51 -0500 (CDT) To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: New Debhelper patch Reply-To: [EMAIL PROTECTED] 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 <[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,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 <[EMAIL PROTECTED]> + +=cut ----- End forwarded message ----- -- see shy jo
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 <[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,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 <[EMAIL PROTECTED]>
+
+=cut
signature.asc
Description: Digital signature

