~ubuntu-branches/ubuntu/natty/dictionaries-common/natty

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
#!/usr/bin/perl -w
#
# Registration with Openoffice.org dictionary list

use Text::Wrap;
$Text::Wrap::columns = 72;

use Debian::Debhelper::Dh_Lib;

my $srcdir_flag = "srcdir";
my $srcdir      = '';
my $language    = '';
my $hyphenation = '';
my $thesaurus   = '';

# Hijacks the --${srcdir_flag} option from the command line, before
# debhelper's parseopt can see it.

if ( my @tmp = reverse grep {/^--$srcdir_flag=/} @ARGV ){
    $srcdir = shift @tmp;
    $srcdir =~ s/--$srcdir_flag=//;
    @ARGV = grep {!/^--$srcdir_flag=/} @ARGV;
    #print STDERR "*OPTS*: [" . join(', ',@ARGV) . "]\n";
}

init();

my $class = "myspell";
my $oooinfodir="/usr/share/myspell/infos/ooo";
my $dictdir = "/usr/share/myspell/dicts";

sub mydie {
    my $msg = shift;
    my $see = shift;
    die "$msg\nPlease see $see.\n";
}

sub mywarn {
  my $msg = shift;
  my $see = shift;
  warn "$msg\nPlease see $see.\n";
  exit 0;
}

foreach $package (@{$dh{DOPACKAGES}}) {

    my $do_mozlinks = "yes";

    # Process the debian/info-myspell file
    my $infofile = "";
    if (not ($infofile = pkgfile ($package, "info-$class"))) {
	mywarn ("There is no debian/info-$class file for package $package.",
	        "the dictionaries-common Policy");
    }

    if (! $dh{NOSCRIPTS}) {
	autoscript ($package, "postinst", "postinst-$class",
		    "s/#PACKAGE#/$package/");
	autoscript ($package, "postrm", "postrm-$class",
		    "s/#PACKAGE#/$package/");
    }

    # Skip setting automatic mozilla links if debian/$package.links exists

    if ( pkgfile($package, "links") ){
	$do_mozlinks = '';
	print STDERR "[installdeb-myspell] " .
	    pkgfile($package, "links") .
	    " exists: Will not automatically set mozilla links\n";
    }

    # Install the file in the openoffice info dir.
    my $lib_dir = tmpdir ($package) . $oooinfodir;
    doit ("install", "-d", $lib_dir);
    doit ("install", "-m644", $infofile, "$lib_dir/$package");

    # Get language, hyphenation and thesaurus names from info file
    # if corresponding entries are present
    open INFOFILE, $infofile;
    while (<INFOFILE>){
	chomp;
	#print STDERR "** " . $_ . "\n";
	if ( m/^DICT.*/ ){
	    next if $language;
	    $language    = ( reverse split (/[\s\t]+/,$_))[0];
	} elsif ( m/^HYPH.*/ ){
	    next if $hyphenation;
	    $hyphenation = ( reverse split (/[\s\t]+/,$_))[0];
	} elsif ( m/^THES.*/ ){
	    next if $thesaurus;
	    $thesaurus = ( reverse split (/[\s\t]+/,$_))[0];
	}
	last if ( $language and $hyphenation and $thesaurus );
    }
    close INFOFILE;

    # Make sure the myspell lib dir exists

    $lib_dir = tmpdir ($package) . $dictdir;
    doit ("install", "-d", $lib_dir);

    # Install .aff and .dic in dicts dir, as well all the symlinks if
    # the language name contains an underscore

    for my $ext ("aff", "dic") {
	my $file = "$language.$ext";
	last unless $language;
	if ( $srcdir ){
	    die ("There is no $srcdir/$file file here\n")
		if not -f "$srcdir/$file";
	    doit ("install", "-m644", "$srcdir/$file", $lib_dir);
	}
	if ( $do_mozlinks && $file =~ /_/) {
	    my $link = $file;
	    $link =~ tr/_/-/;
	    doit ("ln", "-fs", $file, "$lib_dir/$link");
	}
    }

    # Install Openoffice hyphenation files, if the info-myspell entry
    # is a hyphenation one (so is called from a hyphenation package)

    if ( $srcdir and $hyphenation ){
	my $file = "$srcdir/$hyphenation.dic";
	die ("There is no $file file here\n")
	    if not -f "$file";
	doit ("install", "-m644", "$file", $lib_dir);
    }

    # Install Openoffice thesaurus files, if the info-myspell entry
    # is a thesaurus one (so is called from a thesaurus package)

    if ( $srcdir and $thesaurus ){
	foreach $ext ("dat","idx"){
	    my $file = "$srcdir/$thesaurus.$ext";
	    die ("There is no $file file here\n")
		if not -f "$file";
	    doit ("install", "-m644", "$file", $lib_dir);
	}
    }
}

__END__

=head1 NAME

B<installdeb-myspell> - debhelper-like utility for
maintainers of Openoffice.org myspell dictionary Debian packages

=head1 SYNOPSIS

 installdeb-myspell [--srcdir=dir] [debhelper options]

=head1 DESCRIPTION

B<installdeb-myspell> is a debhelper like program that is
responsible for installing appropriate debhelper snippets in
an myspell dictionary package for use under Openoffice.org,
according to the Debian Spell Dictionaries and Tools Policy.

I will also install Openoffice.org hyphenation or thesaurus
files if so requested when used from a Openoffice.org
hyphenation or thesaurus package and add appropriate debhelper
snippets so they are added to the dictionary.lst file.

For more details, see
 /usr/share/doc/dictionaries-common/dsdt-policy.txt.

The actions executed by B<installdeb-myspell> are the
following:

=over

=item Maintainer Scripts

B<installdeb-myspell> installs the necessary
scraps of code in the F<postinst> and F<postrm> scripts.

=item Language info file

B<installdeb-myspell> will look for a file containing
myspell dictionary information, called
F<debian/info-myspell> or
F<debian/package.info-myspell>.  If this file is
successfully parsed, it is installed in the
F<[tmpdir]/usr/share/myspell/infos/ooo> directory.

A typical info-myspell file for a myspell dictionary will
contain something like (all variants must refer to the same dict)

 # Spanish variants
 DICT es ES es_ES
 DICT es AR es_ES
 ...

while will, for a typical hyphenation file, be something like

 # Danish hyphenation
 HYPH da DK hyph_da_DK

or for a sample thesaurus,

 THES en US th_en_US

all with no leading whitespaces.

=item Mozilla spellchecker compatibility

B<installdeb-myspell> will set appropriate symlinks in
destination directory for mozilla spellchecker compatibility unless
debian/$package.links exists. If so, symlink creation is expected
to be handled through debhelper. This will be needed for some languages
(like eo) where mozilla expects the plain isolang code instead of the
lang-COUNTRY one.

=item Dictionary files installation

If the B<--srcdir=dir> option is set B<installdeb-myspell> will look for
the F<.aff/.dic> files in the directory specified by dir and install them
in the default target directory (F<[tmpdir]/usr/share/myspell/dicts>).
Base name will be extracted from the F<info-myspell> file. Same for
hyphenation and thesaurus files.

=item Debconf files

As opposed to B<installdeb-ispell> and B<installdeb-wordlist>, B<installdeb-myspell>
does nothing related to debconf files, that are not needed for myspell. For that
reason if you need to add debconf stuff with debhelper
to your myspell dictionary package do it in the usual way and call
dh_installdebconf(1) as for any other package.

=back

=head1 OPTIONS

--srcdir=dir  Will look for .aff/.dic files in the specified directory
              for myspell dict packages, for .dat files in
              Openoffice.org hyphenation packages and for {.dat,.idx}
              files in Openoffice.org thesaurus packages, installing
              them if present in the default target directory. Base
              name will be extracted from the info-myspell file. If
              this option is specified and files are not present an
              error will appear.

The usual debhelper(1) options are accepted.

=head1 NOTES

This program is not part of debhelper, although it is intended to be used
in Openoffice.org myspell dictionary packages using debhelper in its
building.

=head1 SEE ALSO

debhelper(1)

This program is part of the dictionaries-common-dev package.  It is
intended to be used by maintainers of Openoffice.org myspell dictionaries.
See the documentation under /usr/share/doc/dictionaries-common-dev.

=head1 AUTHORS

Rafael Laboissiere

=cut

#  LocalWords:  debhelper Debian myspell Openoffice