File: tocsubstvars

package info (click to toggle)
developers-reference 11.0.21
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,044 kB
  • sloc: makefile: 171; javascript: 74; python: 63; perl: 25; sh: 5
file content (37 lines) | stat: -rwxr-xr-x 753 bytes parent folder | download | duplicates (3)
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;
        /^\*\s+\d+\.\s/ && push(@toc, $_);
    }
    close(FILE) || die("closing $f: $!\n");
    return @toc;
}

my @entoc = gettoc("build/en/text/index.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);
}