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 / sbin / remove-default-ispell < prev    next >
Encoding:
Text File  |  2006-12-19  |  2.2 KB  |  103 lines

  1. #!/usr/bin/perl -w
  2.  
  3. use Debian::DictionariesCommon q(:all);
  4. use Debconf::Client::ConfModule q(:all);
  5.  
  6. die "$0: You must run this as root.\n" if ($> != 0);
  7.  
  8. die "Usage: $0 package-name\n" if (scalar @ARGV != 1);
  9.  
  10. version ('2.0');
  11.  
  12. sub get_choices (){
  13.   my $class      = shift;
  14.   my $question   = "shared/packages-$class";
  15.   my @choices = ();
  16.   
  17.   my ($errorcode,$pkgowners) = metaget ($question, "owners");
  18.   return if $errorcode;
  19.   
  20.   foreach (split (/\s*,\s*/, $pkgowners)){
  21.     my $entry = metaget ("$_/languages", "default");
  22.     for ( $entry ){           # Trim leading/trailing whitespaces
  23.       s/^\s+//;
  24.       s/\s+$//;
  25.     }
  26.     push (@choices, split(/\s*,\s*/, $entry));
  27.   }
  28.   return sort {lc $a cmp lc $b} @choices;
  29. }
  30.  
  31. # ---------------------------------------------------------------------
  32.  
  33. my $class    = "ispell";
  34. my $question = "dictionaries-common/default-$class";
  35.  
  36. ($ret, $value) = get $question;
  37.  
  38. if ($ret == 0) {
  39.  
  40.   updatedb ($class);
  41.  
  42.   my $package      = $ARGV[0];
  43.   my $dictionaries = loaddb ($class);
  44.   my $languages    = metaget ("$package/languages", "default");
  45.   my @newchoices   = ();
  46.   my %langsinpkg   = ();
  47.  
  48.   for ( $languages ){ # Trim leading/trailing whitespaces
  49.     s/^\s+//;
  50.     s/\s+$//;
  51.   }
  52.   
  53.   foreach ( split (/\s*,\s*/, $languages) ){
  54.     $langsinpkg{$_}++;
  55.   }
  56.   
  57.   foreach $choice ( &get_choices($class) ){
  58.     push (@newchoices, $choice) unless exists $langsinpkg{$choice};
  59.   }
  60.   
  61.   subst ($question, "choices", join (', ', @newchoices));
  62.   
  63.   if ( exists $langsinpkg{$value} ) {
  64.     system "select-default-$class --rebuild";
  65.   } else {
  66.     system "update-default-$class --rebuild";
  67.   }
  68. }
  69.  
  70. #Local Variables:
  71. #perl-indent-level: 2
  72. #End:
  73.  
  74. __END__
  75.  
  76. =head1 NAME
  77.  
  78. remove-default-ispell - remove default ispell dictionary
  79.  
  80. =head1 SYNOPSIS
  81.  
  82.  remove-default-ispell <package>
  83.  
  84. =head1 DESCRIPTION
  85.  
  86. WARNING: Not to be used from the command line unless you know very well what you are doing.
  87.  
  88. When called from package postrm, this program will take care of removing the entries 
  89. associated to a ispell package from the dictionaries-common database 
  90. and call for the new selection if it was the default one.
  91.  
  92. =head1 SEE ALSO
  93.  
  94. The dictionaries-common policy document
  95.  
  96. =head1 AUTHORS
  97.  
  98. Rafael Laboissiere
  99.  
  100. =cut
  101.  
  102. #  LocalWords:  ispell wordlist
  103.