diff options
author | Sven Joachim <svenjoac@gmx.de> | 2019-11-03 00:18:19 +0100 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2019-11-26 02:42:44 +0100 |
commit | f029f28260b62a43792d39f9e935132425d4b609 (patch) | |
tree | dd163f4d60e41ced52d434690f64e93de5a213c5 /scripts | |
parent | 956272322b1a54a4fc8c539ac4000add8dfb6007 (diff) | |
download | dpkg-f029f28260b62a43792d39f9e935132425d4b609.tar.gz |
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 <guillem@debian.org>
Signed-off-by: Guillem Jover <guillem@debian.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/dpkg-gencontrol.pl | 9 |
1 files changed, 8 insertions, 1 deletions
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 |