]> git.donarmstrong.com Git - lilypond.git/blob - debian/update_doc_packages
add all of the per-language package files
[lilypond.git] / debian / update_doc_packages
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 use IO::File;
7
8 my $cf = $ARGV[0];
9 my $df = $ARGV[1];
10
11 my $cfh = IO::File->new("debian/control",'r') or
12     die "Unable to open $cf for reading: $!";
13
14 my $dfh = IO::File->new("debian/doc_languages.txt",'r') or
15     die "Unable to open $df for reading: $!";
16
17 # read in languages
18 my %languages;
19 while (<$dfh>) {
20     chomp;
21     my ($type,$short,$long) = split /\s+/;
22     $languages{$type}{$short} = $long;
23 }
24
25 # parse control file
26 my $new_control_file;
27 my $discard_stanza = 0;
28 while (<$cfh>) {
29     if (/^Package: lilypond-doc-(pdf|html)-.*/) {
30         $discard_stanza = 1;
31     }
32     if (/^\n?$/) {
33         if ($discard_stanza) {
34             $discard_stanza = 0;
35             next;
36         }
37     }
38     next if $discard_stanza;
39     $new_control_file .= $_;
40 }
41 close($cfh);
42
43 for my $type (sort keys %languages) {
44     my $uc_type = uc($type);
45     my $recommends = '';
46     my $depends = '';
47     if ($type eq 'html') {
48         $recommends = '';
49         # this is required because the images are only in the -html
50         # package
51         $depends = ', lilypond-doc-html'
52     } else {
53         $recommends = "\nRecommends: evince | pdf-viewer";
54     }
55     for my $lang (sort keys %{$languages{$type}}) {
56         my $ucfirst_long_lang = ucfirst($languages{$type}{$lang});
57         # write out the control file stanza
58         $new_control_file .= <<EOF;
59 Package: lilypond-doc-$type-$lang
60 Section: doc
61 Architecture: all
62 Depends: \${misc:Depends}, dpkg (>= 1.15.4) | install-info${depends}${recommends}
63 Suggests: lilypond (>= \${source:Version})
64 Description: LilyPond $uc_type Documentation in $ucfirst_long_lang
65  LilyPond is a music typesetter, an automated engraving system.  It
66  produces beautiful sheet music using a high level description file as input.
67  .
68  This package contains the $uc_type documentation in $ucfirst_long_lang for the
69  LilyPond music typesetting software.
70
71 EOF
72         # write out the package.install file for this example
73         my $install_fh = IO::File->new("debian/lilypond-doc-$type-${lang}.install",'w') or
74             die "Unable to open debian/lilypond-doc-$type-${lang}.install for writing: $!";
75         if ($type eq 'html') {
76             print {$install_fh} <<EOF;
77 usr/share/doc/lilypond/html/*/*/*.${lang}.html
78 usr/share/doc/lilypond/html/*/*.${lang}.html
79 usr/share/doc/lilypond/html/*.${lang}.html
80 EOF
81
82         } else {
83             print {$install_fh} <<EOF;
84 usr/share/doc/lilypond/html/*/*.${lang}.pdf
85 usr/share/doc/lilypond/html/*.${lang}.pdf
86 EOF
87         }
88         close($install_fh);
89     }
90 }
91
92 $cfh = IO::File->new('debian/control','w') or
93     die "Unable to open debian/control for writing: $!";
94 print {$cfh} $new_control_file;
95
96 close($cfh);