Bug#774073: dh-make-perl: Ceating core module, install fails with "trying to overwrite foo which is also in bar"
On Sun, 2014-12-28 at 12:19 +, Andy Beverley wrote: > When creating an updated version of a module that is already in core, > the subsequent install fails (as expected) with a message such as: > "trying to overwrite '/usr/bin/instmodsh', which is also in package > perl 5.14.2-21+deb7u2". I'm having another look at this, but I have some memory fade. Does anyone know why I put rules.dh.core in debian/ rather than share/ ? Which one should it be in? Thanks, Andy
Bug#774073: dh-make-perl: Ceating core module, install fails with trying to overwrite foo which is also in bar
-=| Niko Tyni, 30.12.2014 12:29:02 +0200 |=- On Mon, Dec 29, 2014 at 12:04:41AM +, Andrew Beverley wrote: On Sun, 2014-12-28 at 14:51 +0200, Niko Tyni wrote: A more robust solution is using dpkg-divert in maintainer scripts to move the core version out of the way and then back later if necessary. See for instance the libmodule-corelist-perl package for an example implementation. Okay, attached is a revised patch that does exactly that. Nice, thanks for your work! It works (and it's taken me all day), but I admit that it's pretty messy, so would welcome any feedback as to how to make this a little tidier. I think that it would be enough to only look for file conflicts in /usr/bin and perhaps in /usr/share/man as a first approximation. Other conflicts may merit manual attention and perhaps a --force-diverts switch or something like that. I'm not sure if there are conflicting (heh) requirements here, with the traditional use of dh-make-perl geared for a base packaging that you're expected to tweak up to the quality and standards of Debian archive inclusion, and this --recursive use aiming for automatically generating packages suitable for local use without human attention. But I don't really consider myself a dh-make-perl maintainer so I'll leave judgement on that to those in the team who do. Perhaps it's as easy as changing defaults for other options (like the --force-diverts above) based on the --recursive flag. I think handling core modules with conflicts makes sense. We don't stumble upon such cases but the code would be useful when we do (and obviously it has its uses as part of the --recursive path). I figured that the dpkg-divert lines have to be generated during build, otherwise it's not easily known which files will be installed. It would be nice to not generate the maintainer scripts at all in the common case where they aren't needed. Also, generating them in the source debian/ directory first and including the #DEBHELPER# marker in them would be cleaner and enable debhelper to replace the marker with any magic it considers necessary when it installs them into the DEBIAN/ binary package directory. (See debhelper(7) and dh_installdeb(1)) I concur with Niko here. Build-time maintainer scripts juggling sounds bad. What I'd try is see if there are possibly conflicting files in /usr/bin (plus manpages) and if there are, create the relevant .preinst and .postrm maintainer scripts, borrowing from e.g. libmodule-build-perl, perhaps changing the version comparison with a call to dpkg-divert --list. -- dam -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#774073: dh-make-perl: Ceating core module, install fails with trying to overwrite foo which is also in bar
On Mon, Dec 29, 2014 at 12:04:41AM +, Andrew Beverley wrote: On Sun, 2014-12-28 at 14:51 +0200, Niko Tyni wrote: A more robust solution is using dpkg-divert in maintainer scripts to move the core version out of the way and then back later if necessary. See for instance the libmodule-corelist-perl package for an example implementation. Okay, attached is a revised patch that does exactly that. Nice, thanks for your work! It works (and it's taken me all day), but I admit that it's pretty messy, so would welcome any feedback as to how to make this a little tidier. I think that it would be enough to only look for file conflicts in /usr/bin and perhaps in /usr/share/man as a first approximation. Other conflicts may merit manual attention and perhaps a --force-diverts switch or something like that. I'm not sure if there are conflicting (heh) requirements here, with the traditional use of dh-make-perl geared for a base packaging that you're expected to tweak up to the quality and standards of Debian archive inclusion, and this --recursive use aiming for automatically generating packages suitable for local use without human attention. But I don't really consider myself a dh-make-perl maintainer so I'll leave judgement on that to those in the team who do. Perhaps it's as easy as changing defaults for other options (like the --force-diverts above) based on the --recursive flag. I figured that the dpkg-divert lines have to be generated during build, otherwise it's not easily known which files will be installed. It would be nice to not generate the maintainer scripts at all in the common case where they aren't needed. Also, generating them in the source debian/ directory first and including the #DEBHELPER# marker in them would be cleaner and enable debhelper to replace the marker with any magic it considers necessary when it installs them into the DEBIAN/ binary package directory. (See debhelper(7) and dh_installdeb(1)) -- Niko Tyni nt...@debian.org -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#774073: dh-make-perl: Ceating core module, install fails with trying to overwrite foo which is also in bar
Package: dh-make-perl Version: 0.75-1 Severity: normal Tags: upstream patch When creating an updated version of a module that is already in core, the subsequent install fails (as expected) with a message such as: trying to overwrite '/usr/bin/instmodsh', which is also in package perl 5.14.2-21+deb7u2. Given that dh-make-perl has to be forced into creating core modules, I think it's appropriate to instruct dpkg that the package contains files that replace the core module. This patch does so. If you think it's more appropriate, I'd be happy to create a further doc patch and/or another command line option to go with this patch. -- System Information: Debian Release: 7.7 APT prefers stable APT policy: (500, 'stable') Architecture: amd64 (x86_64) Kernel: Linux 3.2.0-4-amd64 (SMP w/1 CPU core) Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages dh-make-perl depends on: ii debhelper 9.20120909 ii dpkg-dev1.16.15 ii fakeroot1.18.4-2 ii libapt-pkg-perl 0.1.26+b1 ii libarray-unique-perl0.08-1 ii libclass-accessor-perl 0.34-1 ii libdpkg-perl1.16.15 ii libemail-address-perl 1.895-1+deb7u1 ii libemail-date-format-perl 1.002-1 ii libfile-which-perl 1.09-1 ii liblist-moreutils-perl 0.33-1+b1 ii libmodule-depends-perl 0.16-1 ii libparse-debcontrol-perl2.005-3 ii libparse-debianchangelog-perl 1.2.0-1 ii libsoftware-license-perl0.103004-2 ii libtie-ixhash-perl 1.21-2 ii libwww-mechanize-perl 1.71-1 ii libyaml-perl0.81-1 ii make3.81-8.2 ii perl5.14.2-21+deb7u2 ii perl-modules [libmodule-corelist-perl] 5.14.2-21+deb7u2 Versions of packages dh-make-perl recommends: ii apt-file 2.5.1 ii git 1:1.7.10.4-1+wheezy1 ii pristine-tar 1.25+deb7u1 dh-make-perl suggests no packages. -- no debconf information -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#774073: dh-make-perl: Ceating core module, install fails with trying to overwrite foo which is also in bar
On Sun, Dec 28, 2014 at 12:19:32PM +, Andy Beverley wrote: Package: dh-make-perl Version: 0.75-1 Severity: normal Tags: upstream patch When creating an updated version of a module that is already in core, the subsequent install fails (as expected) with a message such as: trying to overwrite '/usr/bin/instmodsh', which is also in package perl 5.14.2-21+deb7u2. Given that dh-make-perl has to be forced into creating core modules, I think it's appropriate to instruct dpkg that the package contains files that replace the core module. This patch does so. Please note that a Replaces entry isn't quite enough for packages with conflicting files to coexist cleanly: in case the replacing package gets removed later, the conflicting file would then be gone from the system altogether. A more robust solution is using dpkg-divert in maintainer scripts to move the core version out of the way and then back later if necessary. See for instance the libmodule-corelist-perl package for an example implementation. -- Niko Tyni nt...@debian.org -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#774073: dh-make-perl: Ceating core module, install fails with trying to overwrite foo which is also in bar
On Sun, 2014-12-28 at 14:51 +0200, Niko Tyni wrote: On Sun, Dec 28, 2014 at 12:19:32PM +, Andy Beverley wrote: Package: dh-make-perl Version: 0.75-1 Severity: normal Tags: upstream patch When creating an updated version of a module that is already in core, the subsequent install fails (as expected) with a message such as: trying to overwrite '/usr/bin/instmodsh', which is also in package perl 5.14.2-21+deb7u2. Given that dh-make-perl has to be forced into creating core modules, I think it's appropriate to instruct dpkg that the package contains files that replace the core module. This patch does so. Please note that a Replaces entry isn't quite enough for packages with conflicting files to coexist cleanly: in case the replacing package gets removed later, the conflicting file would then be gone from the system altogether. Good point, I hadn't thought of that. A more robust solution is using dpkg-divert in maintainer scripts to move the core version out of the way and then back later if necessary. See for instance the libmodule-corelist-perl package for an example implementation. Thanks for the example. I'm currently thinking of this as a solution, but wondering whether there is an easier way? 1. Check if the module is provided by core 2. If so, check which files in the new package are already in core 3. For each of those files, generate a dpkg-divert line In the case of a large module, there could be several dozen dpkg-divert lines, but I can't see a better way of doing it? Thanks, Andy -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#774073: dh-make-perl: Ceating core module, install fails with trying to overwrite foo which is also in bar
On Sun, 2014-12-28 at 14:51 +0200, Niko Tyni wrote: A more robust solution is using dpkg-divert in maintainer scripts to move the core version out of the way and then back later if necessary. See for instance the libmodule-corelist-perl package for an example implementation. Okay, attached is a revised patch that does exactly that. It works (and it's taken me all day), but I admit that it's pretty messy, so would welcome any feedback as to how to make this a little tidier. I figured that the dpkg-divert lines have to be generated during build, otherwise it's not easily known which files will be installed. Comments welcome! From 1037863029557e6f03252c0d0f7256c9d8f0e45e Mon Sep 17 00:00:00 2001 From: Andy Beverley a...@andybev.com Date: Sun, 28 Dec 2014 23:57:06 + Subject: [PATCH] Fix install fails with trying to overwrite foo which is also in bar This patch installs dpkg-divert lines into preinst and postrm to preserve files that are also installed by core packages. If a module is built that is also part of core, these lines will allow the 2 packages to coexist on the same system. --- debian/rules.dh.core| 30 ++ lib/Debian/Rules.pm | 13 + lib/DhMakePerl/Command/Packaging.pm |7 +-- lib/DhMakePerl/Command/make.pm |6 -- 4 files changed, 52 insertions(+), 4 deletions(-) create mode 100755 debian/rules.dh.core diff --git a/debian/rules.dh.core b/debian/rules.dh.core new file mode 100755 index 000..6a8f24b --- /dev/null +++ b/debian/rules.dh.core @@ -0,0 +1,30 @@ +#!/usr/bin/make -f + +# Rules file for core modules. This adds dpkg-divert commands to the +# package to save existing copies of files that will be overwritten + +%: + dh $@ + +override_dh_auto_configure: + dh_auto_configure -- NO_PERLLOCAL=1 + +override_dh_md5sums: + # md5sums will contain all the files to be installed. Once it's been + # created, see whether any of the files to be installed already exist + # as part of another package + dh_md5sums + # The initial part of the shell script + echo '#!/bin/sh\n\nset -e\n\nif [ $$1 = install ] || [ $$1 = upgrade ]\nthen' debian/PACKAGENAME/DEBIAN/preinst + # For each file in md5sums, see if it exists in another package on the + # system, and if it does, add the dpkg-divert commands + cut -d ' ' -f 3 debian/PACKAGENAME/DEBIAN/md5sums|xargs dpkg -S / 2 /dev/null|awk '/^perl/ {print dpkg-divert --add --package PACKAGENAME --rename --divert $$2 .bundled $$2 }' debian/PACKAGENAME/DEBIAN/preinst + # The end of the script + echo 'fi\nexit 0' debian/PACKAGENAME/DEBIAN/preinst + # Make the preinst file executable + chmod +x debian/PACKAGENAME/DEBIAN/preinst + # Same again for the package removal (postrm) + echo '#!/bin/sh\n\nset -e\n\nif [ $$1 = remove ]\nthen' debian/PACKAGENAME/DEBIAN/postrm + cut -d ' ' -f 3 debian/PACKAGENAME/DEBIAN/md5sums|xargs dpkg -S / 2 /dev/null|awk '/^perl/ {print dpkg-divert --remove --package PACKAGENAME --rename --divert $$2 .bundled $$2 }' debian/PACKAGENAME/DEBIAN/postrm + echo 'fi\nexit 0' debian/PACKAGENAME/DEBIAN/postrm + chmod +x debian/PACKAGENAME/DEBIAN/postrm diff --git a/lib/Debian/Rules.pm b/lib/Debian/Rules.pm index 9adc5e2..259d6af 100644 --- a/lib/Debian/Rules.pm +++ b/lib/Debian/Rules.pm @@ -369,6 +369,19 @@ sub write { } } +=item transform $sub + +Transforms each line of the file using the subroutine $sub + +=cut + +sub transform { +my $self = shift; +my $sub = shift or die Please pass a regular expression with which to transform; + +$self-lines( [ map { $sub-($_) } @{ $self-lines } ] ); +} + sub DESTROY { my $self = shift; diff --git a/lib/DhMakePerl/Command/Packaging.pm b/lib/DhMakePerl/Command/Packaging.pm index 6c0b158..e615c38 100644 --- a/lib/DhMakePerl/Command/Packaging.pm +++ b/lib/DhMakePerl/Command/Packaging.pm @@ -20,7 +20,7 @@ __PACKAGE__-mk_accessors( mod_cpan_version meta perlname author version rules docs examples copyright -control +control core_module ) ); @@ -867,7 +867,7 @@ sub create_rules { $self-backup_file($file); -my $rulesname = 'rules.dh.tiny'; +my $rulesname = $self-core_module ? 'rules.dh.core' : 'rules.dh.tiny'; for my $source ( catfile( $self-cfg-home_dir, $rulesname ), @@ -876,6 +876,9 @@ sub create_rules { if ( -e $source ) { print Using rules: $source\n if $self-cfg-verbose; $self-rules-read($source); +my $pkgname = $self-pkgname; +# Substitute any variables in the rules file +$self-rules-transform( sub{ s/PACKAGENAME/$pkgname/g; $_ } ); last; }; } diff --git a/lib/DhMakePerl/Command/make.pm b/lib/DhMakePerl/Command/make.pm index 64a067f..1449737 100644 --- a/lib/DhMakePerl/Command/make.pm +++ b/lib/DhMakePerl/Command/make.pm @@ -14,7 +14,7 @@ __PACKAGE__-mk_accessors( perlname version