Debian Codegraph @

helper/check-cmdsel-debs-data

raw
1 #! /usr/bin/perl
2 use warnings;
3 use strict;
4 use integer;
5 use FindBin;
6 use lib $FindBin::RealBin;
7 use Def;
8
9 # This extremely obscure helper script checks the packages named in
10 # cmdsel-debs.data against one or more lists of selected packages (the
11 # lists each having one binary package name per line). If you don't
12 # know what this is about, you can ignore this script.
13
14 our $file_data = "${FindBin::RealBin}/cmdsel-debs.data";
15
16 our $usage = <<END;
17 usage: $0 [-h] [selections file...]
18 -h print this usage message
19 END
20
21 # Read command-line arguments and options.
22 my @opt;
23 my @arg;
24 push @{ /^-\S/ ? \@opt : \@arg }, $_ for @ARGV;
25 my %opt = map {
26 my $o = $_;
27 map { substr( $o, $_, 1 ) => 1 } 1 .. length($o)-1
28 } @opt;
29 if ( $opt{'?'} || $opt{h} ) {
30 print $usage;
31 exit 0;
32 }
33
34 # Read in the selections.
35 my %sel;
36 for ( @arg ) {
37 open F, '<', $_;
38 while (<F>) {
39 chomp;
40 $sel{$_} = 1 if /\S/ && !/^#/;
41 }
42 close F;
43 }
44
45 # Object to unselected packages in the data file.
46 open F, '<', $file_data;
47 {
48 my $cmd2 = '';
49 my $sect2 = '';
50 while (<F>) {
51 my( $cmd, $sect, $pkg ) = /^(\S+)\(([^()\s]+)\)\s+(\S+)\s*$/
52 or die "$0: badly formatted data line\n$_\n";
53 $sel{$pkg} or warn "$0: package $pkg unselected or unknown\n";
54 $sect gt $sect2 || ( $sect eq $sect2 && $cmd gt $cmd2 )
55 or warn
56 "$0: commands $cmd2($sect2) and $cmd($sect) are misordered\n";
57 $cmd2 = $cmd; $sect2 = $sect;
58 }
59 }
60 close F;
61