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

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

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

use Debian::DictionariesCommon q(:all);

my $dictdir = "/usr/share/dictionaries-common/debconf";
my $class = "aspell";

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}}) {

  # Process the debian/info-aspell 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");
  }
  # Parse the debian/info-aspell file
  my $dicts = parseinfo ($infofile);

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

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


}


__END__

=head1 NAME

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

=head1 SYNOPSIS

 installdeb-aspell [debhelper options]

=head1 DESCRIPTION

B<installdeb-aspell> is a debhelper like program that is
responsible for installing appropriate debhelper snippets in
an aspell dictionary 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-aspell> are the
following:

=over

=item Maintainer Scripts

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

=item Language info file

B<installdeb-aspell> also checks a file containing
aspell dictionary information, called
F<debian/info-aspell> or
F<debian/package.info-aspell>.  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>, B<installdeb-aspell>
does nothing related to debconf files, since aspell relies on the
environment variable 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 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 aspell 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 ispell dictionaries and wordlist
packages for Debian.  See the documentation under
/usr/share/doc/dictionaries-common-dev.

=head1 AUTHORS

Rafael Laboissiere

=cut

#  LocalWords:  aspell ispell wordlist debconf debhelper Debian config postrm
#  LocalWords:  debian
