[debhelper-devel] Bug#867881: debhelper: dh_compress fails if there are multiple hardlinks and the targets exist

Sven Joachim svenjoac at gmx.de
Mon Jul 10 09:51:36 UTC 2017


Package: debhelper
Version: 2.0.86
Severity: normal

It is no problem for dh_compress to compress a file foo even if foo.gz
already exists, thanks to gzip's -f option.  However, there is a
situation where it fails: if foo and bar are hardlinks to the same file,
and both foo.gz and bar.gz exist as in the attached source package, an
error occurs:

,----
| dh_compress
| ln: failed to create hard link 'usr/share/man/man1/foo.1.gz': File exists
| dh_compress: ln usr/share/man/man1/bar.1.gz usr/share/man/man1/foo.1.gz returned exit code 1
| dh_compress: Aborting due to earlier error
| debian/rules:7: recipe for target 'override_dh_compress' failed
| make[1]: *** [override_dh_compress] Error 25
| make[1]: Leaving directory '/tmp/foo'
| debian/rules:4: recipe for target 'binary' failed
| make: *** [binary] Error 2
| dpkg-buildpackage: error: fakeroot debian/rules binary gave error exit status 2
`----

This is the situation that happened in #867846, but it's not exactly a
new problem - I could reproduce it with debhelper 2.0.86 in a potato
chroot.  Probably it has been around "forever", debhelper 1.2.20 seems
to be the first version of dh_compress with working hardlink support,
but I could not get that to build.

The following patch makes sense to me, what do you think?

--8<---------------cut here---------------start------------->8---
diff --git a/dh_compress b/dh_compress
index b5b1fb36..a0000d08 100755
--- a/dh_compress
+++ b/dh_compress
@@ -196,7 +196,7 @@ on_pkgs_in_parallel {
 			# Remove old file.
 			rm_files($_);
 			# Make new hardlink.
-			doit("ln","$hardlinks{$_}.gz","$_.gz");
+			doit("ln","-f","$hardlinks{$_}.gz","$_.gz");
 		}
 
 		verbose_print("cd '$olddir'");
--8<---------------cut here---------------end--------------->8---


-- System Information:
Debian Release: buster/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (101, 'experimental')
Architecture: i386 (x86_64)
Foreign Architectures: amd64

Kernel: Linux 4.12.0-nouveau (SMP w/2 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), LANGUAGE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages debhelper depends on:
ii  autotools-dev            20161112.1
ii  binutils                 2.28-6
ii  dh-autoreconf            14
ii  dh-strip-nondeterminism  0.035-2
ii  dpkg                     1.18.24
ii  dpkg-dev                 1.18.24
ii  file                     1:5.30-1
ii  libdpkg-perl             1.18.24
ii  man-db                   2.7.6.1-2
ii  perl                     5.24.1-7
ii  po-debconf               1.0.20

debhelper recommends no packages.

Versions of packages debhelper suggests:
ii  dh-make  2.201608

-- no debconf information

-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo_0.0.tar.xz
Type: application/x-xz
Size: 820 bytes
Desc: test package 
URL: <http://lists.alioth.debian.org/pipermail/debhelper-devel/attachments/20170710/a0b88a77/attachment-0003.bin>


More information about the debhelper-devel mailing list