diff -Nru dictionaries-common-1.5.17ubuntu1/debian/changelog dictionaries-common-1.9.2ubuntu1/debian/changelog --- dictionaries-common-1.5.17ubuntu1/debian/changelog 2011-02-05 00:15:41.000000000 +0100 +++ dictionaries-common-1.9.2ubuntu1/debian/changelog 2011-02-09 09:44:47.000000000 +0100 @@ -1,3 +1,54 @@ +dictionaries-common (1.9.2ubuntu1) natty; urgency=low + + * Merge from debian unstable. (LP: #715644) Remaining changes: + - scripts/system/dc-debconf-select.pl: Drop default debconf priority + from 'high' to 'medium'. + + -- Angel Abad Wed, 09 Feb 2011 09:38:08 +0100 + +dictionaries-common (1.9.2) unstable; urgency=low + + * ispell-autobuildhash: + - Cleanup tempdir by setting 'CLEANUP' when creating it. + Do not do that if debg is enabled. + * scripts/system/dc-debconf-default-value.pl: + - Remove redundant (on debug) info. + + -- Agustin Martin Domingo Tue, 08 Feb 2011 18:58:09 +0100 + +dictionaries-common (1.9.1) unstable; urgency=low + + * support/emacsen/debian-ispell.el: + - Prefer aspell over ispell (Closes: #612399). + * debian/dictionaries-common.config-footer: + - Fix 'uninitialized value' messages when no elements are to + be installed for a class in first installation. + * debian/dc-debconf-select.pl: + - Make sure dc-debconf-default-value.pl is not loaded from + dictionaries-common.config (Closes: #612377). + + -- Agustin Martin Domingo Tue, 08 Feb 2011 18:01:32 +0100 + +dictionaries-common (1.9.0) unstable; urgency=low + + * Use strict for the different perl scripts. + * {a,i}spell-autobuildhash: + - Add a dry-run option. + - Code reorganization and clean-up. + * Basic support for {a,i}spell-autobuildhash triggers. + * aspell-autobuildhash: Leave --per-conf empty instead of using + /dev/null. Helps testing in chroots. + * ispell-autobuildhash: Use File::Temp::tempdir for temporary + directory creation. + * Partial reorganization of the config scripts. + * No longer deal with emacs21 and emacs22. Add emacs20 to + build-exclusion list. (Closes: #610574). + * Explain patched ispell.el and flyspell.el addition (Closes: #606299). + * debian-ispell.el: Make sure flyspell tickbox is enabled at startup + if appropriate. + + -- Agustin Martin Domingo Mon, 07 Feb 2011 11:39:46 +0100 + dictionaries-common (1.5.17ubuntu1) natty; urgency=low * Merge from debian unstable. (LP: #711487) Remaining changes: diff -Nru dictionaries-common-1.5.17ubuntu1/debian/control dictionaries-common-1.9.2ubuntu1/debian/control --- dictionaries-common-1.5.17ubuntu1/debian/control 2010-10-24 23:26:52.000000000 +0200 +++ dictionaries-common-1.9.2ubuntu1/debian/control 2011-02-09 05:42:51.000000000 +0100 @@ -66,9 +66,11 @@ Suggests: ispell, emacsen-common, jed-extra Description: Common utilities for spelling dictionary tools These are utilities shared by all ispell, myspell and wordlist - dictionaries, including support for some tools that use ispell - (like emacsen, jed and mutt). More info about naming conventions - and availability of those dictionaries in the README file. + dictionaries, including support for some tools that use ispell + (like emacsen, jed and mutt) and some patched spell-checking + lisp files for better system integration. + More info about naming conventions and availability of those + dictionaries in README.Debian file. . Maintainers should install dictionaries-common-dev as well, and read its documentation. diff -Nru dictionaries-common-1.5.17ubuntu1/debian/dictionaries-common.config-footer dictionaries-common-1.9.2ubuntu1/debian/dictionaries-common.config-footer --- dictionaries-common-1.5.17ubuntu1/debian/dictionaries-common.config-footer 2010-10-20 11:54:00.000000000 +0200 +++ dictionaries-common-1.9.2ubuntu1/debian/dictionaries-common.config-footer 2011-02-09 05:42:51.000000000 +0100 @@ -7,20 +7,23 @@ # Prompting the questions if required if ( not -e $dcscript ){ # First dictionaries-common installation - foreach $class ("ispell","wordlist"){ - &dc_debugprint("\n- dictionaries-common.config: Initial configuration for class $class.\n\n"); - my $guessed = &dc_set_default_value_for_class($class); - &dc_debconf_select($class,$priority{$class}); - # This might have been pre-seeded and question not asked. - # Make sure question is tagged as seen in this case - if ( $guessed ){ + foreach my $class ("ispell","wordlist"){ + &dc_debugprint("\n- dictionaries-common.config: Initial configuration for class \"$class\".\n\n"); + # This returns $class and $priority (along with here unused $guess) + my $classinfo = &dc_set_default_value_for_class($class); + if ( $classinfo ){ + &dc_debconf_select($classinfo); + # This might have been pre-seeded and question not asked. + # Make sure question is tagged as seen in this case fset ("dictionaries-common/default-$class", "seen", "true"); go(); + } else { + &dc_debconf_select($class); } } } else { # Reconfiguring or upgrading - foreach $class ("ispell","wordlist"){ - &dc_debconf_select($class); + foreach my $class ("ispell","wordlist"){ + &dc_debconf_select({'class' => $class}); } } diff -Nru dictionaries-common-1.5.17ubuntu1/debian/dictionaries-common.config-header dictionaries-common-1.9.2ubuntu1/debian/dictionaries-common.config-header --- dictionaries-common-1.5.17ubuntu1/debian/dictionaries-common.config-header 2010-10-20 11:54:00.000000000 +0200 +++ dictionaries-common-1.9.2ubuntu1/debian/dictionaries-common.config-header 2011-02-09 05:42:51.000000000 +0100 @@ -7,6 +7,7 @@ # - dictionaries-common.config-footer # ------------------------------------------------------------------------- +use strict; use Debconf::Client::ConfModule q(:all); version ('2.0'); diff -Nru dictionaries-common-1.5.17ubuntu1/debian/dictionaries-common.postinst dictionaries-common-1.9.2ubuntu1/debian/dictionaries-common.postinst --- dictionaries-common-1.5.17ubuntu1/debian/dictionaries-common.postinst 2010-10-20 11:54:00.000000000 +0200 +++ dictionaries-common-1.9.2ubuntu1/debian/dictionaries-common.postinst 2011-02-09 05:42:51.000000000 +0100 @@ -76,7 +76,23 @@ fi ;; - + triggered) + for trigger in ${*#triggered}; do + [ -z "$DICT_COMMON_DEBUG" ] || echo "Running trigger $trigger" >&2 + case $trigger in + triggered) + ;; + aspell-autobuildhash) + aspell-autobuildhash --triggered + ;; + ispell-autobuildhash) + ispell-autobuildhash --triggered + ;; + *) + echo "Unsupported trigger $trigger" >&2 + esac + done + ;; abort-upgrade|abort-remove|abort-deconfigure) ;; @@ -95,3 +111,7 @@ #DEBHELPER# exit 0 + +# Local Variables: +# sh-indentation: 2 +# End: \ No hay ningún carácter de nueva línea al final del archivo diff -Nru dictionaries-common-1.5.17ubuntu1/debian/dictionaries-common.triggers dictionaries-common-1.9.2ubuntu1/debian/dictionaries-common.triggers --- dictionaries-common-1.5.17ubuntu1/debian/dictionaries-common.triggers 1970-01-01 01:00:00.000000000 +0100 +++ dictionaries-common-1.9.2ubuntu1/debian/dictionaries-common.triggers 2011-02-08 19:10:55.000000000 +0100 @@ -0,0 +1,3 @@ +# Triggers for dictionaries-common +interest aspell-autobuildhash +interest ispell-autobuildhash diff -Nru dictionaries-common-1.5.17ubuntu1/debian/emacsen-install dictionaries-common-1.9.2ubuntu1/debian/emacsen-install --- dictionaries-common-1.5.17ubuntu1/debian/emacsen-install 2010-10-20 11:54:00.000000000 +0200 +++ dictionaries-common-1.9.2ubuntu1/debian/emacsen-install 2011-02-09 05:42:51.000000000 +0100 @@ -28,8 +28,8 @@ xemacs*) flags="-no-site-file" ;; - emacs19|emacs-snapshot*) - # Do not byte-compile anything for emacs19 or emacs-snapshot + emacs19|emacs20|emacs21|emacs22|emacs-snapshot*) + # Do not byte-compile anything for above emacsen flavours echo "install/${package}: Skipping byte-compilation for $flavour" exit 0 ;; diff -Nru dictionaries-common-1.5.17ubuntu1/debian/README.Debian dictionaries-common-1.9.2ubuntu1/debian/README.Debian --- dictionaries-common-1.5.17ubuntu1/debian/README.Debian 2010-10-20 11:54:00.000000000 +0200 +++ dictionaries-common-1.9.2ubuntu1/debian/README.Debian 2011-02-09 05:42:51.000000000 +0100 @@ -89,8 +89,44 @@ that this sometimes need changing the LANG value from a thing like 'spanish' to something like 'es_ES'. Check if this is your case. ----------------------------------- - -- Agustin Martin Domingo , Fri, 15 Jan 2010 15:54:28 +0100 +Other relevant README's: +====================== + +README.dictionary.lst: +---------------------- + * Obsolescence of dictionary.lst + +README.jed-support: +------------------- + * JED Support in dictionaries-common + +README.emacs: +------------- + * Why shipping ispell.el and flyspell.el, already included in {X,}Emacs? + * Selecting a default dictionary locally + * Using aspell with ispell.el + * Force disabling of dictionaries-common emacsen-stuff + * ispell.el loading at start-up + * Spell-checking utf-8 buffers + * Adding customized entries for emacs + * Some other tips for flyspell.el + +README.problems: +---------------- + * Debugging dictionaries-common first configuration from debian-installer + * debconf question asked on every upgrade + * Problems installing or removing a wordlist/ispell dictionary + +README.source: +-------------- + * Using a patch system to manage modifications. + + -- Agustin Martin Domingo , Thu, 27 Jan 2011 13:20:17 +0100 + + Local Variables: + ispell-local-dictionary: "american" + End: LocalWords: debian debconf usr alioth org wordlists wordlist debhelper http - LocalWords: iamerican wspanish miscfiles xemacs wbritish var html dpkg + LocalWords: iamerican wspanish miscfiles xemacs wbritish var html dpkg ispell + LocalWords: flyspell diff -Nru dictionaries-common-1.5.17ubuntu1/debian/README.dictionary.lst dictionaries-common-1.9.2ubuntu1/debian/README.dictionary.lst --- dictionaries-common-1.5.17ubuntu1/debian/README.dictionary.lst 2010-10-20 11:54:00.000000000 +0200 +++ dictionaries-common-1.9.2ubuntu1/debian/README.dictionary.lst 2011-02-09 05:42:51.000000000 +0100 @@ -1,7 +1,7 @@ -`/etc/openoffice/dictionary.lst' is not used at all in +"/etc/openoffice/dictionary.lst" is not used at all in OpenOffice.org >=3. No need to try getting that file or recreating it in that case, is useless and will be removed. -`/etc/openoffice/dictionary.lst' is only needed if you are +"/etc/openoffice/dictionary.lst" is only needed if you are using OpenOffice.org <3. Remember, otherwise it will be removed. diff -Nru dictionaries-common-1.5.17ubuntu1/debian/README.emacs dictionaries-common-1.9.2ubuntu1/debian/README.emacs --- dictionaries-common-1.5.17ubuntu1/debian/README.emacs 2010-10-20 11:54:00.000000000 +0200 +++ dictionaries-common-1.9.2ubuntu1/debian/README.emacs 2011-02-09 05:42:51.000000000 +0100 @@ -1,5 +1,15 @@ # -*- readme-debian -*- +Why shipping ispell.el and flyspell.el, already included in {X,}Emacs? +--------------------------------------------------------------------- + +Note that they are not the same as those shipped by {X,}Emacs. + +They follow those in FSF Emacs trunk, so they are usually way more recent +than those shipped with normal Emacs releases. They are also patched to +work with XEmacs and to provide a common *spell interface to all emacsen +flavors in Debian, with integration of dictionaries system. + Selecting a default dictionary locally -------------------------------------- @@ -45,7 +55,7 @@ and add your flavor to the `skip-emacs-flavors-list' list. -ispell.el loading at startup +ispell.el loading at start-up ---------------------------- Emacs comes dumped with an ispell-menu-map containing a set of @@ -75,7 +85,7 @@ However this is not available out-of-the-box for all encodings. If this is not working for you, please try installing package 'mule-ucs'. The drawback -is that your emacs startup will become (much) slower. Remember, this will +is that your emacs start-up will become (much) slower. Remember, this will not work for xemacs21-nomule. Adding customized entries for emacs @@ -178,8 +188,8 @@ (< bufsize maxsize)) (flyspell-buffer))))) ----------------------------------- - -- Agustin Martin Domingo , Fri, 16 Jan 2009 20:39:11 +0100 + + -- Agustin Martin Domingo , Thu, 27 Jan 2011 13:24:27 +0100 Local Variables: ispell-local-dictionary: "american" diff -Nru dictionaries-common-1.5.17ubuntu1/debian/README.problems dictionaries-common-1.9.2ubuntu1/debian/README.problems --- dictionaries-common-1.5.17ubuntu1/debian/README.problems 2010-10-20 11:54:00.000000000 +0200 +++ dictionaries-common-1.9.2ubuntu1/debian/README.problems 2011-02-09 05:42:51.000000000 +0100 @@ -19,7 +19,7 @@ debconf question asked on every upgrade --------------------------------------- -If everytime you upgrade any wordlist or ispell dictionary are asked +If every time you upgrade any wordlist or ispell dictionary are asked about preferred language (and not only at most the first time you installed it) there is a problem, because that is not what current code should do. @@ -66,7 +66,7 @@ > but that's a small price to pay for a consistent debconf database. ---------------------------------- - -- Agustin Martin Domingo , Tue, 13 Feb 2007 15:40:06 +0100 + -- Agustin Martin Domingo , Thu, 27 Jan 2011 13:27:51 +0100 LocalWords: debian debconf usr alioth org wordlists wordlist debhelper http - LocalWords: iamerican wspanish miscfiles xemacs wbritish var html dpkg + LocalWords: iamerican wspanish miscfiles xemacs wbritish var html dpkg ispell diff -Nru dictionaries-common-1.5.17ubuntu1/Makefile.in dictionaries-common-1.9.2ubuntu1/Makefile.in --- dictionaries-common-1.5.17ubuntu1/Makefile.in 2011-02-05 00:15:41.000000000 +0100 +++ dictionaries-common-1.9.2ubuntu1/Makefile.in 2011-02-09 05:42:51.000000000 +0100 @@ -95,6 +95,12 @@ debhelper_scripts_noauto := $(addprefix scripts/debhelper/, \ installdeb-myspell) +dico_config := debian/dictionaries-common.config +dico_config_parts := debian/dictionaries-common.config-header \ + scripts/system/dc-debconf-default-value.pl \ + scripts/system/dc-debconf-select.pl \ + debian/dictionaries-common.config-footer + ######################################################################### # Policy definitions @@ -105,7 +111,7 @@ ######################################################################### # Main target for build -all: $(policy).txt $(system_scripts) $(debhelper_scripts) $(select_readmes) +all: $(policy).txt $(system_scripts) $(debhelper_scripts) $(select_readmes) $(dico_config) ######################################################################### @@ -120,6 +126,11 @@ perl -pi -e 's/\015 *//g' | \ iconv -f iso-8859-1 -t utf-8 > $@ +######################################################################### +# Make dictionaries-common debconf config file combining the diferent parts + +$(dico_config): $(dico_config_parts) + cat $^ > $@ ######################################################################### # Template rules using the slice filter @@ -217,20 +228,13 @@ scripts/system/dc-debconf-default-value.pl \ $(share_dict_dir) - # -- Make debconf config file combining the diferent parts - cat debian/dictionaries-common.config-header \ - scripts/system/dc-debconf-default-value.pl \ - scripts/system/dc-debconf-select.pl \ - debian/dictionaries-common.config-footer \ - > debian/dictionaries-common.config - ######################################################################### # Mr Proper clean: rm -f $(policy).html $(policy).txt $(maintainer_scripts) \ $(system_scripts) $(debhelper_scripts) $(select_readmes) \ - debian/dictionaries-common.config + $(dico_config) distclean: clean rm -f Makefile config.* scripts/Debian/DictionariesCommon.pm \ diff -Nru dictionaries-common-1.5.17ubuntu1/scripts/debhelper/installdeb.in dictionaries-common-1.9.2ubuntu1/scripts/debhelper/installdeb.in --- dictionaries-common-1.5.17ubuntu1/scripts/debhelper/installdeb.in 2010-10-20 11:54:00.000000000 +0200 +++ dictionaries-common-1.9.2ubuntu1/scripts/debhelper/installdeb.in 2011-02-09 05:42:51.000000000 +0100 @@ -2,8 +2,11 @@ # # Registration with [I:ispell dictionary:][A:aspell dictionary:][H:hunspell dictionary:][W:wordlists:] +use strict; + my $class = "[I:ispell:][A:aspell:][H:hunspell:][W:wordlist:]"; my $no_pre_post; +my $no_config; #[IW: my $write_elanguages; my $no_installdebconf; @@ -38,7 +41,7 @@ my $package = shift; my $dicts = shift; - return if ($dh{NOSCRIPTS}); + return if $no_config; my $dictdir = "/usr/share/dictionaries-common/debconf"; my $debug = 1 if exists $ENV{'DICT_COMMON_DEBUG'}; @@ -69,6 +72,7 @@ # Check if there is a debian/[package.]config.in file if ($orig_config_file = pkgfile ($package, "config.in")) { + my $isshell; # Read it and check if it is a Bourne shell or a Perl script open (INCONFIG, "< $orig_config_file"); if ((my $shell_line = ) =~ m{^\#!\s*(/bin/sh|/usr/bin/perl)}){ @@ -223,7 +227,12 @@ use Debian::DictionariesCommon q(:all); -foreach $package (@{$dh{DOPACKAGES}}) { +if ( defined $dh{NOSCRIPTS} ){ + $no_pre_post = 1; + $no_config = 1; +}; + +foreach my $package (@{$dh{DOPACKAGES}}) { my $lib_dir = tmpdir($package) . getlibdir($class); my $infofile; @@ -242,7 +251,7 @@ doit ("install", "-d", $lib_dir); doit ("install", "-m644", $infofile, "$lib_dir/$package"); - unless ( $dh{NOSCRIPTS} or $no_pre_post) { + unless ( $no_pre_post) { autoscript ($package, "postinst", "postinst-$class", "s/#PACKAGE#/$package/"); autoscript ($package, "postrm", "postrm-$class", diff -Nru dictionaries-common-1.5.17ubuntu1/scripts/debhelper/installdeb-myspell dictionaries-common-1.9.2ubuntu1/scripts/debhelper/installdeb-myspell --- dictionaries-common-1.5.17ubuntu1/scripts/debhelper/installdeb-myspell 2010-10-20 11:54:00.000000000 +0200 +++ dictionaries-common-1.9.2ubuntu1/scripts/debhelper/installdeb-myspell 2011-02-09 05:42:51.000000000 +0100 @@ -3,6 +3,7 @@ # 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; @@ -68,7 +69,7 @@ "thesauri" => "/usr/share/mythes"); -foreach $package (@{$dh{DOPACKAGES}}) { +foreach my $package (@{$dh{DOPACKAGES}}) { my %datahash = (); @@ -209,7 +210,7 @@ print STDERR "Installing THES $thesaurus files in $destdir\n"; $thesdir =~ s/.*\///; doit ("install", "-d", $destdir); - foreach $ext ("dat","idx"){ + foreach my $ext ("dat","idx"){ my $basefile = "$thesaurus.$ext"; my $srcfile = "$srcdir/$basefile"; my $ltarget = "../../$thesdir/$basefile"; diff -Nru dictionaries-common-1.5.17ubuntu1/scripts/Debian/DictionariesCommon.pm.in dictionaries-common-1.9.2ubuntu1/scripts/Debian/DictionariesCommon.pm.in --- dictionaries-common-1.5.17ubuntu1/scripts/Debian/DictionariesCommon.pm.in 2010-10-20 11:54:00.000000000 +0200 +++ dictionaries-common-1.9.2ubuntu1/scripts/Debian/DictionariesCommon.pm.in 2011-02-09 05:42:51.000000000 +0100 @@ -2,6 +2,7 @@ package Debian::DictionariesCommon; +use strict; use base qw(Exporter); use Text::Iconv; @@ -15,6 +16,7 @@ build_emacsen_support build_jed_support build_squirrelmail_support + dico_activate_trigger ); # Import :all to get everything. our %EXPORT_TAGS = (all => [@EXPORT_OK]); @@ -81,10 +83,10 @@ my $dictentries = ''; my $thevalue = ''; - foreach $thedict ( sort keys %{$dictionaries}){ + foreach my $thedict ( sort keys %{$dictionaries}){ $dictentries = $dictionaries->{$thedict}; @dictarray = (); - foreach $thekey ( sort keys %{$dictentries}){ + foreach my $thekey ( sort keys %{$dictentries}){ $thevalue = $dictentries->{$thekey}; # Make sure \ and ' are escaped in keyvals $thevalue =~ s/(\\|\')/\\$1/g; @@ -100,6 +102,7 @@ open (DB,"> $output"); print DB generate_comment("### ") . "\n"; + print DB "package Debian::DictionariesCommon::dbfile;\n\n"; print DB "%dictionaries = (\n"; print DB join (",\n",@fullarray); print DB "\n);\n\n1;\n"; @@ -163,26 +166,33 @@ # ------------------------------------------------------------------ my $class = shift; my $dbfile = "$cachedir/$class.db"; + if (-e $dbfile) { do $dbfile; } - return \%dictionaries; + return \%Debian::DictionariesCommon::dbfile::dictionaries; } # ------------------------------------------------------------------ sub getdefault { # ------------------------------------------------------------------ -# If available, read current user's default from given file. +# Read default value from specified file. Comments and empty lines are ignored. # ------------------------------------------------------------------ - $file = shift; + my $file = shift; + my $lang; + if (-f $file) { - my $lang = `cat $file`; - chomp $lang; - return $lang; - } - else { - return undef; + open( my $FILE,"< $file") + or die "Dictionaries-common::getdefault: Could not open $file for read. Aborting ...\n"; + while (<$FILE>){ + next if m/^\s*\#/; + next if m/^\s*$/; + $lang = $_; + last; + } + close $FILE; } + return $lang; } # ------------------------------------------------------------------ @@ -246,7 +256,7 @@ $| = 1; print "\nSelect your personal ispell dictionary for use with ispell-wrapper\n\n"; - for ($i = 0; $i < scalar @choices; $i++) { + for ( my $i = 0; $i < scalar @choices; $i++ ) { print " " . ($i == $initial ? "*" : " ") . " [" . ($i+1) . "] $choices[$i]\n"; } @@ -289,10 +299,10 @@ my %entries = (); my %class_locales = (); - foreach $class ( @classes ){ + foreach my $class ( @classes ){ my $dictionaries = loaddb ($class); - foreach $k (keys %$dictionaries) { + foreach my $k (keys %$dictionaries) { my $lang = $dictionaries->{$k}; next if (exists $lang->{'emacs-display'} @@ -348,7 +358,7 @@ # Write alists of ispell, hunspell and aspell only installed dicts and their properties - foreach $class ( @classes ) { + foreach my $class ( @classes ) { my @class_dicts = reverse sort keys %{ $entries{$class} }; if ( scalar @class_dicts ){ $elisp .= "\n;; Adding $class dicts\n\n"; @@ -405,11 +415,11 @@ ## ifexists constructs, insuring that the $jedsupport file will ## always evaluate correctly. - foreach $class ( @classes ){ + foreach my $class ( @classes ){ my %class_slang = (); my %class_slang_u8 = (); if ( my $dictionaries = loaddb ($class) ){ - foreach $k (sort keys %$dictionaries) { + foreach my $k (sort keys %$dictionaries) { my $lang = $dictionaries->{$k}; next if (exists $lang->{'jed-display'} && $lang->{'jed-display'} eq "no"); @@ -518,6 +528,23 @@ close PHP; } +# ------------------------------------------------------------------ +sub dico_activate_trigger { +# ------------------------------------------------------------------ +# Try activating provided trigger if run under dpkg control. +# Return true in success, nil otherwise. +# ------------------------------------------------------------------ + my $trigger = shift; + + die "DictionariesCommon::dico_activate_trigger: No trigger provided. Aborting ...\n" unless $trigger; + + if ( defined $ENV{'DPKG_RUNNING_VERSION'} && + system("type dpkg-trigger >/dev/null 2>&1 && dpkg-trigger $trigger") == 0 ){ + return 1; + } + return; +} + # Ensure we evaluate to true. 1; diff -Nru dictionaries-common-1.5.17ubuntu1/scripts/system/aspell-autobuildhash dictionaries-common-1.9.2ubuntu1/scripts/system/aspell-autobuildhash --- dictionaries-common-1.5.17ubuntu1/scripts/system/aspell-autobuildhash 2010-10-20 11:54:00.000000000 +0200 +++ dictionaries-common-1.9.2ubuntu1/scripts/system/aspell-autobuildhash 2011-02-09 05:42:51.000000000 +0100 @@ -2,12 +2,11 @@ # # script for aspell hash autorebuild in Debian systems # -# Copyright 2004-2009 Agustin Martin Domingo -# +# Copyright 2004-2010 Agustin Martin Domingo # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, @@ -16,47 +15,49 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# +# along with this program; if not, see . +# ------------------------------------------------------------------------- + +use strict; + +my $debug; +my $dry_run; +my $force; +my $triggered; sub usage { - print STDERR "\nUsage:\taspell-autobuildhash [--debug] [--force]\n" - . "\n" - . "Options:\n" - . "\t--debug Show debugging infor about aspell-autobuildhash\n" - . "\t internal work. Will also enable aspell affix validation.\n" - . "\t--force Do the job regardless of versions comparisons.\n"; + print STDERR "\nUsage:\taspell-autobuildhash [options]\n" + . "\n" + . "Options:\n" + . "\t--debug Show debugging infor about aspell-autobuildhash\n" + . "\t internal work. Will also enable aspell affix validation.\n" + . "\t--dry-run Show what would be done, but do nothing real.\n" + . "\t--force Do the job regardless of versions comparisons.\n" + . "\t--triggered Tell the script that is run in the triggers stage.\n"; } sub debugprint { - print STDERR "@_\n" if $debug; + print STDERR "@_\n" if $debug; } sub mymessage{ - my $message = join(" ",@_); - my $question = "dictionaries-common/ispell-autobuildhash-message"; - my $hashfile = ''; - - if ( $lang ) { - $hashfile = "$lang"; - } else { - $hashfile = "dictionaries-common"; - } - - subst($question,"xxpell","aspell"); - subst($question,"XXpell","Aspell"); - subst($question,"hashfile",$hashfile); - subst($question,"errormsg",$message); - fset ($question,"seen","false"); - title("dictionaries-common: Running aspell-autobuildhash"); - input("critical",$question); - go (); + my $lang = shift; + my $message = join(" ",@_); + my $question = "dictionaries-common/ispell-autobuildhash-message"; + + subst($question,"xxpell","aspell"); + subst($question,"XXpell","Aspell"); + subst($question,"hashfile","$lang"); + subst($question,"errormsg","$message"); + fset ($question,"seen","false"); + title("dictionaries-common: Running aspell-autobuildhash"); + input("critical",$question); + go (); } sub myerror { - mymessage @_; - exit 1; + mymessage @_; + exit 1; } # --------------------------------------------------------------------- @@ -64,63 +65,67 @@ # --------------------------------------------------------------------- sub autorebuild { - my $lang = shift || # The dictionary name - myerror "No argument passed to function autorebuild"; - my $data = "/usr/lib/aspell"; # The data/lib dir - my $langsfile = "/usr/share/aspell/$lang.contents"; # The subdicts file - my $options = " --per-conf=/dev/null "; # Make sure no personal conf is used at all - my @sublangs = (); - - $options .= " --dont-validate-affixes " unless $debug; - - myerror "aspell data dir $data does not exist" unless ( -d $data ); - - if ( -e $langsfile ){ - open (LANGSFILE, "< $langsfile") || die "Could not open $langsfile for reading"; - @sublangs = ; - close LANGSFILE; + my $lang = shift || # The dictionary name + myerror("aspell-autobuildhash","No argument passed to function autorebuild"); + my $data = "/usr/lib/aspell"; # The data/lib dir + my $langsfile = "/usr/share/aspell/$lang.contents"; # The subdicts file + my $options = " --per-conf= "; # Make sure no personal conf is used at all + my @sublangs = (); + + $options .= " --dont-validate-affixes " unless $debug; + + myerror "aspell data dir $data does not exist" unless ( -d $data ); + + if ( -e $langsfile ){ + open (LANGSFILE, "< $langsfile") || die "Could not open $langsfile for reading"; + @sublangs = ; + close LANGSFILE; + } else { + push @sublangs, $lang; + } + chomp @sublangs; + + foreach ( @sublangs ){ + next if m/^\s*$/; + next if m/^\s*\#/; + s/^\s+//; + s/\s+$//; + + my $sublang = $_; + my $base = "/usr/share/aspell/$sublang"; # The wordlist basename + my $hash = "/var/lib/aspell/$sublang.rws"; # The hash file + my $msg = ''; + my $unpack = ''; + + print STDERR "aspell-autobuildhash: processing: $lang [$sublang]\n"; + + if ( -e "$base.mwl.gz" ){ + $unpack = "zcat $base.mwl.gz"; + } elsif ( -e "$base.wl.gz") { + $unpack = "zcat $base.wl.gz"; + } elsif ( -e "$base.cwl.gz") { + $unpack = "zcat $base.cwl.gz | precat"; } else { - push @sublangs, $lang; + mymessage($lang,"Could not find any of $base.{mwl,wl,cwl}.gz"); + return 0; } - foreach ( @sublangs ){ - - next if m/^[\t\s]*$/; - chomp; - s/^[\s\t]*//; - s/[\s\t]*$//; - next if m/^\#/; - - my $sublang = $_; - my $base = "/usr/share/aspell/$sublang"; # the wordlist basename - my $hash = "/var/lib/aspell/$sublang.rws"; # the hash file - my $msg = ''; - my $unpack = ''; - - print STDERR "aspell-autobuildhash: processing: $lang [$sublang]\n"; - - - if ( -e "$base.mwl.gz" ){ - $unpack = "zcat $base.mwl.gz"; - } elsif ( -e "$base.wl.gz") { - $unpack = "zcat $base.wl.gz"; - } elsif ( -e "$base.cwl.gz") { - $unpack = "zcat $base.cwl.gz | precat"; - } else { - mymessage "Could not find any of $base.{mwl,wl,cwl}.gz"; - return 0; - } + #$unpack = "$unpack | aspell clean strict"; + my $command = "$unpack | aspell $options --local-data-dir=$data --lang=$lang create master $hash"; + if ( $dry_run ){ + print STDERR "$command\n"; + } else { + debugprint(" - command: $command"); + system ("$command") == 0 + or $msg = "Could not build the hash file for $sublang" ; + } - #$unpack = "$unpack | aspell clean strict"; - system ("$unpack | aspell $options --local-data-dir=$data --lang=$lang create master $hash") == 0 - or $msg = "Could not build the hash file for $sublang" ; - - if ( $msg ){ # Do not break postinst if hash cannot be built - mymessage ($msg); # Just inform about that - return 0; - } + if ( $msg ){ # Do not break postinst if hash cannot be built + mymessage ($lang,$msg); # Just inform about that + return 0; } - return 1; + } + return 1; } # --------------------------------------------------------------------- @@ -128,77 +133,75 @@ # --------------------------------------------------------------------- sub get_aspell_compat { + my $aspell_compat; + my $aspellcompatfile = "/usr/share/aspell/aspell.compat"; - my $aspell_compat = ''; - - if ( -e $aspellcompatfile ){ - open (COMPAT,"$aspellcompatfile"); - chomp ( $aspell_compat = ); - close COMPAT; - } else { - $force = "yes"; - } - return $aspell_compat; + if ( -e $aspellcompatfile ){ + open (COMPAT,"$aspellcompatfile"); + chomp ( $aspell_compat = ); + close COMPAT; + } + return $aspell_compat; } # --------------------------------------------------------------------- # The main program # --------------------------------------------------------------------- -use Debian::DictionariesCommon q(dico_checkroot); +use Debian::DictionariesCommon qw(dico_checkroot dico_activate_trigger); use Debconf::Client::ConfModule q(:all); use Getopt::Long; +# Check if we are root dico_checkroot(); -$compatdir = "/var/lib/aspell"; -$aspellcompatfile = "/usr/share/aspell/aspell.compat"; - -$force = ''; -$debug = ''; - -GetOptions ('debug' => \$debug, - 'force' => \$force) or usage(); - -if ( -x "/usr/bin/aspell" ){ - - $aspell_compat = get_aspell_compat(); - - foreach $compat ( <$compatdir/*.compat> ){ - my $build_hash = ''; - my $lang_compat = ''; - - $lang = $compat; - $lang =~ s/\.compat$//; - $lang =~ s/.*\///; - - open (COMPAT,"$compat"); - $lang_compat = ; - close COMPAT; - $lang_compat = 0 if not $lang_compat; - chomp $lang_compat; - - $build_hash = "yes" if ( $aspell_compat ne $lang_compat ); - $build_hash = "yes" if $force; - - if ( $build_hash ){ - debugprint "$lang => aspell_compat: [$aspell_compat]; lang_compat: [$lang_compat]"; - if ( autorebuild($lang) ){ - debugprint " +++ Updating $compat"; - open (COMPAT,">","$compat"); - if ( $aspell_compat ){ - print COMPAT "$aspell_compat\n"; - } else { - print COMPAT "0\n"; - } - close COMPAT; - } else { - debugprint " --- $compat not updated because of an error"; - } +GetOptions ('debug' => \$debug, + 'dry-run' => \$dry_run, + 'force' => \$force, + 'triggered' => \$triggered +) or usage(); + +my $compatdir = "/var/lib/aspell"; +my $aspell_compat = get_aspell_compat(); + +unless ( $triggered or $force ) { + exit if dico_activate_trigger("aspell-autobuildhash"); +} + +$force++ unless $aspell_compat; + +if ( system("which aspell > /dev/null 2>&1" ) == 0 ){ + foreach my $compat ( <$compatdir/*.compat> ){ + my $lang = $compat; + $lang =~ s/\.compat$//; + $lang =~ s/.*\///; + + open (COMPAT,"$compat"); + my $lang_compat = ; + close COMPAT; + chomp $lang_compat if $lang_compat; + $lang_compat = 0 unless $lang_compat; + + if ( $force || $aspell_compat ne $lang_compat ){ + print STDERR "--\n" if ( $debug or $dry_run ); + debugprint "$lang => compat: \"$compat\", aspell_compat: [$aspell_compat]; lang_compat: [$lang_compat]"; + if ( autorebuild($lang) ){ + my $newcompat = $aspell_compat || 0; + if ( $dry_run ){ + print STDERR "$newcompat > $compat\n" + } else { + open (COMPAT,">","$compat"); + print COMPAT "$newcompat\n"; + close COMPAT; + debugprint "Updated $compat to $newcompat"; } + } else { + debugprint " *=* $compat not updated because of an error"; + } } + } } else { - debugprint " aspell is not installed. Doing nothing"; + debugprint " aspell is not installed. Doing nothing"; } __END__ @@ -214,8 +217,10 @@ Options: --debug Show extra info about aspell-autobuildhash internal work. Will also enable aspell affix validation. + --dry-run Show what would be done, but do nothing real. --force Rebuild the hash file for all dicts providing a compat file skipping the test. + --triggered Tell the script that is run in the triggers stage. =head1 DESCRIPTION @@ -231,8 +236,15 @@ --debug Show some extra information about aspell-autobuildhash internal work. Will also enable aspell affix validation. + --dry-run Show what would be done, but do nothing real. --force Rebuild the hash file for all dicts providing a compat file regardless of the compatibility levels found. + --triggered Tell the script that is run in the triggers stage. When + run under dpkg control, do not try to set the + 'aspell-autobuildhash' trigger, but run real + B code. When not run under dpkg + control, real code will always be run and '--triggered' + option has no real effect. =head1 PACKAGE MAINTAINERS diff -Nru dictionaries-common-1.5.17ubuntu1/scripts/system/dc-debconf-default-value.pl dictionaries-common-1.9.2ubuntu1/scripts/system/dc-debconf-default-value.pl --- dictionaries-common-1.5.17ubuntu1/scripts/system/dc-debconf-default-value.pl 2010-10-20 11:54:00.000000000 +0200 +++ dictionaries-common-1.9.2ubuntu1/scripts/system/dc-debconf-default-value.pl 2011-02-09 05:42:51.000000000 +0100 @@ -7,14 +7,9 @@ # from the debian-installer settings, envvars or pre-policy symlinks and the # list of ispell dictionaries and wordlists to be installed -$priority{"ispell"} = "critical"; # These will be changed later, -$priority{"wordlist"} = "critical"; # Do not change value here. -$dcscript = "/usr/share/dictionaries-common/dc-debconf-select.pl"; -$fromdcconfig = "yes"; -$debug = "yes" if exists $ENV{'DICT_COMMON_DEBUG'}; +my $dcscript = "/usr/share/dictionaries-common/dc-debconf-select.pl"; +my $debug = "yes" if exists $ENV{'DICT_COMMON_DEBUG'}; - -my %debconf_vals = (); my @suffixes = ("","-large","-medium","-small","-gut"); my %equivs = ("bg" => "bulgarian", "ca" => "catalan", @@ -51,7 +46,6 @@ "sv" => "swedish", "tl" => "tagalog", "uk" => "ukrainian"); -my %pending_keys = (); my %alternatives = ("ispell" => "ispell-dictionary.hash", "wordlist" => "dictionary"); @@ -68,23 +62,24 @@ # ------------------------------------------------------------- # Set debconf value unless already set # ------------------------------------------------------------- - my $question = shift; - my $value = shift; - my $priority = $priority{$class} || ""; + my $guessed = shift; + my $question = $guessed->{'question'}; + my $value = $guessed->{'guess'}; + my $priority = $guessed->{'priority'}; my ($errorcode, $oldvalue) = get($question); $oldvalue = "unset" unless $oldvalue; if ( $errorcode or $oldvalue eq "unset" ){ - &dc_debugprint(" $question: errorcode: $errorcode; priority: $priority\n" . - " Old:[$oldvalue] --> New:[$value]\n"); + &dc_debugprint(" dict-common::dc_set: $question: errorcode: $errorcode; priority: $priority\n" . + " Old:[$oldvalue] --> New:[$value]\n"); set("$question","$value"); } elsif ( $oldvalue eq $value ) { - print STDERR "Info: $question is already set to + print STDERR " dict-common::dc_set: $question is already set to [$oldvalue]. Preserving it.\n"; } else { - print STDERR "Warning: $question is already set to + print STDERR " dict-common::dc_set: Warning: $question is already set to [$oldvalue]. Not setting to [$value]\n"; } @@ -92,14 +87,13 @@ if ( $debug ){ # --- Check if question value is actually set ($errorcode, $oldvalue) = get($question); if ( $errorcode ){ - print STDERR " dictionaries-common: $question reading failed with $errorcode\n"; + print STDERR " dict-common::dc_set: $question reading failed with $errorcode\n"; } elsif ( $oldvalue) { - print STDERR " dictionaries-common: $question actually set to [$oldvalue]\n"; + print STDERR " dict-common::dc_set: $question is set to [$oldvalue]\n"; } else { - print STDERR " dictionaries-common: $question value is void, bad thing\n"; + print STDERR " dict-common::dc_set: $question value is void, bad thing\n"; } } - &dc_debugprint ("Not tried: " . join(', ',sort keys %pending_keys) . "\n"); } # ------------------------------------------------------------- @@ -108,50 +102,40 @@ # Look if a dict matching $langkey in %equivs is to be installed # and return the preferred language name if so. # ------------------------------------------------------------- - my $langkey = shift; - my $classprefix = shift; - my $thestring = ''; - my $thepackage = ''; - my $thevariant = ''; - my @thevalues = (); - - if ( exists $pending_keys{$langkey} ){ # Make sure we do not try it again - &dc_debugprint("Trying langkey \"$langkey\" with classprefix \"$classprefix\"\n"); - delete $pending_keys{$langkey}; - } else { - if ( exists $equivs{$langkey} ){ - # This $langkey was already tried, no need to try it again - &dc_debugprint("Already done langkey $langkey\n"); - } else { - # This $langkey does not exist - &dc_debugprint("Non-existant langkey $langkey\n"); - } - return; - } + my $langkey = shift; + my $classinfo = shift; + my $classprefix = $classinfo->{'prefix'}; + my $debconf_vals = $classinfo->{'languages'}; + my $debconf_defaultvals = $classinfo->{'default_langs'}; + my @thevalues = (); + my $thestring; + my $thepackage; + my $thevariant; + my $pkgfullname; - if ( exists $equivs{$langkey} ){ + if ( defined $equivs{$langkey} ){ ($thepackage,$thevariant) = split ("->",$equivs{$langkey}); - foreach $suffix ( @suffixes ){ + foreach my $suffix ( @suffixes ){ if ( $thepackage eq "miscfiles" ){ $pkgfullname = "$thepackage$suffix"; } else { $pkgfullname = "$classprefix$thepackage$suffix"; } - &dc_debugprint(" Trying package $pkgfullname\n"); - if ( exists $debconf_vals{"$pkgfullname"} ){ - if ( exists $debconf_defaultvals{"$pkgfullname"} ){ - $thestring = $debconf_defaultvals{"$pkgfullname"}; + &dc_debugprint(" dc_extractlangname: Trying package $pkgfullname\n"); + if ( defined $debconf_vals->{"$pkgfullname"} ){ + if ( defined $debconf_defaultvals->{"$pkgfullname"} ){ + $thestring = $debconf_defaultvals->{"$pkgfullname"}; } else { - $thestring = $debconf_vals{"$pkgfullname"}; + $thestring = $debconf_vals->{"$pkgfullname"}; } @thevalues = sort split (/\s*,\s*/,$thestring); if ( $thevariant ){ @thevalues = grep {/$thevariant/i} @thevalues; } @thevalues = sort { - $a =~ m/tex/i <=> $b =~ m/tex/i # Sort tex variants last - || - $a cmp $b } @thevalues; + # Sort tex variants last + $a =~ m/tex/i <=> $b =~ m/tex/i + || $a cmp $b } @thevalues; if ( scalar @thevalues >= 1 ){ return "$thevalues[0]"; } else { @@ -168,44 +152,43 @@ # Try different combinations of $language and $country and possible # fallbacks in case dc_extractlangname() does not find a good guess # ------------------------------------------------------------- - my $class = shift; - my $language = shift; - my $country = shift; - my $guessed = ''; - my @possible_fallbacks = (); - my $classprefix = substr($class,0,1); - my $msgprefix = "dict-common->dc_guesslang"; - - &dc_debugprint("$msgprefix: Looking for langkey matches [$class,$classprefix,$language,$country].\n"); - if ( $guessed = &dc_extractlangname("$language" . "_" . uc($country),$classprefix) - || &dc_extractlangname("$language" . "_" . uc("$country") . ":1",$classprefix) - || &dc_extractlangname("$language",$classprefix) - || &dc_extractlangname("$language:1",$classprefix) + my $classinfo = shift; + my $language = shift; + my $country = shift; + my $class = $classinfo->{'class'}; + my $classprefix = $classinfo->{'prefix'}; + my $msgprefix = "dc_guesslang"; + my $priority = "medium"; + my $guessed; + + &dc_debugprint(" $msgprefix: Looking for langkey matches [$class,$classprefix,$language,$country].\n"); + if ( $guessed = &dc_extractlangname("$language" . "_" . uc($country),$classinfo) + || &dc_extractlangname("$language" . "_" . uc("$country") . ":1",$classinfo) + || &dc_extractlangname("$language",$classinfo) + || &dc_extractlangname("$language:1",$classinfo) ){ - $priority{$class} = "low"; - return $guessed; + $priority = "low"; } else { - @possible_fallbacks = grep {/$language\_/} sort keys %equivs; - $priority{$class} = "medium"; - foreach ( @possible_fallbacks ){ - return $guessed if ( $guessed = &dc_extractlangname($_,$classprefix)); - } - $priority{$class} = "high"; - return; - } -} - -# ------------------------------------------------------------- -sub dc_guessotherlang (){ -# ------------------------------------------------------------- -# Iterate over the not yet tried $langkey values for a dict to be -# installed. Return first match -# ------------------------------------------------------------- - my $guessed = ''; - - foreach ( sort keys %pending_keys ){ - return $guessed if ( $guessed = &dc_extractlangname($_)); - } + my @sorted_keys = sort { + # Sort keys matching ^$language_ first + $b =~ m/^$language(\_|:|$)/ cmp $a =~ m/^$language(\_|:|$)/ + # Then american english + || $b =~ m/^en\_US/ cmp $a =~ m/^en\_US/ + # Then any english variant + || $b =~ m/^en\_/ cmp $a =~ m/^en\_/ + # Then anything else alphabetically + || $a cmp $b + } keys %equivs; + &dc_debugprint(" dc_guesslang: Trying an alternative for $class from keys:\n " + . join(', ',@sorted_keys) . "\n"); + foreach ( @sorted_keys ){ + last if ( $guessed = &dc_extractlangname($_, $classinfo) ); + } + } + return { 'guess' => $guessed, + 'priority' => $priority, + 'class' => $class + } if $guessed; } # ------------------------------------------------------------- @@ -213,12 +196,12 @@ # ------------------------------------------------------------- # Try guessing langkey after (woody or older) former symlink # ------------------------------------------------------------- - my $class = shift; - my $prefix = ''; - my $guess = ''; - my $language = ''; - my $link = "/etc/alternatives/$alternatives{$class}"; + my $class = shift; + my $link = "/etc/alternatives/$alternatives{$class}"; my %reverse_equivs = (); + my $prefix; + my $guess; + my $language; return unless ( -l $link ); @@ -261,7 +244,7 @@ # ------------------------------------------------------------- my $class = shift; my $file = "/var/lib/dpkg/alternatives/$alternatives{$class}"; - my $status = ''; + my $status; if ( -r $file ){ open(FILE,"< $file") or return; @@ -274,11 +257,15 @@ } # ------------------------------------------------------------- -sub dc_debconf_rebuild (){ +sub dc_parse_classinfo (){ # ------------------------------------------------------------- -# Gather info from debconf for the (to be) installed packages for class -# %debconf_vals : pkg -> languages provided by package -# %debconf_defaultvals : pkg -> default language for package +# Gather info for (to be) installed packages for class +# debconf info: +# $classinfo->{'languages'}: pkg -> languages provided by package +# $classinfo->{'default_langs'}: pkg -> default language for package +# Other info +# $classinfo->{'class'}: Class +# $classinfo->{'classprefix'}: Class prefix # ------------------------------------------------------------- my $class = shift; return unless $class; @@ -286,15 +273,22 @@ my ($errorcode,$pkgowners) = metaget ($question, "owners"); return if $errorcode; - %debconf_vals = (); - %debconf_defaultvals = (); - foreach ( split (/\s*,\s*/,$pkgowners) ){ - #$debconf_vals{$_} = metaget ("$_/languages", "default"); - $debconf_vals{$_} = get ("$_/languages"); - my ($errorcode,$pkgdefaults) = get ("$_/defaults"); - $debconf_defaultvals{$_} = $pkgdefaults if not $errorcode; - } - return "ok"; + my %debconf_vals = (); + my %debconf_defaultvals = (); + my %classprefix = ( 'ispell' => "i", "wordlist" => "w" ); + + foreach my $pkg ( split (/\s*,\s*/,$pkgowners) ){ + $debconf_vals{$pkg} = get ("$pkg/languages"); + my ($errorcode,$pkgdefaults) = get ("$pkg/defaults"); + $debconf_defaultvals{$pkg} = $pkgdefaults unless $errorcode; + } + + return { + 'class' => $class, + 'prefix' => $classprefix{$class}, + 'languages' => \%debconf_vals, + 'default_langs' => \%debconf_defaultvals + } if %debconf_vals; } # ----------------------------------------------------------------- @@ -373,29 +367,22 @@ # $language $country pair and set it if found. # ----------------------------------------------------------------- my $class = shift; - my $guessed; - my $msgprefix = "dict-common.config->dc_set_default_value_for_class"; + my $msgprefix = "dc_set_default_value_for_class"; my $question = "dictionaries-common/default-$class"; my $oldlink = "/etc/alternatives/$alternatives{$class}"; + my $guessed; - if ( &dc_debconf_rebuild($class) ){ + if ( my $classinfo = &dc_parse_classinfo($class) ){ # Ancient symlinks may be different for different classes, my ( $language, $country ) = &dc_guess_language_country_strings($class); - %pending_keys = %equivs; # First try something reasonably close to the lang +country pair - if ( $guessed = &dc_guesslang($class,$language,$country) ){ - &dc_debugprint("$msgprefix: Guessed value ->($class,$language,$country,$guessed)\n"); + if ( $guessed = &dc_guesslang($classinfo,$language,$country) ){ + &dc_debugprint(" $msgprefix: Guessed value ->($class,$language,$country,$guessed->{'guess'},$guessed->{'priority'})\n"); } else { - if ( $guessed = &dc_guesslang($class,"en","US") # Try an English variant - || &dc_guessotherlang ){ # Try anything - &dc_debugprint("$msgprefix: Forcing [$guessed] for ($class,$language,$country)\n"); - $priority{$class} = "medium"; - } else { - # Signal an error. This should never happen, so the critical priority. - &dc_debugprint("$msgprefix: No good or bad guess found for ($class,$language,$country)\n"); - $priority{$class} = "critical"; - } + # Signal an error. This should never happen, thus the critical priority. + &dc_debugprint(" $msgprefix: No good or bad guess found for ($class,$language,$country)\n"); + return; } # We may have ancient pre-policy alternative based symlinks with @@ -403,19 +390,18 @@ # in the same run. This is an upgrade from an ancient setup, we better ask. if ( -l $oldlink ){ if ( &dc_manual_alternative($class) ){ - &dc_debugprint("$msgprefix: Ancient $class alternative was in manual mode. Setting critical priority\n"); - $priority{$class} = "critical"; + &dc_debugprint(" $msgprefix: Ancient $class alternative was in manual mode. Setting critical priority\n"); + $guessed->{'priority'} = "critical"; } else { - foreach ( keys %debconf_vals ){ - my $oldpackage = $_; + foreach my $oldpackage ( keys %{$classinfo->{'languages'}} ){ next if ( $oldpackage eq "dictionaries-common" ); $oldpackage = "wenglish" if ( $oldpackage eq "wamerican" ); # critical priority if exists debconf entry without a # previous package installed. This means that besides # upgrading, new dicts are being installed. if ( not -e "/var/lib/dpkg/info/$oldpackage.list" ){ - $priority{$class} = "critical"; - &dc_debugprint("$msgprefix: New dict [$oldpackage] is to be installed\n"); + $guessed->{'priority'} = "critical"; + &dc_debugprint( "$msgprefix: New dict [$oldpackage] is to be installed\n"); last; } } @@ -423,7 +409,10 @@ } # Actually set the value if found - &dc_set($question,$guessed) if $guessed; + if ( $guessed ) { + $guessed->{'question'} = $question; + &dc_set($guessed); + } } else { &dc_debugprint("$msgprefix: No elements found for $class\n"); } diff -Nru dictionaries-common-1.5.17ubuntu1/scripts/system/dc-debconf-select.pl dictionaries-common-1.9.2ubuntu1/scripts/system/dc-debconf-select.pl --- dictionaries-common-1.5.17ubuntu1/scripts/system/dc-debconf-select.pl 2010-10-24 23:26:52.000000000 +0200 +++ dictionaries-common-1.9.2ubuntu1/scripts/system/dc-debconf-select.pl 2011-02-09 05:42:51.000000000 +0100 @@ -5,13 +5,17 @@ # /usr/share/dictionaries-common for single ispell dicts/wordlists use # --------------------------------------------------------------------------- +use strict; + sub dico_get_packages (){ # Get list of packages sharing the question my $class = shift; my $question = "shared/packages-$class"; + my @pkglist = (); my ($errorcode,$packages) = metaget ($question, "owners"); - return [ split (/\s*,\s*/, $packages) ] unless $errorcode; + @pkglist = split (/\s*,\s*/, $packages) unless $errorcode; + return \@pkglist; } sub dico_parse_languages (){ @@ -25,7 +29,7 @@ $packages = &dico_get_packages($class) unless $packages; - foreach $pkg ( @$packages ){ + foreach my $pkg ( @$packages ){ my ($errorcode, $entry ) = metaget("$pkg/$variant", "default"); unless ( $errorcode ){ $entry =~ s/^\s+//; @@ -56,7 +60,7 @@ print STDERR " * Packages with elanguages: $elanglist\n" if $debug; } - foreach $pkg ( keys %$languages ){ + foreach my $pkg ( keys %$languages ){ my @langs = split(/\s*,\s*/, $languages->{$pkg}); my @elangs = @langs; if ( exists $elanguages->{$pkg} ){ @@ -67,7 +71,7 @@ } @elangs = @tmp if ( $#langs == $#tmp ); } - foreach $index ( 0 .. $#langs ){ + foreach my $index ( 0 .. $#langs ){ $mappinghash{$langs[$index]} = $elangs[$index]; } } @@ -76,58 +80,74 @@ sort {lc($mappinghash{$a}) cmp lc($mappinghash{$b})} keys %mappinghash); if ( $debug ){ - print STDERR "- Choices:\n[$choices]\n"; - print STDERR "- Echoices:\n[$echoices]\n"; + print STDERR " * Choices:\n [$choices]\n"; + print STDERR " * Echoices:\n [$echoices]\n"; print STDERR "-------- $debug_prefix end --------\n"; } return $choices, $echoices; } sub dc_debconf_select (){ - my $class = shift; - my $priority = shift; - my $question = "dictionaries-common/default-$class"; - my $packages = &dico_get_packages($class); + my $classinfo = shift; my $debug = 1 if exists $ENV{'DICT_COMMON_DEBUG'}; my $reconfigure = 1 if exists $ENV{'DEBCONF_RECONFIGURE'}; - my $flagdir = "/var/cache/dictionaries-common"; - my $newflag = "$flagdir/flag-$class-new"; - my $langscript = "/usr/share/dictionaries-common/dc-debconf-default-value.pl"; my $echoices; - my @oldchoices = (); - my %newchoices = (); my %title = ('ispell' => "Dictionaries-common: Ispell dictionary", 'wordlist' => "Dictionaries-common: Wordlist dictionary" - ); - my $debug_prefix = "[$class,dc_debconf_select]"; + ); + + my $class; + my $priority; + my $is_dcconfig; + # If $classinfo is a hash reference, function is called from dictionaries-common.config + if ( ref($classinfo) eq 'HASH' ){ + $class = $classinfo->{'class'}; + $priority = $classinfo->{'priority'} if ( defined $classinfo->{'priority'} ); + $is_dcconfig = 1; + } else { + # Otherwise is called from ispell dictionary/wordlist config + $class = $classinfo; + } + my $packages = &dico_get_packages($class); return unless $packages; + my $question = "dictionaries-common/default-$class"; + my $flagdir = "/var/cache/dictionaries-common"; + my $newflag = "$flagdir/flag-$class-new"; + my $debug_prefix = "[$class,dc_debconf_select]"; + print STDERR "----- $debug_prefix start -----------\n" if $debug; # Get new base list of provided languages + my %newchoices = (); my $languages = &dico_parse_languages($class,"languages",$packages); - foreach $pkg ( keys %$languages ) { - foreach $lang ( split(/\s*,\s*/, $languages->{$pkg}) ){ + foreach my $pkg ( keys %$languages ) { + foreach my $lang ( split(/\s*,\s*/, $languages->{$pkg}) ){ $newchoices{$lang}++; } } my $choices = join (', ', sort {lc($a) cmp lc($b)} keys %newchoices); # Get old list of provided languages - @oldchoices = split(/\s*,\s*/,metaget ($question, "choices-c")); + my @oldchoices = split(/\s*,\s*/,metaget ($question, "choices-c")); pop @oldchoices; # Remove the manual entry my $oldchoices = join (', ', sort {lc($a) cmp lc($b)} @oldchoices); # If dictionaries-common is already installed (-r $langscript), - # there are elements for this chass to be installed (%newchoices) + # there are elements for this class to be installed (%newchoices) # and there were none before (! $oldchoices), means that we are installing # for the first time elements in this class, with dictionaries-common # already installed. Try getting a reasonable default value + my $langscript = "/usr/share/dictionaries-common/dc-debconf-default-value.pl"; if ( -r $langscript && %newchoices && ! $oldchoices ){ - print STDERR "$debug_prefix: Configuring $class class for the first time\n\n" if $debug; - require $langscript; - &dc_set_default_value_for_class($class); + print STDERR "$debug_prefix: Configuring class \"$class\" for the first time\n\n" if $debug; + # If called from dictionaries-common.config we already have + # $langscript, and probably more recent. Including it here will cause + # some warnings about subroutine re-definitions and even errors. + require $langscript unless $is_dcconfig; + my $guessed = &dc_set_default_value_for_class($class); + $priority = $guessed->{'priority'} if ( defined $guessed->{'priority'} ); } # Read current value of default ispell dict / wordlist. @@ -157,10 +177,10 @@ print STDERR "$debug_prefix:\n" . - " Class: $class, Priority: $priority\n" . - " Question: $question, Previous or guessed value: $curval\n" . - " New choices:[$choices]\n" . - " Old choices:[$oldchoices]\n" if $debug; + " * Class: $class, Priority: $priority\n" . + " * Question: $question, Previous or guessed value: $curval\n" . + " * New choices: [$choices]\n" . + " * Old choices: [$oldchoices]\n" if $debug; # May ask question if there is no match if ( scalar %newchoices ) { @@ -168,7 +188,7 @@ fset ($question, "seen", "false"); # Let future processes in this apt run know that a new $class element is to be installed if ( -d $flagdir ) { - open ($FLAG,"> $newflag") + open (my $FLAG, "> $newflag") or die "Could not open $newflag for write. Aborting ...\n"; print $FLAG "1\n"; close $FLAG; @@ -187,10 +207,10 @@ } # If called from dictionaries-common.config, check actual values in debug mode - if ( $debug && $fromdcconfig ){ - print STDERR "dictionaries-common.config: Checking really set values for $question\n"; - print STDERR " Choices-C string: " . metaget ($question, "choices-c") . "\n"; - print STDERR " Really set value: " . get ($question) . "\n"; + if ( $debug && $is_dcconfig ){ + print STDERR " * Checking really set values for $question:\n"; + print STDERR " - Choices-C string: " . metaget ($question, "choices-c") . "\n"; + print STDERR " - Really set value: " . get ($question) . "\n"; } print STDERR "----- $debug_prefix end -----------\n" if $debug; } diff -Nru dictionaries-common-1.5.17ubuntu1/scripts/system/ispell-autobuildhash dictionaries-common-1.9.2ubuntu1/scripts/system/ispell-autobuildhash --- dictionaries-common-1.5.17ubuntu1/scripts/system/ispell-autobuildhash 2010-10-20 11:54:00.000000000 +0200 +++ dictionaries-common-1.9.2ubuntu1/scripts/system/ispell-autobuildhash 2011-02-09 05:42:51.000000000 +0100 @@ -2,12 +2,11 @@ # # script for ispell hash autorebuild in Debian systems # -# Copyright 2003-2009 Agustin Martin Domingo -# +# Copyright 2003-2011 Agustin Martin Domingo # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, @@ -16,75 +15,69 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# +# along with this program; if not, see . +# ------------------------------------------------------------------ + +use strict; +use Debian::DictionariesCommon qw(dico_checkroot dico_activate_trigger); +use Debconf::Client::ConfModule q(:all); +use File::Temp qw(tempdir); +use Getopt::Long; + +my $debug; +my $dry_run; +my $force; +my $triggered; +my $compatdir = "/var/lib/ispell"; + +# Set tmpdir base, honouring TMPDIR. Real tmpdir is set after options parsing. +my $tmpdir = $ENV{'TMPDIR'} || '/tmp'; sub usage { - print STDERR "\nUsage:\tispell-autobuildhash [--debug] [--force]\n" - . "\n" - . "Options:\n" - . "\t--debug Show ispell-autobuildhash debugging information\n" - . "\t--force Do the job regardless of versions comparisons\n"; + print STDERR "\nUsage:\tispell-autobuildhash [options]\n" + . "\n" + . "Options:\n" + . "\t--debug Show ispell-autobuildhash debugging information.\n" + . "\t--dry-run Show what would be done, but do nothing real.\n" + . "\t--force Do the job regardless of versions comparisons.\n" + . "\t--triggered Tell the script that is run in the triggers stage.\n"; } sub debugprint { - print STDERR "@_\n" if $debug; + print STDERR "@_\n" if $debug; } sub mymessage{ - my $message = join(" ",@_); - my $question = "dictionaries-common/ispell-autobuildhash-message"; - my $hashfile = ''; - - if ( $dict ) { - $hashfile = "$dict.hash"; - } else { - $hashfile = "dictionaries-common"; - } - - subst($question,"xxpell","ispell"); - subst($question,"XXpell","Ispell"); - subst($question,"hashfile",$hashfile); - subst($question,"errormsg",$message); - fset ($question,"seen","false"); - title("dictionaries-common: Running ispell-autobuildhash"); - input("critical",$question); - go (); + my $dict = shift; + my $message = join(" ",@_); + my $question = "dictionaries-common/ispell-autobuildhash-message"; + + subst($question,"xxpell","ispell"); + subst($question,"XXpell","Ispell"); + subst($question,"hashfile",$dict); + subst($question,"errormsg",$message); + fset ($question,"seen","false"); + title("dictionaries-common: Running ispell-autobuildhash"); + input("critical",$question); + go (); } sub old_myerror { - print " + my $dict = shift; + print " ** Error: @_ This error was caused by package providing hash $dict, although it can be made evident during other package postinst. Please complain to the maintainer of package providing hash $dict. In the meantime you might need to remove package providing $dict.hash\n"; - myclean(); - exit 1; + myclean(); + exit 1; } sub myerror { - mymessage @_; - $build_status = "error"; -# myclean(); -# exit 1; -} - -sub myclean { - unlink <$tempfile*>; - rmdir $tmpdir; -} - - -# --------------------------------------------------------------------- -# What to do if a signal is trapped -# --------------------------------------------------------------------- - -sub trap { - myclean(); - exit 1 + my $dict = shift; + mymessage $dict,@_; } # --------------------------------------------------------------------- @@ -92,40 +85,59 @@ # --------------------------------------------------------------------- sub autorebuild { - my $dict = shift || # The dictionary name - myerror "No argument passed to function autorebuild"; - my $zmwl = "/usr/share/ispell/$dict.mwl.gz"; # the compressed munched wordlist - my $aff = "/usr/lib/ispell/$dict.aff"; # the aff file - my $hash = "/var/lib/ispell/$dict.hash"; # the hash file - my $desc = "/usr/share/ispell/$dict.desc"; # the .desc file - - print STDERR "ispell-autobuildhash: Processing \'$dict\' dict\n"; - - if ( -e $aff ){ - if ( -e $zmwl ){ - system ("gzip -dc $zmwl > $tempfile") == 0 - or myerror "Could not gunzip the munched wordlist for $dict"; - system ("buildhash -s $tempfile $aff $hash") == 0 - or myerror "Could not build the hash file for $dict" ; - - } elsif ( -e $desc ) { - if ( -x "/usr/sbin/update-ispell-hash" ) { - system ("update-ispell-hash -d $dict > /dev/null") == 0 - or myerror "Problems running update-ispell-hash for $dict"; - debugprint "Found and run update-ispell-hash"; - } elsif ( -x "/usr/sbin/update-ipolish-hash" ) { - system ("update-ipolish-hash -d $dict > /dev/null") == 0 - or myerror "Problems running update-ipolish-hash for $dict"; - debugprint "Found and run update-ipolish-hash"; - } else { - myerror "Could not find any of update-ispell-hash, update-ipolish-hash" - } + my $dict = shift; # The dictionary name + my $zmwl = "/usr/share/ispell/$dict.mwl.gz"; # the compressed munched wordlist + my $aff = "/usr/lib/ispell/$dict.aff"; # the aff file + my $hash = "/var/lib/ispell/$dict.hash"; # the hash file + my $desc = "/usr/share/ispell/$dict.desc"; # the .desc file + + die "ispell-autobuildhash: No argument passed to function autorebuild.\n" unless $dict; + + print STDERR "ispell-autobuildhash: Processing \'$dict\' dict\n"; + + my $tempfile = "$tmpdir/$dict-mwl"; + if ( -e $aff ){ + if ( -e $zmwl ){ + my $gzip_cmd = "gzip -dc $zmwl > $tempfile"; + my $build_cmd = "buildhash -s $tempfile $aff $hash"; + if ( $dry_run ) { + print STDERR "$gzip_cmd\n"; + print STDERR "$build_cmd\n"; + } else { + system ("$gzip_cmd") == 0 + or myerror($dict,"Could not gunzip the munched wordlist for $dict"); + system ("$build_cmd") == 0 + or myerror($dict,"Could not build the hash file for $dict") ; + } + } elsif ( -e $desc ) { + if ( -x "/usr/sbin/update-ispell-hash" ) { + my $cmd = "update-ispell-hash -d $dict > /dev/null"; + if ( $dry_run ) { + print STDERR "$cmd\n"; } else { - myerror "Could not find $zmwl"; + system ("$cmd") == 0 + or myerror($dict,"Problems running update-ispell-hash for $dict"); } + debugprint "Found and run update-ispell-hash"; + } elsif ( -x "/usr/sbin/update-ipolish-hash" ) { + my $cmd = "update-ipolish-hash -d $dict > /dev/null"; + if ( $dry_run ) { + print STDERR "$cmd\n"; + } else { + system ("$cmd") == 0 + or myerror($dict,"Problems running update-ipolish-hash for $dict"); + } + debugprint "Found and run update-ipolish-hash"; + } else { + myerror($dict,"Could not find any of update-ispell-hash, update-ipolish-hash"); + } } else { - myerror "Could not find affix file $aff"; + myerror($dict,"Could not find $zmwl"); } + } else { + myerror $dict,"Could not find affix file $aff"; + } + return "ok"; } # --------------------------------------------------------------------- @@ -133,87 +145,80 @@ # --------------------------------------------------------------------- sub get_ispell_compat { - my @internal; - my $ispell_compat; - if ( -e $ispellcompatfile ){ - open (COMPAT,"$ispellcompatfile"); - chomp ( $ispell_compat = ); - close COMPAT; - } elsif ( -e "/usr/bin/ispell" ){ -# $ispell_compat = `ispell -v | head -n 1 | sed 's/.*Version \([^\ ]*\).*/\1/g'` - $ispell_compat = `ispell -v | head -n 1`; - @internal = split(" ",$ispell_compat); - $ispell_compat = $internal[4]; - } else { - myerror "ispell is not installed"; - } - return $ispell_compat; + my $ispell_compat; + my $ispellcompatfile = "/usr/share/ispell/ispell.compat"; + + if ( -e $ispellcompatfile ){ + open (COMPAT,"$ispellcompatfile"); + chomp ( $ispell_compat = ); + close COMPAT; + } elsif ( system("which ispell > /dev/null 2>&1") == 0 ){ + $ispell_compat = (split(" ",`ispell -v | head -n 1`))[4]; + } + + return $ispell_compat; } # --------------------------------------------------------------------- # The main program # --------------------------------------------------------------------- -use Debian::DictionariesCommon q(dico_checkroot); -use Debconf::Client::ConfModule q(:all); -use Getopt::Long; - dico_checkroot(); -$SIG{INT} = \&trap; -$SIG{KILL} = \&trap; -$SIG{TERM} = \&trap; - -$tmpdir = "/tmp/ispell-auto-$$"; -$tempfile = "$tmpdir/ispellhash"; -$compatdir = "/var/lib/ispell"; -$ispellcompatfile = "/usr/share/ispell/ispell.compat"; - -$force = ''; -$debug = ''; -$build_status = ''; - -GetOptions ('debug' => \$debug, - 'force' => \$force) or usage(); - -mkdir($tmpdir,0700) || die "can't mkdir $tmpdir: $!"; - -if ( -x "/usr/bin/ispell" ){ - $ispell_compat = get_ispell_compat(); - foreach $dict ( <$compatdir/*.compat> ){ - $build_status = ''; - my $dict_compat = ''; - $dict =~ s/\.compat$//; - $dict =~ s/.*\///; - if ( $force ) { - $dict_compat = "forced"; - autorebuild $dict; - } else { - open (COMPAT,"$compatdir/$dict.compat"); - $dict_compat = ; - close COMPAT; - $dict_compat = 0 if not $dict_compat; - chomp $dict_compat; - autorebuild $dict if ($ispell_compat ne $dict_compat); - } - debugprint "$dict => ispell_compat: [$ispell_compat]; dict_compat: [$dict_compat]"; - if ( not $build_status ){ - debugprint " +++ Updating $compatdir/$dict.compat"; - open (COMPAT,">","$compatdir/$dict.compat"); - print COMPAT "$ispell_compat\n"; - close COMPAT; +# Options processing +GetOptions ('debug' => \$debug, + 'dry-run' => \$dry_run, + 'force' => \$force, + 'triggered' => \$triggered + ) or usage(); + +unless ( $triggered or $force ){ + exit if dico_activate_trigger("ispell-autobuildhash"); +} + +# Prepare temporary directory +$tmpdir = tempdir("ispell-auto.XXXXXXXXXX", + CLEANUP => ( ! $debug ), # Remove tempdir tree on exit unless $debug + DIR => "$tmpdir"); + +print STDERR "ispell-autobuildhash: Using temporary directory\"$tmpdir\"\n" + if $debug; + +if ( my $ispell_compat = get_ispell_compat() ){ + foreach my $dict ( <$compatdir/*.compat> ){ + my $dict_compat = "forced"; + $dict =~ s/\.compat$//; + $dict =~ s/.*\///; + + unless ( $force ) { + open (COMPAT,"$compatdir/$dict.compat"); + $dict_compat = ; + close COMPAT; + chomp $dict_compat if $dict_compat; + $dict_compat = 0 unless $dict_compat; + } + + if ($force || $ispell_compat ne $dict_compat) { + print STDERR "--\n" if ( $debug or $dry_run ); + debugprint "$dict => ispell_compat: [$ispell_compat]; dict_compat: [$dict_compat]"; + if ( autorebuild $dict ) { + if ( $dry_run ){ + print STDERR "$ispell_compat > $compatdir/$dict.compat\n"; } else { - debugprint " --- $compatdir/$dict.compat not updated because of an error"; + open (COMPAT,">","$compatdir/$dict.compat"); + print COMPAT "$ispell_compat\n"; + close COMPAT; + debugprint "Updated $compatdir/$dict.compat to $ispell_compat"; } - - unlink <$tempfile*>; + } else { + debugprint " --- ispell-autobuildhash: $compatdir/$dict.compat not updated because of an error"; + } } + } } else { - debugprint " ispell is not installed. Doing nothing"; + debugprint "ispell-autobuildhash: no ispell compat info. ispell may not be installed. Aborting ...\n"; } -myclean (); - __END__ =head1 NAME @@ -226,8 +231,10 @@ Options: --debug Show some extra ispell-autobuildhash information. + --dry-run Show what would be done, but do nothing real. --force Rebuild the hash file for all dicts providing a compat file skipping the test. + --triggered Tell the script that is run in the triggers stage. =head1 DESCRIPTION @@ -241,9 +248,16 @@ =head1 OPTIONS ---debug Show some extra ispell-autobuildhash information. ---force Rebuild the hash file for all dicts providing a compat - file regardless of the compatibility levels found. + --debug Show some extra ispell-autobuildhash information. + --dry-run Show what would be done, but do nothing real. + --force Rebuild the hash file for all dicts providing a compat + file regardless of the compatibility levels found. + --triggered Tell the script that is run in the triggers stage. When + run under dpkg control, do not try to set the + 'ispell-autobuildhash' trigger, but run real + B code. When not run under dpkg + control, real code will always be run and '--triggered' + option has no real effect. =head1 PACKAGE MAINTAINERS diff -Nru dictionaries-common-1.5.17ubuntu1/scripts/system/ispell-wrapper dictionaries-common-1.9.2ubuntu1/scripts/system/ispell-wrapper --- dictionaries-common-1.5.17ubuntu1/scripts/system/ispell-wrapper 2011-02-05 00:15:41.000000000 +0100 +++ dictionaries-common-1.9.2ubuntu1/scripts/system/ispell-wrapper 2011-02-09 05:42:51.000000000 +0100 @@ -1,127 +1,130 @@ #!/usr/bin/perl -w +use strict; use Debian::DictionariesCommon q(:all); use Getopt::Long; -Getopt::Long::Configure(pass_through,no_auto_abbrev); +Getopt::Long::Configure("pass_through","no_auto_abbrev"); # Autoflush output buffers $|=1; +my $class = "ispell"; +my $dictionaries = loaddb ($class); +my $emacsen; +my $regexp; +my $dryrun; + +# ------------------------------------------------- +sub isoconv { +# ------------------------------------------------- # Function to convert ISO-8859-1 (latin1) accented characters to # non-accented one. Of course, this only works for west European # languages. We might try to find a more general solution based on # the current locale character set. - -sub isoconv { +# ------------------------------------------------- my $s = shift; $s =~ y{A-ZÁÉÍÓÚÝáéíóúýÀÈÌÒÙàèìòùÂÊÎÔÛâêîôûÄËÏÖÜäëïößüÿÃÇÐÑÕãçñõÅÆØåæø} {a-zaeiouyaeiouyaeiouaeiouaeiouaeiouaeiouaeiosuyacdnoacnoaeoaeo}; return $s; } -# -# Function to try getting $lang after emacsen name -# - +# ------------------------------------------------- sub try_emacsen () { - return unless ( $emacsen ); - my @available_emacsen = (); - foreach $k (keys %$dictionaries) { - my $language = $dictionaries->{$k}; - my $hashname = $language->{"hash-name"}; - my $emacsenname = exists $language->{"emacsen-name"} ? - $language->{"emacsen-name"} : $hashname; - return $k if ( lc($emacsen) eq lc($emacsenname) ); - push @available_emacsen,$emacsenname; - } - print STDERR "Available emacs dict names are:\n"; - foreach ( sort @available_emacsen ){ - print STDERR " $_\n"; - } - die "$0: Selected emacs dict name [$emacsen] -does not match any of the available values\n"; +# ------------------------------------------------- +# Function to try getting $lang after emacsen name +# ------------------------------------------------- + my $emacsen = shift; + return unless $emacsen; + my %available_emacsen = (); + foreach my $lang (keys %$dictionaries) { + my $language = $dictionaries->{$lang}; + my $hashname = $language->{"hash-name"}; + my $emacsenname = exists $language->{"emacsen-name"} ? + $language->{"emacsen-name"} : $hashname; + return $lang if ( lc($emacsen) eq lc($emacsenname) ); + $available_emacsen{$emacsenname}++; + } + die "$0: \"$emacsen\" does not match any available emacs dict value:\n " + . join("\n ", sort keys %available_emacsen) . "\n"; } -# -# Function to try getting $lang after $regexp -# - +# ------------------------------------------------- sub try_regexp () { - return unless $regexp; - my @regexp_matches = (); - $regexp = isoconv ($regexp); - foreach $key ( keys %$dictionaries ) { - $_ = isoconv ( $key ); - push (@regexp_matches, $key) - if /$regexp/; - } - if (scalar @regexp_matches == 1){ - return $regexp_matches[0]; - } elsif ( scalar @regexp_matches == 0 ) { - die "$0: No installed language matched `$regexp'\n"; - } else { - die ("$0: More than one installed languages matched `$regexp':\n " - . join ("\n ", @regexp_matches) . "\n"); +# ------------------------------------------------- +# Function to try getting $lang after $regexp +# ------------------------------------------------- + my $regexp = shift; + return unless $regexp; + my $guess; + my %regexp_matches = (); + + $regexp = isoconv ($regexp); + foreach my $key ( keys %$dictionaries ) { + $_ = isoconv ( $key ); + if ( /$regexp/ ) { + $regexp_matches{$key}++; + $guess = $key; } + } + + die "$0: No installed language matched `$regexp'\n" unless $guess; + + if ( scalar keys %regexp_matches == 1) { + return $guess; + } else { + die ("$0: More than one installed languages matched `$regexp':\n " + . join ("\n ", sort keys %regexp_matches) . "\n"); + } } # -------------------------------------------------------------------- # Now the main program # -------------------------------------------------------------------- -my $lang = ''; -my $class = "ispell"; -my $cli_opts = ""; - -$dictionaries = loaddb ("ispell"); - -# In the POD section below there is an extensive description on the -# priority order for determining the ispell language. - -$emacsen = ''; -$regexp = ''; -my $dryrun = ''; - GetOptions ('emacs=s' => \$emacsen, 'language=s' => \$regexp, 'dry-run' => \$dryrun); die " ispell-wrapper is a wrapper to ispell, but ispell is not installed.\n" - unless ( -x "/usr/bin/ispell" ); + unless ( -x "/usr/bin/ispell" ); $regexp = $ENV{ISPELLDEFAULT} unless $regexp; $regexp =~ s/([^\\]|^)(\(|\))/$1\\$2/g if $regexp; # Make sure () are escaped -$lang = &try_emacsen () - || &try_regexp () - || &getuserdefault () - || &dico_getsysdefault ("ispell"); +# In the POD section below there is an extensive description on the +# priority order for determining the ispell language. +my $lang = &try_emacsen($emacsen) + || &try_regexp ($regexp) + || &getuserdefault () + || &dico_getsysdefault ("ispell"); print STDERR " Warning: --language=$regexp will be overriden by --emacs=$emacsen setting\n\n" - if ( defined $lang && $regexp && $emacsen ); + if ( defined $lang && $regexp && $emacsen ); -$ispell_wrapper_args = &dico_get_spellchecker_params($class,$dictionaries->{$lang}); +my $ispell_wrapper_args = &dico_get_spellchecker_params($class,$dictionaries->{$lang}); -# Ignore $lang results if -d is set from commandline +# Ignore $lang results if -d is explicitly set from commandline foreach ( @ARGV ) { - if (/^\-d/){ - $ispell_wrapper_args = ""; - } - $cli_opts .= " $_"; + if ( /^\-d/ ){ + $ispell_wrapper_args = ""; + last; + } } +my $cli_opts = join(' ',@ARGV); + print STDERR "Warning: \'$lang\' values overriden with \'$cli_opts\'\n" - if ( not $ispell_wrapper_args && defined $lang ); + if ( not $ispell_wrapper_args && defined $lang ); -$command_to_run = "ispell $ispell_wrapper_args $cli_opts"; +my $command_to_run = "ispell $ispell_wrapper_args $cli_opts"; if ( $dryrun ){ - print "--\n$command_to_run\n--\n"; + print "--\n$command_to_run\n--\n"; } else { - exec $command_to_run; + exec $command_to_run; } # Local Variables: diff -Nru dictionaries-common-1.5.17ubuntu1/scripts/system/remove-default.in dictionaries-common-1.9.2ubuntu1/scripts/system/remove-default.in --- dictionaries-common-1.5.17ubuntu1/scripts/system/remove-default.in 2010-10-20 11:54:00.000000000 +0200 +++ dictionaries-common-1.9.2ubuntu1/scripts/system/remove-default.in 2011-02-09 05:42:51.000000000 +0100 @@ -1,5 +1,6 @@ #!/usr/bin/perl -w +use strict; use Debian::DictionariesCommon q(dico_checkroot); use Debconf::Client::ConfModule q(:all); diff -Nru dictionaries-common-1.5.17ubuntu1/scripts/system/select-default.in dictionaries-common-1.9.2ubuntu1/scripts/system/select-default.in --- dictionaries-common-1.5.17ubuntu1/scripts/system/select-default.in 2010-10-20 11:54:00.000000000 +0200 +++ dictionaries-common-1.9.2ubuntu1/scripts/system/select-default.in 2011-02-09 05:42:51.000000000 +0100 @@ -1,12 +1,13 @@ #!/usr/bin/perl -w +use strict; use Debian::DictionariesCommon q(:all); use Debconf::Client::ConfModule q(:all); use Getopt::Long; dico_checkroot (); -my $rebuild = ''; +my $rebuild; GetOptions ('rebuild' => \$rebuild); diff -Nru dictionaries-common-1.5.17ubuntu1/scripts/system/update-default.in dictionaries-common-1.9.2ubuntu1/scripts/system/update-default.in --- dictionaries-common-1.5.17ubuntu1/scripts/system/update-default.in 2010-10-20 11:54:00.000000000 +0200 +++ dictionaries-common-1.9.2ubuntu1/scripts/system/update-default.in 2011-02-09 05:42:51.000000000 +0100 @@ -1,13 +1,14 @@ #!/usr/bin/perl -w +use strict; use Debian::DictionariesCommon q(:all); use Debconf::Client::ConfModule q(:all); use Getopt::Long; dico_checkroot (); -my $rebuild = ''; -my $ignoresymlinks = ''; +my $rebuild; +my $ignoresymlinks; GetOptions ('rebuild' => \$rebuild, 'ignore-symlinks' => \$ignoresymlinks); @@ -38,9 +39,9 @@ or print STDERR " $program: Warning: could not remove $newflag\n"; } -($ret, $value) = get ($question); +my ($ret, $value) = get ($question); -if ($ret == 0 && $value ){ +if ( $ret == 0 && $value ){ updatedb ($class); my $dictionaries = loaddb ($class); @@ -69,7 +70,7 @@ # strip leading/trailing whitespace and create a list of available keys s/^\s+//; s/\s+$//; - push (@available_keys,$_) if ( exists $dictionaries->{$_} ); + push (@available_keys,$_) if ( defined $dictionaries->{$_} ); } my $choices = join (', ', sort {lc $a cmp lc $b} @available_keys); my $forced_key = $available_keys[0] || @@ -94,7 +95,7 @@ } # Check if links are possible and complain otherwise - if ( exists $dictionaries->{$value}{"hash-name"} ){ + if ( defined $dictionaries->{$value}{"hash-name"} ){ my $hash = "$libdir/" . $dictionaries->{$value}{"hash-name"}; foreach my $i ([I:".hash", ".aff":][W:"":]) { if (-e "$hash$i") { diff -Nru dictionaries-common-1.5.17ubuntu1/scripts/system/update-dictcommon.in dictionaries-common-1.9.2ubuntu1/scripts/system/update-dictcommon.in --- dictionaries-common-1.5.17ubuntu1/scripts/system/update-dictcommon.in 2010-10-20 11:54:00.000000000 +0200 +++ dictionaries-common-1.9.2ubuntu1/scripts/system/update-dictcommon.in 2011-02-09 05:42:51.000000000 +0100 @@ -1,5 +1,6 @@ #!/usr/bin/perl -w +use strict; use Debian::DictionariesCommon q(:all); dico_checkroot (); diff -Nru dictionaries-common-1.5.17ubuntu1/support/emacsen/debian-ispell.el dictionaries-common-1.9.2ubuntu1/support/emacsen/debian-ispell.el --- dictionaries-common-1.5.17ubuntu1/support/emacsen/debian-ispell.el 2010-10-20 11:54:00.000000000 +0200 +++ dictionaries-common-1.9.2ubuntu1/support/emacsen/debian-ispell.el 2011-02-09 05:42:51.000000000 +0100 @@ -78,7 +78,8 @@ :help "Supply explicit dictionary file name")) ;; -- (define-key ispell-menu-map [ispell-kill-ispell] - '(menu-item "Kill Process" ispell-kill-ispell + '(menu-item "Kill Process" + (lambda () (interactive) (ispell-kill-ispell nil 'clear)) :enable (and (boundp 'ispell-process) ispell-process (eq (ispell-process-status) 'run)) :visible (featurep 'ispell) @@ -169,13 +170,16 @@ ["Continue Check" ispell-continue (featurep 'ispell)] ["Complete Word Frag" ispell-complete-word-interior-frag t] ["Complete Word" ispell-complete-word t] - ["Kill Process" ispell-kill-ispell (featurep 'ispell)] + ["Kill Process" (ispell-kill-ispell nil 'clear) (featurep 'ispell)] ["Customize..." (customize-group 'ispell) t] ;; flyspell-mode may not be bound... ["flyspell" flyspell-mode - :style toggle :selected flyspell-mode ] + :style toggle + :selected (and (boundp 'flyspell-mode) + flyspell-mode) + :active (boundp 'flyspell-mode)] "-" - ["Save Personal Dict" (ispell-pdict-save t t)(featurep 'ispell)] + ["Save Personal Dict" (ispell-pdict-save t t) (featurep 'ispell)] ["Change Dictionary" ispell-change-dictionary t]))) (if (null dicts) (setq dicts (cons "default" nil))) @@ -437,16 +441,17 @@ (debian-pkg-add-load-path-item mypath))) ;; -------------------------------------------------------------------------- -;; Set ispell-program-name consistently for all emacsen flavours, preferring -;; ispell over aspell for backwards compatibility +;; Set ispell-program-name consistently for all emacsen flavours. Prefer +;; aspell over ispell as has been for some time in FSF Emacs. Leave hunspell +;; as last option, hunspell support for -a is still too buggy. ;; -------------------------------------------------------------------------- (or (boundp 'ispell-program-name) (setq ispell-program-name - (if (executable-find "ispell") - "ispell" - (if (executable-find "aspell") - "aspell" + (if (executable-find "aspell") + "aspell" + (if (executable-find "ispell") + "ispell" (if (executable-find "hunspell") "hunspell" "ispell"))))) diff -Nru dictionaries-common-1.5.17ubuntu1/support/emacsen/startup.el.in dictionaries-common-1.9.2ubuntu1/support/emacsen/startup.el.in --- dictionaries-common-1.5.17ubuntu1/support/emacsen/startup.el.in 2010-10-20 11:54:00.000000000 +0200 +++ dictionaries-common-1.9.2ubuntu1/support/emacsen/startup.el.in 2011-02-09 05:42:51.000000000 +0100 @@ -6,6 +6,8 @@ (let ((skip-emacs-flavors-list '(emacs19 emacs20 + emacs21 + emacs22 emacs-snapshot)) (debian-dict-entries "@CACHEDIR@/@EMACSENSUPPORT@")) (if (member debian-emacs-flavor skip-emacs-flavors-list)