summaryrefslogtreecommitdiff
path: root/dh_compress
diff options
context:
space:
mode:
authorjoey <joey>1999-08-17 05:07:14 +0000
committerjoey <joey>1999-08-17 05:07:14 +0000
commitaa3db12b0c4892841179e5b135de6568f8ebdd3c (patch)
treee10677c9107b657641fef26cbc06d78ed7fa3c46 /dh_compress
parent35e3686ae9a536a4b91ccc97f9b1c8dbf6593af6 (diff)
downloaddebhelper-aa3db12b0c4892841179e5b135de6568f8ebdd3c.tar.gz
r156: Initial Import
Diffstat (limited to 'dh_compress')
-rwxr-xr-xdh_compress36
1 files changed, 19 insertions, 17 deletions
diff --git a/dh_compress b/dh_compress
index 2933e516..ffca30af 100755
--- a/dh_compress
+++ b/dh_compress
@@ -57,33 +57,35 @@ foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
# Look for files with hard links. If we are going to compress both,
# we can preserve the hard link across the compression and save
# space in the end.
+ my @f=();
foreach (@files) {
($dev, $inode, undef, $nlink)=stat($_);
if ($nlink > 1) {
- @{$hardlinks{$_}}=($dev,$inode);
+ if (! $seen{"$inode.$dev"}) {
+ $seen{"$inode.$dev"}=$_;
+ push @f, $_;
+ }
+ else {
+ # This is a hardlink.
+ $hardlinks{$_}=$seen{"$inode.$dev"};
+ }
+ }
+ else {
+ push @f, $_;
}
}
- # TODO: with the info we have now, we could remove the hard link files
- # from the list of files to compress and save some time.
- if (@files) {
- doit("gzip","-9f",@files);
+ if (@f) {
+ doit("gzip","-9f",@f);
}
# Now change over any files we can that used to be hard links so
# they are again.
- my $old_dev='';
- my $old_inode='';
- my $old_fn='';
- foreach (sort keys %hardlinks) {
- if ($hardlinks{$_}[0] eq $old_dev &&
- $hardlinks{$_}[1] eq $old_inode) {
- doit("rm","-f","$_.gz");
- doit("ln","$old_fn.gz","$_.gz");
- }
- $old_dev=$hardlinks{$_}[0];
- $old_inode=$hardlinks{$_}[1];
- $old_fn=$_;
+ foreach (keys %hardlinks) {
+ # Remove old file.
+ doit("rm","-f","$_");
+ # Make new hardlink.
+ doit("ln","$hardlinks{$_}.gz","$_.gz");
}
chdir($olddir);