On Sun, Feb 06, 2005 at 01:19:24PM -0800, Don Armstrong wrote: > Package: dictionaries-common > Severity: important > Version: 0.24.7 > > dictionaries-common needs to have an option in the debconf prompting > such that a user can decline to have dictionaries-common munge their > precious configuration settings. > > That is, if I've got a dicionary and hash file installed that > dicionaries-common doesn't know about, I should be able to keep as my > default if I've set the symlinks myself. > > [This probably is a serious bug, since it doesn't allow administrators > to preserve their configuration file settings, but I'll leave the RC > nature of this bug to your discretion.] > A fix for that is in unstable, for two weeks now, and I think this should go into sarge. I have prepared a sarge package with this problem fixed, and would like to know the release team opinion about the convenience of its upload to testing-proposed-updates, since it involves changes that are neither very small nor absolutely straightforward. This is the changelog for the manual mode stuff dealing with the above problem, * Introducing a manual mode so administrators are allowed to preserve their personal settings (closes: #293926): - debian/dictionaries-common.templates: + Declare itself as an ispell dictionary and wordlist with a manual value, so a manual option is added to the debconf selection menu. - scripts/system/{update,remove}-default.in: + Behavior adjusted when debconf selection is ~manual~ to not try setting symlinks. - debian/dictionaries-common.config-base: + Make sure shared question is prompted if ~manual~ is not yet one of the options. + Force question be prompted if ispell/wordlist alternative was set in manual mode. + Improved debugging code. - debian/dictionaries-common.preinst: + Make sure old alternatives are removed when in manual mode. remove-default.in change also includes fix for #272530 [Selecting a wordlist in preconf leads to confusion], since the same code area is involved. There are some minor changes that I think should also go there, * debian/dictionaries-common.config-base: - Deal with debian-installer/language values using @ variant. - Added new tagalog entry to the %equivs hash. itagalog is already in Debian. If debian-installer/language uses as first entry a locale with a @ variant in some cases the automatic selection might not be correct. This will not be a problem for most languages where match in the two letters language code is enough, but might be in some (rare) others. Since fix is simple I propose to put it. The second thing is just adding a new language to a hash. plus some new l10n stuff, * debian/po: - Added turkish debconf templates translation, thanks to Mehmet Turker (closes: #281420). - Added Romanian debconf templates translation, thanks to Sorin Batariuc (closes: #283207). - Updated Galician debconf templates translation, thanks to Jacobo Tarrio (closes: #296305). - Added new Tagalog debconf templates translation, thanks to Eric Pareja (closes: #296411). I am attaching a diff file of dictionaries-common-0.22.40sarge8 against previous dictionaries-common-0.22.40sarge7, stripped of the l10n changes. Full packages are available for inspection at our alioth repository, http://dict-common.alioth.debian.org/testing with sources and changes file in the sources subdir. Cheers, -- Agustin
diff -Nru /tmp/cA4MuZxM8E/dictionaries-common-0.22.40sarge7/debian/changelog /tmp/HW6oi2vuuT/dictionaries-common-0.22.40sarge8/debian/changelog --- /tmp/cA4MuZxM8E/dictionaries-common-0.22.40sarge7/debian/changelog 2004-11-05 13:03:20.000000000 +0100 +++ /tmp/HW6oi2vuuT/dictionaries-common-0.22.40sarge8/debian/changelog 2005-02-24 19:18:39.000000000 +0100 @@ -1,3 +1,37 @@ +dictionaries-common (0.22.40sarge8) testing-proposed-updates; urgency=low + + * debian/dictionaries-common.config-base: + - Deal with debian-installer/language values using @ variant. + - Added new tagalog entry to the %equivs hash. itagalog is + already in Debian. + * Introducing a manual mode so administrators are allowed + to preserve their personal settings (closes: #293926): + - debian/dictionaries-common.templates: + + Declare itself as an ispell dictionary and wordlist with a + manual value, so a manual option is added to the debconf + selection menu. + - scripts/system/{update,remove}-default.in: + + Behavior adjusted when debconf selection is ~manual~ to not + try setting symlinks. + - debian/dictionaries-common.config-base: + + Make sure shared question is prompted if ~manual~ is not yet + one of the options. + + Force question be prompted if ispell/wordlist alternative was + set in manual mode. + - debian/dictionaries-common.preinst: + + Make sure old alternatives are removed when in manual mode. + * debian/po: + - Added turkish debconf templates translation, + thanks to Mehmet Turker (closes: #281420). + - Added Romanian debconf templates translation, + thanks to Sorin Batariuc (closes: #283207). + - Updated Galician debconf templates translation, + thanks to Jacobo Tarrio (closes: #296305). + - Added new Tagalog debconf templates translation, + thanks to Eric Pareja (closes: #296411). + + -- Agustin Martin Domingo <agmartin@debian.org> Thu, 24 Feb 2005 19:09:54 +0100 + dictionaries-common (0.22.40sarge7) testing-proposed-updates; urgency=low * debian/po: diff -Nru /tmp/cA4MuZxM8E/dictionaries-common-0.22.40sarge7/debian/dictionaries-common.config-base /tmp/HW6oi2vuuT/dictionaries-common-0.22.40sarge8/debian/dictionaries-common.config-base --- /tmp/cA4MuZxM8E/dictionaries-common-0.22.40sarge7/debian/dictionaries-common.config-base 2004-08-24 13:15:07.000000000 +0200 +++ /tmp/HW6oi2vuuT/dictionaries-common-0.22.40sarge8/debian/dictionaries-common.config-base 2005-02-24 19:18:40.000000000 +0100 @@ -67,31 +67,36 @@ "pt_BR" => "brazilian", "ru" => "russian", "sv" => "swedish", + "tl" => "tagalog", "uk" => "ukrainian"); my %reverse_equivs = (); +my %alternatives = ("ispell" => "ispell-dictionary.hash", + "wordlist" => "dictionary"); sub dc_debugprint(){ print STDERR "@_" if $debug; } sub dc_set (){ - my $question = shift; - my $value = shift; + my $question = shift; + my $value = shift; + + my ($errorcode, $oldvalue) = get($question); - my ($errorcode,$existingvalue) = get($question); - &dc_debugprint("*** ($errorcode,$existingvalue)\n"); - $errorcode = "unset" if not $existingvalue; - &dc_debugprint("***+ ($errorcode,$existingvalue)\n"); - if ( $errorcode ){ + $oldvalue = "unset" unless $oldvalue; + if ( $errorcode or $oldvalue eq "unset" ){ + &dc_debugprint(" errorcode: $errorcode; $question + Old:[$oldvalue] --> New:[$value]\n"); set("$question","$value"); - } elsif ( $existingvalue eq $value ) { + } elsif ( $oldvalue eq $value ) { print STDERR "Info: $question is already set to - $existingvalue. Preserving it.\n"; + [$oldvalue]. Preserving it.\n"; } else { print STDERR "Warning: $question is already set to - $existingvalue. - Not setting to $value\n"; + [$oldvalue]. + Not setting to [$value]\n"; } + &dc_debugprint("---\n"); } sub extractlang (){ @@ -101,7 +106,7 @@ my $thevariant = ''; my @thevalues = (); - &dc_debugprint("$language\n"); + &dc_debugprint("Trying lang $language\n"); if ( exists $equivs{$language} ){ ($thepackage,$thevariant) = split ("->",$equivs{$language}); foreach $prfx ( @prefixes ){ @@ -110,7 +115,7 @@ } else { $pkgfullname = "$classprefix$thepackage$prfx"; } - &dc_debugprint("$pkgfullname\n"); + &dc_debugprint("Trying package $pkgfullname\n"); if ( exists $debconf_vals{"$pkgfullname"} ){ if ( exists $debconf_defaultvals{"$pkgfullname"} ){ $thestring = $debconf_defaultvals{"$pkgfullname"}; @@ -200,6 +205,22 @@ return; } +sub dc_manual_alternative (){ + my $class = shift; + my $file = "/var/lib/dpkg/alternatives/$alternatives{$class}"; + my $status = ''; + + if ( -r $file ){ + open(FILE,"< $file") or return; + $status = <FILE>; + close FILE; + $status = "" unless $status; + chomp $status; + return unless ( exists $debconf_vals{"dictionaries-common"} ); + return $debconf_vals{"dictionaries-common"} if ( $status eq "manual" ); + } +} + sub dc_debconf_rebuild (){ my $class = shift; return unless $class; @@ -223,9 +244,12 @@ if ( not -e $dcscript ){ ($errorcode,$language) = get($di_language); - if ( not $errorcode and $language ){ - # Deal with de_DE:de_DE:de:en_GB:en like entries - ($language,$country) = split("_",( split(":",$language) )[0]); + if ( not $errorcode and $language ){ # Installing from scratch + # Deal with de_DE:de_DE@euro:de:en_GB:en like entries + $language = ( split(":",$language) )[0]; + #($language,$langvariant) = split("@",$language); + $language = ( split("@",$language) )[0]; + ($language,$country) = split("_",$language); if ( not $country ){ ($errorcode,$country) = get($di_country); if ( $errorcode or not $country ){ @@ -236,7 +260,7 @@ $classprefix = substr($class,0,1); if ( &dc_debconf_rebuild($class) ){ if ( $guessed = &guesslang($class,$language,$country) ){ - &dc_debugprint("($class,$language,$country)\n"); + &dc_debugprint("* Guessed [d-i]->($class,$language,$country)\n"); &dc_set("dictionaries-common/default-$class","$guessed"); } else { if ( $guessed = &guesslang($class,"en","US") ){ @@ -252,7 +276,7 @@ } } } - } else { + } else { # Upgrading from woody or previous release foreach ( keys %equivs ){ $reverse_equivs{$equivs{$_}} = $_; } @@ -260,12 +284,24 @@ $classprefix = substr($class,0,1); if ( &dc_debconf_rebuild($class) ){ if ( $guessed = &guesslink($class) ){ - foreach ( keys %debconf_vals ){ - my $oldpackage = $_; - $oldpackage = "wenglish" if ( $oldpackage eq "wamerican" ); + if ( &dc_manual_alternative($class) ){ + &dc_debugprint("- $class was in manual mode. Setting critical priority\n"); $priority{$class} = "critical"; - last if ( not -e "/var/lib/dpkg/info/$oldpackage.list"); + } else { $priority{$class} = "low"; + foreach ( keys %debconf_vals ){ + my $oldpackage = $_; + 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("* New dict [$oldpackage] is to be installed\n"); + last; + } + } } &dc_set("dictionaries-common/default-$class","$guessed"); } @@ -276,14 +312,20 @@ # Prompting the questions if required -if ( not -e $dcscript or $ARGV[0] eq "reconfigure" ){ +if ( not -e $dcscript ){ # First dictionaries-common installation foreach $class ("ispell","wordlist"){ &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 ( $priority{$class} ne "critical" ){ fset ("dictionaries-common/default-$class", "seen", "true"); go(); } } +} else { # Reconfiguring or upgrading + foreach $class ("ispell","wordlist"){ + &dc_debconf_select($class); + } } # diff -Nru /tmp/cA4MuZxM8E/dictionaries-common-0.22.40sarge7/debian/dictionaries-common.preinst /tmp/HW6oi2vuuT/dictionaries-common-0.22.40sarge8/debian/dictionaries-common.preinst --- /tmp/cA4MuZxM8E/dictionaries-common-0.22.40sarge7/debian/dictionaries-common.preinst 2003-09-04 14:23:30.000000000 +0200 +++ /tmp/HW6oi2vuuT/dictionaries-common-0.22.40sarge8/debian/dictionaries-common.preinst 2005-02-24 19:18:40.000000000 +0100 @@ -6,18 +6,21 @@ case "$1" in install|upgrade) # This will clean up the alternatives for ispell-dictionary.hash # set by the pre-Policy ispell dictionary packages - # + # A /var/lib/dpkg/alternatives/ispell-dictionary.hash file is sometimes left + # if alternative was set to manual mode. Setting it to --auto ensures removal. DICTS=`/usr/sbin/update-alternatives --display ispell-dictionary.hash \ | grep priority | cut -f1 -d" "` for i in $DICTS ; do /usr/sbin/update-alternatives --remove ispell-dictionary.hash $i done + /usr/sbin/update-alternatives --auto ispell-dictionary.hash # The same for wordlists WORDS=`/usr/sbin/update-alternatives --display dictionary \ | grep priority | cut -f1 -d" "` for i in $WORDS ; do /usr/sbin/update-alternatives --remove dictionary $i done + /usr/sbin/update-alternatives --auto dictionary ;; esac diff -Nru /tmp/cA4MuZxM8E/dictionaries-common-0.22.40sarge7/debian/dictionaries-common.templates /tmp/HW6oi2vuuT/dictionaries-common-0.22.40sarge8/debian/dictionaries-common.templates --- /tmp/cA4MuZxM8E/dictionaries-common-0.22.40sarge7/debian/dictionaries-common.templates 2004-07-05 18:58:28.000000000 +0200 +++ /tmp/HW6oi2vuuT/dictionaries-common-0.22.40sarge8/debian/dictionaries-common.templates 2005-02-24 19:18:40.000000000 +0100 @@ -96,3 +96,16 @@ will not set the default ispell dictionary. . Use instead 'select-default-ispell' or 'select-default-wordlist' scripts. + +Template: shared/packages-ispell +Type: text +Description: + +Template: shared/packages-wordlist +Type: text +Description: + +Template: dictionaries-common/languages +Type: text +Default: ~manual~ (I set symlinks manually) +Description: diff -Nru /tmp/cA4MuZxM8E/dictionaries-common-0.22.40sarge7/scripts/system/remove-default.in /tmp/HW6oi2vuuT/dictionaries-common-0.22.40sarge8/scripts/system/remove-default.in --- /tmp/cA4MuZxM8E/dictionaries-common-0.22.40sarge7/scripts/system/remove-default.in 2003-10-13 12:30:34.000000000 +0200 +++ /tmp/HW6oi2vuuT/dictionaries-common-0.22.40sarge8/scripts/system/remove-default.in 2005-02-24 19:18:44.000000000 +0100 @@ -1,5 +1,6 @@ #!/usr/bin/perl -w +use Debian::DictionariesCommon q(:all); use Debconf::Client::ConfModule q(:all); die "$0: You must run this as root.\n" if ($> != 0); @@ -10,43 +11,53 @@ my $class = "[I:ispell:][W:wordlist:]"; my $question = "dictionaries-common/default-$class"; +my $manual = ''; +my $options = ""; -(my $ret, my $value) = get $question; +($ret, $value) = get $question; if ($ret == 0) { - my $package = $ARGV[0]; - my @languages = split (/\s*,\s*/, metaget ("$package/languages", - "default")); - my @oldchoices = split (/\s*,\s*/, metaget ($question, "choices")); - my @newchoices = (); - foreach $choice ( @oldchoices ){ - my $found = 0; - foreach (@languages) { - s/\s*(.*)\s*/$1/; - if ($_ eq $choice){ - $found = 1; - last; - } - } - push (@newchoices, $choice) if ($found == 0); - } + $manual = "yes" if ( $value =~ m/^~manual.*/i ); - subst ($question, "choices", join (', ', @newchoices)); + updatedb ($class); - my $found = 0; - foreach my $k (@languages) { - last if ($found = ($value eq $k)); + my $package = $ARGV[0]; + my $dictionaries = loaddb ($class); + my $languages = metaget ("$package/languages", "default"); + my @oldchoices = split (/\s*,\s*/, metaget ($question, "choices")); + my @newchoices = (); + my %langsinpkg = (); + + for ( $languages ){ # Trim leading/trailing whitespaces the perlfaq way + s/^\s+//; + s/\s+$//; } - - if ($found == 1) { - system "select-default-[I:ispell:][W:wordlist:]"; + + foreach ( split (/\s*,\s*/, $languages) ){ + $langsinpkg{$_}++; + } + + foreach $choice ( @oldchoices ){ + push (@newchoices, $choice) unless exists $langsinpkg{$choice}; } - system "update-default-[I:ispell:][W:wordlist:] --rebuild"; - + subst ($question, "choices", join (', ', @newchoices)); + + if ( $manual || scalar(keys %{$dictionaries}) <= 1 ) { + $options = "--ignore-symlinks"; + } else { + if ( exists $langsinpkg{$value} ) { + system "select-default-[I:ispell:][W:wordlist:]"; + } + } + system "update-default-[I:ispell:][W:wordlist:] --rebuild $options"; } +#Local Variables: +#perl-indent-level: 2 +#End: + __END__ =head1 NAME diff -Nru /tmp/cA4MuZxM8E/dictionaries-common-0.22.40sarge7/scripts/system/update-default.in /tmp/HW6oi2vuuT/dictionaries-common-0.22.40sarge8/scripts/system/update-default.in --- /tmp/cA4MuZxM8E/dictionaries-common-0.22.40sarge7/scripts/system/update-default.in 2004-06-02 12:36:42.000000000 +0200 +++ /tmp/HW6oi2vuuT/dictionaries-common-0.22.40sarge8/scripts/system/update-default.in 2005-02-24 19:18:44.000000000 +0100 @@ -8,6 +8,7 @@ my $rebuild = ''; my $ignoresymlinks = ''; + GetOptions ('rebuild' => \$rebuild, 'ignore-symlinks' => \$ignoresymlinks); @@ -18,16 +19,22 @@ my $question = "dictionaries-common/default-$class"; my $iquestion = "dictionaries-common/invalid_debconf_value"; my $linkdir = "/etc/dictionaries-common"; +my $manual = ''; [I:my $emacsen_default = "nil"; my $emacsen_default_file = "/var/cache/dictionaries-common/emacsen-ispell-default.el";:] -my ($ret, $value) = get ($question); +($ret, $value) = get ($question); if ($ret == 0 && $value ){ updatedb ($class); my $dictionaries = loaddb ($class); + if ( $value =~ m/^~manual.*/i ){ # Check if we are in manual mode + $ignoresymlinks = "yes"; + $manual = "yes"; + } + if ( not $ignoresymlinks) { if (not exists $dictionaries->{$value}){ # Handle invalid debconf values @@ -41,25 +48,25 @@ die "Selected [I:ispell dictionary:I][W:wordlist:W]:\n" . " $value \n" . "does not correspond to any installed package in the system\n" . - "and no alternative [I:ispell dictionary:I][W:wordlist:W] could be selected."; + "and no alternative [I:ispell dictionary:I][W:wordlist:W] could be selected.\n"; subst($iquestion,"value",$value); - fset ($iquestion,"isdefault","true"); + fset ($iquestion,"seen","false"); input("high",$iquestion); # Warn about what happened subst ($question, "choices", $choices); # Put sane values in debconf choices field set ($question, $forced_key); # Set debconf value to a sane one - fset ($question,"isdefault","true"); + fset ($question,"seen","false"); input ("critical", $question); title ("dictionaries-common: [I:ispell dictionaries:I][W:wordlists:W]"); go (); ($ret, $value) = get ($question); die "\n Could not get a valid value for debconf question:\n" . - "$question" + "$question\n" if ( $ret != 0 ); # This should never be reached } die "Selected [I:ispell dictionary:][W:wordlist:]:\n" . " $value \n" . - "does not contain a hash name entry in the database." + "does not contain a hash name entry in the database.\n" if (not exists $dictionaries->{$value}{"hash-name"}); [I: setsysdefault ($value); # This here is only for ispell, not wordlist @@ -73,7 +80,7 @@ the file to link [$hash$i] was not found. Please report this as a bug to the maintainer of the [I:ispell dictionary:][W:wordlist:] package you tried to select. -In the meantime select other default value for your [I:ispell dictionary:][W:wordlist:]." +In the meantime select other default value for your [I:ispell dictionary:][W:wordlist:].\n" if (not -e "$hash$i"); system "ln -fs $hash$i $linkdir/[I:default:][W:words:]$i"; @@ -81,13 +88,15 @@ } } [I: - if ( exists $dictionaries->{$value}{"emacs-display"} - and lc($dictionaries->{$value}{"emacs-display"}) eq "no" ){ - $emacsen_default = "nil"; - } elsif ( exists $dictionaries->{$value}{"emacsen-name"} ){ - $emacsen_default = "\"" . $dictionaries->{$value}{"emacsen-name"} . "\""; - } elsif( exists $dictionaries->{$value}{"hash-name"} ){ - $emacsen_default = "\"" . $dictionaries->{$value}{"hash-name"} . "\""; + unless ( $manual ){ + if ( exists $dictionaries->{$value}{"emacs-display"} + and lc($dictionaries->{$value}{"emacs-display"}) eq "no" ){ + $emacsen_default = "nil"; + } elsif ( exists $dictionaries->{$value}{"emacsen-name"} ){ + $emacsen_default = "\"" . $dictionaries->{$value}{"emacsen-name"} . "\""; + } elsif( exists $dictionaries->{$value}{"hash-name"} ){ + $emacsen_default = "\"" . $dictionaries->{$value}{"hash-name"} . "\""; + } }:] } @@ -109,7 +118,7 @@ build_emacsen_support (); build_jed_support (); system ("ispell-autobuildhash") == 0 - or die "Error running ispell-autobuildhash"; + or die "Error running ispell-autobuildhash\n"; # End of specific ispell support :] }
Attachment:
signature.asc
Description: Digital signature