]> git.donarmstrong.com Git - lilypond.git/blob - debian/update_doc_packages
Fix Broken usage of dpkg-maintscript-helper (relative pathnames vs. aboslute pathname...
[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 Replaces: lilypond-doc (<< 2.16.2-1~exp+1)
67 Breaks: lilypond-doc (<< 2.16.2-1~exp+1)
68 Description: LilyPond $uc_type Documentation in $ucfirst_long_lang
69  LilyPond is a music typesetter, an automated engraving system.  It
70  produces beautiful sheet music using a high level description file as input.
71  .
72  This package contains the $uc_type documentation in $ucfirst_long_lang for the
73  LilyPond music typesetting software.
74
75 EOF
76         # write out the package.install file for this example
77         my $install_fh = IO::File->new("debian/lilypond-doc-$type-${lang}.install",'w') or
78             die "Unable to open debian/lilypond-doc-$type-${lang}.install for writing: $!";
79         if ($type eq 'html') {
80             print {$install_fh} <<EOF;
81 usr/share/doc/lilypond/html/*/*/*.${lang}.html
82 usr/share/doc/lilypond/html/*/*.${lang}.html
83 usr/share/doc/lilypond/html/*.${lang}.html
84 EOF
85
86         } else {
87             print {$install_fh} <<EOF;
88 usr/share/doc/lilypond/html/*/*.${lang}.pdf
89 EOF
90         }
91         close($install_fh);
92         my $docbase_fh = IO::File->new("debian/lilypond-doc-$type-${lang}.doc-base-special",'w') or
93             die "Unable to open debian/lilypond-doc-$type-${lang}.doc-base-special for writing: $!";
94         print {$docbase_fh} <<EOF;
95 Document: lilypond.${lang}
96 Title: GNU LilyPond, the music typesetter
97 Author: Various
98 Abstract: This documentation describes LilyPond (the GNU Project music
99  typesetter), the LilyPond music input language, and the Mutopia project,
100  a.k.a. "Music To the People."
101 Section: Typesetting
102
103 EOF
104         if ($type eq 'html') {
105             print {$docbase_fh} <<EOF;
106 Format: HTML
107 Index: /usr/share/doc/lilypond/html/index.${lang}.html
108 Files: /usr/share/doc/lilypond/html/*/*/*.${lang}.html /usr/share/doc/lilypond/html/*/*.${lang}.html /usr/share/doc/lilypond/html/*.${lang}.html
109 EOF
110
111         } else {
112             print {$docbase_fh} <<EOF;
113 Format: PDF
114 Files: /usr/share/doc/lilypond/html/Documentation/*.${lang}.pdf*
115 EOF
116         }
117         close ($docbase_fh);
118     }
119 }
120
121 $cfh = IO::File->new('debian/control','w') or
122     die "Unable to open debian/control for writing: $!";
123 print {$cfh} $new_control_file;
124
125 close($cfh);