/usr/bin/installdeb-myspell is in dictionaries-common-dev 1.20.5.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 | #!/usr/bin/perl -w
#
# ooo dict/thesauri/hyphenation file installation with optional ooo2
# compatible symlinks and registration with Openoffice.org dictionary list.
use strict;
use Text::Wrap;
$Text::Wrap::columns = 72;
use Debian::Debhelper::Dh_Lib;
my $srcdir = '';
my $o2compat = '';
my $dico_debug = '';
my $do_altlinks = 1;
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;
}
sub dico_parse_options {
my @options = ();
foreach my $opt ( @_ ){
if ( $opt eq "--dico-debug" ){
$dico_debug = 1;
} elsif ( $opt =~ s/^--srcdir=// ){
$srcdir = $opt;
} elsif ( $opt eq "--dico-alt-links" ){
$do_altlinks = 1;
} elsif ( $opt eq "--dico-no-alt-links" ){
$do_altlinks = '';
} elsif ( $opt eq "--o2compat" ){
$o2compat = 1;
} elsif ( $opt eq "--no-o2compat" ){
$o2compat = '';
} else {
push @options, $opt;
}
}
return @options;
}
# Hijack installdeb-myspell specific options from the
# command line, before debhelper's parseopt can see them.
@ARGV = dico_parse_options @ARGV;
# And now initialize debhelper
init();
# and do the real work
my $old_destdir;
my $class = "myspell";
my $oooinfodir = "/usr/share/myspell/infos/ooo";
my $old_installdir = "/usr/share/myspell/dicts";
my %installdir = ( "hunspell" => "/usr/share/hunspell",
"hyphenation" => "/usr/share/hyphen",
"thesauri" => "/usr/share/mythes");
foreach my $package (@{$dh{DOPACKAGES}}) {
my %datahash = ();
# 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 ( $o2compat ) {
# Install the info file in the openoffice2 info dir if requested.
my $old_infodir = tmpdir ($package) . $oooinfodir;
doit ("install", "-d", $old_infodir);
doit ("install", "-m644", $infofile, "$old_infodir/$package");
# Make sure the old myspell dict/hyphen/thesauri dir exists if requested
$old_destdir = tmpdir ($package) . $old_installdir;
doit ("install", "-d", $old_destdir);
}
# Parse info file for dict, hyphen, thesauri, lang and country data..
open INFOFILE, $infofile;
while (<INFOFILE>){
next if m/^\s*\#/;
chomp;
s/\#.*$//;
print STDERR $_ . "\n" if $dico_debug;
my ( $type, $lang, $country, $file) = split(' ',$_);
$datahash{$type}{$file}{"$lang\_$country"}++;
}
close INFOFILE;
# If --srcdir is passed, install .aff and .dic in dicts dir as
# well as mozilla symlinks if it contains an underscore.
if ( $srcdir && defined $datahash{'DICT'} ){
foreach my $dictionary ( keys %{$datahash{'DICT'}} ) {
my $dictdir = $installdir{"hunspell"};
my $destdir = tmpdir ($package) . $dictdir;
my @alternatives = keys %{$datahash{'DICT'}{$dictionary}};
print STDERR "Installing DICT $dictionary files in $destdir\n";
print STDERR " Alternatives: " . join(', ',@alternatives) . "\n"
if $dico_debug;
doit ("install", "-d", $destdir);
$dictdir =~ s/.*\///;
for my $ext ("aff", "dic") {
my $basefrom = my $basedest = "$dictionary.$ext";
my $srcfile = "$srcdir/$basefrom";
die ("There is no $srcfile file here\n")
unless -f "$srcfile";
# Install base dict in destination directory.
$basedest =~ tr/-/_/;
if ( $basefrom ne $basedest ){
print STDERR " Warning: $basefrom renamed to $basedest\n"
}
doit ("install", "-m644", "$srcfile", "$destdir/$basedest");
# Install symlink to base dict in old destdir if in o2compat mode.
# If name has been changed (tr/-/_/) it is in Mozilla form in
# dictionaries.lst, so use original name for link origin.
if ( $o2compat ){
my $lbasefrom = ( $basedest eq $basefrom ) ? $basedest : $basefrom;
my $ltarget = "../../$dictdir/$basedest";
print STDERR " Installing symlink olddir/$lbasefrom to $ltarget\n"
if $dico_debug;
doit ("ln", "-fs", "$ltarget", "$old_destdir/$lbasefrom");
}
# Install Mozilla symlinks in old destdir if in o2compat mode.
if ( $o2compat && $basedest =~ /_/ ) {
my $mozlink = $basedest;
$mozlink =~ tr/_/-/;
my $ltarget = "../../$dictdir/$basedest";
print STDERR " Installing Mozilla alternative symlink olddir/$mozlink to $ltarget\n"
if $dico_debug;
doit ("ln", "-fs", "$ltarget", "$old_destdir/$mozlink");
}
# Install normal and Mozilla symlinks for alternative names if needed.
if ( $do_altlinks ){
foreach my $altlink ( @alternatives) {
my $newlink = "$altlink.$ext";
unless ( $newlink eq $basedest ){
print STDERR " Installing alternative symlink $newlink to $basedest\n"
if $dico_debug;
doit ("ln", "-fs", $basedest, "$destdir/$newlink");
if ( $o2compat && $newlink =~ /_/ ){
my $ltarget = "../../$dictdir/$basedest";
my $mozlink = $newlink;
$mozlink =~ tr/_/-/;
print STDERR " Installing Mozilla alternative symlink olddir/$mozlink to $ltarget\n"
if $dico_debug;
doit ("ln", "-fs", "$ltarget", "$old_destdir/$mozlink");
}
}
}
}
}
}
}
# If --srcdir is passed, install Openoffice hyphenation files
# after data in info file
if ( $srcdir && defined $datahash{'HYPH'} ){
foreach my $hyphenation ( keys %{$datahash{'HYPH'}} ) {
my $hyphdir = $installdir{"hyphenation"};
my $destdir = tmpdir ($package) . $hyphdir;
print STDERR "Installing HYPH $hyphenation files in $destdir\n";
my $basefile = "$hyphenation.dic";
my $srcfile = "$srcdir/$basefile";
$hyphdir =~ s/.*\///;
my $ltarget = "../../$hyphdir/$basefile";
die ("There is no $srcfile file here\n")
if not -f "$srcfile";
doit ("install", "-d", $destdir);
doit ("install", "-m644", "$srcfile", $destdir);
doit ("ln", "-fs", "$ltarget", "$old_destdir/$basefile")
if $o2compat;
}
}
# If --srcdir is passed, install Openoffice thesaurus files
# after data in info file
if ( $srcdir && defined $datahash{'THES'} ){
foreach my $thesaurus ( keys %{$datahash{'THES'}} ) {
my $thesdir = $installdir{"thesauri"};
my $destdir = tmpdir ($package) . $thesdir;
print STDERR "Installing THES $thesaurus files in $destdir\n";
$thesdir =~ s/.*\///;
doit ("install", "-d", $destdir);
foreach my $ext ("dat","idx"){
my $basefile = "$thesaurus.$ext";
my $srcfile = "$srcdir/$basefile";
my $ltarget = "../../$thesdir/$basefile";
die ("There is no $srcfile file here\n")
if not -f "$srcfile";
doit ("install", "-m644", "$srcfile", $destdir);
doit ("ln", "-fs", "$ltarget", "$old_destdir/$basefile")
if $o2compat;
}
}
}
}
__END__
=head1 NAME
B<installdeb-myspell> - debhelper-like helper for Debian packages
containing myspell/hunspell dictionaries or Openoffice.org
thesauri/hyphenation files.
=head1 SYNOPSIS
installdeb-myspell [--srcdir=dir] [--dico-debug] [--{no-}o2compat] [debhelper options]
=head1 DESCRIPTION
B<installdeb-myspell> is a debhelper like program to help
installing myspell/hunspell dicts as well as Openoffice.org
thesauri or hyphenation files, after contents of an
F<info-myspell> file whose format is that for old
Openoffice.org 2. This needs the B<--srcdir> option enabled.
If in o2 compatibility mode, it will also install appropriate
debhelper snippets, info file and compatibility symlinks
in a way a package containing myspell/hunspell dictionaries
or Openoffice.org thesauri or hyphenation files can be used
in Debian lenny and former under Openoffice.org 2 and Mozilla*
according to the dictionaries policy valid at that time.
Note that unless B<--srcdir> option is used or o2compat mode
is enabled, this program will do nothing.
For more details, see
/usr/share/doc/dictionaries-common/dsdt-policy.txt.
The actions executed by B<installdeb-myspell> are the
following (only some of them are done if not in o2
compatibility mode):
=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 named F<debian/info-myspell>
or F<debian/package.info-myspell>. That file contains myspell/hunspell
dictionary, OOO thesauri or hyphenation information with lines like
TYPE LANG COUNTRY NAME
If this file is successfully parsed and the o2compat option is enabled,
it is installed in the F<[tmpdir]/usr/share/myspell/infos/ooo> directory.
A typical F<info-myspell> file for a myspell/hunspell dictionary will
contain something like
# 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 whitespace. Commented lines are allowed.
=item Dictionary, thesaurus and hyphenation 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/hunspell>).
Base name will be extracted from the F<info-myspell> file (last string in
the line). If target dict uses the ancient Mozilla hyphen form, it will
be renamed to the lowbar form on installation.
Same (but the renaming) for hyphenation and thesaurus files, to be installed in
F<[tmpdir]/usr/share/hyphen> and F<[tmpdir]/usr/share/mythes>.
If o2compat option is enabled, I<lenny> compatibility symlinks will be
installed as well.
=item Dictionaries alternative symlinks creation
B<installdeb-myspell> will, according to info extracted from the F<info-myspell>,
automatically set B<lang_COUNTRY> symlinks to the dict files installed by
B<installdeb-myspell>. This will only be done when the B<--srcdir> option is
used.
If B<--srcdir> option is used and the F<info-myspell> file contains something
like
# Spanish variants
DICT es ES es
DICT es AR es
...
B<installdeb-myspell> will automatically set B<es_ES> and B<es_AR> symlinks
=item Mozilla spellchecker compatibility
For myspell/hunspell dictionaries, Mozilla had a B<lang{,-COUNTRY}> to names
translation table using hyphens as separators (and for some languages not using
country part at all) instead of lowbars.
Shortly, that will no longer be the case. Mozilla will also accept
B<lang_COUNTRY> format for that translation table, no special things
will be needed. In particular, do not duplicate entries in both lowbar
and hyphen forms. Use lowbar.
=item Debconf files
As opposed to B<installdeb-ispell> and B<installdeb-wordlist>, B<installdeb-myspell>
does nothing related to debconf files, not needed for myspell/hunspell dicts and
OOO thesauri and hyphenation files. If you need to add debconf stuff with debhelper
proceed in the usual way and call dh_installdebconf(1) as for any other package.
=back
=head1 OPTIONS
--dico-debug Show some B<installdeb-myspell> specific debugging info.
Does not enable debhelper debug, you need to enable
it separately.
--srcdir=dir Will look for F<.aff/.dic> files in the specified directory
for myspell/hunspell dict packages, for F<.dic> files in
Openoffice.org hyphenation packages and for F<.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.
--{no-}o2compat Disable/enable openoffice2 compatibility. If enabled,
info file will be installed in
F<[tmpdir]/usr/share/myspell/infos/ooo> and compatibility
symlinks will be set from the old
F<[tmpdir]/usr/share/myspell/dicts location>. This option
is disabled by default.
--dico-{no-}alt-links {Process/Do not process} alternative symlinks
according to info found in the myspell info file.
The usual debhelper(7) options are accepted.
=head1 NOTES
This program is not part of debhelper, although depends on and is
intended to work together with it.
=head1 SEE ALSO
debhelper(7)
This program is part of the dictionaries-common-dev package. It is
intended for use by maintainers of packages containing myspell/hunspell
dictionaries or Openoffice.org thesauri/hyphenation files.
See the documentation under /usr/share/doc/dictionaries-common-dev.
=head1 AUTHORS
Rafael Laboissiere <rafael@debian.org>,
Agustin Martin <agmartin@debian.org>
=cut
# LocalWords: debhelper Debian myspell Openoffice
|