Added some code to peer into a data structure in Maemian/Schedule.pm. Also added the
[maemian] / nokia-lintian / collection / file-info
1 #!/usr/bin/perl -w
2 # file-info -- lintian collection script
3
4 # Copyright (C) 1998 Richard Braakman
5
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.
10
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.
15
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,
20 # MA 02110-1301, USA.
21
22 use strict;
23
24 ($#ARGV == 1) or fail("syntax: file-info <pkg> <type>");
25 my $pkg = shift;
26 my $type = shift;
27
28 -f "fields/package" or fail("file-info invoked in wrong directory");
29
30 unlink("file-info");
31 chdir("unpacked")
32     or fail("cannot chdir to unpacked directory: $!");
33
34 use FileHandle;
35 use lib "$ENV{'LINTIAN_ROOT'}/lib";
36 use Pipeline;
37
38 my $XARGS=FileHandle->new;
39 pipeline_open($XARGS, (sub { exec 'xargs', '-0r', 'file' }), "../file-info")
40     or fail("cannot fork: $!");
41 open(INDEX, '<', "../index")
42     or fail("cannot open index file: $!");
43 while (<INDEX>) {
44     chop;
45     $_ = (split(" ", $_, 6))[5];
46     s/ link to .*//;
47     s/ -> .*//;
48     s/(\G|[^\\](?:\\\\)*)\\(\d{3})/"$1" . chr(oct $2)/ge;
49     s/\\\\/\\/;
50     printf $XARGS "%s\0", $_;
51 }
52 close(INDEX);
53
54 close($XARGS) or fail("xargs for file exited with code $?");
55
56 exit 0;
57
58 # -----------------------------------
59
60 sub fail {
61     if ($_[0]) {
62         print STDERR "internal error: $_[0]\n";
63     } elsif ($!) {
64         print STDERR "internal error: $!\n";
65     } else {
66         print STDERR "internal error.\n";
67     }
68     exit 1;
69 }