/usr/bin/installdeb-aspell 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 | #!/usr/bin/perl -w
#
# Registration with aspell dictionary
use strict;
my $class = "aspell";
my $no_pre_post;
my $no_config;
my $debug;
#
#
# -------------------------------------------------------
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 aspell
use Debian::Debhelper::Dh_Lib;
init();
use Debian::DictionariesCommon q(:all);
if ( defined $dh{NOSCRIPTS} ){
$no_pre_post = 1;
$no_config = 1;
};
$debug++ if ( defined $ENV{DICT_COMMON_DEBUG} );
foreach my $package (@{$dh{DOPACKAGES}}) {
my $lib_dir = tmpdir($package) . getlibdir($class);
my $infofile;
# Process the debian/info-aspell 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-aspell 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");
# Install debhelper and debhelper-like auto-scripts
unless ( $dh{NOSCRIPTS} or $no_pre_post) {
if ( $class ne "wordlist" ){
my %hash_extension = ("ispell" => "hash", "aspell" => "rws");
my %auto_hash_basenames = ();
my %auto_extra_hash_basenames = ();
# Get list of basenames for compat and contents files
my %auto_compat_basenames = ();
my %auto_contents_basenames = ();
foreach my $language ( keys %$dicts ){
my $entry = $dicts->{$language};
if ( defined $entry->{'auto-compat'} ) {
my $compat = $entry->{'auto-compat'};
foreach ( split(" ", $compat) ){
s/\.compat$//;
$auto_compat_basenames{$_}++;
}
}
if ( defined $entry->{'auto-contents'} ) {
my $contents = $entry->{'auto-contents'};
foreach ( split(" ", $contents) ){
s/\.contents$//;
$auto_contents_basenames{$_}++;
}
}
# Hashes list should be created automatically. This is here to
# add an extra hash name to the clean list on package
# removal. If you think about this, you may prefer to
# unconditionally remove old file from maintainer scripts.
if ( defined $entry->{'auto-extra-hash'} ) {
my $extra_hashes = $entry->{'auto-extra-hash'};
foreach ( split(" ", $extra_hashes) ){
s/\.$hash_extension{$class}$//;
$auto_hash_basenames{$_}++;
$auto_extra_hash_basenames{$_}++;
}
}
}
# Get automatic list of basenames for different hashes
foreach my $base_name ( sort keys %auto_compat_basenames ){
my $contents_file;
if ( $class eq "aspell" ) {
# Check if there is an associated contents file.
my $tmp_contents_file = "debian/$base_name.contents";
if ( -e $tmp_contents_file ) {
print STDERR "installeb-$class: Found contents file \"$tmp_contents_file\".\n"
if $debug;
# and if it has been declared.
if ( defined $auto_contents_basenames{$base_name} ){
print STDERR "installeb-$class: contents file \"$tmp_contents_file\" is properly declared.\n"
if $debug;
$contents_file = $tmp_contents_file;
} else {
print STDERR "installdeb-$class: Warning:\n"
. "\"$tmp_contents_file\" found, but no associated 'auto-compat' entry in info file.\n"
. "Ignoring \"$tmp_contents_file\"...\n";
}
} elsif ( defined $auto_contents_basenames{$base_name} ){
die "installdeb-$class error: No matching \"$tmp_contents_file\" for 'auto-compat' entry \"$base_name\". Aborting ...\n";
}
}
# Parse aspell contents file if enabled and present.
if ( $contents_file ){
open (my $CONTENTS, "< $contents_file")
or die "Could not open contents file \"$contents_file\". Aborting ...";
while (<$CONTENTS>){
next if m /^\s*\#/;
next if m/^\s*$/;
chomp;
s/\.rws$//;
# Add contents info to list of hashes to be removed.
$auto_hash_basenames{$_}++;
}
close $CONTENTS;
} else {
# Add base name to list of hashes to be removed.
$auto_hash_basenames{$base_name}++;
}
}
if ( scalar %auto_compat_basenames && $debug ){
print STDERR "installeb-$class info:\n";
if ( %auto_contents_basenames ){
print STDERR " auto-contents: \"",join(', ',sort keys %auto_contents_basenames),"\"\n";
}
print STDERR " auto-compat: \"",join(', ',sort keys %auto_compat_basenames),"\"\n";
print STDERR " auto-hash: \"", join(', ',sort keys %auto_hash_basenames), "\"\n";
}
if ( scalar %auto_compat_basenames ){
my $auto_compats = join(" ", map { $_ . ".compat" } sort keys %auto_compat_basenames);
my $auto_hashes = join(" ", map { $_ . ".$hash_extension{$class}" } sort keys %auto_hash_basenames);
my $varlibrm = "$auto_compats $auto_hashes";
# Install extra auto-scripts for auto-compat handling
autoscript ($package, "preinst", "preinst-compatfile-$class",
"s/#COMPAT#/$auto_compats/");
autoscript ($package, "postinst", "postinst-compatfile-$class",
"s/#COMPAT#/$auto_compats/");
autoscript ($package, "postrm", "postrm-varlibrm-$class",
"s/#VARLIBRM#/$varlibrm/");
# Make sure /var/lib/{a,i}spell directory is available.
my $var_lib_dir = tmpdir($package) . "/var/lib/$class";
doit ("install", "-d", $var_lib_dir);
# Automatically provide symlinks for the different hashes
my $usr_lib_dir = tmpdir($package) . "/usr/lib/$class";
doit ("install", "-d", $usr_lib_dir);
foreach my $hash ( sort keys %auto_hash_basenames ){
# Not for extra hashes only for the clean list
next if ( defined $auto_extra_hash_basenames{$hash} );
$hash = $hash . '.' .$hash_extension{$class};
unless ( -e "$usr_lib_dir/$hash" ){
print STDERR "installdeb-$class: Setting \"$usr_lib_dir/$hash\" symlink.\n" if $debug;
symlink "/var/lib/$class/$hash", "$usr_lib_dir/$hash"
}
}
}
}
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-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-dev/dsdt-policy.txt.gz
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</var/lib/dictionaries-common/aspell> directory.
=item * Debconf files
As opposed to B<installdeb-ispell> and B<installdeb-wordlist>, neither B<installdeb-aspell>
nor B<installdeb-hunspell> do anything 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.
=item * Extra installdeb-aspell options in Language info file
For benefit of aspell dictionaries using B<aspell-autobuildhash>,
B<installdeb-aspell> script will look for C<'auto-compat'> and
C<'auto-contents'> fields in F<$lang.info-aspell>, containing base
name(s) of your compat and, if needed, contents file(s). If
C<'auto-compat'> entry is found two debhelper snippets are added, one
to create/reset compatfile(s) in postinst and the other to remove
files in a removal list (initially containing compat files) from
postrm. If C<'auto-contents'> entry is found, contents file at
F<debian/> will be parsed and its contents added to the removal list,
otherwise a hash with the same basename of the compatfile is expected
and added to the removal list. Unless previous stuff exists,
F</usr/lib/aspell}/$dict.rws -E<gt> /var/lib/aspell/$dict.rws>
symlinks will also be automatically created. If you use a contents
file and enable it in C<'auto-contents'> you usually will need only
the same base name enabled in C<'auto-compat'>.
=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
aspell 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
# mode: flyspell-prog
# ispell-local-dictionary: "american"
# End:
# LocalWords: aspell ispell wordlist debconf debhelper Debian config postrm
# LocalWords: debian elanguages installdeb dephelper installdebconf Elanguage
# LocalWords: Laboissiere
|