]> git.donarmstrong.com Git - lilypond.git/blob - debian/update_doc_packages
Remove Replaces/Breaks for lilypond-doc (<< 2.16.2-1~exp+1).
[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 $cfh = IO::File->new("debian/control",'r') or
14     die "Unable to open debian/control for reading: $!";
15
16 my $dfh = IO::File->new("debian/doc_languages.txt",'r') or
17     die "Unable to open debian/doc_languages.txt for reading: $!";
18
19 # read in languages
20 my %languages;
21 while (<$dfh>) {
22     chomp;
23     my ($type,$short,$long) = split /\s+/;
24     $languages{$type}{$short} = $long;
25 }
26
27 # parse control file
28 my $new_control_file;
29 my $discard_stanza = 0;
30 while (<$cfh>) {
31     if (/^Package: lilypond-doc-(pdf|html)-.*/) {
32         $discard_stanza = 1;
33     }
34     if (/^\n?$/) {
35         if ($discard_stanza) {
36             $discard_stanza = 0;
37             next;
38         }
39     }
40     next if $discard_stanza;
41     $new_control_file .= $_;
42 }
43 close($cfh);
44
45 for my $type (sort keys %languages) {
46     my $uc_type = uc($type);
47     my $recommends = '';
48     my $depends = '';
49     if ($type eq 'html') {
50         $recommends = '';
51         # this is required because the images are only in the -html
52         # package
53         $depends = ', lilypond-doc-html'
54     } else {
55         $recommends = "\nRecommends: evince | pdf-viewer";
56     }
57     for my $lang (sort keys %{$languages{$type}}) {
58         my $ucfirst_long_lang = ucfirst($languages{$type}{$lang});
59         # write out the control file stanza
60         $new_control_file .= <<EOF;
61 Package: lilypond-doc-$type-$lang
62 Section: doc
63 Architecture: all
64 Depends: \${misc:Depends}, dpkg (>= 1.15.4) | install-info${depends}${recommends}
65 Suggests: lilypond (>= \${source:Version})
66 Description: LilyPond $uc_type Documentation in $ucfirst_long_lang
67  LilyPond is a music typesetter, an automated engraving system.  It
68  produces beautiful sheet music using a high level description file as input.
69  .
70  This package contains the $uc_type documentation in $ucfirst_long_lang for the
71  LilyPond music typesetting software.
72
73 EOF
74         # write out the package.install file for this example
75         my $install_fh = IO::File->new("debian/lilypond-doc-$type-${lang}.install",'w') or
76             die "Unable to open debian/lilypond-doc-$type-${lang}.install for writing: $!";
77         if ($type eq 'html') {
78             print {$install_fh} <<EOF;
79 usr/share/doc/lilypond/html/*/*/*.${lang}.html
80 usr/share/doc/lilypond/html/*/*.${lang}.html
81 usr/share/doc/lilypond/html/*.${lang}.html
82 EOF
83
84         } else {
85             print {$install_fh} <<EOF;
86 usr/share/doc/lilypond/html/*/*.${lang}.pdf
87 EOF
88         }
89         close($install_fh);
90         my $docbase_fh = IO::File->new("debian/lilypond-doc-$type-${lang}.doc-base-special",'w') or
91             die "Unable to open debian/lilypond-doc-$type-${lang}.doc-base-special for writing: $!";
92         print {$docbase_fh} <<EOF;
93 Document: lilypond.${lang}
94 Title: GNU LilyPond, the music typesetter
95 Author: Various
96 Abstract: This documentation describes LilyPond (the GNU Project music
97  typesetter), the LilyPond music input language, and the Mutopia project,
98  a.k.a. "Music To the People."
99 Section: Typesetting
100
101 EOF
102         if ($type eq 'html') {
103             print {$docbase_fh} <<EOF;
104 Format: HTML
105 Index: /usr/share/doc/lilypond/html/index.${lang}.html
106 Files: /usr/share/doc/lilypond/html/*/*/*.${lang}.html /usr/share/doc/lilypond/html/*/*.${lang}.html /usr/share/doc/lilypond/html/*.${lang}.html
107 EOF
108
109         } else {
110             print {$docbase_fh} <<EOF;
111 Format: PDF
112 Files: /usr/share/doc/lilypond/html/Documentation/*.${lang}.pdf*
113 EOF
114         }
115         close ($docbase_fh);
116     }
117 }
118
119 $cfh = IO::File->new('debian/control','w') or
120     die "Unable to open debian/control for writing: $!";
121 print {$cfh} $new_control_file;
122
123 close($cfh);