#!/usr/bin/perl -w
#
# Registration with hunspell dictionary

my $class = "hunspell";
my $no_pre_post;
#

# -------------------------------------------------------
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;
}

# =======================================================
# Main part
# =======================================================

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

# --- No extra options for hunspell 

use Debian::Debhelper::Dh_Lib;
init();

use Debian::DictionariesCommon q(:all);

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

  my $lib_dir = tmpdir($package) . getlibdir($class);
  my $infofile;

  # Process the debian/info-hunspell file
  unless ( $infofile = pkgfile ($package, "info-$class") ) {
    mywarn ("There is no debian/[package.]info-$class file for package $package.",
            "the dictionaries-common Policy");
  }

  # Parse the debian/info-hunspell file
  my $dicts = parseinfo ($infofile);

  # If we get here, the parseinfo call was successful. Install the
  # file in the dictionaries-common lib dir.
  doit ("install", "-d", $lib_dir);
  doit ("install", "-m644", $infofile, "$lib_dir/$package");

  unless ( $dh{NOSCRIPTS} or $no_pre_post) {
    autoscript ($package, "postinst", "postinst-$class",
		"s/#PACKAGE#/$package/");
    autoscript ($package, "postrm", "postrm-$class",
		"s/#PACKAGE#/$package/");
  }
  # -- No debconf handling needed for aspell or hunspell --
}


__END__

=head1 NAME

B<installdeb-hunspell> - debhelper-like utility for
maintainers of  Debian packages

=head1 SYNOPSIS

 installdeb-hunspell [debhelper options] 

=head1 DESCRIPTION

B<installdeb-hunspell> is a debhelper like program that is
responsible for installing appropriate debhelper snippets in
a  package,
according to the Debian Spell Dictionaries and Tools Policy.

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

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

=over

=item * Maintainer Scripts

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

=item * Language info file

B<installdeb-hunspell> also checks a file containing
 information, called
F<debian/info-hunspell> or
F<debian/package.info-hunspell>.  If this file is
successfully parsed, it is installed in the
F<[tmpdir]/var/lib/dictionaries-common> directory.

=item * Debconf files


As opposed to B<installdeb-ispell> and B<installdeb-wordlist>, neither B<installdeb-aspell>
nor B<installdeb-hunspell> does nothing related to debconf files, since both aspell and
hunspell rely on the environment variable C<LANG> for default dictionary selection
instead of using symlinks set after a debconf question on dictionary
installation. For that reason if you need to add debconf stuff with debhelper
to your aspell or hunspell dictionary package do it in the usual way and call
dh_installdebconf(1) as for any other package.

=back

=head1 OPTIONS

The usual dephelper(1) options are accepted. 

=head1 NOTES

This program is not part of debhelper, although it is intended to be used
in hunspell 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
hunspell dictionary
packages for Debian. See the documentation
under /usr/share/doc/dictionaries-common-dev.

=head1 AUTHORS

Rafael Laboissiere, Agustin Martin

=cut

# Local Variables:
#  mode: perl
#  ispell-local-dictionary: "american"
# End:

#  LocalWords:  aspell ispell wordlist debconf debhelper Debian config postrm
#  LocalWords:  debian elanguages installdeb dephelper installdebconf Elanguage
#  LocalWords:  Laboissiere
