aboutsummaryrefslogtreecommitdiffstats
path: root/rpmdrake
blob: 638c9f3075b7140f2f76ac653b327dee4f2f0ebb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
#!/usr/bin/perl
#*****************************************************************************
# 
#  Copyright (c) 2002 Guillaume Cottenceau (gc at mandrakesoft dot com)
# 
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License version 2, as
#  published by the Free Software Foundation.
# 
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  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.
# 
#*****************************************************************************
#
# $Id$

"@ARGV" =~ /-h/ and do {
    printf STDERR "Usage: %s [OPTION]...
  --noconfirmation       don't ask first confirmation question in MandrakeUpdate mode
", basename($0);
    exit 0;
};

$> and (exec {'consolehelper'} $0, @ARGV or die "consolehelper missing");


use lib qw(/usr/lib/libDrakX);

use strict;
use vars qw($MODE %options $typical_width $max_info_in_descr);

use rpmdrake;


$MODE = 'install';
$0 =~ '/rpmdrake-remove$' and $MODE = 'remove';
$0 =~ '/MandrakeUpdate$'  and $MODE = 'update';

/^-?-(\S+)$/ and $options{$1} = 1 foreach @ARGV;


$::isStandalone = 1;
Gtk->init;


sub ctreefy { $_[0] =~ s,/,|,g; $_[0] }

sub beautify_description {
    my ($t, $tmp);
    foreach (split "\n", $_[0]) {
	s/^\s*//;
        if (/^$/ || /^\s*(-|\*|\+|o)\s/) {
            ($t || $tmp) and $t .= "$tmp\n";
            $tmp = $_;
        } else {
            $tmp = ($tmp ? "$tmp " : ($t && "\n") . $tmp) . $_;
        }
    }
    "$t$tmp\n";
}

sub myformatList {
    my $r = formatList(40, @_);
    $r =~ s/(.{50}\S*)\s/$1\n/g;
    $r
}

sub split_fullname { $_[0] =~ /^(.*)-([^-]+-[^-]+)$/ }
sub my_fullname { my ($name, $version, $release) = $_[0]->fullname; "$name-$version-$release" }

sub parse_compssUsers_flat {
    my ($urpm) = @_;
    my (%compssUsers, $category);
    my $compss = '/var/lib/urpmi/compssUsers.flat';
    -r $compss or $compss = '/usr/share/rpmdrake/compssUsers.flat.default';
    -r $compss or die "Internal error, please report";;
    foreach (cat_($compss)) {
	s/#.*//;
	/^\s*$/ and next;
	if (/^\S.*/) {
	    if (/^(.+?) \[icon=.+?\] \[path=(.+?)\]/) {
		$category = translate($2).'|'.translate($1);
	    } else {
		print STDERR "Malformed category in compssUsers.flat: <$_>\n";
	    }
	} elsif (/^\t(\d) (\S+)\s*$/) {
	    $category or print STDERR "Entry without category <$_>\n";
	    push @{$compssUsers{$2}}, $category . ($1 <= 3 ? '|'._("Other") : '');
	}
    }
    \%compssUsers;
}

sub pkg2medium {
    my ($p, $urpm) = @_;
    my $tmp;
    each_index { !$_->{ignore} && $p->id <= $_->{end} and $tmp ||= ${$urpm->{media}}[$::i] } @{$urpm->{media}};
    $tmp;
}

sub extract_header {
    my ($pkg, $urpm) = @_;
    if ($MODE eq 'remove') {
	@$max_info_in_descr or return;
	my $name = my_fullname($pkg->{pkg});
	add2hash($pkg, { files => scalar(`rpm -ql $name`), changelog => scalar(`rpm -q --changelog $name`) });
    } else {
	my ($headersdir, $p, $medium) = ('/root/tmp/headers/', $pkg->{pkg}, pkg2medium($pkg->{pkg}, $urpm));
	my $hdlist =  "$urpm->{statedir}/$medium->{hdlist}";
	if (-r $hdlist) {  #- packdrake segfaults when giving a missing file :(
	    standalone::explanations("Extracting header of " . $p->header_filename . " from $hdlist");
	    my $packer;
	    eval { $packer = new packdrake($hdlist, quiet => 1) } or log::l("Warning, hdlist seems corrupted :-("), goto header_non_available;
	    $packer->extract_archive($headersdir, $p->header_filename);
	    $p->update_header($headersdir . $p->header_filename) or log::l("Warning, could not extract header!"), goto header_non_available;
	    rm_rf($headersdir);
	    add2hash($pkg, { summary => $p->summary, description => beautify_description($p->description) });
	    my $localtime2changelog = sub { scalar(localtime($_[0])) =~ /(.*) \S+ (\d{4})$/; "$1 $2" };
	    @$max_info_in_descr and add2hash($pkg, { files => join("\n", $p->files),
						     changelog => join("\n", mapn { "* ".$localtime2changelog->($_[2])." $_[0]\n\n$_[1]\n" }
							   [ $p->changelog_name ], [ $p->changelog_text ], [ $p->changelog_time ]) });
	    $p->pack_header;
	} else {
	  header_non_available:
	    add2hash($pkg, { summary => _("(Non available)"), description => undef });
	}
    }
}

sub do_search($$$$$$) {
    my ($find_entry, $tree, $options, $current_search_type, $urpm, $pkgs) = @_;
    my $entry = $find_entry->get_text or return;
    my ($results_ok, $results_none) = (_("Search results"), _("Search results (none)"));
    $options->{delete_category}->($_) foreach ($results_ok, $results_none);
    $options->{state}{flat} and $options->{delete_all}->();
    $tree->collapse_recursive(undef);
    my @search_results;
    if ($current_search_type ne 'normal') {
	if ($MODE eq 'remove') {
	    @search_results = map { if_(eval { ($pkgs->{$_}{summary}.$pkgs->{$_}{description}) =~ /$entry/i }, $_) } keys %$pkgs;
	} else {
	    my @hdlists = map { my $h = "$urpm->{statedir}/$_->{hdlist}";
				if_(!$_->{ignore} && (!($MODE eq 'update') || $_->{update}) && (-r $h), $h) } @{$urpm->{media}};
	    my $total_size = sum(map { my $pack; eval { $pack = new packdrake($_, quiet => 1) } ? $pack->{toc_f_count} : 0 } @hdlists);
	    my $searchstop;
	    my $searchw = my_gtk->new;
	    gtkadd($searchw->{window}, gtkpack__(new Gtk::VBox(1, 5),
						 new Gtk::Label(_("Please wait, searching...")),
						 my $searchprogress = gtkset_usize(new Gtk::ProgressBar, 400, 0),
						 gtkpack__(gtkset_layout(new Gtk::HButtonBox, 'spread'),
							   gtksignal_connect(new Gtk::Button(but(_("Stop"))),
									     clicked => sub { $searchstop = 1 }))));
	    $searchw->sync;
	    open SF, 'parsehdlist --fileswinfo --description --summary '.join(' ', map { "\'$_\'" } @hdlists).' |';
	    my ($pkg, $progresscount);
	    while (<SF>) {
		$searchstop and last;
		if (/^NAME<([^>]+)> VERSION<([^>]+)> RELEASE<([^>]+)>/) {
		    $pkg = "$1-$2-$3";
		    $progresscount++; $progresscount <= $total_size and $searchprogress->update($progresscount/$total_size);
		    $searchw->flush;
		    next;
		}
		$pkg or next;
		my (undef, $key, $value) = split ':', $_;
		if ($current_search_type eq 'descriptions') {
		    $key =~ /^summary|description$/ or next;
		} else {
		    $key eq 'files' or next;
		}
		if (eval { $value =~ /$entry/i }) {
		    exists $pkgs->{$pkg} and push @search_results, $pkg;
		    $pkg = '';
		}
	    }
	    close SF;
	    @search_results = uniq(@search_results); #- there can be multiple packages with same version/release for different arch's
	    $searchw->destroy;
	}
    } else {
	@search_results = grep { eval { $_ =~ /$entry/i } } keys %$pkgs;
    }
    if (@search_results) {
	$options->{add_nodes}->(map { [ $_, _("Search results").($options->{tree_mode} eq 'by_presence'
								 ? '|'.($pkgs->{$_}{pkg}->flag_installed ? _("Upgradable") : _("Addable"))
								 : ($options->{tree_mode} eq 'by_selection'
								    ? '|'.($pkgs->{$_}{selected} ? _("Selected") : _("Not selected"))
								    : ''))
				      ] } sort { uc($a) cmp uc($b) } @search_results);
	$tree->expand($tree->node_nth($tree->rows-1));
    } else {
	$options->{add_nodes}->([ '', $results_none, { nochild => 1 }]);
    }
}

sub db { URPM::DB::open or die 'Couldn\'t open RPM DB' }

sub run_treeview_dialog {
    my ($pkgs_provider, $callback_action) = @_;

    my ($urpm, $pkgs, $descriptions) = $pkgs_provider->();

    my ($options, $size_selected, $compssUsers, $info, $info_update, $tree, $disable_treeselect_callback, %elems);
    my (undef, $size_free) = MDK::Common::System::df('/usr');

    my $formatlistpkg = sub { myformatList(sort { uc($a) cmp uc($b) } @_) };
    my $is_locale_available = sub {
	grep { $urpm->{depslist}[$_[0]]->flag_selected } keys %{$urpm->{provides}{$_[0]} || {}} and return 1;
	my $found;
	db->traverse_tag('name', [ $_ ], sub { $found ||= 1 });
	return $found;
    };
    my $callback_choices = sub {
	my ($urpm, $db, $state, $choices) = @_;
	foreach my $pkg (@$choices) {
	    foreach ($pkg->requires_nosense) {
		/locales-/ or next;
		$is_locale_available->($_) and return $pkg;
	    }
	}
	my $callback = sub {
	    interactive_msg(_("More information on package..."), $options->{get_info}->($_[0]), scroll => 1);
	};
	$choices->[interactive_list(_("Please choose"), _("One of the following packages is needed:"),
				    [ map { my_fullname($_) } @$choices ], $callback)];
    };
    my $choices_auto;
    my $callback_choices_auto = sub {
	my ($urpm, $db, $state, $choices) = @_;
	member(my_fullname($_), @$choices_auto) and return $_ foreach @$choices;
	return $choices->[0];  #- theoretically unreachable, but at least try to fallback on something usable
    };
    my $closure_removal = sub {
	$urpm->{state}{ask_remove} = {};
	my $db = db;
	foreach (@_) {
	    $db->traverse_tag('name', [ (split_fullname($_))[0] ], sub {
				  my_fullname($_[0]) eq $_ or return;
				  $urpm->resolve_closure_ask_remove($db, $urpm->{state}, $_[0], undef);
			      }) or die _("unknown package ") . "$_\n";
	}
	keys %{$urpm->{state}{ask_remove}};
    };
    $options = {
		   node_state => sub { $_[0] ? ($pkgs->{$_[0]}{selected} ? 'selected' : 'unselected')
					     : 'XXX' },  #- checks $_[0] -> hack for partial tree displaying
		   build_tree => sub {
		       my ($add_node, $flat, $mode) = @_;
		       my @elems;
		       my $w = wait_msg(_("Please wait, listing packages..."));
		       $disable_treeselect_callback = 1;
		       if ($mode eq 'mandrake_choices') {
			   foreach my $pkg (keys %$pkgs) {
			       my ($name) = split_fullname($pkg);
			       push @elems, [ $pkg, $_ ] foreach @{$compssUsers->{$name}};
			   }
		       } else {
			   my @keys = keys %$pkgs;
			   if ($MODE eq 'update') {
			       member('normal', @$mandrakeupdate_wanted_categories)
				 or @keys = grep { my ($name) = split_fullname($_);
						   member($descriptions->{$name}{importance}, @$mandrakeupdate_wanted_categories) } @keys;
			       if (@keys == 0) {
				   $add_node->('', _("(none)"), { nochild => 1 });
				   my $explanation_only_once if 0;
				   $explanation_only_once or interactive_msg(_("No update"),
_("The list of updates is void. This means that either there is
no available update for the packages installed on your computer,
or you already installed all of them."));
				   $explanation_only_once = 1;
			       }
			   }
			   @elems = map { [ $_, !$flat && ctreefy($pkgs->{$_}{pkg}->group) ] } @keys;
		       }
		       my %sortmethods = (by_size => sub { sort { $pkgs->{$b->[0]}{pkg}->size <=> $pkgs->{$a->[0]}{pkg}->size } @_ },
					  by_selection => sub { sort { $pkgs->{$b->[0]}{selected} <=> $pkgs->{$a->[0]}{selected}
								       || uc($a->[0]) cmp uc($b->[0]) } @_ },
					  flat => sub { sort { uc($a->[0]) cmp uc($b->[0]) } @_ });
		       if ($flat) {
			   $add_node->($_->[0], '') foreach $sortmethods{$mode || 'flat'}->(@elems);
		       } else {
			   if ($mode eq 'by_source') {
			       $add_node->($_->[0], pkg2medium($pkgs->{$_->[0]}{pkg}, $urpm)->{name}) foreach $sortmethods{flat}->(@elems);
			   } elsif ($mode eq 'by_presence') {
			       $add_node->($_->[0], $pkgs->{$_->[0]}{pkg}->flag_installed ? _("Upgradable") : _("Addable"))
				 foreach $sortmethods{flat}->(@elems);
			   } else {
			       #- special case, we don't populate all the tree at first (to speed things up)
			       %elems = ();
			       foreach my $root (sort { $a cmp $b } uniq(map { ($_->[1] =~ /([^\|]+)\|?.*/)[0] } @elems)) {
				   $add_node->('', $root);
				   @{$elems{$root}} = sort { $a->[1] cmp $b->[1] || uc($a->[0]) cmp uc($b->[0]) }
				                      grep { $_->[1] =~ /^\Q$root|\E?/ } @elems;
			       }
			   }
		       }
		       $disable_treeselect_callback = 0;
		       remove_wait_msg($w);
		   },
		   grep_unselected => sub { grep { exists $pkgs->{$_} && !$pkgs->{$_}{selected} } @_ },
		   toggle_nodes => sub {
		       my ($set_state, @nodes) = @_;
		       @nodes = grep { exists $pkgs->{$_} } @nodes;
		       int(@nodes) or return;
		       my $new_state = !$pkgs->{$nodes[0]}{selected};

		       my @nodes_with_deps;
		       my $deps_msg = sub {
			   my ($title, $msg, $nodes, $nodes_with_deps) = @_;
			   @$nodes_with_deps > @$nodes or return 1;
			   interactive_msg($title, $msg . $formatlistpkg->(sort { $a cmp $b } difference2($nodes_with_deps, $nodes)),
					   yesno => 1, text => { yes => _("Ok"), no => _("Cancel") });
		       };
		       if ($MODE eq 'remove') {
			   if ($new_state) {
			       slow_func($tree->window, sub { $closure_removal->(@nodes) });
			       @nodes_with_deps = grep { !$pkgs->{$_}{selected} } keys %{$urpm->{state}{ask_remove}};
			       $deps_msg->(_("Some additional packages need to be removed"),
					   _("Because of their dependencies, the following package(s) also need to be\nremoved:\n\n"),
					   \@nodes, \@nodes_with_deps) or @nodes_with_deps = ();
			   } else {
			       slow_func($tree->window,
					 sub { @nodes_with_deps = grep { intersection(\@nodes, [ $closure_removal->($_) ]) }
						                  grep { $pkgs->{$_}{selected} } keys %$pkgs });
			       $deps_msg->(_("Some packages can't be removed"),
					   _("Because of their dependencies, the following package(s) must be\nunselected now:\n\n"),
					   \@nodes, \@nodes_with_deps) or @nodes_with_deps = ();
			   }
		       } else {
			   if ($new_state) {
			       $urpm->{state}{selected} = {};
			       if (@nodes > 1) {
				   #- unselect i18n packages of which locales is not already present (happens when user clicks on KDE group)
				   my @bad_i18n_pkgs;
				   foreach my $sel (@nodes) {
				       foreach ($pkgs->{$sel}{pkg}->requires_nosense) {
					   /locales-([^-]+)/ or next;
					   $sel =~ /-$1[-_]/ && !$is_locale_available->($_) and push @bad_i18n_pkgs, $sel;
				       }
				   }
				   @nodes = difference2(\@nodes, \@bad_i18n_pkgs);
			       }
			       slow_func($tree->window,
					 sub { $urpm->resolve_requested(db, $urpm->{state}, { map { $pkgs->{$_}{pkg}->id => 1 } @nodes },
							   callback_choices => $callback_choices, no_flag_update => 1, keep_state => 1) });
			       my $pkg_sel_after_selection = sub {
				   $urpm->deselect_unwanted_packages($urpm->{state}{selected});
				   if (%{$urpm->{state}{ask_unselect} || {}}) {
				       delete @{$urpm->{state}{selected}}{keys %{delete $urpm->{state}{ask_unselect}}};
				   }
				   @nodes_with_deps = map { my_fullname($urpm->{depslist}[$_]) } keys %{$urpm->{state}{selected}};
			       };
			       $pkg_sel_after_selection->();
			       if (!$deps_msg->(_("Additional packages needed"), 
						_("To satisfy dependencies, the following package(s) also need\nto be installed:\n\n"),
						\@nodes, \@nodes_with_deps)) {
				   @nodes_with_deps = ();
				   goto packages_selection_ok;
			       }

			       $choices_auto = \@nodes_with_deps;
			       $urpm->{state}{selected} = {};
			       slow_func($tree->window,
					 sub { $urpm->resolve_requested(db, $urpm->{state}, { map { $pkgs->{$_}{pkg}->id => 1 } @nodes },
									callback_choices => $callback_choices_auto) });
			       $pkg_sel_after_selection->();
			       if (my @cant = difference2(\@nodes, \@nodes_with_deps)) {
				   interactive_msg(_("Some packages can't be installed"),
						   _("Sorry, the following package(s) can't be selected:\n\n") . $formatlistpkg->(@cant));
				   foreach (@cant) {
				       $pkgs->{$_}{pkg}->set_flag_requested(0);
				       $pkgs->{$_}{pkg}->set_flag_required(0);
				   }
			       }
			     packages_selection_ok:
			   } else {
			       $urpm->{state}{unselected} = {};
			       slow_func($tree->window,
					 sub { $urpm->resolve_unrequested(db, $urpm->{state},
									  { map { $pkgs->{$_}{pkg}->id => undef } @nodes },
									  no_flag_update => 1) });
			       @nodes_with_deps = map { my_fullname($urpm->{depslist}[$_]) } keys %{$urpm->{state}{unselected}};
			       if (!$deps_msg->(_("Some packages need to be removed"),
						_("Because of their dependencies, the following package(s) must be\nunselected now:\n\n"),
						\@nodes, \@nodes_with_deps)) {
				   @nodes_with_deps = ();
				   goto packages_unselection_ok;
			       }
			       slow_func($tree->window,
					 sub { $urpm->resolve_unrequested(db, $urpm->{state},
									  { map { $pkgs->{$_}{pkg}->id => undef } @nodes }) });
			       @nodes_with_deps = map { my_fullname($urpm->{depslist}[$_]) } keys %{$urpm->{state}{unselected}};
			     packages_unselection_ok:
			   }
		       }

		       foreach (@nodes_with_deps) {
			   exists $pkgs->{$_} or next;  #- some deps may exist on some packages which aren't listed because
			                                #- not upgradable (older than what currently installed)
			   $set_state->($_, $new_state ? 'selected' : 'unselected');
			   $pkgs->{$_}{selected} = $new_state;
			   $size_selected += $pkgs->{$_}{pkg}->size * ($new_state ? 1 : -1);
		       }
		   },
		   get_status => sub { $MODE eq 'install' ? _("Selected: %d MB / Free disk space: %d MB",
							      $size_selected/(1024*1024), $size_free/1024)
					                  : _("Selected size: %d MB", $size_selected/(1024*1024)) },
		   get_info => sub { my ($key) = @_;
				     exists $pkgs->{$key} or return;  #- related to the partial tree displaying hackery ($key can be '')
				     my ($name, $version) = split_fullname($key);
				     exists $pkgs->{$key}{description} && (!@$max_info_in_descr || exists $pkgs->{$key}{files})
				       or slow_func($tree->window, sub { extract_header($pkgs->{$key}, $urpm) });
				     my $max_info = if_(@$max_info_in_descr, _("%sFiles:\n%s\n\nChangelog:\n%s",
					   $MODE eq 'remove' ? '' : _("Source: %s\n", pkg2medium($pkgs->{$key}{pkg}, $urpm)->{name}),
					   $pkgs->{$key}{files} || _("(Non available)"),
					   $pkgs->{$key}{changelog} || _("(Non available)")));
				     if ($MODE eq 'update') {
					 gtktext_insert($info_update, beautify_description($descriptions->{$name}{pre}));
					 _("Name: %s\nVersion: %s\nSize: %s KB\nImportance: %s\n\nSummary: %s\n\n%s\n",
					   $name, $version, int($pkgs->{$key}{pkg}->size/1024), $descriptions->{$name}{importance},
					   $pkgs->{$key}{summary}, beautify_description($descriptions->{$name}{description})) . $max_info
				     } else {
					 _("Name: %s\nVersion: %s\nSize: %s KB\n\nSummary: %s\n\n%s\n",
					   $name, $version, int($pkgs->{$key}{pkg}->size/1024),
					   $pkgs->{$key}{summary}, $pkgs->{$key}{description}) . $max_info
				     }
				 },
		   check_interactive_to_toggle => sub { 1 },
		   grep_allowed_to_toggle => sub { @_ },
		   rebuild_tree => sub {},
		  };

    $::noBorder = 1;
    my $w = my_gtk->new('rpmdrake');
    $::noBorder = 0;
    $tree = Gtk::CTree->new(3, 0);
    $tree->set_selection_mode('browse');
    $tree->set_column_auto_resize($_, 1) foreach 0..2;
    $typical_width = $tree->get_style->font->string_width(translate("Graphical Environment")."xmms-more-vis-plugins");
    $typical_width > 500 and $typical_width = 500;  #- try to not being crazy with a too large value
    $typical_width < 150 and $typical_width = 150;
    $tree->set_column_max_width(0, $typical_width);
    $tree->signal_connect(tree_expand => sub { 
			      #- hackish: if first child has '' as name, then we need to expand on the fly
			      if (($_[0]->node_get_pixtext($_[1]->row->children, 0))[0] eq '') {
				  $_[0]->remove_node($_[1]->row->children);
				  my $row_name = ($_[0]->node_get_pixtext($_[1], 0))[0];
				  slow_func($tree->window, sub { $options->{add_nodes}->(@{$elems{$row_name}}) });
			      }
			  });

    my @modes_buttons;
    if ($MODE eq 'update') {
	$options->{state}{flat} = 1;
	my %toggle_infos = (security => _("Security updates"), bugfix => _("Bugfixes updates"), normal => _("Normal updates"));
	my @toggle_names_ordered = qw(security bugfix normal);
	@modes_buttons = map { new Gtk::CheckButton(but($toggle_infos{$_})) } @toggle_names_ordered;
	mapn {
	    member($_[0], @$mandrakeupdate_wanted_categories) and $_[1]->set_active(1);
	    my $capture_value = $_[0];
	    $_[1]->signal_connect(clicked => sub {
				      $disable_treeselect_callback = 1;
				      if ($_[0]->get_active) {
					  push @$mandrakeupdate_wanted_categories, $capture_value;
				      } else {
					  @$mandrakeupdate_wanted_categories = difference2($mandrakeupdate_wanted_categories,
											   [ $capture_value ]);
				      }
				      $options->{rebuild_tree}->();
				      $disable_treeselect_callback = 0;
				  });
	} \@toggle_names_ordered, \@modes_buttons;
    } else {
	my %radios_infos = (mandrake_choices => { name => _("Mandrake choices"),           flat => 0 },
			    flat             => { name => _("All packages, alphabetical"), flat => 1 },
	                    by               => { name => _("All packages,"),              flat => 0 });
	$compssUsers = parse_compssUsers_flat($urpm);
	my @radios_names_ordered = qw(mandrake_choices flat by);
	$compssUsers or shift @radios_names_ordered;
	@modes_buttons = gtkradio($radios_infos{mandrake_choices}{name}, map { $radios_infos{$_}{name} } @radios_names_ordered);

	mapn {
	    my $capture_mode = $_[0];
	    $_[1]->signal_connect(clicked => sub {
				      if ($_[0]->get_active) {
					  $disable_treeselect_callback = 1;
					  ($options->{tree_mode}, $options->{state}{flat}) = $capture_mode eq 'by'
					        ? ($options->{tree_submode}, $options->{tree_subflat})
					        : ($capture_mode,            $radios_infos{$capture_mode}{flat});
					  $options->{rebuild_tree}->();
					  $disable_treeselect_callback = 0;
				      }
				  });
	} \@radios_names_ordered, \@modes_buttons;
	$options->{tree_mode} = $radios_names_ordered[0];

	my $advanced_menu = new Gtk::Menu;
	my $radio_by;
	my @advanced_modes = ([ 'by_group', _("by group"), 0 ], [ 'by_size', _("by size"), 1 ],
			      [ 'by_selection', _("by selection state"), 1 ]);
	$MODE eq 'install' and push @advanced_modes, ([ 'by_source', _("by source repository"), 0 ], [ 'by_presence', _("by update availability"), 0 ]);
	foreach (@advanced_modes) {
	    my ($capt_mode, $capt_flat) = ($_->[0], $_->[2]);
	    $advanced_menu->append(gtksignal_connect(gtkshow(new_with_label Gtk::MenuItem($_->[1])),
						     activate => sub {
							 $options->{tree_submode} = $capt_mode;
							 $options->{tree_subflat} = $capt_flat;
							 $radio_by->activate;
						     }));
	}
	$options->{tree_submode} = $advanced_modes[0]->[0];
	each_index {
	    if ($_ eq 'by') {
		$radio_by = $modes_buttons[$::i];
		$modes_buttons[$::i] = gtkpack(new Gtk::HBox(0, 0), $modes_buttons[$::i], my $t = new Gtk::OptionMenu);
		$t->set_menu($advanced_menu);
	    }
	} @radios_names_ordered;
    }

    my $search_types_menu = new Gtk::Menu;
    my @search_types = ([ 'normal', _("in names") ], [ 'descriptions', _("in descriptions") ]);
    $MODE ne 'remove' and push @search_types, [ 'files', _("in files") ];
    my $current_search_type = $search_types[0]->[0];
    foreach (@search_types) {
	my $capt_type = $_->[0];
	$search_types_menu->append(gtksignal_connect(gtkshow(new_with_label Gtk::MenuItem($_->[1])),
						     activate => sub { $current_search_type = $capt_type }));
    }
    my $search_types_optionmenu = new Gtk::OptionMenu;
    $search_types_optionmenu->set_menu($search_types_menu);

    my $menu_descr = new Gtk::Menu;
    my @menu_descr_modes = ([ 'normal', _("Normal information"), [] ], [ 'max', _("Maximum information"), [1] ]);
    foreach (@menu_descr_modes) {
	my ($mode, $text, $val) = @$_;
	$menu_descr->append(gtksignal_connect(gtkshow(new_with_label Gtk::MenuItem($text)),
					      activate => sub {
						  $max_info_in_descr = $val;
						  $options->{display_info}->();
					      }));
    }
    $info = new Gtk::Text;
    $info->signal_connect(button_press_event => sub { $_[1]->{button} eq 3 or return 0;
						      $menu_descr->popup(undef, undef, $_[1]->{button}, $_[1]->{time});
						      return 1; });

    my $find_entry;
    my $find_callback = sub { do_search($find_entry, $tree, $options, $current_search_type, $urpm, $pkgs) };

    my $do_action = sub {
	int(grep { $pkgs->{$_}{selected} } keys %$pkgs) or return;
	if ($MODE ne 'remove' && %{$urpm->{state}{ask_remove} || {}}) {
	    interactive_msg(_("Some packages need to be removed"),
_("The following packages have to be removed for others to be upgraded:

%s

Is it ok to continue?", $formatlistpkg->(sort { $a cmp $b } keys %{$urpm->{state}{ask_remove}})), yesno => 1)
	      or return;
	}
	$callback_action->($urpm, $pkgs);
	($urpm, $pkgs, $descriptions) = $pkgs_provider->({ skip_updating_mu => 1 });
	$size_selected = 0;
	(undef, $size_free) = MDK::Common::System::df('/usr');
	$options->{rebuild_tree}->();
    };

    my $darea;
    gtkadd($w->{window}, 
	   gtkpack_(new Gtk::VBox(0, 3),
		    0, gtkset_usize($darea = new Gtk::DrawingArea, 0, 40),
		    1, gtkadd(gtkset_shadow_type(gtkset_border_width(new Gtk::Frame, 3), 'none'),
			      gtkpack_(new Gtk::VBox(0, 3),
				       0, gtkpack__(new Gtk::HBox(0, 10),
						    new Gtk::Label(_("Find:")),
						    $search_types_optionmenu,
						    gtksignal_connect($find_entry = new Gtk::Entry,
								      key_press_event => sub { $_[1]->{keyval} == 0xff0d
												 and $find_callback->() }),
						    gtksignal_connect(new Gtk::Button(but(_("Search"))), clicked => \&$find_callback)),
				       0, gtkpack__(new Gtk::HBox(0, 0), gtkpack(new Gtk::VBox(0, 0), @modes_buttons)),
				       1, gtkpack(new Gtk::HBox(0, 0),
						  createScrolledWindow($tree),
						  $MODE eq 'update' ? gtkpack(new Gtk::VBox(0, 0),
									      createScrolledWindow($info),
									      createScrolledWindow($info_update = new Gtk::Text))
						                    : createScrolledWindow($info)),
				       0, gtkpack(new Gtk::HBox(1, 20),
						  my $status = new Gtk::Label,
						  gtkpack(new Gtk::HBox(1, 20),
							  gtksignal_connect(new Gtk::Button(but($MODE eq 'remove' ? _("Remove")
												                  : _("Install"))),
									    clicked => sub { $do_action->() }),
							  gtksignal_connect(new Gtk::Button(but(_("Quit"))),
									    clicked => sub { Gtk->main_quit })))
				       ))));
    my ($pixmap_back) = gtkcreate_png('title-backpart');
    $darea->signal_connect(expose_event => sub {
		       my (undef, undef, $dx, $dy) = @{$darea->allocation};
		       my $dbl_area = new Gtk::Gdk::Pixmap($darea->window, $dx, $dy);
		       fill_tiled($darea, $dbl_area, $pixmap_back, 110, 55, $dx, $dy);
		       my $style = $darea->style->copy();
		       $style->font(Gtk::Gdk::Font->fontset_load(_("-adobe-times-bold-r-normal--25-*-100-100-p-*-iso8859-*,*-r-*")));
		       my %t = (remove => _("Software Packages Removal"), update => _("Mandrake Update"),
				install => _("Software Packages Installation"));
		       $dbl_area->draw_string($style->font, $darea->style->white_gc,
					      ($dx-$style->font->string_width($t{$MODE}))/2, 30, $t{$MODE});
		       $darea->window->draw_pixmap($darea->style->white_gc, $dbl_area, 0, 0, 0, 0, $dx, $dy);
		       0;
		   });

    $w->{window}->set_usize($typical_width*2.7, 500);
    $w->{rwindow}->show_all;
    my $widgets = { w => $w, tree => $tree, info => $info, status => $status};

    ask_browse_tree_info_given_widgets($options, $widgets);
}


# -=-=-=---=-=-=---=-=-=-- install packages -=-=-=---=-=-=---=-=-=-

sub get_installable_pkgs {
    my ($updates, $opts) = @_;
    my $update_name = 'update_source';
    my %update_descr;
    my @update_medias;

    if ($updates) {
	my $urpm = new urpm;
	$urpm->configure();
	my ($statedir, $cachedir) = map { $urpm->{$_} } qw (statedir cachedir);
	@update_medias = grep { !$_->{ignore} && $_->{update} } @{$urpm->{media}};
	undef $urpm;
	if (@update_medias > 0) {
	    if (!$opts->{skip_updating_mu}) {
		$options{noconfirmation} or interactive_msg('rpmdrake',
_("I need to contact the mirror to get latest update packages.
Please check that your network is currently running.

Is it ok to continue?"), yesno => 1) or myexit -1;
		my $w = wait_msg(_("Please wait, contacting mirror to update packages information."));
		system('/usr/sbin/urpmi.update', map { $_->{name} } @update_medias) == 0
		  or fatal_msg(_("Error updating medium"),
			       _("There was an unrecoverable error while updating packages information."));
		remove_wait_msg($w);
	    }
	} else {
	  mu_retry_another_mirror:
	    my $m = choose_mirror;
	    $m or interactive_msg(_("How to choose manually your mirror"),
_("You may also choose your desired mirror manually: to do so,
launch the Software Sources Manager, and then add a `Security
updates' source.

Then, restart MandrakeUpdate.", $update_name)), myexit -1;
	    my ($r) = cat_('/etc/mandrake-release') =~ /release\s(\S+)/;
	    my $w = wait_msg(_("Please wait, contacting mirror to initialize updates packages."));
	    my $retval = system("/usr/sbin/urpmi.addmedia --update $update_name $m/$r/RPMS/ with ../base/hdlist.cz");
	    remove_wait_msg($w);
	    if ($retval != 0) {
		interactive_msg(_("Error adding update medium"),
_("There was an error while adding the update medium via urpmi.

This may be due to a broken or temporary unavailable mirror, or when your
Mandrake Linux version (%s) is not yet / no more supported by Mandrake Linux
Official Updates.

Do you want to try another mirror?", $r), yesno => 1) and goto mu_retry_another_mirror;
		myexit -1;
	    }
	}

	my ($cur, $section);
	foreach (map { cat_("$statedir/descriptions.$_->{name}"), '%package dummy' } @update_medias) {
	    /^%package (.+)/ and do {
		$update_descr{$_} = $cur foreach @{$cur->{pkgs}};
		$cur = {};
		$cur->{pkgs} = [ split /\s/, $1 ];
		$section = 'pkg';
		next;
	    };
	    /^Update: (.+)/ && $section eq 'pkg' and $cur->{update} = $1;
	    /^Importance: (.+)/ && $section eq 'pkg' and $cur->{importance} = $1;
	    /^%pre/ and do { $section = 'pre'; next; };
	    /^%description/ and do { $section = 'description'; next; };
	    $section eq 'pre' and $cur->{pre} .= $_;
	    $section eq 'description' and $cur->{description} .= $_;
	}
    }

    my $w = wait_msg(_("Please wait, finding available packages..."));
    my $urpm = new urpm;
    my %installable_pkgs;

    $urpm->configure;
    @update_medias = grep { !$_->{ignore} && $_->{update} } @{$urpm->{media}};

    $urpm->compute_installed_flags(db);

    foreach my $pkg (@{$urpm->{depslist}}) {
	$pkg->flag_upgrade or next;
	$updates and ($pkg->flag_installed && grep { $pkg->id >= $_->{start} && $pkg->id <= $_->{end} } @update_medias or next);
	$installable_pkgs{my_fullname($pkg)} = { selected => 0, pkg => $pkg };
    }

    remove_wait_msg($w);
    ($urpm, \%installable_pkgs, \%update_descr);
}

sub dialog_rpmnew {
    my ($exitstatus, %p2r) = @_;
    my $sum_rpmnew = sum(map { int @{$p2r{$_}} } keys %p2r);
    if ($exitstatus == 0 && $sum_rpmnew == 0) {
	interactive_msg(_("Everything installed successfully"), _("All requested packages were installed successfully."));
	return;
    }
    my $d = my_gtk->new(_("Installation finished"));
    my $inspect = sub {
	my ($file) = @_;
	my $d = my_gtk->new(_("Inspecting %s", $file));
	my ($rpmnew, $rpmsave) = ("$file.rpmnew", "$file.rpmsave");
	my $rpmfile = 'rpmnew';
	-r $rpmnew or $rpmfile = 'rpmsave';
	-r $rpmnew && -r $rpmsave && (stat $rpmsave)[9] > (stat $rpmnew)[9] and $rpmfile = 'rpmsave';
	$rpmfile eq 'rpmsave' and $rpmnew = $rpmsave;
	my %texts;
	gtkadd($d->{window},
	       gtkpack_(gtkset_usize(new Gtk::VBox(0, 5), $typical_width*2.5, 500),
			0, new Gtk::Label("$file:"),
			1, createScrolledWindow($texts{file} = new Gtk::Text),
			0, new Gtk::Label("$rpmnew:"),
			1, createScrolledWindow($texts{rpmnew} = new Gtk::Text),
			0, new Gtk::Label("changes:"),
			1, createScrolledWindow($texts{diff} = new Gtk::Text),
			0, gtkpack__(create_hbox(),
				     gtksignal_connect(new Gtk::Button(_("Remove .%s", $rpmfile)),
						       clicked => sub { unlink $rpmnew; Gtk->main_quit }),
				     gtksignal_connect(new Gtk::Button(_("Use .%s as main file", $rpmfile)),
						       clicked => sub { renamef($rpmnew, $file); Gtk->main_quit }),
				     gtksignal_connect(new Gtk::Button(_("Do nothing")),
						       clicked => sub { Gtk->main_quit }),
				    )));
	my $fixedfont = Gtk::Gdk::Font->fontset_load(_("-misc-fixed-medium-r-normal--12-*-*-100--*-*-*-*-*,*"));
	my %contents = (file => scalar(cat_($file)), rpmnew => scalar(cat_($rpmnew)), diff => join('', `diff -u $file $rpmnew`));
	$texts{$_}->insert($fixedfont, undef, undef, $contents{$_}) foreach keys %contents;
	$d->main;
    };
    my $packtable = create_packtable({},
				     map { my $pkg = $_;
					   map {
					       my $f = $_;
					       my $b = new Gtk::Button(but(_("Inspect...")));
					       [ gtkpack__(new Gtk::HBox(0, 0),
							   new Gtk::Label("$pkg:$f")),
						 gtksignal_connect($b,
								   clicked => sub {
								       $inspect->($f);
								       -r "$f.rpmnew" || -r "$f.rpmsave"
									 or $b->set_sensitive(0)
								     }) ]
					   } @{$p2r{$pkg}}
				       } keys %p2r);
    gtkadd($d->{window},
	   gtkpack__(new Gtk::VBox(0,5),
		     new Gtk::Label(_("The installation is finished; %s.\n\nSome configuration files were created as `.rpmnew' or `.rpmsave',\nyou may now inspect some in order to take actions:",
				      $exitstatus ? _("some packages failed to install\ncorrectly")
				      : _("everything was installed correctly"))),
		     $sum_rpmnew < 6 ? $packtable
		                     : gtkset_usize(createScrolledWindow($packtable), $typical_width*1.7, min(70 + $sum_rpmnew*20, 450)),
		     gtkpack__(create_hbox(), gtksignal_connect(new Gtk::Button(_("Ok")), clicked => sub { Gtk->main_quit }))));
    $d->main;
}

sub perform_installation {  #- (partially) duplicated from /usr/sbin/urpmi :-(
    my ($urpm) = @_;

    standalone::explanations("Removing package $_") foreach keys %{$urpm->{state}{ask_remove}};

    my %pkgs;
    @pkgs{ map { $_->id } grep { $_->flag_selected } @{$urpm->{depslist}} } = undef;
    my ($local_sources, $list, $local_to_removes) = $urpm->get_source_packages(\%pkgs);
    foreach my $l (@$list) {
	standalone::explanations("Installing package $_") foreach sort values %$l;
    }
    if (!$local_sources && !$list) {
	fatal_msg(_("Unable to get source packages."),
		  _("Unable to get source packages, sorry."));
    }
    foreach (@$local_to_removes) {
	unlink $_;
    }

    my %sources = $urpm->download_source_packages($local_sources, $list, '',
						  sub { interactive_msg(_("Change medium"),
									_("Please insert the medium named \"%s\" on device [%s]", @_),
									yesno => 1, text => { yes => _("Ok"), no => _("Cancel") }) });
    my @rpms_install = grep { $_ !~ /\.src\.rpm$/ } values %{$urpm->extract_packages_to_install(\%sources) || {}};
    my @rpms_upgrade = grep { $_ !~ /\.src\.rpm$/ } values %sources;

    if (@rpms_install || @rpms_upgrade) {
	foreach (@rpms_install, @rpms_upgrade) {
	    m|^/| && ! -e $_ or next;
	    interactive_msg(_("Installation failed"),
			    _("Installation failed, some files are missing.\nYou may want to update your sources database."));
	    return;
	}
	%{$urpm->{state}{ask_remove}} and slow_func(_("Please wait, removing packages to allow others to be upgraded..."),
						    sub { system('rpm', '-e', '--nodeps', keys %{$urpm->{state}{ask_remove}}) });
	if (my $pid = fork()) {
	    while (!waitpid($pid, c::WNOHANG())) {
		select(undef, undef, undef, 0.1);
		my_gtk::flush;
	    }
	} else {
	    exec('grpmi', (map { ("-noupgrade", $_) } @rpms_install), @rpms_upgrade);
	    fatal_msg(_("Program missing"),
		      _("A required program is missing (grpmi). Check your installation."));
	    myexit -1;
	}
	my $exitstatus = $?;
	# /var/lib/nfs/etab /var/lib/nfs/rmtab /var/lib/nfs/xtab /var/cache/man/whatis
	my @ignores_rpmnew = qw(/etc/group /etc/passwd /etc/localtime /etc/shells /etc/adjtime /etc/ld.so.conf /etc/modules 
                        /etc/security/fileshare.conf /etc/sudoers /etc/sysconfig/alsa /etc/sysconfig/autofsck /etc/sysconfig/harddisks
                        /etc/sysconfig/installkernel /etc/sysconfig/msec /etc/sysconfig/nfs /etc/sysconfig/pcmcia /etc/sysconfig/init
                        /etc/sysconfig/rawdevices /etc/sysconfig/saslauthd /etc/sysconfig/syslog /etc/sysconfig/usb /etc/sysconfig/xinetd);

	my %pkg2rpmnew;
	foreach my $u (@rpms_upgrade) {
	    $u =~ m|/([^/]+-[^-]+-[^-]+)\.[^\./]+\.rpm$|
	      and $pkg2rpmnew{$1} = [ grep { m|^/etc| && (-r "$_.rpmnew" || -r "$_.rpmsave") && !member($_, @ignores_rpmnew) }
				      map { chomp_($_) } `rpm -ql $1` ];
	}
	dialog_rpmnew($exitstatus, %pkg2rpmnew);
    } else {
	interactive_msg(_("Everything already installed."),
			_("Everything already installed (is this supposed to happen at all?)."));
    }
}


# -=-=-=---=-=-=---=-=-=-- remove packages -=-=-=---=-=-=---=-=-=-

sub get_installed_pkgs {
    use URPM;

    my $w = wait_msg(_("Please wait, reading packages database..."));
    my @base = qw(basesystem);
    my (%base, %basepackages);
    my $db = db;
    my $sig_handler = sub { undef $db; exit 3 };
    local $SIG{INT} = $sig_handler;
    local $SIG{QUIT} = $sig_handler;
    while (defined($_ = shift @base)) {
	exists $basepackages{$_} and next;
	$db->traverse_tag(/^\// ? 'path' : 'whatprovides', [ $_ ], sub {
			      push @{$basepackages{$_}}, my_fullname($_[0]);
			      push @base, $_[0]->requires_nosense;
			  });
    }
    foreach (values %basepackages) {
	my $n = @$_;
	foreach (@$_) {
	    $base{$_} = \$n;
	}
    }
    my %installed_pkgs;
    $db->traverse(sub {
		      my ($pkg) = @_;
		      my $fullname = my_fullname($pkg);
		      $base{$fullname} && ${$base{$fullname}}
			#- I need to extract summary and description since they'll be lost when $pkg->pack_header
			or $installed_pkgs{$fullname} = { selected => 0, pkg => $pkg, summary => $pkg->summary,
							  description => beautify_description($pkg->description) };
		      $pkg->pack_header;
		  });
    remove_wait_msg($w);
    (new urpm, \%installed_pkgs);
}

sub perform_removal {
    my ($urpm, $pkgs) = @_;
    my @toremove = grep { $pkgs->{$_}{selected} } keys %$pkgs;
    standalone::explanations("Removing package $_") foreach sort @toremove;
    slow_func(_("Please wait, removing packages..."),
	      sub { $urpm->install(\@toremove, {}, {}) });
}


# -=-=-=---=-=-=---=-=-=-- main -=-=-=---=-=-=---=-=-=-

readconf;

if (!member($MODE, @$already_splashed)) {
    interactive_msg('rpmdrake',
_("%s

Is it ok to continue?",
        $MODE eq 'remove' ?
  _("Welcome to the software removal tool!

This tool will help you choose which software you want to remove from
your computer.")
      : $MODE eq 'update' ?
  _("Welcome to MandrakeUpdate!

This tool will help you choose the updates you want to install on your
computer.")
      :
  _("Welcome to the software installation tool!

Your Mandrake Linux system comes with several thousands of software
packages on CDROM or DVD. This tool will help you choose which software
you want to install on your computer."))
  , yesno => 1) or myexit -1;
	push @$already_splashed, $MODE;
    }

if ($MODE eq 'remove') {
    run_treeview_dialog(sub { get_installed_pkgs }, \&perform_removal);
} elsif ($MODE eq 'update') {
    run_treeview_dialog(sub { get_installable_pkgs(1, @_) }, \&perform_installation);
} else {
    run_treeview_dialog(sub { get_installable_pkgs }, \&perform_installation);
}

writeconf;

myexit 0;