chiark / gitweb /
script to make the manual TOC into a substvar for debian/control
authoraph <aph@313b444b-1b9f-4f58-a734-7bb04f332e8d>
Mon, 27 Jan 2003 19:41:40 +0000 (19:41 +0000)
committeraph <aph@313b444b-1b9f-4f58-a734-7bb04f332e8d>
Mon, 27 Jan 2003 19:41:40 +0000 (19:41 +0000)
description use

git-svn-id: svn://anonscm.debian.org/ddp/manuals/trunk/developers-reference@2121 313b444b-1b9f-4f58-a734-7bb04f332e8d

debian/tocsubstvars [new file with mode: 0755]

diff --git a/debian/tocsubstvars b/debian/tocsubstvars
new file mode 100755 (executable)
index 0000000..9e40a38
--- /dev/null
@@ -0,0 +1,38 @@
+#!/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);
+$entoc =~ s/\'//g;
+
+foreach my $package (@{$dh{DOPACKAGES}}) {
+    addsubstvar($package, "TOC:en", $entoc);
+}
+
+