diff options
-rwxr-xr-x | rpmdrake | 378 |
1 files changed, 168 insertions, 210 deletions
@@ -30,7 +30,6 @@ use common; use POSIX qw(_exit); use URPM; use utf8; -BEGIN { $::no_global_argv_parsing = 1 } use standalone; BEGIN { #- we want to run this code before the Gtk->init of the use-my_gtk @@ -109,7 +108,7 @@ $default_list_mode = 'all' if $MODE eq 'install'; if ($MODE eq 'remove') { $default_list_mode = 'installed'; } elsif ($MODE eq 'update') { - $default_list_mode = 'all_updates'; + $default_list_mode = 'security'; } eval { @@ -122,7 +121,7 @@ eval { }; if ($@) { print "This program cannot be run in console mode.\n"; - POSIX::_exit(0); #- skip ugtk2::END + _exit(0); #- skip ugtk2::END } $MODE eq 'update' || $options{root} and require_root_capability(); @@ -133,16 +132,15 @@ $::noborderWhenEmbedded = 1; package gurpm; ugtk2->import(':all'); -mygtk2->import(qw(gtknew)); our ($mainw, $label, $progressbar, $vbox, $cancel, $hbox_cancel); sub init { my ($title, $initializing, %options) = @_; $mainw = ugtk2->new($title, %options); - $label = gtknew('Label', text => $initializing); - $progressbar = gtknew('ProgressBar', width => 300); - gtkadd($mainw->{window}, $vbox = gtknew('VBox', spacing => 5, border_width => 6, children_tight => [ $label, $progressbar ])); + $label = Gtk2::Label->new($initializing); + $progressbar = gtkset_size_request(Gtk2::ProgressBar->new, 300, -1); + gtkadd($mainw->{window}, gtkpack__($vbox = gtkset_border_width(Gtk2::VBox->new(0, 5),6), $label, $progressbar)); $mainw->{rwindow}->set_position('center-on-parent'); $mainw->sync; } @@ -170,8 +168,8 @@ sub validate_cancel { gtkpack__( $vbox, $hbox_cancel = gtkpack__( - gtknew('HButtonBox'), - $cancel = gtknew('Button', text => $cancel_msg, clicked => \&$cancel_cb), + create_hbox(), + $cancel = gtksignal_connect(Gtk2::Button->new($cancel_msg), clicked => \&$cancel_cb), ), ); } @@ -391,6 +389,10 @@ sub rpm_description { "$t$tmp\n"; } +sub myformatList { + my $nb = 40; + join("\n", @_ <= $nb ? @_ : (@_[0..$nb-1], '...')); +} sub split_fullname { $_[0] =~ /^(.*)-([^-]+-[^-]+)$/ } sub my_fullname { @@ -460,18 +462,18 @@ sub extract_header { #- preprocess changelog for faster TextView insert reaction [ map { [ "$_\n", if_(/^\*/, { 'weight' => Gtk2::Pango->PANGO_WEIGHT_BOLD }) ] } split("\n", $_[0]) ]; }; - my $name = urpm_name($pkg->{pkg}); + my $name = my_fullname($pkg->{pkg}); if ($pkg->{pkg}->flag_installed && !$pkg->{pkg}->flag_upgrade) { add2hash($pkg, { files => [ split /\n/, chomp_(scalar(run_rpm("rpm -ql $name"))) || N("(none)") ], changelog => $chg_prepro->(scalar(run_rpm("rpm -q --changelog $name"))) }); } else { my ($p, $medium) = ($pkg->{pkg}, pkg2medium($pkg->{pkg}, $urpm)); - my $hdlist = urpm::media::any_hdlist($medium); + my $hdlist = $medium->{virtual} ? "$medium->{url}/$medium->{with_hdlist}" : "$urpm->{statedir}/$medium->{hdlist}"; $hdlist =~ s!^file:/+!!; if (-r $hdlist) { my $packer; require MDV::Packdrakeng; - eval { $packer = MDV::Packdrakeng->open(archive => $hdlist, quiet => 1) } or do { + eval { $packer = MDV::Packdrakeng->open (archive => $hdlist, quit => 1) } or do { warn "Warning, hdlist seems corrupted ($@)\n"; goto header_non_available; }; @@ -505,13 +507,13 @@ sub extract_header { } sub open_db { - my ($o_force) = @_; + my ($force) = @_; my $host; log::explanations("opening the RPM database"); if ($options{parallel} && ((undef, $host) = @{$options{parallel}})) { my $done if 0; my $dblocation = "/var/cache/urpmi/distantdb/$host"; - if (!$done || $o_force) { + if (!$done || $force) { print "syncing db from $host to $dblocation..."; mkdir_p "$dblocation/var/lib/rpm"; system "rsync -Sauz -e ssh $host:/var/lib/rpm/ $dblocation/var/lib/rpm"; @@ -529,7 +531,7 @@ my $db = open_db(); sub do_search($$$$$$$) { my ($find_entry, $tree, $tree_model, $options, $current_search_type, $urpm, $pkgs) = @_; - my $entry = $find_entry->get_text or return; + my $entry = quotemeta $find_entry->get_text or return; my $entry_rx = eval { qr/$entry/i } or return; my ($results_ok, $results_none) = (N("Search results"), N("Search results (none)")); $options->{delete_category}->($_) foreach $results_ok, $results_none; @@ -546,7 +548,7 @@ sub do_search($$$$$$$) { $w->{real_window}, sub { $db->traverse(sub { - push @search_results, map { if_($_ =~ $entry_rx, urpm_name($_[0])) } $_[0]->files; + push @search_results, map { if_($_ =~ $entry_rx, my_fullname($_[0])) } $_[0]->files; }); @search_results = grep { exists $pkgs->{$_} } uniq(@search_results); }, @@ -554,14 +556,14 @@ sub do_search($$$$$$$) { } } else { my @hdlists = map { - my $h = urpm::media::any_hdlist($_); + my $h = $_->{virtual} ? "$_->{url}/$_->{with_hdlist}" : "$urpm->{statedir}/$_->{hdlist}"; $h =~ s!^file:/+!!; if_(!$_->{ignore} && ($MODE ne 'update' || $_->{update}) && -r $h, $h); } @{$urpm->{media}}; my $total_size = sum( map { my $pack; - eval { require MDV::Packdrakeng; $pack = MDV::Packdrakeng->open(archive => $_, quiet => 1) } ? $pack->{toc_f_count} : 0; + eval { require packdrake; $pack = new packdrake($_, quiet => 1) } ? $pack->{toc_f_count} : 0; } @hdlists ); my $searchstop; @@ -569,11 +571,11 @@ sub do_search($$$$$$$) { gtkadd( $searchw->{window}, gtkpack__( - gtknew('VBox', spacing => 5), - gtknew('Label', text => N("Please wait, searching...")), - my $searchprogress = gtknew('ProgressBar', width => 300), + Gtk2::VBox->new(0, 5), + Gtk2::Label->new(N("Please wait, searching...")), + my $searchprogress = gtkset_size_request(Gtk2::ProgressBar->new, 300, -1), gtkpack__( - gtknew('HButtonBox', layout => 'spread'), + gtkset_layout(Gtk2::HButtonBox->new, 'spread'), gtksignal_connect( Gtk2::Button->new(but(N("Stop"))), clicked => sub { $searchstop = 1 }, @@ -587,8 +589,8 @@ sub do_search($$$$$$$) { local $_; while (<$sf>) { $searchstop and last; - if (/^NAME<([^>]+)> VERSION<([^>]+)> RELEASE<([^>]+)> ARCH<([^>]+)>/) { - $pkg = "$1-$2-$3.$4"; + if (/^NAME<([^>]+)> VERSION<([^>]+)> RELEASE<([^>]+)>/) { + $pkg = "$1-$2-$3"; $progresscount++; $progresscount <= $total_size and $searchprogress->set_fraction($progresscount/$total_size); $searchw->flush; next; @@ -635,7 +637,12 @@ sub find_installed_version { @version ? join(',', sort @version) : N("(none)"); } -sub formatlistpkg { join("\n", sort { uc($a) cmp uc($b) } @_) } +#- remove architecture +sub remove_arch { + $_[0] =~ /(.*)\.[^\.]+$/ ? $1 : $_[0]; +} + +sub formatlistpkg { myformatList(sort { uc($a) cmp uc($b) } @_) } sub format_header { my ($str) = @_; @@ -650,8 +657,8 @@ sub format_field { package Gtk2::Mdv::TextView; sub new { - my ($_class) = @_; - my $w = mygtk2::gtknew('TextView'); + my ($_class, $icon, $text, $o_options) = @_; + my $w = Gtk2::TextView->new; my $time if 0; require Time::HiRes; $w->signal_connect(size_allocate => sub { @@ -673,12 +680,11 @@ package main; sub format_pkg_simplifiedinfo { my ($pkgs, $key, $urpm, $descriptions) = @_; - my ($name, $_version) = split_fullname($key); - my $medium = pkg2medium($pkgs->{$key}{pkg}, $urpm)->{name}; - my $update_descr = $pkgs->{$key}{pkg}->flag_upgrade && $descriptions->{$name}{pre} && $descriptions->{$name}{medium} eq $medium; + my ($name, $version) = split_fullname($key); + my $update_descr = $pkgs->{$key}{pkg}->flag_upgrade && $descriptions->{$name}{pre}; my $s = ugtk2::markup_to_TextView_format(join("\n", format_header($name . ' - ' . $pkgs->{$key}{summary}) . # workaround gtk+ bug where GtkTextView wronly limit embedded widget size to bigger line's width (#25533): - "\x{200b} \x{feff}" . ' ' x 120, + "\x{200b} \x{feff}" . (' ' x 120), if_($update_descr, # is it an update? format_field(N("Importance: ")) . escape_text_for_TextView_markup_format($descriptions->{$name}{importance}), format_field(N("Reason for update: ")) . escape_text_for_TextView_markup_format(rpm_description($descriptions->{$name}{pre})), @@ -695,9 +701,8 @@ sub format_pkg_simplifiedinfo { push @$s, @{ ugtk2::markup_to_TextView_format(join("\n", (escape_text_for_TextView_markup_format($pkgs->{$key}{description} || $descriptions->{$name}{description}) || '<i>' . N("No description") . '</i>') )) }; - push @$s, [ "\n" ]; push @$s, [ gtkadd(gtkshow(my $exp = Gtk2::Expander->new(format_field(N("Files:")))), - gtknew('TextView', text => + gtktext_insert(Gtk2::TextView->new, exists $pkgs->{$key}{files} ? ugtk2::markup_to_TextView_format('<tt>' . join("\n", map { "\x{200e}$_" } @{$pkgs->{$key}{files}}) . '</tt>') #- to highlight information : N("(Not available)"), @@ -705,7 +710,7 @@ sub format_pkg_simplifiedinfo { $exp->set_use_markup(1); push @$s, [ "\n\n" ]; push @$s, [ gtkadd(gtkshow(my $exp2 = Gtk2::Expander->new(format_field(N("Changelog:")))), - gtknew('TextView', text => $pkgs->{$key}{changelog} || N("(Not available)")) + gtktext_insert(Gtk2::TextView->new, $pkgs->{$key}{changelog} || N("(Not available)")) ) ]; $exp2->set_use_markup(1); $s; @@ -730,7 +735,7 @@ sub format_pkg_info { format_field(N("Currently installed version: ")) . find_installed_version($pkgs->{$key}{pkg}), ) ); - my @max_info = @$max_info_in_descr && $changelog_first ? (@chglo, @files) : (@files, '', @chglo); + my @max_info = ($changelog_first ? (@chglo, @files) : (@files, '', @chglo)) if @$max_info_in_descr; ugtk2::markup_to_TextView_format(join("\n", format_field(N("Name: ")) . $name, format_field(N("Version: ")) . $version, format_field(N("Architecture: ")) . $pkgs->{$key}{pkg}->arch, @@ -755,11 +760,10 @@ sub format_pkg_info { sub run_treeview_dialog { my ($callback_action) = @_; my ($urpm, $pkgs, $descriptions); - my (%filter_methods, $force_displaying_group, @initial_selection, $initial_selection_done); + my (%filter_methods, $force_displaying_group); my $switch_pkg_list_mode = sub { my ($mode) = @_; return if !$mode; - return if !$filter_methods{$mode}; $force_displaying_group = 1; $filter_methods{$mode}->(); }; @@ -776,23 +780,18 @@ sub run_treeview_dialog { all_updates => sub { my %pkgs = grep { my $p = $h->{installable}{$_}; $p->{pkg} && !$p->{selected} && $p->{pkg}->flag_installed && $p->{pkg}->flag_upgrade } keys %{$h->{installable}}; $pkgs = { - (map { $_ => $h->{updates}{$_} } keys %{$h->{updates}}), + (map { $_ => $pkgs->{$_} } keys %{$h->{updates}}), (map { $_ => $h->{installable}{$_} } keys %pkgs) }; }, #security => sub { $pkgs = }, #normal => sub { $pkgs = } ); - if (!$initial_selection_done) { - $filter_methods{all}->(); - @initial_selection = grep { $pkgs->{$_}{selected} } keys %$pkgs; - $initial_selection_done = 1; - } foreach my $importance (qw(bugfix security normal)) { $filter_methods{$importance} = sub { $pkgs = $h->{updates}; $pkgs = { map { $_ => $pkgs->{$_} } grep { - my ($name, $_version) = split_fullname($_); + my ($name, $version) = split_fullname($_); $descriptions->{$name}{importance} eq $importance } keys %$pkgs }; }; } @@ -800,7 +799,9 @@ sub run_treeview_dialog { $switch_pkg_list_mode->($mode); }; - my ($options, $size_selected, $compssUsers, $tree, $tree_model, $detail_list, $detail_list_model, %elems); + $pkgs_provider->({}, $default_list_mode); # default mode + + my ($options, $size_selected, $compssUsers, $tree, $tree_model, $detail_tree, $detail_tree_model, %elems); my (undef, $size_free) = MDK::Common::System::df('/usr'); $w = ugtk2->new(N("Software Management")); @@ -823,13 +824,14 @@ sub run_treeview_dialog { my $callback = sub { interactive_msg_(N("More information on package..."), $options->{get_info}->($_[0]), scroll => 1) }; $choices = [ sort { $a->name cmp $b->name } @$choices ]; my @choices = interactive_list_(N("Please choose"), N("One of the following packages is needed:"), - [ map { urpm_name($_) } @$choices ], $callback); + [ map { my_fullname($_) } @$choices ], $callback); $choices->[$choices[0]]; }; my $closure_removal = sub { $urpm->{state} = {}; - urpm::select::find_packages_to_remove($urpm, $urpm->{state}, \@_); + map { s/\.[^.]*$// } # urpm::select::find_packages_to_remove add spurious arch at end + urpm::select::find_packages_to_remove($urpm, $urpm->{state}, \@_); }; my $force_rebuild; $options = { @@ -841,7 +843,7 @@ sub run_treeview_dialog { my ($group, $parent) = @_; my $pixbuf; my $path = $group =~ /\|/ ? '/usr/share/icons/mini/' : '/usr/share/icons/'; - my $create_pixbuf = sub { gtknew('Pixbuf', file => join('', $path, $_[0], '.png')) }; + my $create_pixbuf = sub { gtkcreate_pixbuf(join('', $path, $_[0], '.png')) }; eval { $pixbuf = $create_pixbuf->($group_icons{$group}) }; eval { $pixbuf ||= $create_pixbuf->($group_icons{$parent}) } if $parent; $pixbuf ||= $create_pixbuf->('applications_section'); @@ -850,7 +852,7 @@ sub run_treeview_dialog { my $pkg = $pkgs->{$_[0]}; my $urpm_obj = $pkg->{pkg}; $_[0] ? $pkg->{selected} ? - ($urpm_obj->flag_installed ? ($urpm_obj->flag_upgrade ? 'to_install' : 'to_remove') : 'to_install') + ($urpm_obj->flag_installed ? ($urpm_obj->flag_upgrade ? 'to_install': 'to_remove') : 'to_install') : ($urpm_obj->flag_installed ? ($urpm_obj->flag_upgrade ? 'to_update' : 'installed') : ($urpm_obj->flag_base ? '/usr/share/rpmdrake/icons/base.png' : 'uninstalled')) : 'XXX'; @@ -941,7 +943,7 @@ or you already installed all of them.")); @nodes = grep { exists $pkgs->{$_} } @nodes or return; #- avoid selecting too many packages at once - return if !$dont_show_selections && @nodes > 2000; + return if !$dont_show_selections && ($MODE ne 'update' && @nodes == keys %$pkgs || @nodes > 2000); my $new_state = !$pkgs->{$nodes[0]}{selected}; my @nodes_with_deps; @@ -965,12 +967,12 @@ or you already installed all of them.")); $w->{real_window}, undef, [ map { my $pkg = $_; - [ gtknew('HBox', children_tight => [ gtkset_selectable(gtknew('Label', text => $pkg), 1) ]), - gtknew('Button', text => N("More information on package..."), + [ gtkpack__(Gtk2::HBox->new(0,0), gtkset_selectable(Gtk2::Label->new($pkg),1)), + gtksignal_connect(Gtk2::Button->new(N("More information on package...")), clicked => sub { interactive_msg_(N("More information on package..."), $options->{get_info}->($pkg), scroll => 1); }) ] } @deps ], - [ gtknew('Button', text => N("Ok"), + [ gtksignal_connect(Gtk2::Button->new(N("Ok")), clicked => sub { Gtk2->main_quit }) ] ); goto deps_msg_again; @@ -1029,7 +1031,7 @@ or you already installed all of them.")); ); }, ); - @nodes_with_deps = map { urpm_name($_) } @requested; + @nodes_with_deps = map { my_fullname($_) } @requested; if (!$deps_msg->(N("Additional packages needed"), N("To satisfy dependencies, the following package(s) also need\nto be installed:\n\n"), \@nodes, \@nodes_with_deps)) @@ -1043,7 +1045,7 @@ or you already installed all of them.")); my @ask_unselect = urpm::select::unselected_packages($urpm, $urpm->{state}); my @reasons = map { my $cant = $_; - my $unsel = find { $_ eq $cant } @ask_unselect; + my $unsel = find { remove_arch($_) eq $cant } @ask_unselect; $unsel ? join("\n", urpm::select::translate_why_unselected($urpm, $urpm->{state}, $unsel)) : ($pkgs->{$_}{pkg}->flag_skip ? N("%s (belongs to the skip list)", $cant) : $cant); @@ -1064,7 +1066,7 @@ or you already installed all of them.")); slow_func($tree->window, sub { @unrequested = $urpm->disable_selected($db, $urpm->{state}, map { $pkgs->{$_}{pkg} } @nodes) }); - @nodes_with_deps = map { urpm_name($_) } @unrequested; + @nodes_with_deps = map { my_fullname($_) } @unrequested; if (!$deps_msg->(N("Some packages need to be removed"), N("Because of their dependencies, the following package(s) must be\nunselected now:\n\n"), \@nodes, \@nodes_with_deps)) @@ -1087,13 +1089,13 @@ or you already installed all of them.")); } else { $pkgs->{$_}{selected} = $new_state; } - $set_state->($_, $options->{node_state}($_), $detail_list_model); + $set_state->($_, $options->{node_state}($_), $detail_tree_model); $pkgs->{$_}{pkg} and $size_selected += $pkgs->{$_}{pkg}->size * ($new_state ? 1 : -1); } }, #- toggle_nodes get_status => sub { - member($default_list_mode, qw(all non_installed)) + $MODE eq 'install' ? N("Selected: %s / Free disk space: %s", formatXiB($size_selected), formatXiB($size_free*1024)) : N("Selected size: %d MB", $size_selected/(1024*1024)); }, @@ -1103,35 +1105,35 @@ or you already installed all of them.")); exists $pkgs->{$key} or return [ [ N("Description not available for this package\n") ] ]; exists $pkgs->{$key}{description} && exists $pkgs->{$key}{files} or slow_func($tree->window, sub { extract_header($pkgs->{$key}, $urpm) }); - my $s; - eval { $s = format_pkg_simplifiedinfo($pkgs, $key, $urpm, $descriptions) }; - if (my $err = $@) { - $s = N("A fatal error occurred: %s.", $err); - } - $s; + format_pkg_simplifiedinfo($pkgs, $key, $urpm, $descriptions); }, check_interactive_to_toggle => sub { 1 }, grep_allowed_to_toggle => sub { @_ }, rebuild_tree => sub {}, }; + if (my @initial_selection = grep { $pkgs->{$_}{selected} } keys %$pkgs) { + $options->{initial_selection} = \@initial_selection; + $pkgs->{$_}{selected} = 0 foreach keys %$pkgs; + } + $tree_model = Gtk2::TreeStore->new("Glib::String", "Glib::String", "Gtk2::Gdk::Pixbuf"); $tree_model->set_sort_column_id(0, 'ascending'); $tree = Gtk2::TreeView->new_with_model($tree_model); $tree->get_selection->set_mode('browse'); - $tree->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::MDV::CellRendererPixWithLabel->new, 'pixbuf' => 2, label => 0)); + $tree->append_column(my $textcolumn = Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::MDV::CellRendererPixWithLabel->new, 'pixbuf' => 2, label => 0)); $tree->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 1)); $tree->set_headers_visible(0); - $detail_list_model = Gtk2::ListStore->new("Glib::String", "Gtk2::Gdk::Pixbuf", "Glib::String"); - $detail_list = Gtk2::TreeView->new_with_model($detail_list_model); - $detail_list->append_column(my $pixcolumn = Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererPixbuf->new, 'pixbuf' => 1)); + $detail_tree_model = Gtk2::TreeStore->new("Glib::String", "Gtk2::Gdk::Pixbuf", "Glib::String"); + $detail_tree = Gtk2::TreeView->new_with_model($detail_tree_model); + $detail_tree->append_column(my $pixcolumn = Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererPixbuf->new, 'pixbuf' => 1)); $pixcolumn->{is_pix} = 1; - $detail_list->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 0)); - $detail_list_model->set_sort_column_id(0, 'ascending'); - $detail_list->set_headers_visible(0); - $detail_list->set_rules_hint(1); + $detail_tree->append_column(my $main_textcolumn = Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 0)); + $detail_tree_model->set_sort_column_id(0, 'ascending'); + $detail_tree->set_headers_visible(0); + $detail_tree->set_rules_hint(1); ($typical_width) = string_size($tree, translate("Graphical Environment") . "xmms-more-vis-plugins"); $typical_width > 600 and $typical_width = 600; #- try to not being crazy with a too large value @@ -1146,7 +1148,7 @@ or you already installed all of them.")); gtkset_mousecursor_normal($tree->window); undef $cursor_to_restore; }, - ) foreach $tree, $detail_list; + ) foreach $tree, $detail_tree; $tree->get_selection->signal_connect(changed => sub { my ($model, $iter) = $_[0]->get_selected; return if !$iter; @@ -1202,9 +1204,9 @@ or you already installed all of them.")); my $val = $_[0]->get_text; return if $val eq $old_value; # workarounding gtk+ sending us sometimes twice events $old_value = $val; - $default_list_mode = $rmodes{$val}; - if (my @cat = $wanted_categories{$rmodes{$val}} && @{$wanted_categories{$rmodes{$val}}}) { - @$mandrakeupdate_wanted_categories = @cat; + $default_list_mode = $val; + if ($wanted_categories{$rmodes{$val}} and my @cat = @{$wanted_categories{$rmodes{$val}}}) { + @{$mandrakeupdate_wanted_categories} = @cat; } if (0) { $reset_search->(); @@ -1236,7 +1238,7 @@ or you already installed all of them.")); { $search_types_optionmenu->set_model(Gtk2::ListStore->new('Glib::String')); my $search_types_renderer = Gtk2::CellRendererText->new; - $search_types_optionmenu->pack_start($search_types_renderer, 0); + $search_types_optionmenu->pack_start($search_types_renderer, Glib::FALSE()); $search_types_optionmenu->set_attributes($search_types_renderer, text => 0); my $iter = $search_types_optionmenu->get_model->iter_nth_child(undef, 0); $iter = $search_types_optionmenu->get_model->insert(0); @@ -1300,16 +1302,14 @@ Do you really want to install all the selected packages?"), yesno => 1) } }; - my $hpaned = gtknew('HPaned', - child1 => gtknew('ScrolledWindow', child => $tree, width => $typical_width*0.9) , resize1 => 0, shrink1 => 0, - resize2 => 1, shrink2 => 0, - child2 => gtknew('VPaned', - child1 => gtknew('ScrolledWindow', child => $detail_list), resize1 => 1, shrink1 => 0, - child2 => gtknew('ScrolledWindow', child => $info), resize2 => 1, shrink2 => 0 - ) - ); + my $hpaned = Gtk2::HPaned->new; + my $vpaned = Gtk2::VPaned->new; + $vpaned->pack1(create_scrolled_window($detail_tree), 1, 0); + $vpaned->pack2(create_scrolled_window($info), 1, 0); + $hpaned->pack1(gtkset_size_request(create_scrolled_window($tree), $typical_width*0.9, -1) , 0, 0); + $hpaned->pack2($vpaned, 1, 0); - my $status = gtknew('Label'); + my $status = Gtk2::Label->new; my $checkbox_show_autoselect; my ($menu, $factory) = create_factory_menu( $w->{real_window}, @@ -1338,7 +1338,7 @@ Do you really want to install all the selected packages?"), yesno => 1) $reset_search->(); $size_selected = 0; $force_displaying_group = 1; - $tree->get_selection->signal_emit('changed'); + $options->{widgets}->{detail_tree_model}->clear; }, undef, '<Item>' ], [ N("/_File") . N("/Reload the _packages list"), undef, sub { slow_func($::main_window->window, sub { @@ -1391,20 +1391,20 @@ Do you really want to install all the selected packages?"), yesno => 1) gtkadd( $w->{window}, gtkpack_( - gtknew('VBox', spacing => 3), + Gtk2::VBox->new(0, 3), 0, $menu, 0, getbanner(), 1, gtkadd( - gtknew('Frame', border_width => 3, shadow_type => 'none'), + gtkset_shadow_type(gtkset_border_width(Gtk2::Frame->new, 3), 'none'), gtkpack_( - gtknew('VBox', spacing => 3), + Gtk2::VBox->new(0, 3), 0, gtkpack__( - gtknew('HBox', spacing => 10), + Gtk2::HBox->new(0, 10), $cbox, - gtknew('Label', text => N("Find:")), + Gtk2::Label->new(N("Find:")), $search_types_optionmenu, gtksignal_connect( - $find_entry = gtknew('Entry'), + $find_entry = Gtk2::Entry->new, key_press_event => sub { $_[1]->keyval == $Gtk2::Gdk::Keysyms{Return} and $find_callback->(); @@ -1417,21 +1417,13 @@ Do you really want to install all the selected packages?"), yesno => 1) ), ), 1, $hpaned, - 0, $status, 0, gtkpack_( - gtknew('HBox', spacing => 20), + Gtk2::HBox->new(0, 20), 0, gtksignal_connect( Gtk2::Button->new(but_(N("Help"))), clicked => sub { rpmdrake::open_help($MODE) }, ), - 1, gtknew('Label'), - 0, gtksignal_connect( - Gtk2::Button->new(but_(N("Select all"))), - clicked => sub { - return if !ref($options->{toggle_all}); - $options->{toggle_all}->(1); - }, - ), + 1, $status, 0, my $action_button = gtksignal_connect( Gtk2::Button->new(but_(N("Apply"))), clicked => sub { $do_action->() }, @@ -1464,19 +1456,12 @@ Do you really want to install all the selected packages?"), yesno => 1) $find_entry->set_text($options{search}[0]) if $options{search}; $w->{rwindow}->show_all; - - $pkgs_provider->({}, $default_list_mode); # default mode - if (@initial_selection) { - $options->{initial_selection} = \@initial_selection; - $pkgs->{$_}{selected} = 0 foreach @initial_selection; - } - $options->{widgets} = { w => $w, tree => $tree, tree_model => $tree_model, - detail_list_model => $detail_list_model, - detail_list => $detail_list, + detail_tree_model => $detail_tree_model, + detail_tree => $detail_tree, info => $info, status => $status, }; @@ -1503,8 +1488,6 @@ sub get_pkgs { myexit(-1) if 0; #FIXME }; - gurpm::init(1 ? N("Please wait") : N("Package installation..."), N("Initializing..."), transient => $w->{real_window}); - my $_guard = before_leaving { gurpm::end() }; if (!$urpm) { $urpm ||= urpm->new; @@ -1516,7 +1499,6 @@ sub get_pkgs { exec('edit-urpm-sources.pl'); } } - my $_lock = urpm::lock::urpmi_db($urpm); my $statedir = $urpm->{statedir}; @update_medias = grep { !$_->{ignore} && $_->{update} } @{$urpm->{media}}; @@ -1531,7 +1513,7 @@ N("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); - urpm::media::select_media($urpm, map { $_->{name} } @update_medias); + $urpm->select_media(map { $_->{name} } @update_medias); update_sources($urpm, noclean => 1, banner => $::isEmbedded); } } else { @@ -1563,67 +1545,53 @@ Then, restart %s.", $rpmdrake::myname_update)), myexit(-1); } } - gurpm::label(N("Reading updates description")); - gurpm::progress(0.05); my ($cur, $section); #- parse the description file - foreach my $medium (@update_medias) { - foreach (cat_("$statedir/descriptions.$medium->{name}")) { - /^%package +(.+)/ and do { - my @pkg_list = split /\s+/, $1; - exists $cur->{importance} && $cur->{importance} !~ /^(?:security|bugfix)\z/ - and $cur->{importance} = 'normal'; - $update_descr{$_} = $cur foreach @{$cur->{pkgs} || []}; - $cur = { pkgs => \@pkg_list, medium => $medium->{name} }; - $section = 'pkg'; - next; - }; - /^%(pre|description)/ and do { $section = $1; next }; - /^Updated?: +(.+)/ && $section eq 'pkg' - and do { $cur->{update} = $1; next }; - /^Importance: +(.+)/ && $section eq 'pkg' - and do { $cur->{importance} = $1; next }; - /^(ID|URL): +(.+)/ && $section eq 'pkg' - and do { $cur->{$1} = $2; next }; - $section =~ /^(pre|description)\z/ and $cur->{$1} .= $_; - } - } + foreach (map { cat_("$statedir/descriptions.$_->{name}"), '%package dummy' } @update_medias) { + /^%package +(.+)/ and do { + my @pkg_list = split /\s+/, $1; + exists $cur->{importance} && $cur->{importance} !~ /^(?:security|bugfix)\z/ + and $cur->{importance} = 'normal'; + $update_descr{$_} = $cur foreach @{$cur->{pkgs} || []}; + $cur = {}; + $cur->{pkgs} = [ @pkg_list ]; + $section = 'pkg'; + next; + }; + /^%(pre|description)/ and do { $section = $1; next }; + /^Updated?: +(.+)/ && $section eq 'pkg' + and do { $cur->{update} = $1; next }; + /^Importance: +(.+)/ && $section eq 'pkg' + and do { $cur->{importance} = $1; next }; + /^(ID|URL): +(.+)/ && $section eq 'pkg' + and do { $cur->{$1} = $2; next }; + $section =~ /^(pre|description)\z/ and $cur->{$1} .= $_; + } my $_unused = N("Please wait, finding available packages..."); + my $wait = wait_msg_(N("Please wait, reading packages database...")); + if (!$::statusbar) { + $wait->{real_window}->show_all; + $wait->{real_window}->realize; + gtkflush(); + $wait->{real_window}->queue_draw; + } + gtkflush(); # find out installed packages: #$urpm = urpm->new; #$urpm->read_config; - my $level = 0.05; - my $total = @{$urpm->{depslist}}; - gurpm::label(N("Please wait, listing base packages...")); - gurpm::progress($level); - - my ($count, $prev_stage, $new_stage, $limit); - - my $reset_update = sub { undef $prev_stage; $count = 0; $limit = $_[0] }; - my $update = sub { - $count++; - $new_stage = $level+($limit-$level)*$count/$total; - if ($prev_stage + 0.01 < $new_stage) { - $prev_stage = $new_stage; - gurpm::progress($new_stage); - } - }; - my @base = ("basesystem", split /,\s*/, $urpm->{global_config}{'prohibit-remove'}); my (%base, %basepackages); my $db = $db; my $sig_handler = sub { undef $db; exit 3 }; local $SIG{INT} = $sig_handler; local $SIG{QUIT} = $sig_handler; - $reset_update->(0.33); while (defined(local $_ = shift @base)) { exists $basepackages{$_} and next; $db->traverse_tag(m|^/| ? 'path' : 'whatprovides', [ $_ ], sub { - $update->(); - push @{$basepackages{$_}}, urpm_name($_[0]); + push @{$basepackages{$_}}, my_fullname($_[0]); push @base, $_[0]->requires_nosense; }); } @@ -1633,23 +1601,20 @@ Then, restart %s.", $rpmdrake::myname_update)), myexit(-1); $base{$_} = \$n; } } - gurpm::label(N("Please wait, finding installed packages...")); - gurpm::progress($level = 0.33); - $reset_update->(0.66); my %installed_pkgs; $db->traverse(sub { my ($pkg) = @_; - $update->(); - my $fullname = urpm_name($pkg); + my $fullname = my_fullname($pkg); #- Extract summary and description since they'll be lost when the header is packed $installed_pkgs{$fullname} = { selected => 0, pkg => $pkg, urpm_name => urpm_name($pkg), summary => rpm_summary($pkg->summary), description => rpm_description($pkg->description), } if !($installed_pkgs{$fullname} && $installed_pkgs{$fullname}{description}); - if (my $name = $base{$fullname}) { + if ($base{$fullname}) { + my $name = $base{$fullname}; $installed_pkgs{$fullname}{base} = \$name; - $pkg->set_flag_base(1) if $$name == 1; + if (${$base{$fullname}} == 1) { $pkg->set_flag_base(1) } } $pkg->pack_header; }); @@ -1666,8 +1631,6 @@ Then, restart %s.", $rpmdrake::myname_update)), myexit(-1); my %installable_pkgs; my %updates; - gurpm::label(N("Please wait, finding available packages...")); - gurpm::progress($level = 0.66); @update_medias = grep { !$_->{ignore} && $_->{update} } @{$urpm->{media}}; check_update_media_version($urpm, @update_medias); @@ -1684,14 +1647,11 @@ Then, restart %s.", $rpmdrake::myname_update)), myexit(-1); $urpm->compute_installed_flags($db); # TODO/FIXME: not for updates $urpm->{depslist}[$_]->set_flag_installed foreach keys %$requested; #- pretend it's installed $urpm->{rpmdrake_state} = $state; #- Don't forget it - gurpm::progress($level = 0.7); my %pkg_sel = map { $_ => 1 } @{$options{'pkg-sel'} || []}; my %pkg_nosel = map { $_ => 1 } @{$options{'pkg-nosel'} || []}; my @updates_media_names = map { $_->{name} } @update_medias; - $reset_update->(1); foreach my $pkg (@{$urpm->{depslist}}) { - $update->(); $pkg->flag_upgrade or next; my $selected = 0; @@ -1701,13 +1661,10 @@ Then, restart %s.", $rpmdrake::myname_update)), myexit(-1); my $n = urpm_name($pkg); $pkg_sel{$n} || $pkg_nosel{$n} or next; $pkg_sel{$n} and $selected = 1; - } else { - # selecting updates by default: - $selected = 1; } - $updates{urpm_name($pkg)} = { selected => $selected, pkg => $pkg }; + $updates{my_fullname($pkg)} = { selected => $selected, pkg => $pkg }; } else { - $installable_pkgs{urpm_name($pkg)} = { selected => $selected, pkg => $pkg }; + $installable_pkgs{my_fullname($pkg)} = { selected => $selected, pkg => $pkg }; } } if ($options{'pkg-sel'} && $options{'pkg-nosel'}) { @@ -1715,6 +1672,7 @@ Then, restart %s.", $rpmdrake::myname_update)), myexit(-1); delete $options{'pkg-sel'}; } + statusbar_msg_remove($wait); $_->{pkg}->set_flag_installed foreach values %installed_pkgs; +{ urpm => $urpm, @@ -1739,7 +1697,6 @@ my %ignores_rpmnew = map { $_ => 1 } qw( /etc/sysconfig/alsa /etc/sysconfig/autofsck /etc/sysconfig/harddisks - /etc/sysconfig/harddrake2/previous_hw /etc/sysconfig/init /etc/sysconfig/installkernel /etc/sysconfig/msec @@ -1773,40 +1730,40 @@ sub dialog_rpmnew { gtkadd( $d->{window}, gtkpack_( - gtknew('VBox', spacing => 5), + Gtk2::VBox->new(0, 5), 1, create_vpaned( create_vpaned( gtkpack_( - gtknew('VBox'), - 0, gtknew('Label', text_markup => qq(<span font_desc="monospace">$file:</span>)), - 1, gtknew('ScrolledWindow', child => $texts{file} = gtknew('TextView')), + Gtk2::VBox->new(0, 0), + 0, gtkset_markup(Gtk2::Label->new, qq(<span font_desc="monospace">$file:</span>)), + 1, create_scrolled_window($texts{file} = Gtk2::TextView->new), ), gtkpack_( - gtknew('VBox'), - 0, gtknew('Label', text_markup => qq(<span font_desc="monospace">$rpmnew:</span>)), - 1, gtknew('ScrolledWindow', child => $texts{rpmnew} = gtknew('TextView')), + Gtk2::VBox->new(0, 0), + 0, gtkset_markup(Gtk2::Label->new, qq(<span font_desc="monospace">$rpmnew:</span>)), + 1, create_scrolled_window($texts{rpmnew} = Gtk2::TextView->new), ), resize1 => 1, ), gtkpack_( - gtknew('VBox'), - 0, gtknew('Label', text => N("changes:")), - 1, gtknew('ScrolledWindow', child => $texts{diff} = gtknew('TextView')), + Gtk2::VBox->new(0, 0), + 0, Gtk2::Label->new(N("changes:")), + 1, create_scrolled_window($texts{diff} = Gtk2::TextView->new), ), resize1 => 1, ), 0, gtkpack__( - gtknew('HButtonBox'), + create_hbox(), gtksignal_connect( - gtknew('Button', text => N("Remove .%s", $rpmfile)), + Gtk2::Button->new(N("Remove .%s", $rpmfile)), clicked => sub { $save_wsize->(); unlink $rpmnew; Gtk2->main_quit }, ), gtksignal_connect( - gtknew('Button', text => N("Use .%s as main file", $rpmfile)), + Gtk2::Button->new(N("Use .%s as main file", $rpmfile)), clicked => sub { $save_wsize->(); renamef($rpmnew, $file); Gtk2->main_quit }, ), gtksignal_connect( - gtknew('Button', text => N("Do nothing")), + Gtk2::Button->new(N("Do nothing")), clicked => sub { $save_wsize->(); Gtk2->main_quit }, ), ) @@ -1830,14 +1787,14 @@ sub dialog_rpmnew { my $f = $_; my $b; [ gtkpack__( - gtknew('HBox'), + Gtk2::HBox->new(0, 0), gtkset_markup( - gtkset_selectable(gtknew('Label'), 1), + gtkset_selectable(Gtk2::Label->new, 1), qq($pkg:<span font_desc="monospace">$f</span>), ) ), gtksignal_connect( - $b = gtknew('Button', text => N("Inspect...")), + $b = Gtk2::Button->new(N("Inspect...")), clicked => sub { $inspect->($f); -r "$f.rpmnew" || -r "$f.rpmsave" or $b->set_sensitive(0); @@ -1845,7 +1802,7 @@ sub dialog_rpmnew { ) ]; } @{$p2r{$pkg}}; } keys %p2r ], - [ gtknew('Button', text => N("Ok"), + [ gtksignal_connect(Gtk2::Button->new(N("Ok")), clicked => sub { Gtk2->main_quit }) ] ); return 0; @@ -1865,7 +1822,7 @@ sub perform_installation { #- (partially) duplicated from /usr/sbin/urpmi :-( my $group; if ($options{parallel} && (($group) = @{$options{parallel}})) { - my $pkgs = join(' ', map { if_($_->flag_requested, urpm_name($_)) } @{$urpm->{depslist}}); + my $pkgs = join(' ', map { if_($_->flag_requested, my_fullname($_)) } @{$urpm->{depslist}}); system("urpmi -v --X --parallel $group $pkgs"); if ($? == 0) { $statusbar_msg_id = statusbar_msg( @@ -1884,8 +1841,7 @@ sub perform_installation { #- (partially) duplicated from /usr/sbin/urpmi :-( return 0; } - my $_lock = urpm::lock::urpmi_db($urpm); - my $_rpm_lock = urpm::lock::rpm_db($urpm, 'exclusive'); + my $_lock = urpm::lock::urpmi_db($urpm, 'exclusive'); my %pkgs = map { $_->id => undef } grep { $_->flag_selected } @{$urpm->{depslist}}; my ($local_sources, $list, $local_to_removes) = urpm::get_pkgs::selected2list($urpm, \%pkgs, @@ -1905,7 +1861,8 @@ sub perform_installation { #- (partially) duplicated from /usr/sbin/urpmi :-( unlink $_; } - my @pkgs = map { scalar($_->fullname) } sort(grep { $_->flag_selected } @{$urpm->{depslist}});#{ $a->name cmp $b->name } @{$urpm->{depslist}}[keys %{$state->{selected}}]; + # FIXME: $_ is trashed: + my @pkgs = map { my $c = $_->fullname; $c } sort(grep { $_->flag_selected } @{$urpm->{depslist}});#{ $a->name cmp $b->name } @{$urpm->{depslist}}[keys %{$state->{selected}}]; @{$urpm->{ask_remove}} = sort urpm::select::removed_packages($urpm, $urpm->{state}); my @to_remove = grep { $_ } map { if_($pkgs->{$_}{selected}, $pkgs->{$_}{urpm_name}) } keys %$pkgs; @@ -1985,8 +1942,6 @@ Is it ok to continue?", join("\n\n", $r, if_($to_install, $to_install)))) : $to_ } } - my $_guard = before_leaving { urpm::removable::try_umounting_removables($urpm) }; - my $something_installed; if (@rpms_install || @rpms_upgrade || @to_remove) { if (my @missing = grep { m|^/| && ! -e $_ } @rpms_install, @rpms_upgrade) { @@ -2040,6 +1995,7 @@ Is it ok to continue?", join("\n\n", $r, if_($to_install, $to_install)))) : $to_ }, ); gurpm::end(); + urpm::removable::try_umounting_removables($urpm); if (@errors || @error_msgs) { interactive_msg_( @@ -2066,38 +2022,40 @@ you may now inspect some in order to take actions:"), and $statusbar_msg_id = statusbar_msg(N("All requested packages were installed successfully.")); if (keys %Readmes) { #- display the README*.urpmi files interactive_packtable( - N("Upgrade information"), + N("Information on packages"), $w->{real_window}, N("These packages come with upgrade information"), [ map { my $fullname = $_; [ gtkpack__( - gtknew('HBox'), - gtkset_selectable(gtknew('Label', text => $Readmes{$fullname}),1), + Gtk2::HBox->new(0, 0), + gtkset_selectable(Gtk2::Label->new($Readmes{$fullname}),1), ), gtksignal_connect( - gtknew('Button', text => N("Upgrade information about this package")), + #- TODO change those labels to something more sensible, e.g. "Upgrade information about this package" + Gtk2::Button->new(N("More information on package...")), clicked => sub { interactive_msg_( - N("Upgrade information about package %s", $Readmes{$fullname}), - (join '' => formatAlaTeX(scalar cat_($fullname))), + N("More information on package... [%s]", $fullname), + (join '' => cat_($fullname)), scroll => 1, ); }, ), ] } keys %Readmes ], - [ gtknew('Button', text => N("Ok"), clicked => sub { Gtk2->main_quit }) ] + [ gtksignal_connect(Gtk2::Button->new(N("Ok")), clicked => sub { Gtk2->main_quit }) ] ); } } else { gurpm::end(); + urpm::removable::try_umounting_removables($urpm); interactive_msg_(N("Error"), N("Unrecoverable error: no package found for installation, sorry.")); } $w->{rwindow}->set_sensitive(1); statusbar_msg_remove($statusbar_msg_id); #- XXX maybe remove this - return !($something_installed || scalar(@to_remove)); + return !$something_installed; fatal_error: gurpm::end(); @@ -2122,7 +2080,7 @@ sub perform_removal { sub { @results = $options{parallel} ? urpm::parallel::remove($urpm, \@toremove) - : urpm::install::install($urpm, \@toremove, {}, {}); + : urpm::install::install($urpm,\@toremove, {}, {}); open_db('force_sync'); }, ); |