File: update_doc_packages

package info (click to toggle)
lilypond 2.19.83-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 76,396 kB
  • sloc: cpp: 79,385; ansic: 75,071; lisp: 59,263; xml: 31,196; python: 22,406; sh: 8,159; yacc: 3,872; perl: 3,507; asm: 1,587; lex: 1,408; makefile: 1,048; tcl: 457; awk: 199; php: 53; csh: 50
file content (123 lines) | stat: -rw-r--r-- 3,736 bytes parent folder | download
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/perl
# update_doc_packages updates debian/control for the lilypond debian
# package, and is released under the terms of the GPL version 2, or
# any later version, at your option. See the file README and COPYING
# for more information.
# Copyright 2012 by Don Armstrong <don@debian.org>.

use warnings;
use strict;

use IO::File;

my $cfh = IO::File->new("debian/control",'r') or
    die "Unable to open debian/control for reading: $!";

my $dfh = IO::File->new("debian/doc_languages.txt",'r') or
    die "Unable to open debian/doc_languages.txt for reading: $!";

# read in languages
my %languages;
while (<$dfh>) {
    chomp;
    my ($type,$short,$long) = split /\s+/;
    $languages{$type}{$short} = $long;
}

# parse control file
my $new_control_file;
my $discard_stanza = 0;
while (<$cfh>) {
    if (/^Package: lilypond-doc-(pdf|html)-.*/) {
	$discard_stanza = 1;
    }
    if (/^\n?$/) {
	if ($discard_stanza) {
	    $discard_stanza = 0;
	    next;
	}
    }
    next if $discard_stanza;
    $new_control_file .= $_;
}
close($cfh);

for my $type (sort keys %languages) {
    my $uc_type = uc($type);
    my $recommends = '';
    my $depends = '';
    if ($type eq 'html') {
	$recommends = '';
	# this is required because the images are only in the -html
	# package
	$depends = ', lilypond-doc-html'
    } else {
	$recommends = "\nRecommends: evince | pdf-viewer";
    }
    for my $lang (sort keys %{$languages{$type}}) {
	my $ucfirst_long_lang = ucfirst($languages{$type}{$lang});
	# write out the control file stanza
	$new_control_file .= <<EOF;
Package: lilypond-doc-$type-$lang
Section: doc
Architecture: all
Depends: \${misc:Depends}, dpkg (>= 1.15.4) | install-info${depends}${recommends}
Suggests: lilypond (>= \${source:Version})
Description: LilyPond $uc_type Documentation in $ucfirst_long_lang
 LilyPond is a music typesetter, an automated engraving system.  It
 produces beautiful sheet music using a high level description file as input.
 .
 This package contains the $uc_type documentation in $ucfirst_long_lang for the
 LilyPond music typesetting software.

EOF
	# write out the package.install file for this example
        my $install_fh = IO::File->new("debian/lilypond-doc-$type-${lang}.install",'w') or
            die "Unable to open debian/lilypond-doc-$type-${lang}.install for writing: $!";
	if ($type eq 'html') {
	    print {$install_fh} <<EOF;
usr/share/doc/lilypond/html/*/*/*.${lang}.html
usr/share/doc/lilypond/html/*/*.${lang}.html
usr/share/doc/lilypond/html/*.${lang}.html
EOF

	} else {
	    print {$install_fh} <<EOF;
usr/share/doc/lilypond/html/*/*.${lang}.pdf
EOF
	}
	close($install_fh);
        my $docbase_fh = IO::File->new("debian/lilypond-doc-$type-${lang}.doc-base-special",'w') or
            die "Unable to open debian/lilypond-doc-$type-${lang}.doc-base-special for writing: $!";
	print {$docbase_fh} <<EOF;
Document: lilypond.${lang}
Title: GNU LilyPond, the music typesetter
Author: Various
Abstract: This documentation describes LilyPond (the GNU Project music
 typesetter), the LilyPond music input language, and the Mutopia project,
 a.k.a. "Music To the People."
Section: Typesetting

EOF
	if ($type eq 'html') {
	    print {$docbase_fh} <<EOF;
Format: HTML
Index: /usr/share/doc/lilypond/html/index.${lang}.html
Files: /usr/share/doc/lilypond/html/*/*/*.${lang}.html /usr/share/doc/lilypond/html/*/*.${lang}.html /usr/share/doc/lilypond/html/*.${lang}.html
EOF

	} else {
	    print {$docbase_fh} <<EOF;
Format: PDF
Files: /usr/share/doc/lilypond/html/Documentation/*.${lang}.pdf*
EOF
	}
	close ($docbase_fh);
    }
}

$cfh = IO::File->new('debian/control','w') or
    die "Unable to open debian/control for writing: $!";
print {$cfh} $new_control_file;

close($cfh);