2 # diffstat -- maemian collection script for source packages
4 # Copyright (C) 1998 Richard Braakman
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, you can find it on the World Wide
18 # Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
19 # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
22 # This could be written more easily in shell script, but I'm trying
23 # to keep everything as perl to cut down on the number of processes
24 # that need to be started in a maemian scan. Eventually all the
25 # perl code will be perl modules, so only one perl interpreter
30 use lib "$ENV{'MAEMIAN_ROOT'}/lib";
33 ($#ARGV == 1) or fail("syntax: diffstat <pkg>");
36 -f "fields/version" or fail("diffstat invoked in wrong directory");
38 open (V, '<', "fields/version") or fail("cannot open fields/version: $!");
39 my $ver = <V>; chomp $ver;
42 unlink('debian-patch');
44 $ver =~ s/^\d://; #Remove epoch for this
46 my $diff_file = "${pkg}_${ver}.diff.gz";
47 unless (-f $diff_file) {
48 # we have to write an empty file so that the checks don't crap out. <sigh>
49 touch_file('diffstat');
53 gunzip_file($diff_file, "debian-patch");
55 open (STAT, '>', "diffstat") or fail("cannot open scripts output file: $!");
56 # diffstat is noisy on stderr if its stdout is not a tty.
57 # Shut it up by redirecting stderr to /dev/null.
58 open STDERR, ">/dev/null";
59 open (DIFF, '-|', qw/diffstat -p1 debian-patch/)
60 or fail("cannot open pipe to diffstat on debian-patch: $!");
61 # Copy all except last line to the STAT file
64 print STAT $previous if $previous;
67 close DIFF or fail("cannot close pipe to diffstat on debian-patch: $!");
68 close STAT or fail("error writing diffstat file: $!");