#!/usr/bin/perl

$basedir="/home/tom/debian/make-diff-test";

opendir (S_IN, "s-in");
@in_files = grep { /^.*\.deb/ } readdir(S_IN);
closedir (S_IN);

PKG: foreach $i (@in_files)
{
	$in = "s-in/$i";
	open (DPKG_DEB, "dpkg-deb -f $in Package |");
	$pkg = <DPKG_DEB>;
	chomp $pkg;
	close (DPKG_DEB);
	open (DPKG_DEB, "dpkg-deb -f $in Version |");
	$ver1 = <DPKG_DEB>;
	chomp $ver1;
	close (DPKG_DEB);
	$ro = <s-out/${pkg}_*.deb>;
	next PKG if (! $ro);
	print "$in $ro $pkg\n";
	open (DPKG_DEB, "dpkg-deb -f $ro Version |");
	$ver2 = <DPKG_DEB>;
	chomp $ver2;
	close (DPKG_DEB);
	system "../make-diff $basedir/$in $basedir/$ro >/dev/null";
	
	@df = <${pkg}_*.deb>;
	print "$pkg '$df[0]'\n";
	
	@stat = stat $in;
	$isz = $stat[7];
	@stat = stat $ro;
	$osz = $stat[7];
	@stat = stat $df[0];
	$dsz = $stat[7];
	
	$pct = ($dsz/$osz)*100;
	
	print "$pkg $ver1 $isz --> $ver2 $osz\n";
	print "Diff $dsz, $pct%\n\n";
}
 