File: tocsubstvars

package info (click to toggle)
developers-reference 3.4.25
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,596 kB
  • sloc: makefile: 134; perl: 25
file content (37 lines) | stat: -rwxr-xr-x 749 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/perl -w

use strict;
use Debian::Debhelper::Dh_Lib;

init();

sub gettoc {
    my $f = shift;
    my @toc;

    open(FILE, "<$f") || die("opening $f: $!\n");
    while (<FILE>) {
        chomp;
        /^\d+\.\s/ && push(@toc, $_);
    }
    close(FILE) || die("closing $f: $!\n");
    return @toc;
}

my @entoc = gettoc("developers-reference.txt");

# sanity test
if ( $#entoc == -1 ) {
    error("found no entries in the TOC, aborting");
} elsif ( $#entoc < 4 ) {
    error("only found " . $#entoc . " entries in the TOC, aborting");
}
verbose_print("found " . $#entoc . " entries in TOC");

my $entoc = "   " . join('${Newline}   ', @entoc);

foreach my $package (@{$dh{DOPACKAGES}}) {
    addsubstvar($package, "TOC:en", $entoc);
}