Updated with current 8.09 build status
[nslu2-linux/master.git] / scripts / package-strip.pl
blob45c64134f88c265857d8ee1f132783c16cff5207
1 #!/usr/bin/perl
3 my $pat = shift(@ARGV) || usage(1);
4 my $infile = shift(@ARGV) || usage(1);
5 my $outfile = shift(@ARGV) || "-";
6 print STDERR "Package-strip processing input file $infile\n";
7 print STDERR "Output to " . ($outfile ne "-" ? $outfile : "stdout") . "\n";
9 # massage the regexp to accept semi-shell-style *
10 $pat =~ s/\*/.*/g;
12 open (I,"<$infile") || die $@;
13 open (O,">>$outfile") || die $@;
14 undef $/;
15 my $srctext = <I>;
16 close(I);
18 my @srclist = split(/\012\012\012/,$srctext);
19 my @outlist = grep(/Package: $pat/,@srclist);
20 print O join("\012\012\012",@outlist);
21 print O "\012\012\012";
23 sub usage {
24 my $cack = shift(@_);
25 print STDERR "usage: Package-strip <regexp> <filename> [output filename]\nRemember to escape wildcard characters for the shell.";
26 die if $cack;