4 unshift @INC, ($::ENV{'BUILD_DIR'} || '/usr/lib/build');
10 my $limit = 80; # throw away deltas bigger than this percentage of the reference
16 return undef if $file =~ /\.(?:patch|delta)\.rpm$/; # XXX: rpmtags?
17 my %res = Build::Rpm::rpmq($file, qw/NAME VERSION RELEASE ARCH SOURCERPM NOSOURCE NOPATCH 1124/);
18 return undef unless %res;
19 return undef if $res{'1124'}->[0] && $res{'1124'}->[0] eq 'drpm';
21 if ($res{'SOURCERPM'}->[0]) {
22 $arch = $res{'ARCH'}->[0];
24 # if ($res{'NOSOURCE'}->[0] || $res{'NOPATCH'}->[0]) {
31 return { name => $res{'NAME'}->[0], file => $file, version => $res{'VERSION'}->[0], release => $res{'RELEASE'}->[0], arch => $arch};
35 if ($ARGV[0] eq '--limit') {
36 shift @ARGV || die "--limit needs an argument\n";
43 my $prevbuild = shift @ARGV || die "USAGE: $0 <oldpkgdir> <directories...>";
44 my @prevbuild = ($prevbuild);
46 while (-e $prevbuild.$i) {
47 push @prevbuild, $prevbuild.$i;
50 for my $dir (@prevbuild) {
51 for my $file (glob $dir.'/*.rpm') {
54 my $n = $q->{'name'}.'.'.$q->{'arch'};
55 push @{$oldpkgs{$n}}, $q;
61 for my $file (glob $dir.'/*.rpm') {
64 my $n = $q->{'name'}.'.'.$q->{'arch'};
65 next unless exists $oldpkgs{$n};
66 for my $old (@{$oldpkgs{$n}}) {
67 my $v = $old->{'version'};
68 my $r = $old->{'release'};
69 if ($v eq $q->{'version'} && $r eq $q->{'release'}) {
70 # skip if same version and release
73 $v .= '_'.$q->{'version'} unless $v eq $q->{'version'};
74 $r .= '_'.$q->{'release'} unless $r eq $q->{'release'};
75 my $on = $old->{'file'};
76 my $nn = $q->{'file'};
77 my $dn = sprintf("%s-%s-%s.%s.drpm", $q->{'name'}, $v, $r, $q->{'arch'});
80 my $ret = system('makedeltarpm', $on, $nn, $dn);
81 if ($ret || ! -e $dn) {
85 my $ns = (stat($dn))[7] || 1;
86 my $os = (stat($file))[7] || 1;
87 my $factor = int($ns / $os * 100);
88 if ($factor > $limit) {
89 print "too big ($factor%), removed\n";
92 print "ok ($factor%)\n";