2 # scripts -- lintian collection script
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,
24 open(SCRIPTS, '>', "scripts") or fail("cannot open scripts output file: $!");
25 open(INDEX, '<', "index") or fail("cannot open index file: $!");
32 next unless /^-/; # skip non-files
35 # Extract the filename field from the tar-like file index.
36 # Note that the split is done with an explicit limit so that filenames
37 # with embedded spaces are handled correctly.
38 $file = (split(' ', $_, 6))[5];
39 $file =~ s/ link to .*//; # cut off info about hard links
40 # This used to call fail() instead of next. However, the check to
41 # see if all files in the index can be opened should be done elsewhere.
42 open(FILE, '<', "unpacked/$file") or next;
43 if (read(FILE, $magic, 2) and $magic eq '#!' and not eof(FILE)) {
46 next if ($scriptpath =~ m/^\#!/); # skip lincity data files
48 my $copy_path = $scriptpath;
49 $scriptpath =~ s/^\s+//; # remove leading whitespace
50 $scriptpath =~ s/^\#.*//; # remove comments
51 if ($scriptpath eq '') {
52 print SCRIPTS "$copy_path $file\n";
54 # This used to have (\S+) rather than (\S*), but that went wrong
55 # with scripts that start with an empty #! line.
57 if ($scriptpath =~ s,^/usr/bin/env\s+,,) {
60 $scriptpath =~ s/^(\S*).*/$1/s;
61 print SCRIPTS $env . "$scriptpath $file\n";
69 open(SCRIPTS, '>', "control-scripts")
70 or fail("cannot open control-scripts output file: $!");
72 opendir(CONTROL, "control")
73 or fail("cannot read control directory: $!");
75 for $file (readdir CONTROL) {
76 next unless -f "control/$file";
77 open(FILE, '<', "control/$file") or fail("cannot open control/$file: $!");
78 if (read(FILE, $magic, 2) and $magic eq '#!') {
80 $scriptpath =~ s/^\s*(\S*).*/$1/s;
81 print SCRIPTS "$scriptpath $file\n"
90 # -----------------------------------
94 print STDERR "internal error: $_[0]\n";
96 print STDERR "internal error: $!\n";
98 print STDERR "internal error.\n";