From f029f28260b62a43792d39f9e935132425d4b609 Mon Sep 17 00:00:00 2001 From: Sven Joachim Date: Sun, 3 Nov 2019 00:18:19 +0100 Subject: dpkg-gencontrol: Take hardlinks into account when computing Installed-Size We should not add up the size of each hardlink into the final sum, otherwise we will get a size in excess. Closes: #923475 Co-Authored-by: Guillem Jover Signed-off-by: Guillem Jover --- scripts/dpkg-gencontrol.pl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/dpkg-gencontrol.pl b/scripts/dpkg-gencontrol.pl index 443217103..a5dda70d0 100755 --- a/scripts/dpkg-gencontrol.pl +++ b/scripts/dpkg-gencontrol.pl @@ -335,13 +335,20 @@ if ($binarypackage ne $sourcepackage || $verdiff) { if (!defined($substvars->get('Installed-Size'))) { my $installed_size = 0; + my %hardlink; my $scan_installed_size = sub { lstat or syserr(g_('cannot stat %s'), $File::Find::name); if (-f _ or -l _) { + my ($dev, $ino, $nlink) = (lstat _)[0, 1, 3]; + # For filesystem objects with actual content accumulate the size # in 1 KiB units. - $installed_size += POSIX::ceil((-s _) / 1024); + $installed_size += POSIX::ceil((-s _) / 1024) + if not exists $hardlink{"$dev:$ino"}; + + # Track hardlinks to avoid repeated additions. + $hardlink{"$dev:$ino"} = 1 if $nlink > 1; } else { # For other filesystem objects assume a minimum 1 KiB baseline, # as directories are shared resources between packages, and other -- cgit v1.2.3