From c35666db02e7f428fbf7e7a3ea65b2fb72206e72 Mon Sep 17 00:00:00 2001 From: Ludwig Nussel Date: Fri, 29 Oct 2010 11:19:02 +0200 Subject: [PATCH] throw away deltas bigger than 80% of the reference --- mkdrpms | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/mkdrpms b/mkdrpms index 1ea2972..373f709 100755 --- a/mkdrpms +++ b/mkdrpms @@ -7,6 +7,7 @@ BEGIN { use Build; use strict; +my $limit = 80; # throw away deltas bigger than this percentage of the reference my %oldpkgs; sub query @@ -30,6 +31,15 @@ sub query return { name => $res{'NAME'}->[0], file => $file, version => $res{'VERSION'}->[0], release => $res{'RELEASE'}->[0], arch => $arch}; } +while (@ARGV) { + if ($ARGV[0] eq '--limit') { + shift @ARGV || die "--limit needs an argument\n"; + $limit = shift @ARGV; + next; + } + last; +} + my $prevbuild = shift @ARGV || die "USAGE: $0 "; my @prevbuild = ($prevbuild); my $i = 1; @@ -74,12 +84,12 @@ for my $dir (@ARGV) { } else { my $ns = (stat($dn))[7] || 1; my $os = (stat($file))[7] || 1; - my $saved = int($ns / $os * 100); - if ($ns >= $os) { - print "too big ($saved%), removed\n"; - unlink $file; + my $factor = int($ns / $os * 100); + if ($factor > $limit) { + print "too big ($factor%), removed\n"; + unlink $ns; } else { - print "ok ($saved%)\n"; + print "ok ($factor%)\n"; } } } -- 2.7.4