home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / share / dictionaries-common / dc-debconf-select.pl next >
Encoding:
Text File  |  2006-12-19  |  2.2 KB  |  65 lines

  1. # -------------------------------------------------------------------------------
  2. # dc-debconf-select.pl:
  3. #  This file will be added to end of dictionaries-common.config-base
  4. #  to make dictionaries-common.config, as well as installed under
  5. #  /usr/share/dictionaries-common for single ispell dicts /wordlists use
  6. # -------------------------------------------------------------------------------
  7.  
  8. sub dc_debconf_select (){
  9.   my $class      = shift;
  10.   my $priority   = shift;
  11.   my $question   = "shared/packages-$class";
  12.   my $debug      = "yes" if exists $ENV{'DICT_COMMON_DEBUG'};
  13.   my @newchoices = ();
  14.   my @oldchoices = ();
  15.   my %title      = ('ispell'   => "Dictionaries-common: Ispell dictionary",
  16.             'wordlist' => "Dictionaries-common: Wordlist dictionary"
  17.             );
  18.   
  19.   $priority = "medium" unless $priority;
  20.   
  21.   my ($errorcode,$pkgowners) = metaget ($question, "owners");
  22.   return if $errorcode;
  23.   
  24.   foreach (split (/\s*,\s*/, $pkgowners)){
  25.     my $entry = metaget ("$_/languages", "default");
  26.     for ( $entry ){ # trim leading/trailing whitespaces
  27.       s/^\s+//;
  28.       s/\s+$//;
  29.     }
  30.     push (@newchoices, split(/\s*,\s*/, $entry));
  31.   }
  32.   my $choices = join (', ', sort {lc $a cmp lc $b} @newchoices);
  33.   
  34.   $question = "dictionaries-common/default-$class";
  35.   @oldchoices = split(/\s*,\s*/,metaget ($question, "choices"));
  36.   pop @oldchoices;
  37.   my $oldchoices = join (', ', @oldchoices);
  38.   print STDERR "** dictionaries-common: $class, $priority, $question\n" .
  39.       "   new:[$choices]\n   old:[$oldchoices]\n" if $debug;
  40.   unless ( scalar @newchoices == 0 ) { 
  41.     if ( $choices ne $oldchoices ) {
  42.       subst ($question, "choices", $choices);
  43.       fset ($question, "seen", "false");
  44.     }   
  45.     input ($priority, $question);
  46.     title ($title{$class});
  47.     go ();
  48.   }
  49.   
  50.   # If called from dictionaries-common.config, check actual values in debug mode
  51.   if ( $debug && $fromdcconfig ){
  52.     print STDERR "** dictionaries-common.config: Checking some real values for $question\n";
  53.     print STDERR "   Real choices: " . metaget ($question, "choices") . "\n";
  54.     print STDERR "   Real value: "   . get ($question) . "\n";
  55.     print STDERR "---\n";
  56.   }
  57. }
  58.  
  59. # Local Variables:
  60. # perl-indent-level: 2
  61. # End:
  62.  
  63. 1;
  64.  
  65.