]> git.donarmstrong.com Git - debhelper.git/blob - dh_scrollkeeper
r596: * dh_scrollkeeper: fixed some overenthusiastic quoting. Closes: #201810
[debhelper.git] / dh_scrollkeeper
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_scrollkeeper - generate ScrollKeeper registration scripts
6
7 =cut
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib;
11
12 =head1 SYNOPSIS
13
14 B<dh_scrollkeeper> [S<I<debhelper options>>] [B<-n>] [S<I<directory>>]
15
16 =head1 DESCRIPTION
17
18 B<dh_scrollkeeper> is a debhelper program that handles correctly
19 registering OMF files that it finds in package build trees with
20 ScrollKeeper.
21
22 This command automatically adds maintainer script snippets for registering
23 and unregistering files with ScrollKeeper (unless B<-n> is used). A
24 dependency on scrollkeeper will be added to C<${misc:Depends}>, so be sure
25 your package uses that variable in F<debian/control>. See
26 L<dh_installdeb(1)> for an explantion of Debhelper maintainer script
27 snippets.
28
29 It will also change any DTD declarations in the OMF and DocBook files
30 to refer to local files instead of remote URLs. This change does not
31 modify the source files, but the files in the package build tree.
32
33 =head1 OPTIONS
34
35 =over 4
36
37 =item B<-n>, B<--noscripts>
38
39 Do not modify F<postinst>/F<postrm> scripts.
40
41 =back
42
43 =head1 NOTES
44
45 Note that this command is not idempotent. "dh_clean -k" should be
46 called between invocations of this command. Otherwise, it may cause
47 multiple instances of the same text to be added to maintainer scripts.
48
49 =cut
50
51 init();
52
53 # This is a list of paths where DocBook files might be stored.
54 my @xml_paths = (
55         'usr/share/gnome/help' # GNOME Help
56 );
57
58 # Append the remaining command line arguments
59 push @xml_paths, @ARGV if @ARGV;
60
61 foreach my $package (@{$dh{DOPACKAGES}}) {
62         my $tmp=tmpdir($package);
63         
64         # Only run if there have been OMF files installed
65         if (-d "$tmp/usr/share/omf") {
66                 # Get a list of the OMF files
67                 my @omf_files = `find $tmp/usr/share/omf -type f -printf '%p\n'`;
68                 if (@omf_files) {
69                         # Change any remote DTDs into local DTDs. We only
70                         # look at the first 10 lines to avoid changing any
71                         # of the content. First, the OMF files
72                         foreach my $file (@omf_files) {
73                                 chomp $file;
74                                 doit("perl", "-i", "-pe", 's,http://scrollkeeper.sourceforge.net/dtds/scrollkeeper-omf-1.0/scrollkeeper-omf.dtd,/usr/share/xml/scrollkeeper/dtds/scrollkeeper-omf.dtd, if $. < 10', $file);
75                         }
76                         # I could be cunning and parse the OMF for the DocBook
77                         # files. That is far too much effort. Find to the
78                         # rescue! Look for .xml files in the list of
79                         # directories we think they might be in.
80                         foreach my $xmlpath (@xml_paths) {
81                                 foreach my $file (`find $tmp/$xmlpath -type f -name \*.xml -printf '%p\n'`) {
82                                         chomp $file;
83                                         doit("perl", "-i", "-pe", 's,http://www.oasis-open.org/docbook/xml/([^/]+)/docbookx.dtd,/usr/share/sgml/docbook/dtd/xml/\\1/docbookx.dtd, if $. < 10', $file);
84                                 }
85                         }
86                 
87                         if (! $dh{NOSCRIPTS}) {
88                                 autoscript($package,"postinst","postinst-scrollkeeper");
89                                 autoscript($package,"postrm","postrm-scrollkeeper");
90                         }
91                         # The scripts use scrollkeeper-update with the -q
92                         # option, so we require 0.3.8+.
93                         addsubstvar($package, "misc:Depends", "scrollkeeper", ">= 0.3.8");
94                 }
95         }
96 }
97
98 =head1 SEE ALSO
99
100 L<debhelper>
101
102 This program is a part of debhelper.
103
104 =head1 AUTHOR
105
106 Ross Burton <ross@burtonini.com>
107
108 =cut