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