~ubuntu-branches/ubuntu/lucid/dictionaries-common/lucid-201002122359

« back to all changes in this revision

Viewing changes to debian/dictionaries-common.config-base

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2005-09-02 13:39:19 UTC
  • mfrom: (1.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050902133919-1yjcebqd0y0op3tz
Tags: 0.49.2ubuntu1
scripts/system/dc-debconf-select.pl: Drop default question priority to
medium so that the default wordlist question is not asked on initial
installation. (This is a temporary workaround, and leaves a dangling
symlink in /usr/share/dict/words.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
                    "tl"      => "tagalog",
71
71
                    "uk"      => "ukrainian");
72
72
my %reverse_equivs = ();
 
73
my %alternatives   = ("ispell"   => "ispell-dictionary.hash",
 
74
                      "wordlist" => "dictionary");
73
75
 
74
76
sub dc_debugprint(){
75
77
    print STDERR "@_" if $debug;
76
78
}
77
79
 
78
80
sub dc_set (){
79
 
    my $question  =  shift;
80
 
    my $value     =  shift;
 
81
    my $question  = shift;
 
82
    my $value     = shift;
 
83
 
 
84
    my ($errorcode, $oldvalue) = get($question);
81
85
    
82
 
    my ($errorcode,$existingvalue) = get($question);
83
 
    &dc_debugprint("*** ($errorcode,$existingvalue)\n");
84
 
    $errorcode = "unset" if not $existingvalue;
85
 
    &dc_debugprint("***+ ($errorcode,$existingvalue)\n");
86
 
    if ( $errorcode ){
 
86
    $oldvalue = "unset" unless $oldvalue;
 
87
    if ( $errorcode or $oldvalue eq "unset" ){
 
88
        &dc_debugprint("  errorcode: $errorcode; $question
 
89
  Old:[$oldvalue] --> New:[$value]\n");
87
90
        set("$question","$value");
88
 
    } elsif ( $existingvalue eq $value ) {
 
91
    } elsif ( $oldvalue eq $value ) {
89
92
        print STDERR "Info: $question is already set to 
90
 
      $existingvalue. Preserving it.\n";
 
93
      [$oldvalue]. Preserving it.\n";
91
94
    } else {
92
95
        print STDERR "Warning: $question is already set to 
93
 
         $existingvalue. 
94
 
         Not setting to $value\n";
 
96
      [$oldvalue].
 
97
      Not setting to [$value]\n";
95
98
    }
 
99
    &dc_debugprint("---\n");
96
100
}
97
101
 
98
102
sub extractlang (){
102
106
    my $thevariant = '';
103
107
    my @thevalues  = ();
104
108
 
105
 
    &dc_debugprint("$language\n");
 
109
    &dc_debugprint("Trying lang $language\n");
106
110
    if ( exists $equivs{$language} ){
107
111
        ($thepackage,$thevariant) = split ("->",$equivs{$language}); 
108
112
        foreach $prfx ( @prefixes ){
111
115
            } else {
112
116
                $pkgfullname = "$classprefix$thepackage$prfx";
113
117
            }
114
 
            &dc_debugprint("$pkgfullname\n");
 
118
            &dc_debugprint("Trying package $pkgfullname\n");
115
119
            if ( exists $debconf_vals{"$pkgfullname"} ){
116
120
                if ( exists $debconf_defaultvals{"$pkgfullname"} ){
117
121
                    $thestring = $debconf_defaultvals{"$pkgfullname"};
201
205
    return;
202
206
}
203
207
 
 
208
sub dc_manual_alternative (){
 
209
    my $class  = shift;
 
210
    my $file   = "/var/lib/dpkg/alternatives/$alternatives{$class}";
 
211
    my $status = '';
 
212
 
 
213
    if ( -r $file ){
 
214
        open(FILE,"< $file") or return;
 
215
        $status = <FILE>;
 
216
        close FILE;
 
217
        $status = "" unless $status;
 
218
        chomp $status;
 
219
        return unless ( exists $debconf_vals{"dictionaries-common"} );
 
220
        return $debconf_vals{"dictionaries-common"} if ( $status eq "manual" );
 
221
    }
 
222
}
 
223
 
204
224
sub dc_debconf_rebuild (){
205
225
    my $class = shift;
206
226
    return unless $class;
224
244
 
225
245
if ( not -e $dcscript ){
226
246
    ($errorcode,$language) = get($di_language);
227
 
    if ( not $errorcode and $language ){
228
 
        # Deal with de_DE:de_DE:de:en_GB:en like entries
229
 
        ($language,$country) = split("_",( split(":",$language) )[0]);
 
247
    if ( not $errorcode and $language ){                # Installing from scratch
 
248
        # Deal with de_DE:de_DE@euro:de:en_GB:en like entries
 
249
        $language = ( split(":",$language) )[0];
 
250
        #($language,$langvariant) = split("@",$language);
 
251
        $language = ( split("@",$language) )[0];
 
252
        ($language,$country) = split("_",$language);
230
253
        if ( not $country ){
231
254
            ($errorcode,$country) = get($di_country);
232
255
            if ( $errorcode or not $country ){
237
260
            $classprefix = substr($class,0,1);
238
261
            if ( &dc_debconf_rebuild($class) ){
239
262
                if ( $guessed = &guesslang($class,$language,$country) ){
240
 
                    &dc_debugprint("($class,$language,$country)\n");
 
263
                    &dc_debugprint("* Guessed [d-i]->($class,$language,$country)\n");
241
264
                    &dc_set("dictionaries-common/default-$class","$guessed");
242
265
                } else {
243
266
                    if ( $guessed = &guesslang($class,"en","US") ){
253
276
                }
254
277
            }
255
278
        }
256
 
    } else {
 
279
    } else {                  # Upgrading from woody or previous release
257
280
        foreach ( keys %equivs ){
258
281
            $reverse_equivs{$equivs{$_}} = $_;
259
282
        }
261
284
            $classprefix = substr($class,0,1);
262
285
            if ( &dc_debconf_rebuild($class) ){
263
286
                if ( $guessed = &guesslink($class) ){
264
 
                    foreach ( keys %debconf_vals ){
265
 
                        my $oldpackage = $_;
266
 
                        $oldpackage = "wenglish" if ( $oldpackage eq "wamerican" );
 
287
                    if ( &dc_manual_alternative($class) ){
 
288
                        &dc_debugprint("- $class was in manual mode. Setting critical priority\n");
267
289
                        $priority{$class} = "critical";
268
 
                        last if ( not -e "/var/lib/dpkg/info/$oldpackage.list");
 
290
                    } else {
269
291
                        $priority{$class} = "low";
 
292
                        foreach ( keys %debconf_vals ){
 
293
                            my $oldpackage = $_;
 
294
                            next if ( $oldpackage eq "dictionaries-common" );
 
295
                            $oldpackage = "wenglish" if ( $oldpackage eq "wamerican" );
 
296
                            # critical priority if exists debconf entry without a
 
297
                            # previous package installed. This means that besides
 
298
                            # upgrading, new dicts are being installed.
 
299
                            if ( not -e "/var/lib/dpkg/info/$oldpackage.list" ){
 
300
                                $priority{$class} = "critical";
 
301
                                &dc_debugprint("* New dict [$oldpackage] is to be installed\n");
 
302
                                last;
 
303
                            }
 
304
                        }
270
305
                    }
271
306
                    &dc_set("dictionaries-common/default-$class","$guessed");
272
307
                }
275
310
    }
276
311
}
277
312
 
 
313
# Unregistering no longer used dictionaries-common/languages and
 
314
# dictionaries-common ownership of other two shared questions
 
315
 
 
316
unregister("dictionaries-common/languages");
 
317
unregister("shared/packages-ispell");
 
318
unregister("shared/packages-wordlist");
 
319
 
278
320
# Prompting the questions if required
279
321
 
280
 
if ( not -e $dcscript or $ARGV[0] eq "reconfigure" ){
 
322
if ( not -e $dcscript ){             # First dictionaries-common installation
281
323
    foreach $class ("ispell","wordlist"){
282
324
        &dc_debconf_select($class,$priority{$class}); 
 
325
        # This might have been pre-seeded and question not asked.
 
326
        # Make sure question is tagged as seen in this case 
283
327
        if ( $priority{$class} ne "critical" ){
284
328
            fset ("dictionaries-common/default-$class", "seen", "true");
285
329
            go();
286
330
        }
287
331
    }
 
332
} else {                              # Reconfiguring or upgrading
 
333
    foreach $class ("ispell","wordlist"){
 
334
        &dc_debconf_select($class);
 
335
    }
288
336
}
289
337
 
290
338