aboutsummaryrefslogtreecommitdiffstats
path: root/lib/AdminPanel/Rpmdragora
diff options
context:
space:
mode:
authorAngelo Naselli <anaselli@linux.it>2015-03-16 19:20:40 +0100
committerAngelo Naselli <anaselli@linux.it>2015-03-16 19:20:40 +0100
commitb4e446c21e299af0441ec44db7a86334980b77c2 (patch)
treeea17c359431cb9e10aeed60346cb7b5a2c7af19d /lib/AdminPanel/Rpmdragora
parentfc9772f1f03684e8dab50ff77d2c46c5e0309c7b (diff)
downloadmanatools-b4e446c21e299af0441ec44db7a86334980b77c2.tar
manatools-b4e446c21e299af0441ec44db7a86334980b77c2.tar.gz
manatools-b4e446c21e299af0441ec44db7a86334980b77c2.tar.bz2
manatools-b4e446c21e299af0441ec44db7a86334980b77c2.tar.xz
manatools-b4e446c21e299af0441ec44db7a86334980b77c2.zip
Moved the tree accordingly
Diffstat (limited to 'lib/AdminPanel/Rpmdragora')
-rw-r--r--lib/AdminPanel/Rpmdragora/.perl_checker1
-rw-r--r--lib/AdminPanel/Rpmdragora/edit_urpm_sources.pm2243
-rw-r--r--lib/AdminPanel/Rpmdragora/formatting.pm209
-rw-r--r--lib/AdminPanel/Rpmdragora/gui.pm1828
-rw-r--r--lib/AdminPanel/Rpmdragora/gurpm.pm298
-rw-r--r--lib/AdminPanel/Rpmdragora/icon.pm234
-rw-r--r--lib/AdminPanel/Rpmdragora/init.pm181
-rw-r--r--lib/AdminPanel/Rpmdragora/open_db.pm171
-rw-r--r--lib/AdminPanel/Rpmdragora/pkg.pm1085
-rw-r--r--lib/AdminPanel/Rpmdragora/rpmnew.pm363
10 files changed, 0 insertions, 6613 deletions
diff --git a/lib/AdminPanel/Rpmdragora/.perl_checker b/lib/AdminPanel/Rpmdragora/.perl_checker
deleted file mode 100644
index 202e0535..00000000
--- a/lib/AdminPanel/Rpmdragora/.perl_checker
+++ /dev/null
@@ -1 +0,0 @@
-Basedir ..
diff --git a/lib/AdminPanel/Rpmdragora/edit_urpm_sources.pm b/lib/AdminPanel/Rpmdragora/edit_urpm_sources.pm
deleted file mode 100644
index c7569646..00000000
--- a/lib/AdminPanel/Rpmdragora/edit_urpm_sources.pm
+++ /dev/null
@@ -1,2243 +0,0 @@
-# vim: set et ts=4 sw=4:
-package ManaTools::Rpmdragora::edit_urpm_sources;
-#*****************************************************************************
-#
-# Copyright (c) 2002 Guillaume Cottenceau
-# Copyright (c) 2002-2007 Thierry Vignaud <tvignaud@mandriva.com>
-# Copyright (c) 2002-2007 Mandriva Linux
-# Copyright (c) 2014 - 2015 Angelo Naselli <anaselli@linux.it>
-#
-# 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: edit_urpm_sources.pm 266598 2010-03-03 12:00:58Z tv $
-
-
-use strict;
-use File::ShareDir ':ALL';
-use File::HomeDir qw(home);
-
-use MDK::Common::Func qw(if_ each_index);
-use MDK::Common::Math qw(max);
-use MDK::Common::File qw(cat_ output);
-use MDK::Common::DataStructure qw(member put_in_hash uniq);
-use MDK::Common::Various qw(to_bool);
-
-use ManaTools::Shared;
-use ManaTools::Shared::Locales;
-use ManaTools::rpmdragora;
-use ManaTools::Rpmdragora::init;
-use ManaTools::Rpmdragora::open_db;
-use ManaTools::Rpmdragora::formatting;
-use ManaTools::Shared::GUI;
-use URPM::Signature;
-use urpm::media;
-use urpm::download;
-use urpm::lock;
-
-use Exporter;
-our @ISA = qw(Exporter);
-our @EXPORT_OK = qw(run);
-
-
-my $urpm;
-my ($mainw, $list_tv, $something_changed);
-
-my %col = (
- mainw => {
- is_enabled => 0,
- is_update => 1,
- type => 2,
- name => 3,
- activatable => 4
- },
-);
-
-my $loc = ManaTools::rpmdragora::locale();
-
-sub get_medium_type {
- my ($medium) = @_;
- my %medium_type = (
- cdrom => $loc->N("CD-ROM"),
- ftp => $loc->N("FTP"),
- file => $loc->N("Local"),
- http => $loc->N("HTTP"),
- https => $loc->N("HTTPS"),
- nfs => $loc->N("NFS"),
- removable => $loc->N("Removable"),
- rsync => $loc->N("rsync"),
- ssh => $loc->N("NFS"),
- );
- return $loc->N("Mirror list") if $medium->{mirrorlist};
- return $medium_type{$1} if $medium->{url} =~ m!^([^:]*)://!;
- return $loc->N("Local");
-}
-
-sub selrow {
- my ($o_list_tv) = @_;
- defined $o_list_tv or $o_list_tv = $list_tv;
- my ($model, $iter) = $o_list_tv->get_selection->get_selected;
- $model && $iter or return -1;
- my $path = $model->get_path($iter);
- my $row = $path->to_string;
- return $row;
-}
-
-sub selected_rows {
- my ($o_list_tv) = @_;
- defined $o_list_tv or $o_list_tv = $list_tv;
- my (@rows) = $o_list_tv->get_selection->get_selected_rows;
- return -1 if @rows == 0;
- map { $_->to_string } @rows;
-}
-
-sub remove_row {
- my ($model, $path_str) = @_;
- my $iter = $model->get_iter_from_string($path_str);
- $iter or return;
- $model->remove($iter);
-}
-
-sub remove_from_list {
- my ($list, $list_ref, $model) = @_;
- my $row = selrow($list);
- if ($row != -1) {
- splice @$list_ref, $row, 1;
- remove_row($model, $row);
- }
-
-}
-
-sub _want_base_distro() {
- $::expert && distro_type(0) eq 'updates' ? interactive_msg(
- $loc->N("Choose media type"),
- $loc->N("In order to keep your system secure and stable, you must at a minimum set up
-sources for official security and stability updates. You can also choose to set
-up a fuller set of sources which includes the complete official Mageia
-repositories, giving you access to more software than can fit on the Mageia
-discs. Please choose whether to configure update sources only, or the full set
-of sources."
- ),
- transient => $::main_window,
- yesno => 1, text => { yes => $loc->N("Full set of sources"), no => $loc->N("Update sources only") },
- ) : 1;
-}
-
-sub easy_add_callback_with_mirror() {
- # when called on early init by rpmdragora
- $urpm ||= fast_open_urpmi_db();
-
- #- cooker and community don't have update sources
- my $want_base_distro = _want_base_distro();
- defined $want_base_distro or return 0;
- my $distro = $ManaTools::rpmdragora::mageia_release;
- my ($mirror) = choose_mirror($urpm, message =>
- $loc->N("This will attempt to install all official sources corresponding to your
-distribution (%s).\n
-I need to contact the Mageia website to get the mirror list.
-Please check that your network is currently running.\n
-Is it ok to continue?", $distro),
- transient => $::main_window,
- ) or return 0;
- ref $mirror or return 0;
- my $wait = wait_msg($loc->N("Please wait, adding media..."));
- add_distrib_update_media($urpm, $mirror, if_(!$want_base_distro, only_updates => 1));
- $offered_to_add_sources->[0] = 1;
- remove_wait_msg($wait);
- return 1;
-}
-
-sub easy_add_callback() {
- # when called on early init by rpmdragora
- $urpm ||= fast_open_urpmi_db();
-
- #- cooker and community don't have update sources
- my $want_base_distro = _want_base_distro();
- defined $want_base_distro or return 0;
- warn_for_network_need(undef, transient => $::main_window) or return 0;
- my $wait = wait_msg($loc->N("Please wait, adding media..."));
- add_distrib_update_media($urpm, undef, if_(!$want_base_distro, only_updates => 1));
- $offered_to_add_sources->[0] = 1;
- remove_wait_msg($wait);
- return 1;
-}
-
-## Internal routine that builds input fields needed to manage
-## the selected media type to be added
-## return HASH reference with the added widgets
-sub _build_add_dialog {
- my $options = shift;
-
- die "replace point is needed" if !defined ($options->{replace_pnt});
- die "dialog is needed" if !defined ($options->{dialog});
- die "selected item is needed" if !defined ($options->{selected});
- die "media info is needed" if !defined ($options->{info});
-
- my %widgets;
- my $factory = yui::YUI::widgetFactory;
-
- $options->{dialog}->startMultipleChanges();
- $options->{replace_pnt}->deleteChildren();
-
- # replace widgets
- my $vbox = $factory->createVBox( $options->{replace_pnt} );
- my $hbox = $factory->createHBox($vbox);
- $factory->createHSpacing($hbox, 1.0);
- my $label = $factory->createLabel($hbox,
- $options->{info}->{$options->{selected}}->{url}
- );
-
- $factory->createHSpacing($hbox, 3.0);
- $widgets{url} = $factory->createInputField($hbox, "", 0);
- $widgets{url}->setWeight($yui::YD_HORIZ, 2);
- if (defined($options->{info}->{$options->{selected}}->{dirsel})) {
- $widgets{dirsel} = $factory->createPushButton($hbox, $loc->N("Browse..."));
- }
- elsif (defined($options->{info}->{$options->{selected}}->{loginpass})) {
- $hbox = $factory->createHBox($vbox);
- $factory->createHSpacing($hbox, 1.0);
- $label = $factory->createLabel($hbox, $loc->N("Login:") );
- $factory->createHSpacing($hbox, 1.0);
- $widgets{login} = $factory->createInputField($hbox, "", 0);
- $label->setWeight($yui::YD_HORIZ, 1);
- $widgets{login}->setWeight($yui::YD_HORIZ, 3);
- $hbox = $factory->createHBox($vbox);
- $factory->createHSpacing($hbox, 1.0);
- $label = $factory->createLabel($hbox, $loc->N("Password:") );
- $factory->createHSpacing($hbox, 1.0);
- $widgets{pass} = $factory->createInputField($hbox, "", 1);
- $label->setWeight($yui::YD_HORIZ, 1);
- $widgets{pass}->setWeight($yui::YD_HORIZ, 3);
-
- }
- # recalc layout
- $options->{replace_pnt}->showChild();
- $options->{dialog}->recalcLayout();
- $options->{dialog}->doneMultipleChanges();
-
- return \%widgets;
-}
-
-sub add_callback() {
-
- my $retVal = 0;
-
- my $appTitle = yui::YUI::app()->applicationTitle();
- ## set new title to get it in dialog
- yui::YUI::app()->setApplicationTitle($loc->N("Add a medium"));
-
- my $factory = yui::YUI::widgetFactory;
-
- my $dialog = $factory->createPopupDialog();
- my $minSize = $factory->createMinSize( $dialog, 60, 5 );
- my $vbox = $factory->createVBox( $minSize );
-
- $factory->createVSpacing($vbox, 0.5);
-
- my $hbox = $factory->createHBox( $factory->createLeft($vbox) );
- $factory->createHeading($hbox, $loc->N("Adding a medium:"));
- $factory->createVSpacing($vbox, 0.5);
-
- $hbox = $factory->createHBox($vbox);
- $factory->createHSpacing($hbox, 1.0);
- my $label = $factory->createLabel($hbox, $loc->N("Type of medium:") );
- my $media_type = $factory->createComboBox($hbox, "", 0);
- $media_type->setWeight($yui::YD_HORIZ, 2);
-
- my %radios_infos = (
- local => { name => $loc->N("Local files"), url => $loc->N("Medium path:"), dirsel => 1 },
- ftp => { name => $loc->N("FTP server"), url => $loc->N("URL:"), loginpass => 1 },
- rsync => { name => $loc->N("RSYNC server"), url => $loc->N("URL:") },
- http => { name => $loc->N("HTTP server"), url => $loc->N("URL:") },
- removable => { name => $loc->N("Removable device (CD-ROM, DVD, ...)"),
- url => $loc->N("Path or mount point:"), dirsel => 1 },
- );
- my @radios_names_ordered = qw(local ftp rsync http removable);
-
- my $itemColl = new yui::YItemCollection;
- foreach my $elem (@radios_names_ordered) {
- my $it = new yui::YItem($radios_infos{$elem}->{'name'}, 0);
- if ($elem eq $radios_names_ordered[0]) {
- $it->setSelected(1);
- }
- $itemColl->push($it);
- $it->DISOWN();
- }
- $media_type->addItems($itemColl);
- $media_type->setNotify(1);
-
- $hbox = $factory->createHBox($vbox);
- $factory->createHSpacing($hbox, 1.0);
- $label = $factory->createLabel($hbox, $loc->N("Medium name:") );
- $factory->createHSpacing($hbox, 1.0);
- my $media_name = $factory->createInputField($hbox, "", 0);
- $media_name->setWeight($yui::YD_HORIZ, 2);
-
- # per function layout (replace point)
- my $align = $factory->createLeft($vbox);
- my $replace_pnt = $factory->createReplacePoint($align);
-
- my $add_widgets = _build_add_dialog({replace_pnt => $replace_pnt, dialog => $dialog,
- info => \%radios_infos, selected => $radios_names_ordered[0]}
- );
- # check-boxes
- $hbox = $factory->createHBox($factory->createLeft($vbox));
- $factory->createHSpacing($hbox, 1.3);
- my $dist_media = $factory->createCheckBox($hbox, $loc->N("Create media for a whole distribution"), 0);
- $hbox = $factory->createHBox($factory->createLeft($vbox));
- $factory->createHSpacing($hbox, 1.3);
- my $update_media = $factory->createCheckBox($hbox, $loc->N("Tag this medium as an update medium"), 0);
- $dist_media->setNotify(1);
-
- # Last line buttons
- $factory->createVSpacing($vbox, 0.5);
- $hbox = $factory->createHBox($vbox);
- my $cancelButton = $factory->createPushButton($hbox, $loc->N("&Cancel"));
- $factory->createHSpacing($hbox, 3.0);
- my $okButton = $factory->createPushButton($hbox, $loc->N("&Ok"));
-
- $cancelButton->setDefaultButton(1);
-
- # dialog event loop
- while(1) {
- my $event = $dialog->waitForEvent();
- my $eventType = $event->eventType();
-
- #event type checking
- if ($eventType == $yui::YEvent::CancelEvent) {
- last;
- }
- elsif ($eventType == $yui::YEvent::WidgetEvent) {
- ### widget
- my $widget = $event->widget();
- if ($widget == $cancelButton) {
- last;
- }
- elsif ($widget == $media_type) {
- my $item = $media_type->selectedItem();
- my $sel = $item ? $item->index() : 0 ;
- $add_widgets = _build_add_dialog({replace_pnt => $replace_pnt, dialog => $dialog,
- info => \%radios_infos, selected => $radios_names_ordered[$sel]}
- );
- }
- elsif ($widget == $dist_media) {
- $update_media->setEnabled(!$dist_media->value());
- }
- elsif ($widget == $okButton) {
- my $item = $media_type->selectedItem();
- my $sel = $item ? $item->index() : 0 ;
- my $info = $radios_infos{$radios_names_ordered[$sel]};
- my $name = $media_name->value();
- my $url = $add_widgets->{url}->value();
- $name eq '' || $url eq '' and interactive_msg('rpmdragora', $loc->N("You need to fill up at least the two first entries.")), next;
- if (member($name, map { $_->{name} } @{$urpm->{media}})) {
- interactive_msg('rpmdragora',
- $loc->N("There is already a medium called <%s>,\ndo you really want to replace it?", $name),
- yesno => 1) or next;
- }
-
- my %i = (
- name => $name,
- url => $url,
- distrib => $dist_media->value() ? 1 : 0,
- update => $update_media->value() ? 1 : undef,
- );
- my %make_url = (
- local => "file:/$i{url}",
- http => $i{url},
- rsync => $i{url},
- removable => "removable:/$i{url}",
- );
- $i{url} =~ s|^ftp://||;
- $make_url{ftp} = sprintf "ftp://%s%s",
- defined($add_widgets->{login})
- ?
- $add_widgets->{login}->value() . ':' . ( $add_widgets->{pass}->value() ?
- $add_widgets->{pass}->value() :
- '')
- :
- '',
- $i{url};
-
- if ($i{distrib}) {
- add_medium_and_check(
- $urpm,
- { nolock => 1, distrib => 1 },
- $i{name}, $make_url{$radios_names_ordered[$sel]}, probe_with => 'synthesis', update => $i{update},
- );
- } else {
- if (member($i{name}, map { $_->{name} } @{$urpm->{media}})) {
- urpm::media::select_media($urpm, $i{name});
- urpm::media::remove_selected_media($urpm);
- }
- add_medium_and_check(
- $urpm,
- { nolock => 1 },
- $i{name}, $make_url{$radios_names_ordered[$sel]}, $i{hdlist}, update => $i{update},
- );
- }
-
- $retVal = 1;
- last;
- }
- else {
- my $item = $media_type->selectedItem();
- my $sel = $item ? $item->index() : 0 ;
- if (defined($radios_infos{$radios_names_ordered[$sel]}->{dirsel}) &&
- defined($add_widgets->{dirsel}) ) {
- if ($widget == $add_widgets->{dirsel}) {
- my $dir = yui::YUI::app()->askForExistingDirectory(home(),
- $radios_infos{$radios_names_ordered[$sel]}->{url}
- );
- $add_widgets->{url}->setValue($dir) if ($dir);
- }
- }
- }
- }
- }
-### End ###
-
- $dialog->destroy();
-
- #restore old application title
- yui::YUI::app()->setApplicationTitle($appTitle) if $appTitle;
-
- return $retVal;
-
-}
-
-sub options_callback() {
-
- my $appTitle = yui::YUI::app()->applicationTitle();
- ## set new title to get it in dialog
- yui::YUI::app()->setApplicationTitle($loc->N("Global options for package installation"));
-
- my $factory = yui::YUI::widgetFactory;
-
- my $dialog = $factory->createPopupDialog();
- my $minSize = $factory->createMinSize( $dialog, 50, 5 );
- my $vbox = $factory->createVBox( $minSize );
-
- my $hbox = $factory->createHBox($vbox);
- $factory->createHSpacing($hbox, 1.0);
- my $label = $factory->createLabel($hbox, $loc->N("Verify RPMs to be installed:") );
- $factory->createHSpacing($hbox, 3.5);
- my $verify_rpm = $factory->createComboBox($hbox, "", 0);
- $verify_rpm->setWeight($yui::YD_HORIZ, 2);
- my @verif = ($loc->N("never"), $loc->N("always"));
- my $verify_rpm_value = $urpm->{global_config}{'verify-rpm'} || 0;
-
- my $itemColl = new yui::YItemCollection;
- my $cnt = 0;
- foreach my $elem (@verif) {
- my $it = new yui::YItem($elem, 0);
- if ($cnt == $verify_rpm_value) {
- $it->setSelected(1);
- }
- $itemColl->push($it);
- $it->DISOWN();
- $cnt++;
- }
- $verify_rpm->addItems($itemColl);
-
- $hbox = $factory->createHBox($vbox);
- $factory->createHSpacing($hbox, 1.0);
- $label = $factory->createLabel($hbox, $loc->N("Download program to use:") );
- $factory->createHSpacing($hbox, 4.0);
- my $downloader_entry = $factory->createComboBox($hbox, "", 0);
- $downloader_entry->setWeight($yui::YD_HORIZ, 2);
-
- my @comboList = urpm::download::available_ftp_http_downloaders() ;
- my $downloader = $urpm->{global_config}{downloader} || $comboList[0];
-
- if (scalar(@comboList) > 0) {
- $itemColl = new yui::YItemCollection;
- foreach my $elem (@comboList) {
- my $it = new yui::YItem($elem, 0);
- if ($elem eq $downloader) {
- $it->setSelected(1);
- }
- $itemColl->push($it);
- $it->DISOWN();
- }
- $downloader_entry->addItems($itemColl);
- }
-
- $hbox = $factory->createHBox($vbox);
- $factory->createHSpacing($hbox, 1.0);
- $label = $factory->createLabel($hbox, $loc->N("XML meta-data download policy:") );
- my $xml_info_policy = $factory->createComboBox($hbox, "", 0);
- $xml_info_policy->setWeight($yui::YD_HORIZ, 2);
-
- my @xml_info_policies = ('', 'never', 'on-demand', 'update-only', 'always');
- my @xml_info_policiesL = ('', $loc->N("Never"), $loc->N("On-demand"), $loc->N("Update-only"), $loc->N("Always"));
- my $xml_info_policy_value = $urpm->{global_config}{'xml-info'};
-
- $itemColl = new yui::YItemCollection;
- $cnt = 0;
- foreach my $elem (@xml_info_policiesL) {
- my $it = new yui::YItem($elem, 0);
- if ($xml_info_policy_value && $xml_info_policy_value eq $xml_info_policies[$cnt]) {
- $it->setSelected(1);
- }
- $itemColl->push($it);
- $it->DISOWN();
- $cnt++;
- }
- $xml_info_policy->addItems($itemColl);
-
- ### TODO tips ###
- #tip =>
- #join("\n",
- #$loc->N("For remote media, specify when XML meta-data (file lists, changelogs & information) are downloaded."),
- #'',
- #$loc->N("Never"),
- #$loc->N("For remote media, XML meta-data are never downloaded."),
- #'',
- #$loc->N("On-demand"),
- #$loc->N("(This is the default)"),
- #$loc->N("The specific XML info file is downloaded when clicking on package."),
- #'',
- #$loc->N("Update-only"),
- #$loc->N("Updating media implies updating XML info files already required at least once."),
- #'',
- #$loc->N("Always"),
- #$loc->N("All XML info files are downloaded when adding or updating media."),
-
- $factory->createVSpacing($vbox, 0.5);
-
-
- ### last line buttons
- $factory->createVSpacing($vbox, 0.5);
- $hbox = $factory->createHBox($vbox);
- my $cancelButton = $factory->createPushButton($hbox, $loc->N("&Cancel"));
- $factory->createHSpacing($hbox, 3.0);
- my $okButton = $factory->createPushButton($hbox, $loc->N("&Ok"));
-
- $cancelButton->setDefaultButton(1);
-
- # dialog event loop
- while(1) {
- my $event = $dialog->waitForEvent();
- my $eventType = $event->eventType();
-
- #event type checking
- if ($eventType == $yui::YEvent::CancelEvent) {
- last;
- }
- elsif ($eventType == $yui::YEvent::WidgetEvent) {
- ### widget
- my $widget = $event->widget();
- if ($widget == $cancelButton) {
- last;
- }
- elsif ($widget == $okButton) {
- my $changed = 0;
- my $item = $verify_rpm->selectedItem();
- if ($item->index() != $verify_rpm_value) {
- $changed = 1;
- $urpm->{global_config}{'verify-rpm'} = $item->index();
- }
- $item = $downloader_entry->selectedItem();
- if ($item->label() ne $downloader) {
- $changed = 1;
- $urpm->{global_config}{downloader} = $item->label();
- }
- $item = $xml_info_policy->selectedItem();
- if ($xml_info_policies[$item->index()] ne $xml_info_policy_value) {
- $changed = 1;
- $urpm->{global_config}{'xml-info'} = $xml_info_policies[$item->index()];
- }
- if ($changed) {
- urpm::media::write_config($urpm);
- $urpm = fast_open_urpmi_db();
- }
-
- last;
- }
- }
- }
-
- ### End ###
-
- $dialog->destroy();
-
- #restore old application title
- yui::YUI::app()->setApplicationTitle($appTitle) if $appTitle;
-
-}
-
-#=============================================================
-
-=head2 remove_callback
-
-=head3 INPUT
-
-$selection: YItemCollection (selected items)
-
-
-=head3 DESCRIPTION
-
-Remove the selected medias
-
-=cut
-
-#=============================================================
-
-sub remove_callback {
- my $selection = shift;
-
- my @rows;
- for (my $it = 0; $it < $selection->size(); $it++) {
- my $item = $selection->get($it);
- push @rows, $item->index();
- }
- @rows == 0 and return 0;
- interactive_msg(
- $loc->N("Source Removal"),
- @rows == 1 ?
- $loc->N("Are you sure you want to remove source \"%s\"?", $urpm->{media}[$rows[0]]{name}) :
- $loc->N("Are you sure you want to remove the following sources?") . "\n\n" .
- format_list(map { $urpm->{media}[$_]{name} } @rows),
- yesno => 1, scroll => 1,
- ) or return 0;
-
- my $wait = wait_msg($loc->N("Please wait, removing medium..."));
- foreach my $row (reverse(@rows)) {
- $something_changed = 1;
- urpm::media::remove_media($urpm, [ $urpm->{media}[$row] ]);
- }
- urpm::media::write_urpmi_cfg($urpm);
- remove_wait_msg($wait);
-
- return 1;
-}
-
-
-#=============================================================
-
-=head2 upwards_callback
-
-=head3 INPUT
-
-$table: Mirror table (YTable)
-
-=head3 DESCRIPTION
-
-Move selected item to high priority level
-
-=cut
-
-#=============================================================
-sub upwards_callback {
- my $table = shift;
-
- ## get the first
- my $item = $table->selectedItem();
- !$item and return 0;
- return 0 if ($item->index() == 0);
- my $row = $item->index();
- my @media = ( $urpm->{media}[$row-1], $urpm->{media}[$row]);
- $urpm->{media}[$row] = $media[0];
- $urpm->{media}[$row-1] = $media[1];
-
- urpm::media::write_config($urpm);
- $urpm = fast_open_urpmi_db();
- return $row - 1;
-}
-
-#=============================================================
-
-=head2 downwards_callback
-
-=head3 INPUT
-
-$table: Mirror table (YTable)
-
-=head3 DESCRIPTION
-
-Move selected item to low priority level
-
-=cut
-
-#=============================================================
-sub downwards_callback {
- my $table = shift;
-
- ## get the first
- my $item = $table->selectedItem();
- !$item and return 0;
- my $row = $item->index();
- return $row if ($row >= $table->itemsCount()-1);
-
- my @media = ( $urpm->{media}[$row], $urpm->{media}[$row+1]);
- $urpm->{media}[$row+1] = $media[0];
- $urpm->{media}[$row] = $media[1];
-
- urpm::media::write_config($urpm);
- $urpm = fast_open_urpmi_db();
- return $row + 1;
-}
-
-#- returns 1 if something changed to force readMedia()
-sub edit_callback {
- my $table = shift;
-
- my $changed = 0;
- ## get the first
- my $item = $table->selectedItem();
- !$item and return 0;
- my $row = $item->index();
-
- my $medium = $urpm->{media}[$row];
- my $config = urpm::cfg::load_config_raw($urpm->{config}, 1);
- my ($verbatim_medium) = grep { $medium->{name} eq $_->{name} } @$config;
-
- my $appTitle = yui::YUI::app()->applicationTitle();
- ## set new title to get it in dialog
- yui::YUI::app()->setApplicationTitle($loc->N("Edit a medium"));
-
- my $factory = yui::YUI::widgetFactory;
-
- my $dialog = $factory->createPopupDialog();
- my $minSize = $factory->createMinSize( $dialog, 80, 5 );
- my $vbox = $factory->createVBox( $minSize );
-
- my $hbox = $factory->createHBox( $factory->createLeft($vbox) );
- $factory->createHeading($hbox, $loc->N("Editing medium \"%s\":", $medium->{name}));
- $factory->createVSpacing($vbox, 1.0);
-
- $hbox = $factory->createHBox($vbox);
- $factory->createHSpacing($hbox, 1.0);
- my $label = $factory->createLabel($hbox, $loc->N("URL:"));
- my $url_entry = $factory->createInputField($hbox, "", 0);
- $url_entry->setWeight($yui::YD_HORIZ, 2);
- $url_entry->setValue($verbatim_medium->{url} || $verbatim_medium->{mirrorlist});
-
- $hbox = $factory->createHBox($vbox);
- $factory->createHSpacing($hbox, 1.0);
- $label = $factory->createLabel($hbox, $loc->N("Downloader:") );
- my $downloader_entry = $factory->createComboBox($hbox, "", 0);
- $downloader_entry->setWeight($yui::YD_HORIZ, 2);
-
- my @comboList = urpm::download::available_ftp_http_downloaders() ;
- my $downloader = $verbatim_medium->{downloader} || $urpm->{global_config}{downloader} || $comboList[0];
-
- if (scalar(@comboList) > 0) {
- my $itemColl = new yui::YItemCollection;
- foreach my $elem (@comboList) {
- my $it = new yui::YItem($elem, 0);
- if ($elem eq $downloader) {
- $it->setSelected(1);
- }
- $itemColl->push($it);
- $it->DISOWN();
- }
- $downloader_entry->addItems($itemColl);
- }
- $factory->createVSpacing($vbox, 0.5);
-
- my $url = $url_entry->value();
-
- $hbox = $factory->createHBox($factory->createLeft($vbox));
- $factory->createHSpacing($hbox, 1.0);
-
- my $tableItem = yui::toYTableItem($item);
- # enabled cell 0, updates cell 1
- my $cellEnabled = $tableItem->cell(0)->label() ? 1 : 0;
- my $enabled = $factory->createCheckBox($hbox, $loc->N("Enabled"), $cellEnabled);
- my $cellUpdates = $tableItem->cell(1)->label() ? 1 : 0;
- my $update = $factory->createCheckBox($hbox, $loc->N("Updates"), $cellUpdates);
- $update->setDisabled() if (!$::expert);
-
- $factory->createVSpacing($vbox, 0.5);
- $hbox = $factory->createHBox($vbox);
- my $cancelButton = $factory->createPushButton($hbox, $loc->N("&Cancel"));
- $factory->createHSpacing($hbox, 3.0);
- my $saveButton = $factory->createPushButton($hbox, $loc->N("&OK"));
- $factory->createHSpacing($hbox, 3.0);
- my $proxyButton = $factory->createPushButton($hbox, $loc->N("&Proxy..."));
-
- $cancelButton->setDefaultButton(1);
-
- # dialog event loop
- while(1) {
- my $event = $dialog->waitForEvent();
- my $eventType = $event->eventType();
-
- #event type checking
- if ($eventType == $yui::YEvent::CancelEvent) {
- last;
- }
- elsif ($eventType == $yui::YEvent::WidgetEvent) {
- ### widget
- my $widget = $event->widget();
- if ($widget == $cancelButton) {
- last;
- }
- elsif ($widget == $saveButton) {
- if ($cellEnabled != $enabled->value()) {
- $urpm->{media}[$row]{ignore} = !$urpm->{media}[$row]{ignore} || undef;
- $changed = 1;
- }
- if ($cellUpdates != $update->value()) {
- $urpm->{media}[$row]{update} = !$urpm->{media}[$row]{update} || undef;
- $changed = 1;
- }
- if ( $changed ) {
- urpm::media::write_config($urpm);
- }
-
- my ($m_name, $m_update) = map { $medium->{$_} } qw(name update);
- # TODO check if really changed first
- $url = $url_entry->value();
- $downloader = $downloader_entry->value();
- $url =~ m|^removable://| and (
- interactive_msg(
- $loc->N("You need to insert the medium to continue"),
- $loc->N("In order to save the changes, you need to insert the medium in the drive."),
- yesno => 1, text => { yes => $loc->N("Ok"), no => $loc->N("Cancel") }
- ) or return 0
- );
- my $saved_proxy = urpm::download::get_proxy($m_name);
- undef $saved_proxy if !defined $saved_proxy->{http_proxy} && !defined $saved_proxy->{ftp_proxy};
- urpm::media::select_media($urpm, $m_name);
- if (my ($media) = grep { $_->{name} eq $m_name } @{$urpm->{media}}) {
- MDK::Common::DataStructure::put_in_hash($media, {
- ($verbatim_medium->{mirrorlist} ? 'mirrorlist' : 'url') => $url,
- name => $m_name,
- if_($m_update && $m_update ne $media->{update} || $m_update, update => $m_update),
- if_($saved_proxy && $saved_proxy ne $media->{proxy} || $saved_proxy, proxy => $saved_proxy),
- if_($downloader ne $media->{downloader} || $downloader, downloader => $downloader),
- modified => 1,
- });
- urpm::media::write_config($urpm);
- update_sources_noninteractive($urpm, [ $m_name ]);
- } else {
- urpm::media::remove_selected_media($urpm);
- add_medium_and_check($urpm, { nolock => 1, proxy => $saved_proxy }, $m_name, $url, undef, update => $m_update, if_($downloader, downloader => $downloader));
- }
- last;
- }
- elsif ($widget == $proxyButton) {
- proxy_callback($medium);
- }
- }
- }
-### End ###
-
- $dialog->destroy();
-
- #restore old application title
- yui::YUI::app()->setApplicationTitle($appTitle) if $appTitle;
-
- return $changed;
-}
-
-sub update_callback() {
- update_sources_interactive($urpm, transient => $::main_window, nolock => 1);
-}
-
-#=============================================================
-
-=head2 proxy_callback
-
-=head3 INPUT
-
-$medium: the medium which proxy is going to be modified
-
-=head3 DESCRIPTION
-
-Set or change the proxy settings for the given media.
-Note that Ok button saves the changes.
-
-=cut
-
-#=============================================================
-sub proxy_callback {
- my ($medium) = @_;
- my $medium_name = $medium ? $medium->{name} : '';
-
- my ($proxy, $proxy_user) = readproxy($medium_name);
- my ($user, $pass) = $proxy_user =~ /^([^:]*):(.*)$/;
-
- my $appTitle = yui::YUI::app()->applicationTitle();
- ## set new title to get it in dialog
- yui::YUI::app()->setApplicationTitle($loc->N("Configure proxies"));
-
- my $factory = yui::YUI::widgetFactory;
-
- my $dialog = $factory->createPopupDialog();
- my $minSize = $factory->createMinSize( $dialog, 80, 5 );
- my $vbox = $factory->createVBox( $minSize );
-
- my $hbox = $factory->createHBox( $factory->createLeft($vbox) );
- $factory->createHeading($hbox,
- $medium_name
- ? $loc->N("Proxy settings for media \"%s\"", $medium_name)
- : $loc->N("Global proxy settings"));
- $factory->createVSpacing($vbox, 0.5);
-
- $hbox = $factory->createHBox($vbox);
- $factory->createHSpacing($hbox, 1.0);
- my $label = $factory->createLabel($hbox, $loc->N("If you need a proxy, enter the hostname and an optional port (syntax: <proxyhost[:port]>):"));
- $factory->createVSpacing($vbox, 0.5);
-
- my ($proxybutton, $proxyentry, $proxyuserbutton, $proxyuserentry, $proxypasswordentry);
-
- $hbox = $factory->createHBox($factory->createLeft($vbox));
- $proxybutton = $factory->createCheckBoxFrame($hbox, $loc->N("Enable proxy"), 1);
- my $frm_vbox = $factory->createVBox( $proxybutton );
- my $align = $factory->createRight($frm_vbox);
- $hbox = $factory->createHBox($align);
- $label = $factory->createLabel($hbox, $loc->N("Proxy hostname:") );
- $proxyentry = $factory->createInputField($hbox, "", 0);
- $label->setWeight($yui::YD_HORIZ, 1);
- $proxyentry->setWeight($yui::YD_HORIZ, 2);
- $proxyuserbutton = $factory->createCheckBoxFrame($factory->createLeft($frm_vbox),
- $loc->N("You may specify a username/password for the proxy authentication:"), 1);
- $proxyentry->setValue($proxy) if $proxy;
-
- $frm_vbox = $factory->createVBox( $proxyuserbutton );
-
- ## proxy user name
- $align = $factory->createRight($frm_vbox);
- $hbox = $factory->createHBox($align);
- $label = $factory->createLabel($hbox, $loc->N("User:") );
- $proxyuserentry = $factory->createInputField($hbox, "", 0);
- $label->setWeight($yui::YD_HORIZ, 1);
- $proxyuserentry->setWeight($yui::YD_HORIZ, 2);
- $proxyuserentry->setValue($user) if $user;
-
- ## proxy user password
- $align = $factory->createRight($frm_vbox);
- $hbox = $factory->createHBox($align);
- $label = $factory->createLabel($hbox, $loc->N("Password:") );
- $proxypasswordentry = $factory->createInputField($hbox, "", 1);
- $label->setWeight($yui::YD_HORIZ, 1);
- $proxypasswordentry->setWeight($yui::YD_HORIZ, 2);
- $proxypasswordentry->setValue($pass) if $pass;
-
- $proxyuserbutton->setValue ($proxy_user ? 1 : 0);
- $proxybutton->setValue ($proxy ? 1 : 0);
-
- # dialog low level buttons
- $factory->createVSpacing($vbox, 0.5);
- $hbox = $factory->createHBox($vbox);
- my $okButton = $factory->createPushButton($hbox, $loc->N("&Ok"));
- $factory->createHSpacing($hbox, 3.0);
- my $cancelButton = $factory->createPushButton($hbox, $loc->N("&Cancel"));
-
- $cancelButton->setDefaultButton(1);
-
- # dialog event loop
- while(1) {
- my $event = $dialog->waitForEvent();
- my $eventType = $event->eventType();
-
- #event type checking
- if ($eventType == $yui::YEvent::CancelEvent) {
- last;
- }
- elsif ($eventType == $yui::YEvent::WidgetEvent) {
- ### widget
- my $widget = $event->widget();
- if ($widget == $cancelButton) {
- last;
- }
- elsif ($widget == $okButton) {
- $proxy = $proxybutton->value() ? $proxyentry->value() : '';
- $proxy_user = $proxyuserbutton->value()
- ? ($proxyuserentry->value() . ':' . $proxypasswordentry->value()) : '';
-
- writeproxy($proxy, $proxy_user, $medium_name);
- last;
- }
- }
- }
-
-### End ###
- $dialog->destroy();
-
- #restore old application title
- yui::YUI::app()->setApplicationTitle($appTitle) if $appTitle;
-
-}
-
-sub parallel_read_sysconf() {
- my @conf;
- foreach (MDK::Common::File::cat_('/etc/urpmi/parallel.cfg')) {
- my ($name, $protocol, $command) = /([^:]+):([^:]+):(.*)/ or print STDERR "Warning, unrecognized line in /etc/urpmi/parallel.cfg:\n$_";
- my $medias = $protocol =~ s/\(([^\)]+)\)$// ? [ split /,/, $1 ] : [];
- push @conf, { name => $name, protocol => $protocol, medias => $medias, command => $command };
- }
- \@conf;
-}
-
-sub parallel_write_sysconf {
- my ($conf) = @_;
- output '/etc/urpmi/parallel.cfg',
- map { my $m = @{$_->{medias}} ? '(' . join(',', @{$_->{medias}}) . ')' : '';
- "$_->{name}:$_->{protocol}$m:$_->{command}\n" } @$conf;
-}
-
-sub remove_parallel {
- my ($num, $conf) = @_;
- if ($num != -1) {
- splice @$conf, $num, 1;
- parallel_write_sysconf($conf);
- }
-}
-
-sub add_callback_ {
- my ($title, $label, $mainw, $widget, $get_value, $check) = @_;
- my $w = ugtk2->new($title, grab => 1, transient => $mainw->{real_window});
- local $::main_window = $w->{real_window};
- gtkadd(
- $w->{window},
- gtkpack__(
- gtknew('VBox', spacing => 5),
- gtknew('Label', text => $label),
- $widget,
- gtknew('HSeparator'),
- gtkpack(
- gtknew('HButtonBox'),
- gtknew('Button', text => $loc->N("Ok"), clicked => sub { $w->{retval} = 1; $get_value->(); Gtk2->main_quit }),
- gtknew('Button', text => $loc->N("Cancel"), clicked => sub { $w->{retval} = 0; Gtk2->main_quit })
- )
- )
- );
- $check->() if $w->main;
-}
-
-sub edit_parallel {
- my ($num, $conf) = @_;
- my $edited = $num == -1 ? {} : $conf->[$num];
- my $w = ugtk2->new($num == -1 ? $loc->N("Add a parallel group") : $loc->N("Edit a parallel group"), grab => 1, center => 1, transient => $::main_window);
- local $::main_window = $w->{real_window};
- my $name_entry;
-
- my ($medias_ls, $hosts_ls) = (Gtk2::ListStore->new("Glib::String"), Gtk2::ListStore->new("Glib::String"));
-
- my ($medias, $hosts) = map {
- my $list = Gtk2::TreeView->new_with_model($_);
- $list->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 0));
- $list->set_headers_visible(0);
- $list->get_selection->set_mode('browse');
- $list;
- } $medias_ls, $hosts_ls;
-
- $medias_ls->append_set([ 0 => $_ ]) foreach @{$edited->{medias}};
-
- my $add_media = sub {
- my $medias_list_ls = Gtk2::ListStore->new("Glib::String");
- my $medias_list = Gtk2::TreeView->new_with_model($medias_list_ls);
- $medias_list->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 0));
- $medias_list->set_headers_visible(0);
- $medias_list->get_selection->set_mode('browse');
- $medias_list_ls->append_set([ 0 => $_->{name} ]) foreach @{$urpm->{media}};
- my $sel;
- add_callback_($loc->N("Add a medium limit"), $loc->N("Choose a medium to add to the media limit:"),
- $w, $medias_list, sub { $sel = selrow($medias_list) },
- sub {
- return if $sel == -1;
- my $media = ${$urpm->{media}}[$sel]{name};
- $medias_ls->append_set([ 0 => $media ]);
- push @{$edited->{medias}}, $media;
- }
- );
- };
-
- my $hosts_list;
- if ($edited->{protocol} eq 'ssh') { $hosts_list = [ split /:/, $edited->{command} ] }
- elsif ($edited->{protocol} eq 'ka-run') { push @$hosts_list, $1 while $edited->{command} =~ /-m (\S+)/g }
- $hosts_ls->append_set([ 0 => $_ ]) foreach @$hosts_list;
- my $add_host = sub {
- my ($entry, $value);
- add_callback_($loc->N("Add a host"), $loc->N("Type in the hostname or IP address of the host to add:"),
- $mainw, $entry = gtkentry(), sub { $value = $entry->get_text },
- sub { $hosts_ls->append_set([ 0 => $value ]); push @$hosts_list, $value }
- );
- };
-
- my @protocols_names = qw(ka-run ssh);
- my @protocols;
- gtkadd(
- $w->{window},
- gtkpack_(
- gtknew('VBox', spacing => 5),
- if_(
- $num != -1,
- 0, gtknew('Label', text => $loc->N("Editing parallel group \"%s\":", $edited->{name}))
- ),
- 1, create_packtable(
- {},
- [ $loc->N("Group name:"), $name_entry = gtkentry($edited->{name}) ],
- [ $loc->N("Protocol:"), gtknew('HBox', children_tight => [
- @protocols = gtkradio($edited->{protocol}, @protocols_names) ]) ],
- [ $loc->N("Media limit:"),
- gtknew('HBox', spacing => 5, children => [
- 1, gtknew('Frame', shadow_type => 'in', child =>
- gtknew('ScrolledWindow', h_policy => 'never', child => $medias)),
- 0, gtknew('VBox', children_tight => [
- gtksignal_connect(Gtk2::Button->new(but($loc->N("Add"))), clicked => sub { $add_media->() }),
- gtksignal_connect(Gtk2::Button->new(but($loc->N("Remove"))), clicked => sub {
- remove_from_list($medias, $edited->{medias}, $medias_ls);
- }) ]) ]) ],
- [ $loc->N("Hosts:"),
- gtknew('HBox', spacing => 5, children => [
- 1, gtknew('Frame', shadow_type => 'in', child =>
- gtknew('ScrolledWindow', h_policy => 'never', child => $hosts)),
- 0, gtknew('VBox', children_tight => [
- gtksignal_connect(Gtk2::Button->new(but($loc->N("Add"))), clicked => sub { $add_host->() }),
- gtksignal_connect(Gtk2::Button->new(but($loc->N("Remove"))), clicked => sub {
- remove_from_list($hosts, $hosts_list, $hosts_ls);
- }) ]) ]) ]
- ),
- 0, gtknew('HSeparator'),
- 0, gtkpack(
- gtknew('HButtonBox'),
- gtksignal_connect(
- gtknew('Button', text => $loc->N("Ok")), clicked => sub {
- $w->{retval} = 1;
- $edited->{name} = $name_entry->get_text;
- mapn { $_[0]->get_active and $edited->{protocol} = $_[1] } \@protocols, \@protocols_names;
- Gtk2->main_quit;
- }
- ),
- gtknew('Button', text => $loc->N("Cancel"), clicked => sub { $w->{retval} = 0; Gtk2->main_quit }))
- )
- );
- $w->{rwindow}->set_size_request(600, -1);
- if ($w->main) {
- $num == -1 and push @$conf, $edited;
- if ($edited->{protocol} eq 'ssh') { $edited->{command} = join(':', @$hosts_list) }
- if ($edited->{protocol} eq 'ka-run') { $edited->{command} = "-c ssh " . join(' ', map { "-m $_" } @$hosts_list) }
- parallel_write_sysconf($conf);
- return 1;
- }
- return 0;
-}
-
-sub parallel_callback() {
- my $w = ugtk2->new($loc->N("Configure parallel urpmi (distributed execution of urpmi)"), grab => 1, center => 1, transient => $mainw->{real_window});
- local $::main_window = $w->{real_window};
- my $list_ls = Gtk2::ListStore->new("Glib::String", "Glib::String", "Glib::String", "Glib::String");
- my $list = Gtk2::TreeView->new_with_model($list_ls);
- each_index { $list->append_column(Gtk2::TreeViewColumn->new_with_attributes($_, Gtk2::CellRendererText->new, 'text' => $::i)) } $loc->N("Group"), $loc->N("Protocol"), $loc->N("Media limit");
- $list->append_column(my $commandcol = Gtk2::TreeViewColumn->new_with_attributes($loc->N("Command"), Gtk2::CellRendererText->new, 'text' => 3));
- $commandcol->set_max_width(200);
-
- my $conf;
- my $reread = sub {
- $list_ls->clear;
- $conf = parallel_read_sysconf();
- foreach (@$conf) {
- $list_ls->append_set([ 0 => $_->{name},
- 1 => $_->{protocol},
- 2 => @{$_->{medias}} ? join(', ', @{$_->{medias}}) : $loc->N("(none)"),
- 3 => $_->{command} ]);
- }
- };
- $reread->();
-
- gtkadd(
- $w->{window},
- gtkpack_(
- gtknew('VBox', spacing => 5),
- 1, gtkpack_(
- gtknew('HBox', spacing => 10),
- 1, $list,
- 0, gtkpack__(
- gtknew('VBox', spacing => 5),
- gtksignal_connect(
- Gtk2::Button->new(but($loc->N("Remove"))),
- clicked => sub { remove_parallel(selrow($list), $conf); $reread->() },
- ),
- gtksignal_connect(
- Gtk2::Button->new(but($loc->N("Edit..."))),
- clicked => sub {
- my $row = selrow($list);
- $row != -1 and edit_parallel($row, $conf);
- $reread->();
- },
- ),
- gtksignal_connect(
- Gtk2::Button->new(but($loc->N("Add..."))),
- clicked => sub { edit_parallel(-1, $conf) and $reread->() },
- )
- )
- ),
- 0, gtknew('HSeparator'),
- 0, gtkpack(
- gtknew('HButtonBox'),
- gtknew('Button', text => $loc->N("Ok"), clicked => sub { Gtk2->main_quit })
- )
- )
- );
- $w->main;
-}
-
-sub keys_callback() {
- my $changed = 0;
- my $appTitle = yui::YUI::app()->applicationTitle();
-
- ## set new title to get it in dialog
- yui::YUI::app()->setApplicationTitle($loc->N("Manage keys for digital signatures of packages"));
-
- my $factory = yui::YUI::widgetFactory;
-
- my $dialog = $factory->createPopupDialog();
- my $minSize = $factory->createMinSize( $dialog, 80, 20 );
- my $vbox = $factory->createVBox( $minSize );
-
- my $hbox_headbar = $factory->createHBox($vbox);
- my $head_align_left = $factory->createLeft($hbox_headbar);
- my $head_align_right = $factory->createRight($hbox_headbar);
- my $headbar = $factory->createHBox($head_align_left);
- my $headRight = $factory->createHBox($head_align_right);
-
-
- my $hbox_content = $factory->createHBox($vbox);
- my $leftContent = $factory->createLeft($hbox_content);
- $leftContent->setWeight($yui::YD_HORIZ,3);
-
- my $frame = $factory->createFrame ($leftContent, "");
-
- my $frmVbox = $factory->createVBox( $frame );
- my $hbox = $factory->createHBox( $frmVbox );
-
- ## media list
- my $yTableHeader = new yui::YTableHeader();
- $yTableHeader->addColumn($loc->N("Medium"), $yui::YAlignBegin);
- my $multiselection = 0;
- my $mediaTbl = $factory->createTable($hbox, $yTableHeader, $multiselection);
- $mediaTbl->setKeepSorting(1);
- $mediaTbl->setImmediateMode(1);
-
- my $itemColl = new yui::YItemCollection;
- foreach (@{$urpm->{media}}) {
- my $name = $_->{name};
-
- my $item = new yui::YTableItem ($name);
- # NOTE row is $item->index()
- $item->setLabel( $name );
- $itemColl->push($item);
- $item->DISOWN();
- }
- $mediaTbl->addItems($itemColl);
-
- ## key list
- $leftContent = $factory->createLeft($hbox_content);
- $leftContent->setWeight($yui::YD_HORIZ,3);
- $frame = $factory->createFrame ($leftContent, "");
- $frmVbox = $factory->createVBox( $frame );
- $hbox = $factory->createHBox( $frmVbox );
- $yTableHeader = new yui::YTableHeader();
- $yTableHeader->addColumn($loc->N("Keys"), $yui::YAlignBegin);
- $multiselection = 0;
- my $keyTbl = $factory->createTable($hbox, $yTableHeader, $multiselection);
- $keyTbl->setKeepSorting(1);
-
- my ($current_medium, $current_medium_nb, @keys);
-
- ### internal subroutines
- my $read_conf = sub {
- $urpm->parse_pubkeys(root => $urpm->{root});
- @keys = map { [ split /[,\s]+/, ($_->{'key-ids'} || '') ] } @{$urpm->{media}};
- };
-
- my $write = sub {
- $something_changed = 1;
- urpm::media::write_config($urpm);
- $urpm = fast_open_urpmi_db();
- $read_conf->();
- };
-
- $read_conf->();
-
- my $key_name = sub {
- exists $urpm->{keys}{$_[0]} ? $urpm->{keys}{$_[0]}{name}
- : $loc->N("no name found, key doesn't exist in rpm keyring!");
- };
-
- my $sel_changed = sub {
- my $item = $mediaTbl->selectedItem();
- if ($item) {
- $current_medium = $item->label();
- $current_medium_nb = $item->index();
-
- yui::YUI::app()->busyCursor();
- yui::YUI::ui()->blockEvents();
- $dialog->startMultipleChanges();
-
- $keyTbl->deleteAllItems();
- my $itemColl = new yui::YItemCollection;
- foreach ( @{$keys[$current_medium_nb]} ) {
- my $it = new yui::YTableItem (sprintf("%s (%s)", $_, $key_name->($_)));
- # NOTE row is $item->index()
- $it->setLabel( $_ );
- $itemColl->push($it);
- $it->DISOWN();
- }
- $keyTbl->addItems($itemColl);
-
- $dialog->recalcLayout();
- $dialog->doneMultipleChanges();
- yui::YUI::ui()->unblockEvents();
- yui::YUI::app()->normalCursor();
- }
- };
-
- my $add_key = sub {
- my $sh_gui = ManaTools::Shared::GUI->new();
- my $item = $mediaTbl->selectedItem();
- if ($item) {
- $current_medium = $item->label();
- $current_medium_nb = $item->index();
- my @list;
- my %key;
- foreach (keys %{$urpm->{keys}}) {
- my $k = sprintf("%s (%s)", $_, $key_name->($_));
- $key{$k} = $_;
- push @list, $k;
- }
-
- my $choice = $sh_gui->ask_fromList({
- title => $loc->N("Add a key"),
- header => $loc->N("Choose a key to add to the medium %s", $current_medium),
- list => \@list,
- });
- if ($choice) {
- my $k = $key{$choice};
- $urpm->{media}[$current_medium_nb]{'key-ids'} = join(',', sort(uniq(@{$keys[$current_medium_nb]}, $k)));
- $write->();
- return 1;
- }
- }
- return 0;
- };
-
- my $remove_key = sub {
- my $sh_gui = ManaTools::Shared::GUI->new();
- my $keyItem = $keyTbl->selectedItem();
- my $mediaItem = $mediaTbl->selectedItem();
- if ($keyItem && $mediaItem) {
- $current_medium = $mediaItem->label();
- $current_medium_nb = $mediaItem->index();
- my $current_key = $keyItem->label();
- my $current_keyVal = yui::toYTableItem($keyItem)->cell(0)->label();
- my $choice = $sh_gui->ask_YesOrNo({
- title => $loc->N("Remove a key"),
- text => $loc->N("Are you sure you want to remove the key <br>%s<br> from medium %s?<br>(name of the key: %s)",
- $current_keyVal, $current_medium, $current_key
- ),
- richtext => 1,
- });
- if ($choice) {
- $urpm->{media}[$current_medium_nb]{'key-ids'} = join(',',
- difference2(\@{$keys[$current_medium_nb]}, [ $current_key ])
- );
- $write->();
- return 1;
- }
- }
-
- return 0;
-
- };
-
-
- #### end subroutines
- $sel_changed->();
-
- my $rightContent = $factory->createRight($hbox_content);
- $rightContent->setWeight($yui::YD_HORIZ,1);
- my $topContent = $factory->createTop($rightContent);
- my $vbox_commands = $factory->createVBox($topContent);
- $factory->createVSpacing($vbox_commands, 1.0);
- my $addButton = $factory->createPushButton($factory->createHBox($vbox_commands), $loc->N("Add"));
- my $remButton = $factory->createPushButton($factory->createHBox($vbox_commands), $loc->N("Remove"));
-
- # dialog buttons
- $factory->createVSpacing($vbox, 1.0);
- $hbox = $factory->createHBox( $vbox );
-
- ### Close button
- my $closeButton = $factory->createPushButton($hbox, $loc->N("&Quit") );
-
- ### dialog event loop
- while(1) {
- my $event = $dialog->waitForEvent();
- my $eventType = $event->eventType();
- my $changed = 0;
- my $selection_changed = 0;
-
- #event type checking
- if ($eventType == $yui::YEvent::CancelEvent) {
- last;
- }
- elsif ($eventType == $yui::YEvent::WidgetEvent) {
- # widget selected
- my $widget = $event->widget();
- my $wEvent = yui::toYWidgetEvent($event);
-
- if ($widget == $closeButton) {
- last;
- }
- elsif ($widget == $addButton) {
- $changed = $add_key->();
- $sel_changed->() if $changed;
- }
- elsif ($widget == $remButton) {
- $changed = $remove_key->();
- $sel_changed->() if $changed;
- }
- elsif ($widget == $mediaTbl) {
- $sel_changed->();
- }
- }
- }
-
- $dialog->destroy();
-
- #restore old application title
- yui::YUI::app()->setApplicationTitle($appTitle) if $appTitle;
-
- return $changed;
-}
-
-#=============================================================
-
-=head2 readMedia
-
-=head3 INPUT
-
-$name: optional parameter, the media called name has to be
- updated
-
-=head3 OUTPUT
-
-$itemColl: yui::YItemCollection containing media data to
- be added to the YTable
-
-=head3 DESCRIPTION
-
-This method reads the configured media and add their info
-to the collection
-
-=cut
-
-#=============================================================
-sub readMedia {
- my ($name) = @_;
- if (defined $name) {
- urpm::media::select_media($urpm, $name);
- update_sources_check(
- $urpm,
- { nolock => 1 },
- $loc->N_("Unable to update medium, errors reported:\n\n%s"),
- $name,
- );
- }
- # reread configuration after updating media else ignore bit will be restored
- # by urpm::media::check_existing_medium():
- $urpm = fast_open_urpmi_db();
-
- my $itemColl = new yui::YItemCollection;
- foreach (grep { ! $_->{external} } @{$urpm->{media}}) {
- my $name = $_->{name};
-
- my $item = new yui::YTableItem (($_->{ignore} ? "" : "X"),
- ($_->{update} ? "X" : ""),
- get_medium_type($_),
- $name);
- ## NOTE anaselli: next lines add check icon to cells, but they are 8x8, a dimension should
- ## be evaluated by font size, so disabled atm
-# my $cell = $item->cell(0); # Checked
-# my $checkedIcon = File::ShareDir::dist_file(ManaTools::Shared::distName(), 'images/Check_8x8.png');
-#
-# $cell->setIconName($checkedIcon) if (!$_->{ignore});
-# $cell = $item->cell(1); # Updates
-# $cell->setIconName($checkedIcon) if ($_->{update});
- ## end icons on cells
-
- # TODO manage to_bool($::expert)
- # row # is $item->index()
- $item->setLabel( $name );
- $itemColl->push($item);
- $item->DISOWN();
- }
-
- return $itemColl;
-}
-
-#=============================================================
-
-=head2 selectRow
-
-=head3 INPUT
-
-$itemCollection: YItem collection in which to find the item that
- has to be selected
-$row: line to be selected
-
-=head3 DESCRIPTION
-
-Select item at row position
-=cut
-
-#=============================================================
-
-sub selectRow {
- my ($itemCollection, $row) = @_;
-
- return if !$itemCollection;
-
- for (my $it = 0; $it < $itemCollection->size(); $it++) {
- my $item = $itemCollection->get($it);
- if ($it == $row) {
- $item->setSelected(1);
- return;
- }
- }
-}
-
-#=============================================================
-
-=head2 _showMediaStatus
-
-=head3 INPUT
-
-$info: HASH reference containing
- item => selected item
- updates => updates checkbox widget
- enabled => enabled checkbox widget
-
-=head3 DESCRIPTION
-
-This internal function enables/disables checkboxes according to the
-passed item value.
-
-=cut
-
-#=============================================================
-sub _showMediaStatus {
- my $info = shift;
-
- die "Updates checkbox is mandatory" if !defined($info->{updates}) || !$info->{updates};
- die "Enabled checkbox is mandatory" if !defined($info->{enabled}) || !$info->{enabled};
-
- if (defined($info->{item})) {
- my $tableItem = yui::toYTableItem($info->{item});
- # enabled cell 0, updates cell 1
- my $cellEnabled = $tableItem && $tableItem->cell(0)->label() ? 1 : 0;
- my $cellUpdates = $tableItem && $tableItem->cell(1)->label() ? 1 : 0;
- $info->{enabled}->setValue($cellEnabled);
- $info->{updates}->setValue($cellUpdates);
- }
- else {
- $info->{enabled}->setDisabled();
- $info->{updates}->setDisabled();
- }
-}
-
-sub mainwindow() {
-
- my $something_changed = 0;
- my $appTitle = yui::YUI::app()->applicationTitle();
-
- ## set new title to get it in dialog
- yui::YUI::app()->setApplicationTitle($loc->N("Configure media"));
- ## set icon if not already set by external launcher TODO
- yui::YUI::app()->setApplicationIcon("/usr/share/mcc/themes/default/rpmdrake-mdk.png");
-
- my $mageiaPlugin = "mga";
- my $factory = yui::YUI::widgetFactory;
-
- my $dialog = $factory->createMainDialog;
- my $vbox = $factory->createVBox( $dialog );
-
- my $hbox_headbar = $factory->createHBox($vbox);
- my $head_align_left = $factory->createLeft($hbox_headbar);
- my $head_align_right = $factory->createRight($hbox_headbar);
- my $headbar = $factory->createHBox($head_align_left);
- my $headRight = $factory->createHBox($head_align_right);
-
- my %fileMenu = (
- widget => $factory->createMenuButton($headbar,$loc->N("File")),
- update => new yui::YMenuItem($loc->N("Update")),
- add_media => new yui::YMenuItem($loc->N("Add a specific media mirror")),
- custom => new yui::YMenuItem($loc->N("Add a custom medium")),
- quit => new yui::YMenuItem($loc->N("&Quit")),
- );
-
- my @ordered_menu_lines = qw(update add_media custom quit);
- foreach (@ordered_menu_lines) {
- $fileMenu{ widget }->addItem($fileMenu{ $_ });
- }
- $fileMenu{ widget }->rebuildMenuTree();
-
- my %optionsMenu = (
- widget => $factory->createMenuButton($headbar, $loc->N("&Options")),
- global => new yui::YMenuItem($loc->N("Global options")),
- man_keys => new yui::YMenuItem($loc->N("Manage keys")),
- parallel => new yui::YMenuItem($loc->N("Parallel")),
- proxy => new yui::YMenuItem($loc->N("Proxy")),
- );
- @ordered_menu_lines = qw(global man_keys parallel proxy);
- foreach (@ordered_menu_lines) {
- $optionsMenu{ widget }->addItem($optionsMenu{ $_ });
- }
- $optionsMenu{ widget }->rebuildMenuTree();
-
- my %helpMenu = (
- widget => $factory->createMenuButton($headRight, $loc->N("&Help")),
- help => new yui::YMenuItem($loc->N("Manual")),
- report_bug => new yui::YMenuItem($loc->N("Report Bug")),
- about => new yui::YMenuItem($loc->N("&About")),
- );
- @ordered_menu_lines = qw(help report_bug about);
- foreach (@ordered_menu_lines) {
- $helpMenu{ widget }->addItem($helpMenu{ $_ });
- }
- $helpMenu{ widget }->rebuildMenuTree();
-
-# my %contextMenu = (
-# enable => $loc->N("Enable/Disable"),
-# update => $loc->N("Check as updates"),
-# );
-# @ordered_menu_lines = qw(enable update);
-# my $itemColl = new yui::YItemCollection;
-# foreach (@ordered_menu_lines) {
-# # last if (!$::expert && $_ eq "update");
-# my $item = new yui::YMenuItem($contextMenu{$_});
-# $item->DISOWN();
-# $itemColl->push($item);
-# }
-# yui::YUI::app()->openContextMenu($itemColl) or die "Cannot create contextMenu";
-
- my $hbox_content = $factory->createHBox($vbox);
- my $leftContent = $factory->createLeft($hbox_content);
- $leftContent->setWeight($yui::YD_HORIZ,3);
-
- my $frame = $factory->createFrame ($leftContent, "");
-
- my $frmVbox = $factory->createVBox( $frame );
- my $hbox = $factory->createHBox( $frmVbox );
-
- my $yTableHeader = new yui::YTableHeader();
- $yTableHeader->addColumn($loc->N("Enabled"), $yui::YAlignCenter);
- $yTableHeader->addColumn($loc->N("Updates"), $yui::YAlignCenter);
- $yTableHeader->addColumn($loc->N("Type"), $yui::YAlignBegin);
- $yTableHeader->addColumn($loc->N("Medium"), $yui::YAlignBegin);
-
- ## mirror list
- my $multiselection = 1;
- my $mirrorTbl = $factory->createTable($hbox, $yTableHeader, $multiselection);
- $mirrorTbl->setKeepSorting(1);
- $mirrorTbl->setImmediateMode(1);
-
- my $itemCollection = readMedia();
- selectRow($itemCollection, 0); #default selection
- $mirrorTbl->addItems($itemCollection);
-
- my $rightContent = $factory->createRight($hbox_content);
- $rightContent->setWeight($yui::YD_HORIZ,1);
- my $topContent = $factory->createTop($rightContent);
- my $vbox_commands = $factory->createVBox($topContent);
- $factory->createVSpacing($vbox_commands, 1.0);
- my $remButton = $factory->createPushButton($factory->createHBox($vbox_commands), $loc->N("Remove"));
- my $edtButton = $factory->createPushButton($factory->createHBox($vbox_commands), $loc->N("Edit"));
- my $addButton = $factory->createPushButton($factory->createHBox($vbox_commands), $loc->N("Add"));
-
- $hbox = $factory->createHBox( $vbox_commands );
- my $item = $mirrorTbl->selectedItem();
- $factory->createHSpacing($hbox, 1.0);
- my $enabled = $factory->createCheckBox($factory->createLeft($hbox), $loc->N("Enabled"));
- my $update = $factory->createCheckBox($factory->createLeft($hbox), $loc->N("Updates"));
- _showMediaStatus({item => $item, enabled => $enabled, updates => $update});
- $update->setNotify(1);
- $enabled->setNotify(1);
- $update->setDisabled() if (!$::expert);
-
- $hbox = $factory->createHBox( $vbox_commands );
- ## TODO icon and label for ncurses
- my $upIcon = File::ShareDir::dist_file(ManaTools::Shared::distName(), 'images/Up_16x16.png');
- my $downIcon = File::ShareDir::dist_file(ManaTools::Shared::distName(), 'images/Down_16x16.png');
- my $upButton = $factory->createPushButton($factory->createHBox($hbox), $loc->N("Up"));
- my $downButton = $factory->createPushButton($factory->createHBox($hbox), $loc->N("Down"));
- $upButton->setIcon($upIcon);
- $downButton->setIcon($downIcon);
-
- $addButton->setWeight($yui::YD_HORIZ,1);
- $edtButton->setWeight($yui::YD_HORIZ,1);
- $remButton->setWeight($yui::YD_HORIZ,1);
- $upButton->setWeight($yui::YD_HORIZ,1);
- $downButton->setWeight($yui::YD_HORIZ,1);
-
-
- # dialog buttons
- $factory->createVSpacing($vbox, 1.0);
- ## Window push buttons
- $hbox = $factory->createHBox( $vbox );
- my $align = $factory->createLeft($hbox);
- $hbox = $factory->createHBox($align);
-
- my $helpButton = $factory->createPushButton($hbox, $loc->N("Help") );
- $align = $factory->createRight($hbox);
- $hbox = $factory->createHBox($align);
-
- ### Close button
- my $closeButton = $factory->createPushButton($hbox, $loc->N("&Quit") );
-
- ### dialog event loop
- while(1) {
- my $event = $dialog->waitForEvent();
- my $eventType = $event->eventType();
- my $changed = 0;
- my $selection_changed = 0;
-
- #event type checking
- if ($eventType == $yui::YEvent::CancelEvent) {
- last;
- }
- elsif ($eventType == $yui::YEvent::MenuEvent) {
- ### MENU ###
- my $item = $event->item();
- my $menuLabel = $item->label();
- if ($menuLabel eq $fileMenu{ quit }->label()) {
- last;
- }
- elsif ($menuLabel eq $helpMenu{ about }->label()) {
- my $translators = $loc->N("_: Translator(s) name(s) & email(s)\n");
- $translators =~ s/\</\&lt\;/g;
- $translators =~ s/\>/\&gt\;/g;
- my $sh_gui = ManaTools::Shared::GUI->new();
- $sh_gui->AboutDialog({ name => "Rpmdragora",
- version => $VERSION,
- credits => $loc->N("Copyright (C) %s Mageia community", '2013-2014'),
- license => $loc->N("GPLv2"),
- description => $loc->N("Rpmdragora is the Mageia package management tool."),
- authors => $loc->N("<h3>Developers</h3>
- <ul><li>%s</li>
- <li>%s</li>
- </ul>
- <h3>Translators</h3>
- <ul><li>%s</li></ul>",
- "Angelo Naselli &lt;anaselli\@linux.it&gt;",
- "Matteo Pasotti &lt;matteo.pasotti\@gmail.com&gt;",
- $translators
- ),
- }
- );
- }
- elsif ($menuLabel eq $fileMenu{ update }->label()) {
- update_callback();
- }
- elsif ($menuLabel eq $fileMenu{ add_media }->label()) {
- $changed = easy_add_callback_with_mirror();
- }
- elsif ($menuLabel eq $fileMenu{ custom }->label()) {
- $changed = add_callback();
- }
- elsif ($menuLabel eq $optionsMenu{ proxy }->label()) {
- proxy_callback();
- }
- elsif ($menuLabel eq $optionsMenu{ global }->label()) {
- options_callback();
- }
- elsif ($menuLabel eq $optionsMenu{ man_keys }->label()) {
- $changed = keys_callback();
- }
- elsif ($menuLabel eq $optionsMenu{ parallel }->label()) {
-# parallel_callback();
- }
- }
- elsif ($eventType == $yui::YEvent::WidgetEvent) {
- # widget selected
- my $widget = $event->widget();
- my $wEvent = yui::toYWidgetEvent($event);
-
- if ($widget == $closeButton) {
- last;
- }
- elsif ($widget == $helpButton) {
- }
- elsif ($widget == $upButton) {
- yui::YUI::app()->busyCursor();
- yui::YUI::ui()->blockEvents();
- $dialog->startMultipleChanges();
-
- my $row = upwards_callback($mirrorTbl);
-
- $mirrorTbl->deleteAllItems();
- my $itemCollection = readMedia();
- selectRow($itemCollection, $row);
- $mirrorTbl->addItems($itemCollection);
-
- $dialog->recalcLayout();
- $dialog->doneMultipleChanges();
- yui::YUI::ui()->unblockEvents();
- yui::YUI::app()->normalCursor();
- }
- elsif ($widget == $downButton) {
- yui::YUI::app()->busyCursor();
- yui::YUI::ui()->blockEvents();
- $dialog->startMultipleChanges();
-
- my $row = downwards_callback($mirrorTbl);
-
- $mirrorTbl->deleteAllItems();
- my $itemCollection = readMedia();
- selectRow($itemCollection, $row);
- $mirrorTbl->addItems($itemCollection);
-
- $dialog->recalcLayout();
- $dialog->doneMultipleChanges();
- yui::YUI::ui()->unblockEvents();
- yui::YUI::app()->normalCursor();
- }
- elsif ($widget == $edtButton) {
- my $item = $mirrorTbl->selectedItem();
- if ($item && edit_callback($mirrorTbl) ) {
- my $row = $item->index();
- yui::YUI::app()->busyCursor();
- yui::YUI::ui()->blockEvents();
-
- $dialog->startMultipleChanges();
-
- my $ignored = $urpm->{media}[$row]{ignore};
- my $itemCollection = readMedia();
- if (!$ignored && $urpm->{media}[$row]{ignore}) {
- # reread media failed to un-ignore an ignored medium
- # probably because urpm::media::check_existing_medium() complains
- # about missing synthesis when the medium never was enabled before;
- # thus it restored the ignore bit
- $urpm->{media}[$row]{ignore} = !$urpm->{media}[$row]{ignore} || undef;
- urpm::media::write_config($urpm);
- #- Enabling this media failed, force update
- interactive_msg('rpmdragora',
- $loc->N("This medium needs to be updated to be usable. Update it now?"),
- yesno => 1,
- ) and $itemCollection = readMedia($urpm->{media}[$row]{name});
- }
- $mirrorTbl->deleteAllItems();
- selectRow($itemCollection, $row);
- $mirrorTbl->addItems($itemCollection);
-
- $dialog->recalcLayout();
- $dialog->doneMultipleChanges();
- yui::YUI::ui()->unblockEvents();
- yui::YUI::app()->normalCursor();
- $selection_changed = 1; # to align $enabled and $update status
- }
- }
- elsif ($widget == $remButton) {
- my $sel = $mirrorTbl->selectedItems();
- $changed = remove_callback($sel);
- }
- elsif ($widget == $addButton) {
- $changed = easy_add_callback();
- }
- elsif ($widget == $update) {
- my $item = $mirrorTbl->selectedItem();
- if ($item) {
- yui::YUI::app()->busyCursor();
- my $row = $item->index();
- $urpm->{media}[$row]{update} = !$urpm->{media}[$row]{update} || undef;
- urpm::media::write_config($urpm);
- yui::YUI::ui()->blockEvents();
- $dialog->startMultipleChanges();
- $mirrorTbl->deleteAllItems();
- my $itemCollection = readMedia();
- selectRow($itemCollection, $row);
- $mirrorTbl->addItems($itemCollection);
- $dialog->recalcLayout();
- $dialog->doneMultipleChanges();
- yui::YUI::ui()->unblockEvents();
- yui::YUI::app()->normalCursor();
- }
- }
- elsif ($widget == $enabled) {
- ## TODO same as $edtButton after edit_callback
- my $item = $mirrorTbl->selectedItem();
- if ($item) {
- my $row = $item->index();
- yui::YUI::app()->busyCursor();
- yui::YUI::ui()->blockEvents();
-
- $dialog->startMultipleChanges();
-
- $urpm->{media}[$row]{ignore} = !$urpm->{media}[$row]{ignore} || undef;
- urpm::media::write_config($urpm);
- my $ignored = $urpm->{media}[$row]{ignore};
- my $itemCollection = readMedia();
- if (!$ignored && $urpm->{media}[$row]{ignore}) {
- # reread media failed to un-ignore an ignored medium
- # probably because urpm::media::check_existing_medium() complains
- # about missing synthesis when the medium never was enabled before;
- # thus it restored the ignore bit
- $urpm->{media}[$row]{ignore} = !$urpm->{media}[$row]{ignore} || undef;
- urpm::media::write_config($urpm);
- #- Enabling this media failed, force update
- interactive_msg('rpmdragora',
- $loc->N("This medium needs to be updated to be usable. Update it now?"),
- yesno => 1,
- ) and $itemCollection = readMedia($urpm->{media}[$row]{name});
- }
- $mirrorTbl->deleteAllItems();
- selectRow($itemCollection, $row);
- $mirrorTbl->addItems($itemCollection);
-
- $dialog->recalcLayout();
- $dialog->doneMultipleChanges();
- yui::YUI::ui()->unblockEvents();
- yui::YUI::app()->normalCursor();
- }
- }
- elsif ($widget == $mirrorTbl) {
- $selection_changed = 1;
- }
- }
- if ($changed) {
- yui::YUI::app()->busyCursor();
- yui::YUI::ui()->blockEvents();
-
- $dialog->startMultipleChanges();
-
- $mirrorTbl->deleteAllItems();
- my $itemCollection = readMedia();
- selectRow($itemCollection, 0); #default selection
- $mirrorTbl->addItems($itemCollection);
-
- $dialog->recalcLayout();
- $dialog->doneMultipleChanges();
- yui::YUI::app()->normalCursor();
- $selection_changed = 1;
- }
- if ($selection_changed) {
- yui::YUI::ui()->blockEvents();
- my $item = $mirrorTbl->selectedItem();
- _showMediaStatus({item => $item, enabled => $enabled, updates => $update});
-
- my $sel = $mirrorTbl->selectedItems();
- if ($sel->size() == 0 || $sel->size() > 1 ) {
- $remButton->setEnabled(($sel->size() == 0) ? 0 : 1);
- $edtButton->setEnabled(0);
- $upButton->setEnabled(0);
- $downButton->setEnabled(0);
- $enabled->setEnabled(0);
- $update->setEnabled(0);
- }
- else {
- $remButton->setEnabled(1);
- $edtButton->setEnabled(1);
- $upButton->setEnabled(1);
- $downButton->setEnabled(1);
- $enabled->setEnabled(1);
- $update->setEnabled(1) if $::expert;
- }
-
- yui::YUI::ui()->unblockEvents();
- }
- }
- $dialog->destroy();
-
- #restore old application title
- yui::YUI::app()->setApplicationTitle($appTitle) if $appTitle;
-
- return $something_changed;
-}
-
-
-sub OLD_mainwindow() {
- undef $something_changed;
- $mainw = ugtk2->new($loc->N("Configure media"), center => 1, transient => $::main_window, modal => 1);
- local $::main_window = $mainw->{real_window};
-
- my $reread_media;
-
- my ($menu, $_factory) = create_factory_menu(
- $mainw->{real_window},
- [ $loc->N("/_File"), undef, undef, undef, '<Branch>' ],
- [ $loc->N("/_File") . $loc->N("/_Update"), $loc->N("<control>U"), sub { update_callback() and $reread_media->() }, undef, '<Item>', ],
- [ $loc->N("/_File") . $loc->N("/Add a specific _media mirror"), $loc->N("<control>M"), sub { easy_add_callback_with_mirror() and $reread_media->() }, undef, '<Item>' ],
- [ $loc->N("/_File") . $loc->N("/_Add a custom medium"), $loc->N("<control>A"), sub { add_callback() and $reread_media->() }, undef, '<Item>' ],
- [ $loc->N("/_File") . $loc->N("/Close"), $loc->N("<control>W"), sub { Gtk2->main_quit }, undef, '<Item>', ],
- [ $loc->N("/_Options"), undef, undef, undef, '<Branch>' ],
- [ $loc->N("/_Options") . $loc->N("/_Global options"), $loc->N("<control>G"), \&options_callback, undef, '<Item>' ],
- [ $loc->N("/_Options") . $loc->N("/Manage _keys"), $loc->N("<control>K"), \&keys_callback, undef, '<Item>' ],
- [ $loc->N("/_Options") . $loc->N("/_Parallel"), $loc->N("<control>P"), \&parallel_callback, undef, '<Item>' ],
- [ $loc->N("/_Options") . $loc->N("/P_roxy"), $loc->N("<control>R"), \&proxy_callback, undef, '<Item>' ],
- if_($0 =~ /edit-urpm-sources/,
- [ $loc->N("/_Help"), undef, undef, undef, '<Branch>' ],
- [ $loc->N("/_Help") . $loc->N("/_Report Bug"), undef, sub { run_drakbug('edit-urpm-sources.pl') }, undef, '<Item>' ],
- [ $loc->N("/_Help") . $loc->N("/_Help"), undef, sub { rpmdragora::open_help('sources') }, undef, '<Item>' ],
- [ $loc->N("/_Help") . $loc->N("/_About..."), undef, sub {
- my $license = MDK::Common::String::formatAlaTeX(translate($::license));
- $license =~ s/\n/\n\n/sg; # nicer formatting
- my $w = gtknew('AboutDialog', name => $loc->N("Rpmdragora"),
- version => $rpmdragora::distro_version,
- copyright => $loc->N("Copyright (C) %s by Mandriva", '2002-2008'),
- license => $license, wrap_license => 1,
- comments => $loc->N("Rpmdragora is the Mageia package management tool."),
- website => 'http://www.mageia.org/',
- website_label => $loc->N("Mageia"),
- authors => 'Thierry Vignaud <vignaud@mandriva.com>',
- artists => 'Hélène Durosini <ln@mandriva.com>',
- translator_credits =>
- #-PO: put here name(s) and email(s) of translator(s) (eg: "John Smith <jsmith@nowhere.com>")
- $loc->N("_: Translator(s) name(s) & email(s)\n"),
- transient_for => $::main_window, modal => 1, position_policy => 'center-on-parent',
- );
- $w->show_all;
- $w->run;
- }, undef, '<Item>'
- ]
- ),
- );
-
- my $list = Gtk2::ListStore->new("Glib::Boolean", "Glib::Boolean", "Glib::String", "Glib::String", "Glib::Boolean");
- $list_tv = Gtk2::TreeView->new_with_model($list);
- $list_tv->get_selection->set_mode('multiple');
- my ($dw_button, $edit_button, $remove_button, $up_button);
- $list_tv->get_selection->signal_connect(changed => sub {
- my ($selection) = @_;
- my @rows = $selection->get_selected_rows;
- my $model = $list;
- # we can delete several medium at a time:
- $remove_button and $remove_button->set_sensitive($#rows != -1);
- # we can only edit/move one item at a time:
- $_ and $_->set_sensitive(@rows == 1) foreach $up_button, $dw_button, $edit_button;
-
- # we can only up/down one item if not at begin/end:
- return if @rows != 1;
-
- my $curr_path = $rows[0];
- my $first_path = $model->get_path($model->get_iter_first);
- $up_button->set_sensitive($first_path && $first_path->compare($curr_path));
-
- $curr_path->next;
- my $next_item = $model->get_iter($curr_path);
- $dw_button->set_sensitive($next_item); # && !$model->get($next_item, 0)
- });
-
- $list_tv->set_rules_hint(1);
- $list_tv->set_reorderable(1);
-
- my $reorder_ok = 1;
- $list->signal_connect(
- row_deleted => sub {
- $reorder_ok or return;
- my ($model) = @_;
- my @media;
- $model->foreach(
- sub {
- my (undef, undef, $iter) = @_;
- my $name = $model->get($iter, $col{mainw}{name});
- push @media, urpm::media::name2medium($urpm, $name);
- 0;
- }, undef);
- @{$urpm->{media}} = @media;
- },
- );
-
- $list_tv->append_column(Gtk2::TreeViewColumn->new_with_attributes($loc->N("Enabled"),
- my $tr = Gtk2::CellRendererToggle->new,
- 'active' => $col{mainw}{is_enabled}));
- $list_tv->append_column(Gtk2::TreeViewColumn->new_with_attributes($loc->N("Updates"),
- my $cu = Gtk2::CellRendererToggle->new,
- 'active' => $col{mainw}{is_update},
- activatable => $col{mainw}{activatable}));
- $list_tv->append_column(Gtk2::TreeViewColumn->new_with_attributes($loc->N("Type"),
- Gtk2::CellRendererText->new,
- 'text' => $col{mainw}{type}));
- $list_tv->append_column(Gtk2::TreeViewColumn->new_with_attributes($loc->N("Medium"),
- Gtk2::CellRendererText->new,
- 'text' => $col{mainw}{name}));
- my $id;
- $id = $tr->signal_connect(
- toggled => sub {
- my (undef, $path) = @_;
- $tr->signal_handler_block($id);
- my $_guard = before_leaving { $tr->signal_handler_unblock($id) };
- my $iter = $list->get_iter_from_string($path);
- $urpm->{media}[$path]{ignore} = !$urpm->{media}[$path]{ignore} || undef;
- $list->set($iter, $col{mainw}{is_enabled}, !$urpm->{media}[$path]{ignore});
- urpm::media::write_config($urpm);
- my $ignored = $urpm->{media}[$path]{ignore};
- $reread_media->();
- if (!$ignored && $urpm->{media}[$path]{ignore}) {
- # reread media failed to un-ignore an ignored medium
- # probably because urpm::media::check_existing_medium() complains
- # about missing synthesis when the medium never was enabled before;
- # thus it restored the ignore bit
- $urpm->{media}[$path]{ignore} = !$urpm->{media}[$path]{ignore} || undef;
- urpm::media::write_config($urpm);
- #- Enabling this media failed, force update
- interactive_msg('rpmdragora',
- $loc->N("This medium needs to be updated to be usable. Update it now?"),
- yesno => 1,
- ) and $reread_media->($urpm->{media}[$path]{name});
- }
- },
- );
-
- $cu->signal_connect(
- toggled => sub {
- my (undef, $path) = @_;
- my $iter = $list->get_iter_from_string($path);
- $urpm->{media}[$path]{update} = !$urpm->{media}[$path]{update} || undef;
- $list->set($iter, $col{mainw}{is_update}, ! !$urpm->{media}[$path]{update});
- $something_changed = 1;
- },
- );
-
- $reread_media = sub {
- my ($name) = @_;
- $reorder_ok = 0;
- $something_changed = 1;
- if (defined $name) {
- urpm::media::select_media($urpm, $name);
- update_sources_check(
- $urpm,
- { nolock => 1 },
- $loc->N_("Unable to update medium, errors reported:\n\n%s"),
- $name,
- );
- }
- # reread configuration after updating media else ignore bit will be restored
- # by urpm::media::check_existing_medium():
- $urpm = fast_open_urpmi_db();
- $list->clear;
- foreach (grep { ! $_->{external} } @{$urpm->{media}}) {
- my $name = $_->{name};
- $list->append_set($col{mainw}{is_enabled} => !$_->{ignore},
- $col{mainw}{is_update} => ! !$_->{update},
- $col{mainw}{type} => get_medium_type($_),
- $col{mainw}{name} => $name,
- $col{mainw}{activatable} => to_bool($::expert),
- );
- }
- $reorder_ok = 1;
- };
- $reread_media->();
- $something_changed = 0;
-
- gtkadd(
- $mainw->{window},
- gtkpack_(
- gtknew('VBox', spacing => 5),
- 0, $menu,
- ($0 =~ /rpm-edit-media|edit-urpm-sources/ ? (0, Gtk2::Banner->new($ugtk2::wm_icon, $loc->N("Configure media"))) : ()),
- 1, gtkpack_(
- gtknew('HBox', spacing => 10),
- 1, gtknew('ScrolledWindow', child => $list_tv),
- 0, gtkpack__(
- gtknew('VBox', spacing => 5),
- gtksignal_connect(
- $remove_button = Gtk2::Button->new(but($loc->N("Remove"))),
- clicked => sub { remove_callback() and $reread_media->() },
- ),
- gtksignal_connect(
- $edit_button = Gtk2::Button->new(but($loc->N("Edit"))),
- clicked => sub {
- my $name = edit_callback(); defined $name and $reread_media->($name);
- }
- ),
- gtksignal_connect(
- Gtk2::Button->new(but($loc->N("Add"))),
- clicked => sub { easy_add_callback() and $reread_media->() },
- ),
- gtkpack(
- gtknew('HBox'),
- gtksignal_connect(
- $up_button = gtknew('Button',
- image => gtknew('Image', stock => 'gtk-go-up')),
- clicked => \&upwards_callback),
-
- gtksignal_connect(
- $dw_button = gtknew('Button',
- image => gtknew('Image', stock => 'gtk-go-down')),
- clicked => \&downwards_callback),
- ),
- )
- ),
- 0, gtknew('HSeparator'),
- 0, gtknew('HButtonBox', layout => 'edge', children_loose => [
- gtksignal_connect(Gtk2::Button->new(but($loc->N("Help"))), clicked => sub { rpmdragora::open_help('sources') }),
- gtksignal_connect(Gtk2::Button->new(but($loc->N("Ok"))), clicked => sub { Gtk2->main_quit })
- ])
- )
- );
- $_->set_sensitive(0) foreach $dw_button, $edit_button, $remove_button, $up_button;
-
- $mainw->{rwindow}->set_size_request(600, 400);
- $mainw->main;
- return $something_changed;
-}
-
-
-sub run() {
- # ignore rpmdragora's option regarding ignoring debug media:
- local $ignore_debug_media = [ 0 ];
-# local $ugtk2::wm_icon = get_icon('rpmdragora-mdk', 'title-media');
- my $lock;
- {
- $urpm = fast_open_urpmi_db();
- my $err_msg = "urpmdb locked\n";
- local $urpm->{fatal} = sub {
- interactive_msg('rpmdragora',
- $loc->N("The Package Database is locked. Please close other applications
-working with the Package Database. Do you have another media
-manager on another desktop, or are you currently installing
-packages as well?"));
- die $err_msg;
- };
- # lock urpmi DB
- eval { $lock = urpm::lock::urpmi_db($urpm, 'exclusive', wait => $urpm->{options}{wait_lock}) };
- if (my $err = $@) {
- return if $err eq $err_msg;
- die $err;
- }
- }
-
- my $res = mainwindow();
- urpm::media::write_config($urpm);
-
- writeconf();
-
- undef $lock;
- $res;
-}
-
-sub readproxy (;$) {
- my $proxy = get_proxy($_[0]);
- ($proxy->{http_proxy} || $proxy->{ftp_proxy} || '',
- defined $proxy->{user} ? "$proxy->{user}:$proxy->{pwd}" : '');
-}
-
-sub writeproxy {
- my ($proxy, $proxy_user, $o_media_name) = @_;
- my ($user, $pwd) = split /:/, $proxy_user;
- set_proxy_config(user => $user, $o_media_name);
- set_proxy_config(pwd => $pwd, $o_media_name);
- set_proxy_config(http_proxy => $proxy, $o_media_name);
- set_proxy_config(ftp_proxy => $proxy, $o_media_name);
- dump_proxy_config();
-}
-
-1;
diff --git a/lib/AdminPanel/Rpmdragora/formatting.pm b/lib/AdminPanel/Rpmdragora/formatting.pm
deleted file mode 100644
index 83a960ab..00000000
--- a/lib/AdminPanel/Rpmdragora/formatting.pm
+++ /dev/null
@@ -1,209 +0,0 @@
-# vim: set et ts=4 sw=4:
-package ManaTools::Rpmdragora::formatting;
-#*****************************************************************************
-#
-# Copyright (c) 2002 Guillaume Cottenceau
-# Copyright (c) 2002-2006 Thierry Vignaud <tvignaud@mandriva.com>
-# Copyright (c) 2003, 2004, 2005 MandrakeSoft SA
-# Copyright (c) 2005, 2006 Mandriva SA
-# Copyright (c) 2013 - 2015 Matteo Pasotti <matteo.pasotti@gmail.com>
-# Copyright (c) 2014 - 2015 Angelo Naselli <anaselli@linux.it>
-#
-# 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: formatting.pm 261189 2009-10-01 14:44:39Z tv $
-
-use strict;
-use utf8;
-use POSIX qw(strftime);
-use MDK::Common::Various qw(internal_error);
-use ManaTools::Shared::Locales;
-use ManaTools::rpmdragora;
-use urpm::msg;
-
-
-use Exporter;
-our @ISA = qw(Exporter);
-our @EXPORT = qw(
- $spacing
- ensure_utf8
- format_changelog_changelogs
- format_changelog_string
- format_field
- format_header
- format_list
- format_name_n_summary
- format_size
- format_filesize
- format_update_field
- my_fullname
- pkg2medium
- rpm_description
- split_fullname
- urpm_name
- );
-
-my $loc = ManaTools::rpmdragora::locale();
-
-sub escape_text_for_TextView_markup_format {
- my ($str) = @_;
- return '' if !$str;
-
- my %rules = ('&' => '&amp;',
- '<' => '&lt;',
- '>' => '&gt;',
- );
- eval { $str =~ s!([&<>])!$rules{$1}!g }; #^(&(amp|lt|gt);)!!) {
- if (my $err = $@) {
- MDK::Common::Various::internal_error("$err\n$str");
- }
- $str;
-}
-
-# from rpmtools, #37482:
-sub ensure_utf8 {
- return '' if !$_[0];
-
- if (utf8::is_utf8($_[0])) {
- utf8::valid($_[0]) and return;
- utf8::encode($_[0]); #- disable utf8 flag
- utf8::upgrade($_[0]);
- } else {
- utf8::decode($_[0]); #- try to set utf8 flag
- utf8::valid($_[0]) and return;
- warn "do not know what to with $_[0]\n";
- }
-}
-
-sub rpm_description {
- my ($description) = @_;
- return '' if !$description;
-
- ensure_utf8($description);
- my $t = "";
- my $tmp = "";
- foreach (split "\n", $description) {
- s/^\s*//;
- if (/^$/ || /^\s*(-|\*|\+|o)\s/) {
- $t || $tmp and $t .= "$tmp\n";
- $tmp = $_;
- } else {
- $tmp = ($tmp ? "$tmp " : ($t && "\n") . $tmp) . $_;
- }
- }
- "$t$tmp\n";
-}
-
-sub split_fullname { $_[0] =~ /^(.*)-([^-]+)-([^-]+)\.([^.-]+)$/ }
-
-sub my_fullname {
- return '?-?-?' unless ref $_[0];
- my ($name, $version, $release) = $_[0]->fullname;
- "$name-$version-$release";
-}
-
-sub urpm_name {
- return '?-?-?.?' unless ref $_[0];
- scalar $_[0]->fullname;
-}
-
-sub pkg2medium {
- my ($p, $urpm) = @_;
- return if !ref $p;
- return { name => $loc->N("None (installed)") } if !defined($p->id); # if installed
- URPM::pkg2media($urpm->{media}, $p) || { name => $loc->N("Unknown"), fake => 1 };
-}
-
-# [ duplicate urpmi's urpm::msg::localtime2changelog() ]
-#- strftime returns a string in the locale charset encoding;
-#- but gtk2 requires UTF-8, so we use to_utf8() to ensure the
-#- output of localtime2changelog() is always in UTF-8
-#- as to_utf8() uses LC_CTYPE for locale encoding and strftime() uses LC_TIME,
-#- it doesn't work if those two variables have values with different
-#- encodings; but if a user has a so broken setup we can't do much anyway
-sub localtime2changelog { $loc->to_utf8(POSIX::strftime("%c", localtime($_[0]))) }
-
-our $spacing = " ";
-sub format_changelog_string {
- my ($installed_version, $string) = @_;
-
- #- preprocess changelog for faster TextView insert reaction
- my $version;
- my $highlight;
- my $chl = [ map {
- my %attrs;
- if (/^\*/) {
- ($version) = /(\S*-\S*)\s*$/;
- $highlight = $installed_version ne $loc->N("(none)") && 0 < URPM::rpmvercmp($version, $installed_version);
- if ($highlight) {
- "<b><i>" . $_ . "</i></b>";
- }
- else {
- "<b>" . $_ . "</b>";
- }
- }
- else {
- "$spacing" . $_ . "\n";
- }
- } split("\n", $string) ];
-
- return $chl;
-}
-
-sub format_changelog_changelogs {
- my ($installed_version, @changelogs) = @_;
- format_changelog_string($installed_version, join("\n", map {
- "* " . localtime2changelog($_->{time}) . " $_->{name}\n\n$_->{text}\n";
- } @changelogs));
-}
-
-sub format_update_field {
- my ($name) = @_;
- '<i>' . escape_text_for_TextView_markup_format($name) . '</i>';
-}
-
-sub format_name_n_summary {
- my ($name, $summary) = @_;
- join("\n", '<b>' . $name . '</b>', escape_text_for_TextView_markup_format($summary));
-}
-
-sub format_header {
- my ($str) = @_;
- '<big>' . escape_text_for_TextView_markup_format($str) . '</big>';
-}
-
-sub format_field {
- my ($str) = @_;
- '<b>' . escape_text_for_TextView_markup_format($str) . '</b>';
-}
-
-sub format_size {
- my ($size) = @_;
- $size >= 0 ?
- $loc->N("%s of additional disk space will be used.", formatXiB($size)) :
- $loc->N("%s of disk space will be freed.", formatXiB(-$size));
-}
-
-sub format_filesize {
- my ($filesize) = @_;
- $filesize ? $loc->N("%s of packages will be retrieved.", formatXiB($filesize)) : ();
-}
-
-sub format_list {
- return join("\n", map { s/^(\s)/ $1/mg; "- $_" } sort { uc($a) cmp uc($b) } @_);
-}
-
-1;
diff --git a/lib/AdminPanel/Rpmdragora/gui.pm b/lib/AdminPanel/Rpmdragora/gui.pm
deleted file mode 100644
index 0cf08822..00000000
--- a/lib/AdminPanel/Rpmdragora/gui.pm
+++ /dev/null
@@ -1,1828 +0,0 @@
-# vim: set et ts=4 sw=4:
-package ManaTools::Rpmdragora::gui;
-#*****************************************************************************
-#
-# Copyright (c) 2002 Guillaume Cottenceau
-# Copyright (c) 2002-2007 Thierry Vignaud <tvignaud@mandriva.com>
-# Copyright (c) 2003, 2004, 2005 MandrakeSoft SA
-# Copyright (c) 2005-2007 Mandriva SA
-# Copyright (c) 2013 - 2015 Matteo Pasotti <matteo.pasotti@gmail.com>
-# Copyright (c) 2014 - 2015 Angelo Naselli <anaselli@linux.it>
-#
-# 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$
-
-############################################################
-# WARNING: do not modify before asking matteo or anaselli
-############################################################
-
-use strict;
-use Sys::Syslog;
-
-use utf8;
-
-use MDK::Common::Func qw(before_leaving find any if_);
-use MDK::Common::DataStructure qw(difference2 member intersection);
-use MDK::Common::Various qw(chomp_ to_bool);
-use MDK::Common::String qw(formatAlaTeX);
-use MDK::Common::Math qw(sum);
-use MDK::Common::System qw(list_passwd);
-
-use ManaTools::rpmdragora;
-use ManaTools::Rpmdragora::open_db;
-use ManaTools::Rpmdragora::formatting;
-use ManaTools::Rpmdragora::init;
-use ManaTools::Rpmdragora::icon qw(get_icon_path);
-use ManaTools::Rpmdragora::pkg;
-use ManaTools::Shared;
-use ManaTools::Shared::GUI;
-use ManaTools::Shared::Locales;
-use ManaTools::Shared::RunProgram qw(get_stdout raw);
-use yui;
-use feature 'state';
-use Carp;
-
-use Exporter;
-our @ISA = qw(Exporter);
-our @EXPORT = qw(
- $descriptions
- $find_entry
- $force_displaying_group
- $force_rebuild
- $pkgs
- $results_ok
- $results_none
- $size_free
- $size_selected
- $urpm
- %grp_columns
- %pkg_columns
- @filtered_pkgs
- @initial_selection
- ask_browse_tree_given_widgets_for_rpmdragora
- build_tree
- callback_choices
- compute_main_window_size
- do_action
- get_info
- get_summary
- group_has_parent
- group_parent
- groups_tree
- is_locale_available
- node_state
- pkgs_provider
- real_quit
- reset_search
- set_node_state
- sort_callback
- switch_pkg_list_mode
- toggle_all
- toggle_nodes
- fast_toggle
- setInfoOnWidget
- );
-
-my $loc = ManaTools::rpmdragora::locale();
-my $shared_gui = ManaTools::Shared::GUI->new() ;
-
-our ($descriptions, %filters, @filtered_pkgs, %filter_methods, $force_displaying_group, $force_rebuild, @initial_selection, $pkgs, $size_free, $size_selected, $urpm);
-our ($results_ok, $results_none) = ($loc->N("Search results"), $loc->N("Search results (none)"));
-
-our %hidden_info = (
- details => "details",
- changelog => "changelog",
- files => "file",
- new_deps => "new_deps",
-
-);
-our %grp_columns = (
- label => 0,
- icon => 2,
-);
-
-our %pkg_columns = (
- text => 0,
- state_icon => 1,
- state => 2,
- selected => 3,
- short_name => 4,
- version => 5,
- release => 6,
- 'arch' => 7,
- selectable => 8,
-);
-
-
-sub compute_main_window_size {
- my ($w) = @_;
- ($typical_width) = string_size($w->{real_window}, $loc->N("Graphical Environment") . "xmms-more-vis-plugins");
- $typical_width > 600 and $typical_width = 600; #- try to not being crazy with a too large value
- $typical_width < 150 and $typical_width = 150;
-}
-
-sub get_summary {
- my ($key) = @_;
- my $summary = $loc->N($pkgs->{$key}{pkg}->summary);
- require utf8;
- utf8::valid($summary) ? $summary : @{[]};
-}
-
-sub get_advisory_link {
- my ($update_descr) = @_;
-
- my $webref = "<br /><a href=\"". $update_descr->{URL} ."\">". $loc->N("Security advisory") ."</a><br />";
-
- [ $webref ];
-}
-
-sub get_description {
- my ($pkg, $update_descr) = @_;
-
- my $descr = ($pkg->{description} ||
- $update_descr->{description} ||
- '<i>'. $loc->N("No description").'</i>');
- $descr =~ s|\n|<br />|g;
-
- return $descr . "<br />";
-}
-
-sub get_string_from_keywords {
- my ($medium, $name) = @_;
- my @media_types;
- if ($medium->{mediacfg}) {
- my ($distribconf, $medium_path) = @{$medium->{mediacfg}};
- @media_types = split(':', $distribconf->getvalue($medium_path, 'media_type')) if $distribconf;
- }
-
- my $unsupported = $loc->N("It is <b>not supported</b> by Mageia.");
- my $dangerous = $loc->N("It may <b>break</b> your system.");
- my $s = "";
- $s .= $loc->N("This package is not free software") . "\n" if member('non-free', @media_types);
- if ($pkgs->{$name}{is_backport} || member('backport', @media_types)) {
- return join("\n",
- $loc->N("This package contains a new version that was backported."),
- $unsupported, $dangerous, $s);
- } elsif (member('testing', @media_types)) {
- return join("\n",
- $loc->N("This package is a potential candidate for an update."),
- $unsupported, $dangerous, $s);
- } elsif (member('updates', @media_types)) {
- return join("\n",
- (member('official', @media_types) ?
- $loc->N("This is an official update which is supported by Mageia.")
- : ($loc->N("This is an unofficial update."), $unsupported))
- ,
- $s);
- } else {
- $s .= $loc->N("This is an official package supported by Mageia") . "\n" if member('official', @media_types);
- return $s if $s;
- }
-
- return;
-}
-
-sub get_main_text {
- my ($medium, $fullname, $name, $summary, $is_update, $update_descr) = @_;
-
- my $txt = get_string_from_keywords($medium, $fullname);
- my $notice = format_field($loc->N("Notice: ")) . $txt if $txt;
- ensure_utf8($notice);
-
- my $hdr = "<h2>" . format_header(join(' - ', $name, $summary)) . "</h2>\n";
- ensure_utf8($hdr);
-
- my $update = MDK::Common::Func::if_($is_update, # is it an update?
- format_field($loc->N("Importance: ")) . format_update_field($update_descr->{importance}),
- format_field($loc->N("Reason for update: ")) . format_update_field(rpm_description($update_descr->{pre})),
- );
- ensure_utf8($update);
-
- my $main_text = $hdr;
- $main_text .= "&nbsp;&nbsp;&nbsp;" . $notice . "<br/>" if $notice;
- $main_text .= "&nbsp;&nbsp;&nbsp;" . $update . "<br/>" if $update;
-
- return $main_text;
-}
-
-sub get_details {
- my ($pkg, $upkg, $installed_version, $raw_medium) = @_;
- my @details = ();
- push @details, format_field($loc->N("Version: ")) . $upkg->EVR;
- push @details, format_field($loc->N("Currently installed version: ")) . $installed_version if($upkg->flag_installed);
- push @details, format_field($loc->N("Group: ")) . translate_group($upkg->group);
- push @details, format_field($loc->N("Architecture: ")) . $upkg->arch;
- push @details, format_field($loc->N("Size: ")) . $loc->N("%s KB", int($upkg->size/1024));
- push @details, eval { format_field($loc->N("Medium: ")) . $raw_medium->{name} };
-
- my @link = get_url_link($upkg, $pkg);
- push @details, join("<br />&nbsp;&nbsp;&nbsp;",@link) if(@link);
- unshift @details, "<br />&nbsp;&nbsp;&nbsp;";
- join("<br />&nbsp;&nbsp;&nbsp;", @details);
-}
-
-sub get_new_deps {
- my ($urpm, $upkg) = @_;
-
- my $deps = slow_func(sub {
- my $state = {};
- my $db = open_rpm_db();
- my @requested = $urpm->resolve_requested__no_suggests_(
- $db, $state,
- { $upkg->id => 1 },
- );
- @requested = $urpm->resolve_requested_suggests($db, $state, \@requested);
- undef $db;
- my @nodes_with_deps = map { urpm_name($_) } @requested;
- my @deps = sort { $a cmp $b } difference2(\@nodes_with_deps, [ urpm_name($upkg) ]);
- @deps = $loc->N("All dependencies installed.") if !@deps;
- return \@deps;
- });
- return $deps;
-}
-
-sub get_url_link {
- my ($upkg, $pkg) = @_;
-
- my $url = $upkg->url || $pkg->{url};
-
- if (!$url) {
- open_rpm_db()->traverse_tag_find('name', $upkg->name, sub { $url = $_[0]->url; return ($url ? 1 : 0) });
- }
-
- return if !$url;
-
- my @a;
- push @a, format_field($loc->N("URL: ")) . ${spacing} . "<a href=\"". $url ."\">". $url ."</a>";
- @a;
-}
-
-sub files_format {
- my ($files) = @_;
-
- return '<tt>' . $spacing . "<br />&nbsp;&nbsp;&nbsp;" . join("<br />&nbsp;&nbsp;&nbsp;", @$files) . '</tt>';
-}
-
-#=============================================================
-
-=head2 format_link
-
-=head3 INPUT
-
- $description: Description to be shown as link
- $url: to be reach when click on $description link
-
-=head3 OUTPUT
-
- $webref: href HTML tag
-
-=head3 DESCRIPTION
-
- This function returns an href string to be published
-
-=cut
-
-#=============================================================
-sub format_link {
- my ($description, $url) = @_;
-
- my $webref = "<a href=\"". $url ."\">". $description ."</a>";
-
- return $webref;
-}
-
-sub _format_pkg_simplifiedinfo {
- my ($pkgs, $key, $urpm, $descriptions, $options) = @_;
- my ($name) = split_fullname($key);
- my $pkg = $pkgs->{$key};
- my $upkg = $pkg->{pkg};
- return if !$upkg;
- my $raw_medium = pkg2medium($upkg, $urpm);
- my $medium = !$raw_medium->{fake} ? $raw_medium->{name} : undef;
- my $update_descr = $descriptions->{$medium}{$name};
- # discard update fields if not matching:
-
- my $is_update = ($upkg->flag_upgrade && $update_descr && $update_descr->{pre});
- my $summary = get_summary($key);
- my $dummy_string = get_main_text($raw_medium, $key, $name, $summary, $is_update, $update_descr);
- my $s;
- push @$s, $dummy_string;
- push @$s, get_advisory_link($update_descr) if $is_update;
-
- push @$s, get_description($pkg, $update_descr);
-
- my $installed_version = eval { find_installed_version($upkg) };
-
- #push @$s, [ gtkadd(gtkshow(my $details_exp = Gtk2::Expander->new(format_field($loc->N("Details:")))),
- # gtknew('TextView', text => get_details($pkg, $upkg, $installed_version, $raw_medium))) ];
- my $detail_link = format_link(format_field($loc->N("Details:")), $hidden_info{details} );
- if ($options->{details}) {
- my $details = get_details($pkg, $upkg, $installed_version, $raw_medium);
- utf8::encode($details);
- $detail_link .= "\n" . $details;
- }
- push @$s, join("\n", $detail_link, "\n");
-
- #push @$s, [ build_expander($pkg, $loc->N("Files:"), 'files', sub { files_format($pkg->{files}) }) ];
- my $files_link = format_link(format_field($loc->N("Files:")), $hidden_info{files} );
- if ($options->{files}) {
- my $wait = ManaTools::rpmdragora::wait_msg();
- if (!$pkg->{files}) {
- extract_header($pkg, $urpm, 'files', $installed_version);
- }
- my $files = $pkg->{files} ? files_format($pkg->{files}) : $loc->N("(Not available)");
- utf8::encode($files);
- $files_link .= "\n\n" . $files;
- ManaTools::rpmdragora::remove_wait_msg($wait);
- }
- push @$s, join("\n", $files_link, "\n");
-
- #push @$s, [ build_expander($pkg, $loc->N("Changelog:"), 'changelog', sub { $pkg->{changelog} }, $installed_version) ];
- my $changelog_link = format_link(format_field($loc->N("Changelog:")), $hidden_info{changelog} );
- if ($options->{changelog}) {
- my $wait = ManaTools::rpmdragora::wait_msg();
- my @changelog = $pkg->{changelog} ? @{$pkg->{changelog}} : ( $loc->N("(Not available)") );
- if (!$pkg->{changelog} || !scalar @{$pkg->{changelog}} ) {
- # my ($pkg, $label, $type, $get_data, $o_installed_version) = @_;
- extract_header($pkg, $urpm, 'changelog', $installed_version);
- @changelog = $pkg->{changelog} ? @{$pkg->{changelog}} : ( $loc->N("(Not available)") );
- }
- utf8::encode(\@changelog);
-
- $changelog_link .= "<br />&nbsp;&nbsp;&nbsp;" . join("<br />&nbsp;&nbsp;&nbsp;", @changelog);
- $changelog_link =~ s|\n||g;
- ManaTools::rpmdragora::remove_wait_msg($wait);
- }
- push @$s, join("\n\n", $changelog_link, "\n");
-
- my $deps_link = format_link(format_field($loc->N("New dependencies:")), $hidden_info{new_deps} );
- if ($options->{new_deps}) {
- if ($upkg->id) { # If not installed
- $deps_link .= "<br />&nbsp;&nbsp;&nbsp;" . join("<br />&nbsp;&nbsp;&nbsp;", @{get_new_deps($urpm, $upkg)});
- # push @$s, get_new_deps($urpm, $upkg);
- }
- }
- push @$s, join("\n", $deps_link, "\n");
-
- return $s;
-}
-
-sub warn_if_no_pkg {
- my ($name) = @_;
- my ($short_name) = split_fullname($name);
- state $warned;
- if (!$warned) {
- $warned = 1;
- interactive_msg($loc->N("Warning"),
- join("\n",
- $loc->N("The package \"%s\" was found.", $name),
- $loc->N("However this package is not in the package list."),
- $loc->N("You may want to update your urpmi database."),
- '',
- $loc->N("Matching packages:"),
- '',
- join("\n", sort map {
- #-PO: this is list fomatting: "- <package_name> (medium: <medium_name>)"
- #-PO: eg: "- rpmdragora (medium: "Main Release"
- $loc->N("- %s (medium: %s)", $_, pkg2medium($pkgs->{$_}{pkg}, $urpm)->{name});
- } grep { /^$short_name/ } keys %$pkgs),
- ),
- scroll => 1,
- );
- }
- return 'XXX';
-}
-
-#
-# @method node_state
-#
-=pod
-
-=head1 node_state(pkgname)
-
-=over 4
-
-=item returns the state of the node (pkg) querying an urpm object from $pkgs->{$pkgname}
-
-=over 6
-
-=item I<to_install>
-
-=item I<to_remove>
-
-=item I<to_update>
-
-=item I<installed>
-
-=item I<uninstalled>
-
-=back
-
-=back
-
-=cut
-
-sub node_state {
- my ($name) = @_;
- #- checks $_[0] -> hack for partial tree displaying
- return 'XXX' if !$name;
- my $pkg = $pkgs->{$name};
- my $urpm_obj = $pkg->{pkg};
- return warn_if_no_pkg($name) if !$urpm_obj;
- $pkg->{selected} ?
- ($urpm_obj->flag_installed ?
- ($urpm_obj->flag_upgrade ? 'to_install' : 'to_remove')
- : 'to_install')
- : ($urpm_obj->flag_installed ?
- ($pkgs->{$name}{is_backport} ? 'backport' :
- ($urpm_obj->flag_upgrade ? 'to_update'
- : ($urpm_obj->flag_base ? 'base' : 'installed')))
- : 'uninstalled');
-}
-
-my ($common, $w, %wtree, %ptree, %pix, @table_item_list);
-
-#
-# @method set_node_state
-#
-
-=pod
-
-=head1 set_node_state($tblItem, $state, $detail_list)
-
-=over 4
-
-=item setup the table row by adding a cell representing the state of the package
-
-=item see node_state
-
-=over 6
-
-=item B<$tblItem> , YTableItem instance
-
-=item B<$state> , string containing the state of the package from node_state
-
-=item B<$detail_list> , reference to the YCBTable
-
-=back
-
-=back
-
-=cut
-
-sub set_node_state {
- my ($tblItem, $state, $detail_list) = @_;
- return if $state eq 'XXX' || !$state;
-
- if ($detail_list) {
- $detail_list->parent()->parent()->startMultipleChanges();
- $tblItem->addCell($state,"/usr/share/rpmdrake/icons/state_$state.png") if(ref $tblItem eq "yui::YCBTableItem");
- if(to_bool(member($state, qw(base installed to_install)))){
- # it should be parent()->setChecked(1)
- $detail_list->checkItem($tblItem, 1);
- # $tblItem->setSelected(1);
- }else{
- $detail_list->checkItem($tblItem, 0);
- # $tblItem->setSelected(0);
- }
-# if(!to_bool($state ne 'base')){
-# #$iter->cell(0)->setLabel('-');
-# $tblItem->cell(0)->setLabel('-');
-# }
- $detail_list->parent()->parent()->doneMultipleChanges();
- }
- else {
- # no item list means we use just the item to add state information
- $tblItem->addCell($state,"/usr/share/rpmdrake/icons/state_$state.png") if(ref $tblItem eq "yui::YCBTableItem");
- $tblItem->check(to_bool(member($state, qw(base installed to_install))));
-# $tblItem->cell(0)->setLabel('-') if !to_bool($state ne 'base');
- }
-}
-
-sub set_leaf_state {
- my ($leaf, $state, $detail_list) = @_;
- # %ptree is a hash using the pkg name as key and a monodimensional array (?) as value
- # were it is stored the index of the item into the table
- my $nodeIndex = $ptree{$leaf}[0];
- my $node = itemAt($detail_list,$nodeIndex);
- set_node_state($node, $state, $detail_list);
-}
-
-#=============================================================
-
-=head2 grep_unselected
-
-=head3 INPUT
-
- $l: ARRAY reference containing the list of package fullnames
-
-=head3 OUTPUT
-
- \@result: ARRAY reference containing the list of packages
- that are not selected
-
-=head3 DESCRIPTION
-
- Function returning the list of not selected packages
-
-=cut
-
-#=============================================================
-sub grep_unselected {
- my $l = shift;
-
- my @result = grep { exists $pkgs->{$_} && !$pkgs->{$_}{selected} } @{$l} ;
- return \@result;
-}
-
-my %groups_tree = ();
-
-#
-# @method add_parent
-#
-
-=pod
-
-=head1 add_parent($tree, $root, $state)
-
-=over 4
-
-=item populates the treeview with the rpm package groups
-
-=over 6
-
-=item B<$tree> , YTree for the group of the rpm packages
-
-=item B<$root> , string containing a path-like sequence (e.g. "foo|bar")
-
-=item B<$state> , not used currently (from the old impl.)
-
-=back
-
-=back
-
-=cut
-
-sub add_parent {
- my ($tree, $root, $state) = @_;
- $tree or return undef;
- #$root or return undef;
- my $parent = 0;
-
- carp "WARNING TODO: add_parent to be removed (called with " . $root . ")\n";
-
- my @items = split('\|', $root);
- my $i = 0;
- my $parentItem = undef;
- my $rootItem = undef;
- for my $item (@items) {
- chomp $item;
- $item = trim($item);
- my $treeItem;
- if($i == 0){
- $parent = $item;
- $treeItem = new yui::YTreeItem($item,get_icon_path($item,0),0);
- $rootItem = $treeItem;
- $parentItem = $treeItem;
- if(!defined($groups_tree{$parent})) {
- $groups_tree{$parent}{parent} = $treeItem;
- $groups_tree{$parent}{children} = ();
-# $tree->addItem($groups_tree{$parent}{'parent'});
- }
- }else{
- #if(any { $_ ne $item } @{$groups_tree{$parent}{'children'}}){
- # push @{$groups_tree{$parent}{'children'}}, $item;
- #}
- $parentItem = new yui::YTreeItem($parentItem, $item,get_icon_path($item,$parent),0);
- if(!defined($groups_tree{$parent}{'children'}{$item})){
-# $treeItem = new yui::YTreeItem($treeItem, $item,get_icon_path($item,$parent),0);
- $treeItem = $parentItem;
- $groups_tree{$parent}{'children'}{$item} = $treeItem;
- $groups_tree{$parent}{'parent'}->addChild($treeItem);
- }
- }
- $i++;
- }
- $tree->addItem($rootItem) if $rootItem;
- $tree->rebuildTree();
-}
-
-
-#=============================================================
-
-=head2 add_tree_item
-
-=head3 INPUT
-
-=item B<$tree> YTree for the group of the rpm packages
-
-=item B<$item> string containing a group (to be added as leaf node)
-
-=item B<$selected> if the new item is selected
-
-
-=head3 DESCRIPTION
-
- This function add a group to the tree view
-
-=cut
-
-#=============================================================
-sub add_tree_item {
- my ($tree, $item, $selected) = @_;
-
- $tree or return undef;
-
- $tree->startMultipleChanges();
- my $treeItem = new yui::YTreeItem($item, get_icon_path($item, 0), 0);
- $treeItem->setSelected($selected);
-
- $tree->addItem($treeItem);
- $tree->rebuildTree();
- $tree->doneMultipleChanges();
-}
-
-#=============================================================
-
-=head2 add_package_item
-
-=head3 INPUT
-
-=item B<$item_list>: reference to a YItemCollection
-
-=item B<$pkg_name>: package name
-
-=item B<$select>: select given package
-
-=head3 DESCRIPTION
-
- populates the item list for the table view with the given rpm package
-
-=cut
-
-#=============================================================
-sub add_package_item {
- my ($item_list, $pkg_name, $select) = @_;
-
- return if !$pkg_name;
-
- return if ref($item_list) ne "yui::YItemCollection";
-
- my $state = node_state($pkg_name) or return;
-
- my $iter;
- if (is_a_package($pkg_name)) {
- my ($name, $version, $release, $arch) = split_fullname($pkg_name);
-
- $name = "" if !defined($name);
- $version = "" if !defined($version);
- $release = "" if !defined($release);
- $arch = "" if !defined($arch);
-
- my $newTableItem = new yui::YCBTableItem(
- $name,
- get_summary($pkg_name),
- $version,
- $release,
- $arch
- );
-
- $newTableItem->setSelected($select);
-
- set_node_state($newTableItem, $state);
-
- $item_list->push($newTableItem);
-
- $newTableItem->DISOWN();
- }
- else {
- carp $pkg_name . " is not a leaf package and that is not managed!";
- }
-
-}
-
-#
-# @method add_node
-#
-
-=pod
-
-=head1 add_node($leaf, $root, $options)
-
-=over 4
-
-=item populates the tableview with the rpm packages or the treeview with the package groups
-
-=over 6
-
-=item B<$leaf> , could be the name of a package or the name of a group o packages
-
-=item B<$root> , string containing a path-like sequence (e.g. "foo|bar")
-
-=item B<$state> , the string with the state of the package if leaf is the name of a package
-
-=back
-
-=back
-
-=cut
-
-sub add_node {
- my ($leaf, $root, $o_options) = @_;
- my $state = node_state($leaf) or return;
- if ($leaf) {
- my $iter;
- if (is_a_package($leaf)) {
-carp "TODO: add_node is_a_package(\$leaf)" . $leaf . "\n";
-
- my ($name, $version, $release, $arch) = split_fullname($leaf);
- #OLD $iter = $w->{detail_list_model}->append_set([ $pkg_columns{text} => $leaf,
- # $pkg_columns{short_name} => format_name_n_summary($name, get_summary($leaf)),
- # $pkg_columns{version} => $version,
- # $pkg_columns{release} => $release,
- # $pkg_columns{arch} => $arch,
- # ]);
- $name = "" if(!defined($name));
- $version = "" if(!defined($version));
- $release = "" if(!defined($release));
- $arch = "" if(!defined($arch));
- #my $newTableItem = new yui::YTableItem(format_name_n_summary($name, get_summary($leaf)),
- my $newTableItem = new yui::YCBTableItem($name,
- get_summary($leaf),
- $version,
- $release,
- $arch);
- $w->{detail_list}->addItem($newTableItem);
- set_node_state($newTableItem, $state, $w->{detail_list});
- # $ptree{$leaf} = [ $newTableItem->label() ];
- $ptree{$leaf} = [ $newTableItem->index() ];
- $table_item_list[$newTableItem->index()] = $leaf;
- $newTableItem->DISOWN();
- } else {
- carp "TODO: add_node !is_a_package(\$leaf) not MANAGED\n";
-# $iter = $w->{tree_model}->append_set(add_parent($w->{tree},$root, $state), [ $grp_columns{label} => $leaf ]);
- #push @{$wtree{$leaf}}, $iter;
- }
- } else {
- carp "TODO: add_node !\$leaf not MANAGED\n";
-
-# my $parent = add_parent($w->{tree}, $root, $state);
- #- hackery for partial displaying of trees, used in rpmdragora:
- #- if leaf is void, we may create the parent and one child (to have the [+] in front of the parent in the ctree)
- #- though we use '' as the label of the child; then rpmdragora will connect on tree_expand, and whenever
- #- the first child has '' as the label, it will remove the child and add all the "right" children
-# $o_options->{nochild} or $w->{tree_model}->append_set($parent, [ $grp_columns{label} => '' ]); # test $leaf?
- }
-}
-
-my ($prev_label);
-sub update_size {
- my ($common) = shift @_;
- if ($w->{status}) {
- my $new_label = $common->{get_status}();
- $prev_label="" if(!defined($prev_label));
- $prev_label ne $new_label and $w->{status}->setText($prev_label = $new_label);
- }
-}
-
-#=============================================================
-
-=head2 treeview_children
-
-=head3 INPUT
-
- $tbl: YCBTable widget containing the package list shown
-
-=head3 OUTPUT
-
- \@l: ARRAY reference containing the list
- of YItem contained into YCBTable
-
-=head3 DESCRIPTION
-
- This functions just returns the YCBTable content such as all the
- YItem objects
-
-=cut
-
-#=============================================================
-sub treeview_children {
- my ($tbl) = @_;
- my $it;
- my @l;
- my $i=0;
- # using iterators
- for ($it = $tbl->itemsBegin(); $it != $tbl->itemsEnd(); ) {
- my $item = $tbl->YItemIteratorToYItem($it);
- push @l, $item;
- $it = $tbl->nextItem($it);
- $i++;
- if ($i == $tbl->itemsCount()) {
- last;
- }
- }
-
- return \@l;
-}
-
-#=============================================================
-
-=head2 children
-
-=head3 INPUT
-
- $tbl: YCBTable object
- @table_item_list: array containing package fullnames
-
-=head3 OUTPUT
-
- \@result: ARRAY reference containing package fullnames
-
-=head3 DESCRIPTION
-
- This Function return the list of package fullnames
-
-=cut
-
-#=============================================================
-
-sub children {
- my ($tbl, $table_item_list) = @_;
- # map { $w->{detail_list}->get($_, $pkg_columns{text}) } treeview_children($w->{detail_list});
- # map { $table_item_list[$_->index()] } treeview_children($w->{detail_list});
- my $children_list = treeview_children($tbl);
- my @result;
- for my $child(@{$children_list}){
- push @result, $table_item_list->[$child->index()];
- }
- return \@result;
-}
-
-sub itemAt {
- my ($table, $index) = @_;
- return $table->item($index);
- #return bless ($table->item($index),'yui::YTableItem');
- #foreach my $item(treeview_children($table)){
- # if($item->index() == $index){
- # print "\n== item label ".$item->label()."\n";
- # return bless ($item, 'yui::YTableItem');
- # }
- #}
-}
-
-
-#=============================================================
-
-=head2 toggle_all
-
-=head3 INPUT
-
- $common: HASH reference containing (### TODO ###)
- widgets => {
- detail_list: YTable reference (?)
- }
- table_item_list => array containing package fullnames
- partialsel_unsel => (?)
-
- set_state_callback => set state callback invoked by
- toggle_nodes if needed. if undef
- set_leaf_state is used.
- $_val: value to be set (so it seems not a toggle! unused?)
-
-=head3 DESCRIPTION
-
-This method (should) check -or un-check if already checked- all
-the packages
-
-=cut
-
-#=============================================================
-sub toggle_all {
- my ($common, $_val) = @_;
- my $w = $common->{widgets};
-
- my $l = children($w->{detail_list}, $common->{table_item_list}) or return;
-
- my $set_state = $common->{set_state_callback} ? $common->{set_state_callback} : \&set_leaf_state;
- my $unsel = grep_unselected($l);
- my $p = $unsel ?
- #- not all is selected, select all if no option to potentially override
- (exists $common->{partialsel_unsel} && $common->{partialsel_unsel}->($unsel, $l) ? difference2($l, $unsel) : $unsel)
- : $l;
- # toggle_nodes($w->{detail_list}, $w->{detail_list_model}, \&set_leaf_state, node_state($p[0]), @p);
-
- toggle_nodes($w->{detail_list}, $w->{detail_list}, $set_state, node_state($p->[0]), @{$p});
- update_size($common);
-}
-
-sub fast_toggle {
- my ($item) = @_;
- #gtkset_mousecursor_wait($w->{w}{rwindow}->window);
- #my $_cleaner = before_leaving { gtkset_mousecursor_normal($w->{w}{rwindow}->window) };
- my $name = $common->{table_item_list}[$item->index()];
- my $urpm_obj = $pkgs->{$name}{pkg};
- if ($urpm_obj->flag_base) {
- interactive_msg($loc->N("Warning"), $loc->N("Removing package %s would break your system", $name));
- return '';
- }
- if ($urpm_obj->flag_skip) {
- interactive_msg($loc->N("Warning"), $loc->N("The \"%s\" package is in urpmi skip list.\nDo you want to select it anyway?", $name), yesno => 1) or return '';
- $urpm_obj->set_flag_skip(0);
- }
- if ($ManaTools::Rpmdragora::pkg::need_restart && !$priority_up_alread_warned) {
- $priority_up_alread_warned = 1;
- interactive_msg($loc->N("Warning"), '<b>' . $loc->N("Rpmdragora or one of its priority dependencies needs to be updated first. Rpmdragora will then restart.") . '</b>' . "\n\n");
- }
- # toggle_nodes($w->{tree}->window, $w->{detail_list_model}, \&set_leaf_state, $w->{detail_list_model}->get($iter, $pkg_columns{state}),
-
- my $old_status = node_state($name);
-
- #$DB::single = 1;
-
-# my $old_state;
-# if($item->checked()){
-# $old_state = "to_install";
-# }else{
-# $old_state = "to_remove";
-# }
- toggle_nodes($w->{tree}, $w->{detail_list}, \&set_leaf_state, $old_status, $name);
- update_size($common);
-};
-
-# ask_browse_tree_given_widgets_for_rpmdragora will run gtk+ loop. its main parameter "common" is a hash containing:
-# - a "widgets" subhash which holds:
-# o a "w" reference on a ugtk2 object
-# o "tree" & "info" references a TreeView
-# o "info" is a TextView
-# o "tree_model" is the associated model of "tree"
-# o "status" references a Label
-# - some methods: get_info, node_state, build_tree, partialsel_unsel, grep_unselected, rebuild_tree, toggle_nodes, get_status
-# - "tree_submode": the default mode (by group, ...), ...
-# - "state": a hash of misc flags: => { flat => '0' },
-# o "flat": is the tree flat or not
-# - "tree_mode": mode of the tree ("gui_pkgs", "by_group", ...) (mainly used by rpmdragora)
-
-sub ask_browse_tree_given_widgets_for_rpmdragora {
- ($common) = @_;
- $w = $common->{widgets};
-
- $common->{table_item_list} = \@table_item_list;
-
- $w->{detail_list} ||= $w->{tree};
- #$w->{detail_list_model} ||= $w->{tree_model};
-
- $common->{add_parent} = \&add_parent;
- my $clear_all_caches = sub {
- %ptree = %wtree = ();
- @table_item_list = ();
- };
- $common->{clear_all_caches} = $clear_all_caches;
- $common->{delete_all} = sub {
- $clear_all_caches->();
- %groups_tree = ();
- };
- $common->{rebuild_tree} = sub {
- $common->{delete_all}->();
- $common->{build_tree}($common->{state}{flat}, $common->{tree_mode});
- update_size($common);
- };
- $common->{delete_category} = sub {
- my ($cat) = @_;
- carp "WARNING TODO delete_category to be removed!";
- exists $wtree{$cat} or return;
- %ptree = ();
- update_size($common);
- return;
- };
- $common->{add_nodes} = sub {
- my (@nodes) = @_;
- carp "TODO ==================> ADD NODES - add packages (" . scalar(@nodes) . ") \n";
- yui::YUI::app()->busyCursor();
-
- my $lastItem = $w->{detail_list}->selectedItem() ? $w->{detail_list}->selectedItem()->label() : "";
- $w->{detail_list}->startMultipleChanges();
- $w->{detail_list}->deleteAllItems();
- my $itemColl = new yui::YItemCollection;
-
- @table_item_list = ();
- my $index = 0;
- foreach(@nodes){
- add_package_item($itemColl, $_->[0], ($lastItem eq $_->[0]));
- warn "Unmanaged param " . $_->[2] if defined $_->[2];
- $ptree{$_->[0]} = [ $index ];
- $index++;
- push @table_item_list, $_->[0];
- }
-
- update_size($common);
- $w->{detail_list}->addItems($itemColl);
- $w->{detail_list}->doneMultipleChanges();
- yui::YUI::app()->normalCursor();
- };
-
- $common->{rebuild_tree}->();
- update_size($common);
- $common->{initial_selection} and toggle_nodes($w->{tree}->window, $w->{detail_list}, \&set_leaf_state, undef, @{$common->{initial_selection}});
- my $_b = before_leaving { $clear_all_caches->() };
- $common->{init_callback}->() if $common->{init_callback};
-
- $w->{w};
-}
-
-our $find_entry;
-
-sub reset_search() {
- return if !$common;
-
-# TODO $common->{delete_category}->($_) foreach $results_ok, $results_none;
- # clear package list:
- yui::YUI::app()->busyCursor();
- my $wdgt = $common->{widgets};
- $wdgt->{detail_list}->startMultipleChanges();
- $wdgt->{detail_list}->deleteAllItems();
- $wdgt->{detail_list}->doneMultipleChanges();
- yui::YUI::app()->normalCursor();
-}
-
-sub is_a_package {
- my ($pkg) = @_;
- return exists $pkgs->{$pkg};
-}
-
-sub switch_pkg_list_mode {
- my ($mode) = @_;
- return if !$mode;
- return if !$filter_methods{$mode};
- $force_displaying_group = 1;
- $filter_methods{$mode}->();
-}
-
-sub is_updatable {
- my $p = $pkgs->{$_[0]};
- $p->{pkg} && !$p->{selected} && $p->{pkg}->flag_installed && $p->{pkg}->flag_upgrade;
-}
-
-sub pkgs_provider {
- my ($mode, %options) = @_;
- return if !$mode;
- my $h = &get_pkgs(%options);
- ($urpm, $descriptions) = @$h{qw(urpm update_descr)};
- $pkgs = $h->{all_pkgs};
- %filters = (
- non_installed => $h->{installable},
- installed => $h->{installed},
- all => [ keys %$pkgs ],
- );
- my %tmp_filter_methods = (
- all => sub {
- [ difference2([ keys %$pkgs ], $h->{inactive_backports}) ];
- },
- all_updates => sub {
- # potential "updates" from media not tagged as updates:
- if (!$options{pure_updates} && !$ManaTools::Rpmdragora::pkg::need_restart) {
- [ @{$h->{updates}},
- difference2([ grep { is_updatable($_) } @{$h->{installable}} ], $h->{backports}) ];
- } else {
- [ difference2($h->{updates}, $h->{inactive_backports}) ];
- }
- },
- backports => sub { $h->{backports} },
- meta_pkgs => sub {
- [ difference2($h->{meta_pkgs}, $h->{inactive_backports}) ];
- },
- gui_pkgs => sub {
- [ difference2($h->{gui_pkgs}, $h->{inactive_backports}) ];
- },
- );
- foreach my $importance (qw(bugfix security normal)) {
- $tmp_filter_methods{$importance} = sub {
- my @media = keys %$descriptions;
- [ grep {
- my ($name) = split_fullname($_);
- my $medium = MDK::Common::Func::find { $descriptions->{$_}{$name} } @media;
- $medium && $descriptions->{$medium}{$name}{importance} eq $importance } @{$h->{updates}} ];
- };
- }
-
- undef %filter_methods;
- foreach my $type (keys %tmp_filter_methods) {
- $filter_methods{$type} = sub {
- $force_rebuild = 1; # force rebuilding tree since we changed filter (FIXME: switch to SortModel)
- @filtered_pkgs = intersection($filters{$filter->[0]}, $tmp_filter_methods{$type}->());
- };
- }
-
- switch_pkg_list_mode($mode);
-}
-
-sub closure_removal {
- local $urpm->{state} = {};
- urpm::select::find_packages_to_remove($urpm, $urpm->{state}, \@_);
-}
-
-sub is_locale_available {
- my ($name) = @_;
- any { $urpm->{depslist}[$_]->flag_selected } keys %{$urpm->{provides}{$name} || {}} and return 1;
- my $found;
- open_rpm_db()->traverse_tag_find('name', $name, sub { $found = 1 });
- return $found;
-}
-
-sub callback_choices {
- my (undef, undef, undef, $choices) = @_;
- return $choices->[0] if $::rpmdragora_options{auto};
- foreach my $pkg (@$choices) {
- foreach ($pkg->requires_nosense) {
- /locales-/ or next;
- is_locale_available($_) and return $pkg;
- }
- }
- my $callback = sub { interactive_msg($loc->N("More information on package..."), get_info($_[0]), scroll => 1) };
- $choices = [ sort { $a->name cmp $b->name } @$choices ];
- my @choices = interactive_list_($loc->N("Please choose"), (scalar(@$choices) == 1 ?
- $loc->N("The following package is needed:") : $loc->N("One of the following packages is needed:")),
- [ map { urpm_name($_) } @$choices ], $callback, nocancel => 1);
- defined $choices[0] ? $choices->[$choices[0]] : undef;
-}
-
-#=============================================================
-
-=head2 info_details
-
-=head3 INPUT
-
- $info_detail_selected: string to get more info details
- (see %hidden_info)
- $info_options: reference to info options that are going to changed
- based on passed $info_detail_selected
-
-=head3 OUTPUT
-
- [0, 1]: 0 if $info_detail_selected not valid, 1 otherwise
-
-=head3 DESCRIPTION
-
- This function change the info_options accordingly to the string passed
- returning 0 if the string is not managed (see %hidden_info)
-
-=cut
-
-#=============================================================
-sub info_details {
- my ($info_detail_selected, $info_options) = @_;
-
- foreach my $k (keys %hidden_info) {
- if ($info_detail_selected eq $hidden_info{$k}) {
- $info_options->{$k} = $info_options->{$k} ? 0 : 1;
- return 1;
- }
- }
- return 0;
-}
-
-#=============================================================
-
-=head2 setInfoOnWidget
-
-=head3 INPUT
-
- $pckgname: full name of the package
- $infoWidget: YRichText object to fill
-
-=head3 DESCRIPTION
-
- This function writes on a YRichText object package info
-
-=cut
-
-#=============================================================
-sub setInfoOnWidget {
- my ($pkgname, $infoWidget, $options) = @_;
-
- return if( ref $infoWidget ne "yui::YRichText");
-
- $infoWidget->setValue("");
-
- my $info_text = "";
-
- my @data = get_info($pkgname, $options);
- for(@{$data[0]}){
- if(ref $_ ne "ARRAY"){
- $info_text .= $_ . "<br />&nbsp;&nbsp;&nbsp;";
- }else{
- for my $subitem(@{$_}) {
- $info_text .= "<br />" . "<br />&nbsp;&nbsp;&nbsp;" . $subitem;
- }
- }
- }
- # change \n to <br/>
- $info_text =~ s|\n|<br/>|g;
-
- $infoWidget->setValue($info_text);
-}
-
-
-sub deps_msg {
- return 1 if $dont_show_selections->[0];
- my ($title, $msg, $nodes, $nodes_with_deps) = @_;
-
- my @deps = sort { $a cmp $b } difference2($nodes_with_deps, $nodes);
- @deps > 0 or return 1;
-
- my $appTitle = yui::YUI::app()->applicationTitle();
-
- ## set new title to get it in dialog
- yui::YUI::app()->setApplicationTitle($title);
-# TODO icon if needed
-# yui::YUI::app()->setApplicationIcon($which_icon);
-
- my $factory = yui::YUI::widgetFactory;
-
- ## | [msg-label] |
- ## | |
- ## | pkg-list | info on selected pkg |(1)
- ## | |
- ## | [cancel] [ok] |
- ####
- # (1) info on pkg list:
- # [ label info ]
- # sub info on click (Details, Files, Changelog, New dependencies)
-
- my $dialog = $factory->createPopupDialog;
- my $vbox = $factory->createVBox( $dialog );
- my $msgBox = $factory->createLabel($vbox, $msg, 1);
-# my $hbox = $factory->createHBox( $vbox );
- my $pkgList = $factory->createSelectionBox( $vbox, $loc->N("Select package") );
- $factory->createVSpacing($vbox, 1);
-
-# my $frame = $factory->createFrame ($hbox, $loc->N("Information on packages"));
-# my $frmVbox = $factory->createVBox( $frame );
- my $infoBox = $factory->createRichText($vbox, "", 0);
- $pkgList->setWeight($yui::YD_HORIZ, 2);
- $infoBox->setWeight($yui::YD_HORIZ, 3);
- $factory->createVSpacing($vbox, 1);
- my $hbox = $factory->createHBox( $vbox );
- my $align = $factory->createRight($hbox);
- my $cancelButton = $factory->createPushButton($align, $loc->N("&Cancel"));
- my $okButton = $factory->createPushButton($hbox, $loc->N("&Ok"));
-
- # adding packages to the list
- my $itemColl = new yui::YItemCollection;
- foreach my $p (map { scalar(urpm::select::translate_why_removed_one($urpm, $urpm->{state}, $_)) } @deps) {
- my $item = new yui::YTableItem ("$p");
- $item->setLabel( $p );
- $itemColl->push($item);
- $item->DISOWN();
- }
- $pkgList->addItems($itemColl);
- $pkgList->setImmediateMode(1);
- my $item = $pkgList->selectedItem();
- if ($item) {
- my $pkg = $item->label();
- setInfoOnWidget($pkg, $infoBox);
- }
-
- my $retval = 0;
- my $info_options = {};
- while(1) {
- my $event = $dialog->waitForEvent();
- my $eventType = $event->eventType();
-
- #event type checking
- if ($eventType == $yui::YEvent::CancelEvent) {
- last;
- }
- elsif ($eventType == $yui::YEvent::MenuEvent) {
- my $item = $event->item();
- if (!$item) {
- #URL emitted or at least a ref into RichText widget
- my $url = yui::toYMenuEvent($event)->id ();
- if (ManaTools::Rpmdragora::gui::info_details($url, $info_options) ) {
- $item = $pkgList->selectedItem();
- my $pkg = $item->label();
- ManaTools::Rpmdragora::gui::setInfoOnWidget($pkg, $infoBox, $info_options);
- }
- else {
- # default it's really a URL
- ManaTools::Rpmdragora::gui::run_browser($url);
- }
- }
- }
- elsif ($eventType == $yui::YEvent::WidgetEvent) {
- ### widget
- my $widget = $event->widget();
- if ($widget == $pkgList) {
- #change info
- $item = $pkgList->selectedItem();
- $info_options = {};
- if ( $item ) {
- my $pkg = $item->label();
- setInfoOnWidget($pkg, $infoBox);
- }
- }
- elsif ($widget == $okButton) {
- $retval = 1;
- last;
- }
- elsif ($widget == $cancelButton) {
- last;
- }
- }
- }
-
- destroy $dialog;
-
- # restore original title
- yui::YUI::app()->setApplicationTitle($appTitle) if $appTitle;
-
- return $retval;
-}
-
-# set_state <- package-fullname, node_state = {to_install, to_remove,...}, list=YTable
-sub toggle_nodes {
- my ($widget, $detail_list, $set_state, $old_state, @nodes) = @_;
-
- @nodes = grep { exists $pkgs->{$_} } @nodes
- or return;
- #- avoid selecting too many packages at once
- return if !$dont_show_selections->[0] && @nodes > 2000;
- my $new_state = !$pkgs->{$nodes[0]}{selected};
-
- my @nodes_with_deps;
-
- my $bar_id = statusbar_msg($loc->N("Checking dependencies of package..."), 0);
-
- my $warn_about_additional_packages_to_remove = sub {
- my ($msg) = @_;
- statusbar_msg_remove($bar_id);
- deps_msg($loc->N("Some additional packages need to be removed"),
- MDK::Common::String::formatAlaTeX($msg) . "\n\n",
- \@nodes, \@nodes_with_deps) or @nodes_with_deps = ();
- };
-
- if (member($old_state, qw(to_remove installed))) { # remove pacckages
- if ($new_state) {
- my @remove;
- slow_func(sub { @remove = closure_removal(@nodes) });
- @nodes_with_deps = grep { !$pkgs->{$_}{selected} && !/^basesystem/ } @remove;
- $warn_about_additional_packages_to_remove->(
- $loc->N("Because of their dependencies, the following package(s) also need to be removed:"));
- my @impossible_to_remove;
- foreach (grep { exists $pkgs->{$_}{base} } @remove) {
- ${$pkgs->{$_}{base}} == 1 ? push @impossible_to_remove, $_ : ${$pkgs->{$_}{base}}--;
- }
- @impossible_to_remove and interactive_msg($loc->N("Some packages cannot be removed"),
- $loc->N("Removing these packages would break your system, sorry:\n\n") .
- format_list(@impossible_to_remove));
- @nodes_with_deps = difference2(\@nodes_with_deps, \@impossible_to_remove);
- } else {
- @nodes_with_deps = grep { intersection(\@nodes, [ closure_removal($_) ]) }
- grep { $pkgs->{$_}{selected} && !member($_, @nodes) } keys %$pkgs;
- push @nodes_with_deps, @nodes;
- $warn_about_additional_packages_to_remove->(
- $loc->N("Because of their dependencies, the following package(s) must be unselected now:\n\n"));
- $pkgs->{$_}{base} && ${$pkgs->{$_}{base}}++ foreach @nodes_with_deps;
- }
- } else {
- if ($new_state) {
- 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);
- }
- my @requested;
- @requested = $urpm->resolve_requested(
- open_rpm_db(), $urpm->{state},
- { map { $pkgs->{$_}{pkg}->id => 1 } @nodes },
- callback_choices => \&callback_choices,
- );
- @nodes_with_deps = map { urpm_name($_) } @requested;
- statusbar_msg_remove($bar_id);
- if (!deps_msg($loc->N("Additional packages needed"),
- MDK::Common::String::formatAlaTeX($loc->N("To satisfy dependencies, the following package(s) also need to be installed:\n\n")) . "\n\n",
- \@nodes, \@nodes_with_deps)) {
- @nodes_with_deps = ();
- $urpm->disable_selected(open_rpm_db(), $urpm->{state}, @requested);
- goto packages_selection_ok;
- }
-
- if (my $conflicting_msg = urpm::select::conflicting_packages_msg($urpm, $urpm->{state})) {
- if (!interactive_msg($loc->N("Conflicting Packages"), $conflicting_msg, yesno => 1, scroll => 1)) {
- @nodes_with_deps = ();
- $urpm->disable_selected(open_rpm_db(), $urpm->{state}, @requested);
- goto packages_selection_ok;
- }
- }
-
- if (my @cant = sort(difference2(\@nodes, \@nodes_with_deps))) {
- my @ask_unselect = urpm::select::unselected_packages($urpm->{state});
- my @reasons = map {
- my $cant = $_;
- my $unsel = MDK::Common::Func::find { $_ eq $cant } @ask_unselect;
- $unsel
- ? join("\n", urpm::select::translate_why_unselected($urpm, $urpm->{state}, $unsel))
- : ($pkgs->{$_}{pkg}->flag_skip ? $loc->N("%s (belongs to the skip list)", $cant) : $cant);
- } @cant;
- my $count = @reasons;
- interactive_msg(
- ($count == 1 ? $loc->N("One package cannot be installed") : $loc->N("Some packages cannot be installed")),
- ($count == 1 ?
- $loc->N("Sorry, the following package cannot be selected:\n\n%s", format_list(@reasons))
- : $loc->N("Sorry, the following packages cannot be selected:\n\n%s", format_list(@reasons))),
- scroll => 1,
- );
- foreach (@cant) {
- next unless $pkgs->{$_}{pkg};
- $pkgs->{$_}{pkg}->set_flag_requested(0);
- $pkgs->{$_}{pkg}->set_flag_required(0);
- }
- }
- packages_selection_ok:
- } else {
- my @unrequested;
- @unrequested = $urpm->disable_selected(open_rpm_db(), $urpm->{state},
- map { $pkgs->{$_}{pkg} } @nodes);
- @nodes_with_deps = map { urpm_name($_) } @unrequested;
- statusbar_msg_remove($bar_id);
- if (!deps_msg($loc->N("Some packages need to be removed"),
- $loc->N("Because of their dependencies, the following package(s) must be unselected now:\n\n"),
- \@nodes, \@nodes_with_deps)) {
- @nodes_with_deps = ();
- $urpm->resolve_requested(open_rpm_db(), $urpm->{state}, { map { $_->id => 1 } @unrequested });
- goto packages_unselection_ok;
- }
- packages_unselection_ok:
- }
- }
-
- foreach (@nodes_with_deps) {
- #- some deps may exist on some packages which aren't listed because
- #- not upgradable (older than what currently installed)
- exists $pkgs->{$_} or next;
- if (!$pkgs->{$_}{pkg}) { #- can't be removed # FIXME; what about next packages in the loop?
- undef $pkgs->{$_}{selected};
- Sys::Syslog::syslog('info|local1', "can't be removed: $_");
- } else {
- $pkgs->{$_}{selected} = $new_state;
- }
- # invoke set_leaf_state($pkgname, node_state, )
- # node_state = {to_install, to_remove,...}
-
- $set_state->($_, node_state($_), $detail_list);
- if (my $pkg = $pkgs->{$_}{pkg}) {
- # FIXME: shouldn't we threat all of them as POSITIVE (as selected size)
- $size_selected += $pkg->size * ($pkg->flag_installed && !$pkg->flag_upgrade ? ($new_state ? -1 : 1) : ($new_state ? 1 : -1));
- }
- }
-}
-
-sub is_there_selected_packages() {
- int(grep { $pkgs->{$_}{selected} } keys %$pkgs);
-}
-
-sub real_quit() {
- if (is_there_selected_packages()) {
- return interactive_msg($loc->N("Some packages are selected."), $loc->N("Some packages are selected.") . "\n" . $loc->N("Do you really want to quit?"), yesno => 1);
- }
-
- return 1;
-}
-
-sub do_action__real {
- my ($options, $callback_action, $o_info) = @_;
- require urpm::sys;
- if (!urpm::sys::check_fs_writable()) {
- $urpm->{fatal}(1, $loc->N("Error: %s appears to be mounted read-only.", $urpm::sys::mountpoint));
- return 1;
- }
- if (!$ManaTools::Rpmdragora::pkg::need_restart && !is_there_selected_packages()) {
- interactive_msg($loc->N("You need to select some packages first."), $loc->N("You need to select some packages first."));
- return 1;
- }
- my $size_added = MDK::Common::Math::sum(map { MDK::Common::Func::if_($_->flag_selected && !$_->flag_installed, $_->size) } @{$urpm->{depslist}});
- if ($MODE eq 'install' && $size_free - $size_added/1024 < 50*1024) {
- interactive_msg($loc->N("Too many packages are selected"),
- $loc->N("Warning: it seems that you are attempting to add so many
-packages that your filesystem may run out of free diskspace,
-during or after package installation ; this is particularly
-dangerous and should be considered with care.
-
-Do you really want to install all the selected packages?"), yesno => 1)
- or return 1;
- }
- my $res = $callback_action->($urpm, $pkgs);
- if (!$res) {
- $force_rebuild = 1;
- pkgs_provider($options->{tree_mode}, MDK::Common::Func::if_($ManaTools::Rpmdragora::pkg::probe_only_for_updates, pure_updates => 1), skip_updating_mu => 1);
- reset_search();
- $size_selected = 0;
- (undef, $size_free) = MDK::Common::System::df('/usr');
- $options->{rebuild_tree}->() if $options->{rebuild_tree};
- $o_info->setValue("") if $o_info;
- }
- $res;
-}
-
-sub do_action {
- my ($options, $callback_action, $o_info) = @_;
- my $res = eval { do_action__real($options, $callback_action, $o_info) };
- my $err = $@;
- # FIXME: offer to report the problem into bugzilla:
- if ($err && $err !~ /cancel_perform/) {
- interactive_msg($loc->N("Fatal error"),
- $loc->N("A fatal error occurred: %s.", $err));
- }
- $res;
-}
-
-sub translate_group {
- join('/', map { $loc->N($_) } split m|/|, $_[0]);
-}
-
-sub ctreefy {
- join('|', map { $loc->N($_) } split m|/|, $_[0]);
-}
-
-sub _build_tree {
- my ($tree, $pkg_by_group_hash, @pkg_name_and_group_list) = @_;
-
- print "TODO ====> BUILD TREE\n";
-
- yui::YUI::app()->busyCursor();
-
- #- we populate all the groups tree at first
- %{$pkg_by_group_hash} = ();
- # better loop on packages, create groups tree and push packages in the proper place:
- my @groups = ();
- foreach my $pkg (@pkg_name_and_group_list) {
- my $grp = $pkg->[1];
- # no state for groups (they're not packages and thus have no state)
- push @groups, $grp;
-
- $pkg_by_group_hash->{$grp} ||= [];
- push @{$pkg_by_group_hash->{$grp}}, $pkg;
- }
-
- my $tree_hash = ManaTools::Shared::pathList2hash({
- paths => \@groups,
- separator => '|',
- });
-
- $tree->startMultipleChanges();
- my $selected = $tree->selectedItem();
- my $groupname = group_path_name($selected) if $selected;
-
- $tree->deleteAllItems() if $tree->hasItems();
-
- # TODO fixing geti icon api to get a better hash from the module
- my %icons = ();
- foreach my $group (@groups) {
- next if defined($icons{$group});
- my @items = split('\|', $group);
- if (scalar(@items) > 1) {
- $icons{$items[0]} = get_icon_path($items[0], 0);
- $icons{$group} = get_icon_path($items[1], $items[0])
- }
- else {
- $icons{$group} = get_icon_path($group, 0);
- }
- }
-
- my $itemColl = new yui::YItemCollection;
- $shared_gui->hashTreeToYItemCollection({
- collection => $itemColl,
- hash_tree => $tree_hash,
- icons => \%icons,
- default_item_separator => '|',
- default_item => $groupname,
- });
-
- $tree->addItems($itemColl);
- $tree->doneMultipleChanges();
- $tree->rebuildTree();
- yui::YUI::app()->normalCursor();
-}
-
-
-sub build_tree {
- my ($tree, $pkg_by_group_hash, $options, $force_rebuild, $flat, $mode) = @_;
- state $old_mode;
- $mode = $options->{rmodes}{$mode} || $mode;
- $old_mode = '' if(!defined($old_mode));
- return if $old_mode eq $mode && !$force_rebuild;
- $old_mode = $mode;
- undef $force_rebuild;
- my @elems;
- my $wait; $wait = statusbar_msg($loc->N("Please wait, listing packages...")) if $MODE ne 'update';
-
- my @keys = @filtered_pkgs;
- if (member($mode, qw(all_updates security bugfix normal))) {
- @keys = grep {
- my ($name) = split_fullname($_);
- member($descriptions->{$name}{importance}, @$mandrakeupdate_wanted_categories)
- || ! $descriptions->{$name}{importance};
- } @keys;
- if (@keys == 0) {
- _build_tree($tree, $pkg_by_group_hash, ['', $loc->N("(none)")]);
-# add_node('', $loc->N("(none)"), { nochild => 1 });
- state $explanation_only_once;
- $explanation_only_once or interactive_msg($loc->N("No update"),
- $loc->N("The list of updates is empty. 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;
- }
- }
- if (scalar @keys) {
- # FIXME: better do this on first group access for faster startup...
- @elems = map { [ $_, !$flat && ctreefy($pkgs->{$_}{pkg}->group) ] } sort_packages(@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]) } @_ },
- by_leaves => sub {
- # inlining part of MDK::Common::Data::difference2():
- my %l; @l{map { $_->[0] } @_} = ();
- my @pkgs_times = ('rpm', '-q', '--qf', '%{name}-%{version}-%{release}.%{arch} %{installtime}\n',
- map { chomp_($_) } ManaTools::Shared::RunProgram::get_stdout('urpmi_rpm-find-leaves'));
- sort { $b->[1] <=> $a->[1] } grep { exists $l{$_->[0]} } map { chomp; [ split ] } run_rpm(@pkgs_times);
- },
- flat => sub { no locale; sort { uc($a->[0]) cmp uc($b->[0]) } @_ },
- by_medium => sub { sort { $a->[2] <=> $b->[2] || uc($a->[0]) cmp uc($b->[0]) } @_ },
- );
- if ($flat) {
- carp "WARNING: TODO \$flat not tested\n";
- _build_tree($tree, $pkg_by_group_hash, map {[$_->[0], '']} $sortmethods{$::mode->[0] || 'flat'}->(@elems));
-# add_node($_->[0], '') foreach $sortmethods{$::mode->[0] || 'flat'}->(@elems);
- }
- else {
- if ($::mode->[0] eq 'by_source') {
- _build_tree($tree, $pkg_by_group_hash, $sortmethods{by_medium}->(map {
- my $m = pkg2medium($pkgs->{$_->[0]}{pkg}, $urpm); [ $_->[0], $m->{name}, $m->{priority} ];
- } @elems));
- }
- elsif ($::mode->[0] eq 'by_presence') {
- _build_tree($tree, $pkg_by_group_hash, map {
- my $pkg = $pkgs->{$_->[0]}{pkg};
- [ $_->[0], $pkg->flag_installed ?
- (!$pkg->flag_skip && $pkg->flag_upgrade ? $loc->N("Upgradable") : $loc->N("Installed"))
- : $loc->N("Addable") ];
- } $sortmethods{flat}->(@elems));
- }
- else {
- _build_tree($tree, $pkg_by_group_hash, @elems);
- }
- }
- }
- statusbar_msg_remove($wait) if defined $wait;
-}
-
-#=============================================================
-
-=head2 get_info
-
-=head3 INPUT
-
- $key: package full name
- $options: HASH reference containing:
- details => show details
- changelog => show changelog
- files => show files
- new_deps => show new dependencies
-
-=head3 DESCRIPTION
-
- return a string with all the package info
-
-=cut
-
-#=============================================================
-sub get_info {
- my ($key, $options) = @_;
- #- the package information hasn't been loaded. Instead of rescanning the media, just give up.
- exists $pkgs->{$key} or return [ [ $loc->N("Description not available for this package\n") ] ];
- #- get the description if needed:
- exists $pkgs->{$key}{description} or slow_func(sub { extract_header($pkgs->{$key}, $urpm, 'info', find_installed_version($pkgs->{$key}{pkg})) });
- _format_pkg_simplifiedinfo($pkgs, $key, $urpm, $descriptions, $options);
-}
-
-sub sort_callback {
- my ($store, $treeiter1, $treeiter2) = @_;
- URPM::rpmvercmp(map { $store->get_value($_, $pkg_columns{version}) } $treeiter1, $treeiter2);
-}
-
-sub run_help_callback {
- my (undef, $url) = @_;
- my ($user) = grep { $_->[2] eq $ENV{USERHELPER_UID} } list_passwd();
- local $ENV{HOME} = $user->[7] if $user && $ENV{USERHELPER_UID};
- ManaTools::Shared::RunProgram::raw({ detach => 1, as_user => 1 }, 'www-browser', $url);
-}
-
-#=============================================================
-
-=head2 run_browser
-
-=head3 INPUT
-
- $url: url to be passed to the configured browser
-
-=head3 DESCRIPTION
-
- This function calls the browser with the given URL
-
-=cut
-
-#=============================================================
-sub run_browser {
- my $url = shift;
-
- my ($user) = grep { $_->[2] eq $ENV{USERHELPER_UID} } MDK::Common::System::list_passwd();
- local $ENV{HOME} = $user->[7] if $user && $ENV{USERHELPER_UID};
- ManaTools::Shared::RunProgram::raw({ detach => 1, as_user => 1 }, 'www-browser', $url);
-}
-
-#=============================================================
-
-=head2 group_path_name
-
-=head3 INPUT
-
- $treeItem: YTreeItem object
-
-=head3 OUTPUT
-
- $fullname: completed path group name
-
-=head3 DESCRIPTION
-
- This function returns the path name treeItem group name (e.g. foo|bar)
-
-=cut
-
-#=============================================================
-sub group_path_name {
- my $treeItem = shift;
-
- my $fullname = $treeItem->label();
- my $it = $treeItem;
- while ($it = $it->parent()) {
- $fullname = join("|", $it->label(), $fullname);
- }
-
- return $fullname;
-}
-
-sub groups_tree {
- carp "DEPRECATED groups_tree: do not use it any more!";
-
- return %groups_tree;
-}
-
-sub group_has_parent {
- my ($group) = shift;
- carp "DEPRECATED group_has_parent: do not use it any more!";
- return 0 if(!defined($group));
- return defined($groups_tree{$group}{parent});
-}
-
-sub group_parent {
- my ($group) = shift;
-
- carp "DEPRECATED group_parent: do not use it any more!";
- # if group is a parent itself return it
- # who use group_parent have to take care of the comparison
- # between a group and its parent
- # e.g. group System has groups_tree{'System'}{parent}->label() = 'System'
- return $groups_tree{$group}{parent} if(group_has_parent($group));
- for my $sup (keys %groups_tree){
- for my $item(keys %{$groups_tree{$sup}{children}}){
- if(defined($group) && ($item eq $group)){
- return $groups_tree{$sup}{parent};
- }
- }
- }
- return undef;
-}
-
-1;
diff --git a/lib/AdminPanel/Rpmdragora/gurpm.pm b/lib/AdminPanel/Rpmdragora/gurpm.pm
deleted file mode 100644
index 20cac6ee..00000000
--- a/lib/AdminPanel/Rpmdragora/gurpm.pm
+++ /dev/null
@@ -1,298 +0,0 @@
-# vim: set et ts=4 sw=4:
-package ManaTools::Rpmdragora::gurpm;
-
-#============================================================= -*-perl-*-
-
-=head1 NAME
-
- ManaTools::Rpmdragora::gurpm - Module that shows the urpmi
- progress status
-
-=head1 SYNOPSIS
-
- my %option = (title => "Urpmi action ivoked", text => "Please wait", );
- my $gurpmi = ManaTools::Rpmdragora::gurpm->new(%option);
- $gurpmi->progress(45);
-
- #add to an existing dialog
- %option = (title => "Urpmi action ivoked", text => "Please wait", main_dialog => $dialog, parent => $parent_container);
- $gurpmi = ManaTools::Rpmdragora::gurpm->new(%option);
- $gurpmi->progress(20);
-
-=head1 DESCRIPTION
-
- This class is used to show the progress of an urpmi operation on
- its progress bar. It can be istantiated as a popup dialog or used
- to add label and progress bar into a YLayoutBox container.
-
-=head1 SUPPORT
-
- You can find documentation for this module with the perldoc command:
-
- perldoc ManaTools::Rpmdragora::gurpm
-
-=head1 AUTHOR
-
- Angelo Naselli <anaselli@linux.it>
-
- Matteo Pasotti <matteo.pasotti@gmail.com>
-
-=head1 COPYRIGHT and LICENSE
-
- Copyright (c) 2002 Guillaume Cottenceau
- Copyright (c) 2002-2007 Thierry Vignaud <tvignaud@mandriva.com>
- Copyright (c) 2003, 2004, 2005 MandrakeSoft SA
- Copyright (c) 2005-2007 Mandriva SA
- Copyright (c) 2013 - 2015 Matteo Pasotti <matteo.pasotti@gmail.com>
- Copyright (C) 2015, Angelo Naselli <anaselli@linux.it>
-
- 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
-
-=cut
-
-
-use Moose;
-use Carp;
-use Time::HiRes;
-
-use yui;
-use feature 'state';
-
-
-has 'title' => (
- is => 'rw',
- isa => 'Str',
-);
-
-has 'text' => (
- is => 'rw',
- isa => 'Str',
-);
-
-has 'main_dialog' => (
- is => 'rw',
- isa => 'yui::YDialog',
-);
-
-has 'parent' => (
- is => 'rw',
- isa => 'yui::YReplacePoint',
-);
-
-has 'label_widget' => (
- is => 'rw',
- isa => 'yui::YLabel',
- init_arg => undef,
-);
-
-has 'progressbar' => (
- is => 'rw',
- isa => 'yui::YProgressBar',
- init_arg => undef,
-);
-
-#=============================================================
-
-=head2 BUILD
-
-=head3 DESCRIPTION
-
- The BUILD method is called after a Moose object is created,
- in this methods Services loads all the service information.
-
-=cut
-
-#=============================================================
-sub BUILD {
- my $self = shift;
-
- my $factory = yui::YUI::widgetFactory;
- my $vbox;
-
- if (! $self->main_dialog) {
- if ($self->parent) {
- carp "WARNING: parent parameter is skipped without main_dialog set\n" ;
- $self->parent(undef);
- }
- $self->main_dialog($factory->createPopupDialog());
- $vbox = $factory->createVBox($self->main_dialog);
- }
- else {
- die "parent parameter is mandatory with main_dialog" if !$self->parent;
- $self->main_dialog->startMultipleChanges();
- $self->parent->deleteChildren();
- $vbox = $factory->createVBox($self->parent);
- $factory->createVSpacing($vbox, 0.5);
- }
-
- $self->label_widget( $factory->createLabel($vbox, $self->text) );
- $self->label_widget->setStretchable( $yui::YD_HORIZ, 1 );
- $self->progressbar( $factory->createProgressBar($vbox, "") );
-
- if ($self->parent) {
- $factory->createVSpacing($vbox, 0.5);
- $self->parent->showChild();
- $self->main_dialog->recalcLayout();
- $self->main_dialog->doneMultipleChanges();
- }
-
- $self->main_dialog->pollEvent();
- $self->flush();
-}
-
-
-#=============================================================
-
-=head2 flush
-
-=head3 DESCRIPTION
-
- Polls a dialog event to refresh the dialog
-
-=cut
-
-#=============================================================
-sub flush {
- my ($self) = @_;
-
- $self->main_dialog->startMultipleChanges();
- $self->main_dialog->recalcLayout();
- $self->main_dialog->doneMultipleChanges();
-
- if ($self->main_dialog->isTopmostDialog()) {
- $self->main_dialog->waitForEvent(10);
- $self->main_dialog->pollEvent();
- }
- else {
- carp "This dialog is not a top most dialog\n";
- }
- yui::YUI::app()->redrawScreen();
-}
-
-#=============================================================
-
-=head2 label
-
-=head3 INPUT
-
- $text: text to be shown on label
-
-=head3 DESCRIPTION
-
- Sets the label text
-
-=cut
-
-#=============================================================
-sub label {
- my ($self, $text) = @_;
-
- $self->main_dialog->startMultipleChanges();
- $self->label_widget->setValue($text) if $text;
- $self->main_dialog->doneMultipleChanges();
-
- $self->flush();
-}
-
-#=============================================================
-
-=head2 progress
-
-=head3 INPUT
-
- $value: integer value in the range 0..100
-
-=head3 DESCRIPTION
-
- Sets the progress bar percentage value
-
-=cut
-
-#=============================================================
-sub progress {
- my ($self, $value) = @_;
- state $time = 0;
-
- $value = 0 if !defined($value) || $value < 0;
- $value = 100 if 100 < $value;
-
- $self->progressbar->setValue($value);
- return if Time::HiRes::clock_gettime() - $time < 0.333;
- $time = Time::HiRes::clock_gettime();
-
- $self->flush();
-}
-
-#=============================================================
-
-=head2 DEMOLISH
-
-=head3 INPUT
-
- $val: boolean value indicating whether or not this method
- was called as part of the global destruction process
- (when the Perl interpreter exits)
-
-=head3 DESCRIPTION
-
- Moose provides a hook for object destruction with the
- DEMOLISH method as it does for construtor with BUILD
-
-=cut
-
-#=============================================================
-sub DEMOLISH {
- my ($self, $val) = @_;
-
- $self->main_dialog->destroy if !$self->parent;
-}
-
-# TODO cancel button cannot be easily managed in libyui polling events
-# removed atm
-#
-# sub validate_cancel {
-# my ($self, $cancel_msg, $cancel_cb) = @_;
-# $self->{main_dialog}->startMultipleChanges();
-# if (!$self->{cancel}) {
-# $self->{cancel} = $self->{factory}->createIconButton($self->{vbox},"",$cancel_msg);
-# #gtkpack__(
-# #$self->{vbox},
-# #$self->{hbox_cancel} = gtkpack__(
-# #gtknew('HButtonBox'),
-# #$self->{cancel} = gtknew('Button', text => $cancel_msg, clicked => \&$cancel_cb),
-# #),
-# #);
-# }
-# #$self->{cancel}->set_sensitive(1);
-# #$self->{cancel}->show;
-# $self->flush();
-# }
-#
-# sub invalidate_cancel {
-# my ($self) = @_;
-# $self->{cancel} and $self->{cancel}->setEnabled(0);
-# }
-#
-# sub invalidate_cancel_forever {
-# my ($self) = @_;
-# #$self->{hbox_cancel} or return;
-# #$self->{hbox_cancel}->destroy;
-# # FIXME: temporary workaround that prevents
-# # Gtk2::Label::set_text() set_text_internal() -> queue_resize() ->
-# # size_allocate() call chain to mess up when ->shrink_topwindow()
-# # has been called (#32613):
-# #$self->shrink_topwindow;
-# }
-
-1;
diff --git a/lib/AdminPanel/Rpmdragora/icon.pm b/lib/AdminPanel/Rpmdragora/icon.pm
deleted file mode 100644
index 6c3887d6..00000000
--- a/lib/AdminPanel/Rpmdragora/icon.pm
+++ /dev/null
@@ -1,234 +0,0 @@
-# vim: set et ts=4 sw=4:
-package ManaTools::Rpmdragora::icon;
-#*****************************************************************************
-#
-# Copyright (c) 2002 Guillaume Cottenceau
-# Copyright (c) 2002-2007 Thierry Vignaud <tvignaud@mandriva.com>
-# Copyright (c) 2003, 2004, 2005 MandrakeSoft SA
-# Copyright (c) 2005-2007 Mandriva SA
-# Copyright (c) 2013 - 2015 Matteo Pasotti <matteo.pasotti@gmail.com>
-# Copyright (c) 2014 - 2015 Angelo Naselli <anaselli@linux.it>
-#
-# 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: icon.pm 237459 2008-02-26 14:20:47Z tv $
-
-use strict;
-
-use ManaTools::rpmdragora;
-use ManaTools::Shared::Locales;
-
-my $loc = ManaTools::rpmdragora::locale();
-
-use Exporter;
-our @ISA = qw(Exporter);
-our @EXPORT_OK = qw(get_icon_path);
-#- /usr/share/rpmlint/config (duplicates are normal, so that we are not too far away from .py)
-my %group_icons = (
- $loc->N("All") => 'system_section',
- $loc->N("Accessibility") => 'accessibility_section',
- $loc->N("Archiving") => 'archiving_section',
- join('|', $loc->N("Archiving"), $loc->N("Backup")) => 'backup_section',
- join('|', $loc->N("Archiving"), $loc->N("Cd burning")) => 'cd_burning_section',
- join('|', $loc->N("Archiving"), $loc->N("Compression")) => 'compression_section',
- join('|', $loc->N("Archiving"), $loc->N("Other")) => 'other_archiving',
- $loc->N("Communications") => 'communications_section',
- join('|', $loc->N("Communications"), $loc->N("Bluetooth")) => 'communications_bluetooth_section',
- join('|', $loc->N("Communications"), $loc->N("Dial-Up")) => 'communications_dialup_section',
- join('|', $loc->N("Communications"), $loc->N("Fax")) => 'communications_fax_section',
- join('|', $loc->N("Communications"), $loc->N("Mobile")) => 'communications_mobile_section',
- join('|', $loc->N("Communications"), $loc->N("Radio")) => 'communications_radio_section',
- join('|', $loc->N("Communications"), $loc->N("Serial")) => 'communications_serial_section',
- join('|', $loc->N("Communications"), $loc->N("Telephony")) => 'communications_phone_section',
- $loc->N("Databases") => 'databases_section',
- $loc->N("Development") => 'development_section',
- join('|', $loc->N("Development"), $loc->N("Basic")) => '',
- join('|', $loc->N("Development"), $loc->N("C")) => '',
- join('|', $loc->N("Development"), $loc->N("C++")) => '',
- join('|', $loc->N("Development"), $loc->N("C#")) => '',
- join('|', $loc->N("Development"), $loc->N("Databases")) => 'databases_section',
- join('|', $loc->N("Development"), $loc->N("Debug")) => '',
- join('|', $loc->N("Development"), $loc->N("Erlang")) => '',
- join('|', $loc->N("Development"), $loc->N("GNOME and GTK+")) => 'gnome_section',
- join('|', $loc->N("Development"), $loc->N("Java")) => '',
- join('|', $loc->N("Development"), $loc->N("KDE and Qt")) => 'kde_section',
- join('|', $loc->N("Development"), $loc->N("Kernel")) => '',
- join('|', $loc->N("Development"), $loc->N("OCaml")) => '',
- join('|', $loc->N("Development"), $loc->N("Other")) => '',
- join('|', $loc->N("Development"), $loc->N("Perl")) => '',
- join('|', $loc->N("Development"), $loc->N("PHP")) => '',
- join('|', $loc->N("Development"), $loc->N("Python")) => '',
- join('|', $loc->N("Development"), $loc->N("Tools")) => 'development_tools_section',
- join('|', $loc->N("Development"), $loc->N("X11")) => '',
- $loc->N("Documentation") => 'documentation_section',
- $loc->N("Editors") => 'editors_section',
- $loc->N("Education") => 'education_section',
- $loc->N("Emulators") => 'emulators_section',
- $loc->N("File tools") => 'file_tools_section',
- $loc->N("Games") => 'amusement_section',
- join('|', $loc->N("Games"), $loc->N("Adventure")) => 'adventure_section',
- join('|', $loc->N("Games"), $loc->N("Arcade")) => 'arcade_section',
- join('|', $loc->N("Games"), $loc->N("Boards")) => 'boards_section',
- join('|', $loc->N("Games"), $loc->N("Cards")) => 'cards_section',
- join('|', $loc->N("Games"), $loc->N("Other")) => 'other_amusement',
- join('|', $loc->N("Games"), $loc->N("Puzzles")) => 'puzzle_section',
- join('|', $loc->N("Games"), $loc->N("Shooter")) => 'shooter_section',
- join('|', $loc->N("Games"), $loc->N("Simulation")) => 'simulation_section',
- join('|', $loc->N("Games"), $loc->N("Sports")) => 'sport_section',
- join('|', $loc->N("Games"), $loc->N("Strategy")) => 'strategy_section',
- $loc->N("Geography") => 'geography_section',
- $loc->N("Graphical desktop") => 'graphical_desktop_section',
- join('|', $loc->N("Graphical desktop"),
- #-PO: This is a package/product name. Only translate it if needed:
- $loc->N("Enlightenment")) => 'enlightment_section',
- join('|', $loc->N("Graphical desktop"),
- #-PO: This is a package/product name. Only translate it if needed:
- $loc->N("GNOME")) => 'gnome_section',
- join('|', $loc->N("Graphical desktop"),
- #-PO: This is a package/product name. Only translate it if needed:
- $loc->N("Icewm")) => 'icewm_section',
- join('|', $loc->N("Graphical desktop"),
- #-PO: This is a package/product name. Only translate it if needed:
- $loc->N("KDE")) => 'kde_section',
- join('|', $loc->N("Graphical desktop"), $loc->N("Other")) => 'more_applications_other_section',
- join('|', $loc->N("Graphical desktop"),
- #-PO: This is a package/product name. Only translate it if needed:
- $loc->N("WindowMaker")) => 'windowmaker_section',
- join('|', $loc->N("Graphical desktop"),
- #-PO: This is a package/product name. Only translate it if needed:
- $loc->N("Xfce")) => 'xfce_section',
- $loc->N("Graphics") => 'graphics_section',
- join('|', $loc->N("Graphics"), $loc->N("3D")) => 'graphics_3d_section',
- join('|', $loc->N("Graphics"), $loc->N("Editors and Converters")) => 'graphics_editors_section',
- join('|', $loc->N("Graphics"), $loc->N("Utilities")) => 'graphics_utilities_section',
- join('|', $loc->N("Graphics"), $loc->N("Photography")) => 'graphics_photography_section',
- join('|', $loc->N("Graphics"), $loc->N("Scanning")) => 'graphics_scanning_section',
- join('|', $loc->N("Graphics"), $loc->N("Viewers")) => 'graphics_viewers_section',
- $loc->N("Monitoring") => 'monitoring_section',
- $loc->N("Networking") => 'networking_section',
- join('|', $loc->N("Networking"), $loc->N("File transfer")) => 'file_transfer_section',
- join('|', $loc->N("Networking"), $loc->N("IRC")) => 'irc_section',
- join('|', $loc->N("Networking"), $loc->N("Instant messaging")) => 'instant_messaging_section',
- join('|', $loc->N("Networking"), $loc->N("Mail")) => 'mail_section',
- join('|', $loc->N("Networking"), $loc->N("News")) => 'news_section',
- join('|', $loc->N("Networking"), $loc->N("Other")) => 'other_networking',
- join('|', $loc->N("Networking"), $loc->N("Remote access")) => 'remote_access_section',
- join('|', $loc->N("Networking"), $loc->N("WWW")) => 'networking_www_section',
- $loc->N("Office") => 'office_section',
- join('|', $loc->N("Office"), $loc->N("Dictionary")) => 'office_dictionary_section',
- join('|', $loc->N("Office"), $loc->N("Finance")) => 'finances_section',
- join('|', $loc->N("Office"), $loc->N("Management")) => 'timemanagement_section',
- join('|', $loc->N("Office"), $loc->N("Organizer")) => 'timemanagement_section',
- join('|', $loc->N("Office"), $loc->N("Utilities")) => 'office_accessories_section',
- join('|', $loc->N("Office"), $loc->N("Spreadsheet")) => 'spreadsheet_section',
- join('|', $loc->N("Office"), $loc->N("Suite")) => 'office_suite',
- join('|', $loc->N("Office"), $loc->N("Word processor")) => 'wordprocessor_section',
- $loc->N("Publishing") => 'publishing_section',
- $loc->N("Sciences") => 'sciences_section',
- join('|', $loc->N("Sciences"), $loc->N("Astronomy")) => 'astronomy_section',
- join('|', $loc->N("Sciences"), $loc->N("Biology")) => 'biology_section',
- join('|', $loc->N("Sciences"), $loc->N("Chemistry")) => 'chemistry_section',
- join('|', $loc->N("Sciences"), $loc->N("Computer science")) => 'computer_science_section',
- join('|', $loc->N("Sciences"), $loc->N("Geosciences")) => 'geosciences_section',
- join('|', $loc->N("Sciences"), $loc->N("Mathematics")) => 'mathematics_section',
- join('|', $loc->N("Sciences"), $loc->N("Other")) => 'other_sciences',
- join('|', $loc->N("Sciences"), $loc->N("Physics")) => 'physics_section',
- $loc->N("Security") => 'security_section',
- $loc->N("Shells") => 'shells_section',
- $loc->N("Sound") => 'sound_section',
- join('|', $loc->N("Sound"), $loc->N("Editors and Converters")) => 'sound_editors_section',
- join('|', $loc->N("Sound"), $loc->N("Midi")) => 'sound_midi_section',
- join('|', $loc->N("Sound"), $loc->N("Mixers")) => 'sound_mixers_section',
- join('|', $loc->N("Sound"), $loc->N("Players")) => 'sound_players_section',
- join('|', $loc->N("Sound"), $loc->N("Utilities")) => 'sound_utilities_section',
- $loc->N("System") => 'system_section',
- join('|', $loc->N("System"), $loc->N("Base")) => 'system_section',
- join('|', $loc->N("System"), $loc->N("Boot and Init")) => 'boot_init_section',
- join('|', $loc->N("System"), $loc->N("Cluster")) => 'parallel_computing_section',
- join('|', $loc->N("System"), $loc->N("Configuration")) => 'configuration_section',
- join('|', $loc->N("System"), $loc->N("Fonts")) => 'chinese_section',
- join('|', $loc->N("System"), $loc->N("Fonts"), $loc->N("True type")) => '',
- join('|', $loc->N("System"), $loc->N("Fonts"), $loc->N("Type1")) => '',
- join('|', $loc->N("System"), $loc->N("Fonts"), $loc->N("X11 bitmap")) => '',
- join('|', $loc->N("System"), $loc->N("Internationalization")) => 'chinese_section',
- join('|', $loc->N("System"), $loc->N("Kernel and hardware")) => 'hardware_configuration_section',
- join('|', $loc->N("System"), $loc->N("Libraries")) => 'system_section',
- join('|', $loc->N("System"), $loc->N("Networking")) => 'networking_configuration_section',
- join('|', $loc->N("System"), $loc->N("Packaging")) => 'packaging_section',
- join('|', $loc->N("System"), $loc->N("Printing")) => 'printing_section',
- join('|', $loc->N("System"), $loc->N("Servers")) => 'servers_section',
- join('|', $loc->N("System"),
- #-PO: This is a package/product name. Only translate it if needed:
- $loc->N("X11")) => 'x11_section',
- $loc->N("Terminals") => 'terminals_section',
- $loc->N("Text tools") => 'text_tools_section',
- $loc->N("Toys") => 'toys_section',
- $loc->N("Video") => 'video_section',
- join('|', $loc->N("Video"), $loc->N("Editors and Converters")) => 'video_editors_section',
- join('|', $loc->N("Video"), $loc->N("Players")) => 'video_players_section',
- join('|', $loc->N("Video"), $loc->N("Television")) => 'video_television_section',
- join('|', $loc->N("Video"), $loc->N("Utilities")) => 'video_utilities_section',
-
- # for Mageia Choice:
- $loc->N("Workstation") => 'system_section',
- join('|', $loc->N("Workstation"), $loc->N("Configuration")) => 'configuration_section',
- join('|', $loc->N("Workstation"), $loc->N("Console Tools")) => 'interpreters_section',
- join('|', $loc->N("Workstation"), $loc->N("Documentation")) => 'documentation_section',
- join('|', $loc->N("Workstation"), $loc->N("Game station")) => 'amusement_section',
- join('|', $loc->N("Workstation"), $loc->N("Internet station")) => 'networking_section',
- join('|', $loc->N("Workstation"), $loc->N("Multimedia station")) => 'multimedia_section',
- join('|', $loc->N("Workstation"), $loc->N("Network Computer (client)")) => 'other_networking',
- join('|', $loc->N("Workstation"), $loc->N("Office Workstation")) => 'office_section',
- join('|', $loc->N("Workstation"), $loc->N("Scientific Workstation")) => 'sciences_section',
- $loc->N("Graphical Environment") => 'graphical_desktop_section',
-
- join('|', $loc->N("Graphical Environment"), $loc->N("GNOME Workstation")) => 'gnome_section',
- join('|', $loc->N("Graphical Environment"), $loc->N("IceWm Desktop")) => 'icewm_section',
- join('|', $loc->N("Graphical Environment"), $loc->N("KDE Workstation")) => 'kde_section',
- join('|', $loc->N("Graphical Environment"), $loc->N("Other Graphical Desktops")) => 'more_applications_other_section',
- $loc->N("Development") => 'development_section',
- join('|', $loc->N("Development"), $loc->N("Development")) => 'development_section',
- join('|', $loc->N("Development"), $loc->N("Documentation")) => 'documentation_section',
- $loc->N("Server") => 'servers_section',
- join('|', $loc->N("Server"), $loc->N("DNS/NIS")) => 'networking_section',
- join('|', $loc->N("Server"), $loc->N("Database")) => 'databases_section',
- join('|', $loc->N("Server"), $loc->N("Firewall/Router")) => 'networking_section',
- join('|', $loc->N("Server"), $loc->N("Mail")) => 'mail_section',
- join('|', $loc->N("Server"), $loc->N("Mail/Groupware/News")) => 'mail_section',
- join('|', $loc->N("Server"), $loc->N("Network Computer server")) => 'networking_section',
- join('|', $loc->N("Server"), $loc->N("Web/FTP")) => 'networking_www_section',
-
- );
-
-sub get_icon_path {
- my ($group, $parent) = @_;
-
- my $path = $parent ? '/usr/share/icons/mini/' : '/usr/share/icons/';
- my $icon_path = "";
- if(defined($group_icons{$group})){
- $icon_path = join('', $path, $group_icons{$group}, '.png');
- }elsif(defined($group_icons{$parent."\|".$group})){
- $icon_path = join('', $path, $group_icons{$parent."\|".$group}, '.png');
- }else{
- $icon_path = join('', $path, 'applications_section', '.png');
- }
- unless(-e $icon_path){
- $icon_path = join('', $path, 'applications_section', '.png');
- }
- return $icon_path;
-}
-
-1;
diff --git a/lib/AdminPanel/Rpmdragora/init.pm b/lib/AdminPanel/Rpmdragora/init.pm
deleted file mode 100644
index f6d570d9..00000000
--- a/lib/AdminPanel/Rpmdragora/init.pm
+++ /dev/null
@@ -1,181 +0,0 @@
-# vim: set et ts=4 sw=4:
-package ManaTools::Rpmdragora::init;
-#*****************************************************************************
-#
-# Copyright (c) 2002 Guillaume Cottenceau
-# Copyright (c) 2002-2007 Thierry Vignaud <tvignaud@mandriva.com>
-# Copyright (c) 2003, 2004, 2005 MandrakeSoft SA
-# Copyright (c) 2005-2007 Mandriva SA
-# Copyright (c) 2013 - 2015 Matteo Pasotti <matteo.pasotti@gmail.com>
-# Copyright (c) 2014 - 2015 Angelo Naselli <anaselli@linux.it>
-#
-# 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: init.pm 263915 2009-12-03 17:41:04Z tv $
-
-use strict;
-use MDK::Common::Func 'any';
-use English;
-BEGIN { $::no_global_argv_parsing = 1 }
-require urpm::args;
-use MDK::Common::Various qw(chomp_);
-
-use ManaTools::Privileges;
-use ManaTools::Shared::Locales;
-
-use Exporter;
-our @ISA = qw(Exporter);
-our @EXPORT = qw(init
- warn_about_user_mode
- $MODE
- $VERSION
- $changelog_first
- $default_list_mode
- %rpmdragora_options
- @ARGV_copy
- );
-
-our @ARGV_copy = @ARGV;
-
-BEGIN { #- we want to run this code before the Gtk->init of the use-my_gtk
- my $loc = ManaTools::Shared::Locales->new(domain_name => 'rpmdrake');
-
- my $basename = sub { local $_ = shift; s|/*\s*$||; s|.*/||; $_ };
- any { /^--?h/ } @ARGV and do {
- printf join("\n", $loc->N("Usage: %s [OPTION]...", $basename->($0)),
-$loc->N(" --auto assume default answers to questions"),
-$loc->N(" --changelog-first display changelog before filelist in the description window"),
-$loc->N(" --media=medium1,.. limit to given media"),
-$loc->N(" --merge-all-rpmnew propose to merge all .rpmnew/.rpmsave files found"),
-$loc->N(" --mode=MODE set mode (install (default), remove, update)"),
-$loc->N(" --justdb update the database, but do not modify the filesystem"),
-$loc->N(" --no-confirmation don't ask first confirmation question in update mode"),
-$loc->N(" --no-media-update don't update media at startup"),
-$loc->N(" --no-verify-rpm don't verify package signatures"),
-if_($0 !~ /MageiaUpdate/, $loc->N(" --parallel=alias,host be in parallel mode, use \"alias\" group, use \"host\" machine to show needed deps")),
-$loc->N(" --rpm-root=path use another root for rpm installation"),
-$loc->N(" --urpmi-root use another root for urpmi db & rpm installation"),
-$loc->N(" --run-as-root force to run as root"),
-$loc->N(" --search=pkg run search for \"pkg\""),
-$loc->N(" --test only verify if the installation can be achieved correctly"),
-chomp_($loc->N(" --version print this tool's version number
-")),
-""
-);
- exit 0;
- };
-}
-
-BEGIN { #- for mcc
- if ("@ARGV" =~ /--embedded (\w+)/) {
- $::XID = $1;
- $::isEmbedded = 1;
- }
-}
-
-
-#- This is needed because text printed by Gtk2 will always be encoded
-#- in UTF-8; we first check if LC_ALL is defined, because if it is,
-#- changing only LC_COLLATE will have no effect.
-use POSIX qw(setlocale LC_ALL LC_COLLATE strftime);
-use locale;
-my $collation_locale = $ENV{LC_ALL};
-if ($collation_locale) {
- $collation_locale =~ /UTF-8/ or setlocale(LC_ALL, "$collation_locale.UTF-8");
-} else {
- $collation_locale = setlocale(LC_COLLATE);
- $collation_locale =~ /UTF-8/ or setlocale(LC_COLLATE, "$collation_locale.UTF-8");
-}
-
-our $VERSION = "1.0.0";
-our %rpmdragora_options;
-
-my $i;
-foreach (@ARGV) {
- $i++;
- /^-?-(\S+)$/ or next;
- my $val = $1;
- if ($val =~ /=/) {
- my ($name, $values) = split /=/, $val;
- my @values = split /,/, $values;
- $rpmdragora_options{$name} = \@values if @values;
- } else {
- if ($val eq 'version') {
- print "$0 $VERSION\n";
- exit(0);
- } elsif ($val =~ /^(test|expert)$/) {
- eval "\$::$1 = 1";
- } elsif ($val =~ /^(q|quiet)$/) {
- urpm::args::set_verbose(-1);
- } elsif ($val =~ /^(v|verbose)$/) {
- urpm::args::set_verbose(1);
- } else {
- $rpmdragora_options{$val} = 1;
- }
- }
-}
-
-foreach my $option (qw(media mode parallel rpm-root search)) {
- if (defined $rpmdragora_options{$option} && !ref($rpmdragora_options{$option})) {
- warn qq(wrong usage of "$option" option!\n);
- exit(-1); # too early for my_exit()
- }
-}
-
-$urpm::args::options{basename} = 1;
-
-our $MODE = ref $rpmdragora_options{mode} ? $rpmdragora_options{mode}[0] : undef;
-our $overriding_config = defined $MODE;
-unless ($MODE) {
- $MODE = 'install';
- $0 =~ m|remove$| and $MODE = 'remove';
- $0 =~ m|update$|i and $MODE = 'update';
-}
-
-our $default_list_mode;
-$default_list_mode = 'gui_pkgs' if $MODE eq 'install';
-if ($MODE eq 'remove') {
- $default_list_mode = 'installed';
-} elsif ($MODE eq 'update') {
- $default_list_mode = 'all_updates';
-}
-
-$MODE eq 'update' || $rpmdragora_options{'run-as-root'} and ManaTools::Privileges::is_root_capability_required();
-$::noborderWhenEmbedded = 1;
-
-require ManaTools::rpmdragora;
-
-our $changelog_first = $ManaTools::rpmdragora::changelog_first_config->[0];
-$changelog_first = 1 if $rpmdragora_options{'changelog-first'};
-
-sub warn_about_user_mode() {
- my $loc = ManaTools::Shared::Locales->new(domain_name => 'rpmdrake');
- my $title = $loc->N("Running in user mode");
- my $msg = $loc->N("You are launching this program as a normal user.\n".
- "You will not be able to perform modifications on the system,\n".
- "but you may still browse the existing database.");
-
- if(($EUID != 0) and (!ManaTools::rpmdragora::interactive_msg($title, $msg))) {
- return 0;
- }
- return 1;
-}
-
-sub init() {
- URPM::bind_rpm_textdomain_codeset();
-}
-
-1;
diff --git a/lib/AdminPanel/Rpmdragora/open_db.pm b/lib/AdminPanel/Rpmdragora/open_db.pm
deleted file mode 100644
index 7bfa7bf5..00000000
--- a/lib/AdminPanel/Rpmdragora/open_db.pm
+++ /dev/null
@@ -1,171 +0,0 @@
-# vim: set et ts=4 sw=4:
-package ManaTools::Rpmdragora::open_db;
-#*****************************************************************************
-#
-# Copyright (c) 2002 Guillaume Cottenceau
-# Copyright (c) 2002-2014 Thierry Vignaud <thierry.vignaud@gmail.com>
-# Copyright (c) 2003, 2004, 2005 MandrakeSoft SA
-# Copyright (c) 2005-2007 Mandriva SA
-# Copyright (c) 2012-2015 Matteo Pasotti <matteo.pasotti@gmail.com>
-# Copyright (c) 2014-2015 Angelo Naselli <anaselli@linux.it>
-#
-# 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: open_db.pm 268344 2010-05-06 13:06:08Z jvictor $
-
-use strict;
-use Sys::Syslog;
-
-use MDK::Common::File qw(cat_ mkdir_p);
-use MDK::Common::Func;
-use ManaTools::rpmdragora;
-use URPM;
-use urpm;
-use urpm::args;
-use urpm::select;
-use urpm::media;
-use urpm::mirrors;
-use feature 'state';
-
-use Exporter;
-our @ISA = qw(Exporter);
-our @EXPORT = qw(fast_open_urpmi_db
- get_backport_media
- get_inactive_backport_media
- get_update_medias
- is_it_a_devel_distro
- open_rpm_db
- open_urpmi_db
- );
-
-my $loc = ManaTools::rpmdragora::locale();
-
-
-# because rpm blocks some signals when rpm DB is opened, we don't keep open around:
-sub open_rpm_db {
- my ($o_force) = @_;
- my $host;
- Sys::Syslog::syslog('info|local1', "opening the RPM database");
- if ($::rpmdragora_options{parallel} && ((undef, $host) = @{$::rpmdragora_options{parallel}})) {
- state $done;
- my $dblocation = "/var/cache/urpmi/distantdb/$host";
- if (!$done || $o_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";
- $? == 0 or die "Couldn't sync db from $host to $dblocation";
- $done = 1;
- print "done.\n";
- }
- URPM::DB::open($dblocation) or die "Couldn't open RPM DB";
- } else {
- my $db;
- if ($::env) {
- #- URPM has same methods as URPM::DB and empty URPM will be seen as empty URPM::DB.
- $db = new URPM;
- $db->parse_synthesis("$::env/rpmdb.cz");
- } else {
- $db = URPM::DB::open($::rpmdragora_options{'rpm-root'}[0]||'');
- }
- $db or die "Couldn't open RPM DB (" . ($::env ? "$::env/rpmdb.cz" : $::rpmdragora_options{'rpm-root'}[0]) . ")";
- }
-}
-
-# do not pay the urpm::media::configure() heavy cost:
-sub fast_open_urpmi_db() {
- my $urpm = urpm->new;
- my $error_happened;
- $urpm->{fatal} = sub {
- $error_happened = 1;
- interactive_msg($loc->N("Fatal error"),
- $loc->N("A fatal error occurred: %s.", $_[1]));
- };
-
- urpm::set_files($urpm, $::rpmdragora_options{'urpmi-root'}[0]) if $::rpmdragora_options{'urpmi-root'}[0];
- $::rpmdragora_options{'rpm-root'}[0] ||= $::rpmdragora_options{'urpmi-root'}[0];
- urpm::args::set_root($urpm, $::rpmdragora_options{'rpm-root'}[0]) if $::rpmdragora_options{'rpm-root'}[0];
- urpm::args::set_debug($urpm) if $::rpmdragora_options{debug};
- $urpm->get_global_options;
- $urpm->{options}{wait_lock} = $::rpmdragora_options{'wait-lock'};
- $urpm->{options}{'verify-rpm'} = !$::rpmdragora_options{'no-verify-rpm'} if defined $::rpmdragora_options{'no-verify-rpm'};
- $urpm->{options}{auto} = $::rpmdragora_options{auto} if defined $::rpmdragora_options{auto};
- urpm::args::set_verbosity();
- if ($::rpmdragora_options{env} && $::rpmdragora_options{env}[0]) {
- $::env = $::rpmdragora_options{env}[0];
- # prevent crashing in URPM.pm prevent when using --env:
- $::env = "$ENV{PWD}/$::env" if $::env !~ m!^/!;
- urpm::set_env($urpm, $::env);
- }
-
- $urpm::args::options{justdb} = $::rpmdragora_options{justdb};
-
- urpm::media::read_config($urpm, 0);
- foreach (@{$urpm->{media}}) {
- next if $_->{ignore};
- urpm::media::_tempignore($_, 1) if $ignore_debug_media->[0] && $_->{name} =~ /debug/i;
- }
- # FIXME: seems uneeded with newer urpmi:
- if ($error_happened) {
- touch('/etc/urpmi/urpmi.cfg');
- exec('edit-urpm-sources.pl');
- }
- $urpm;
-}
-
-sub is_it_a_devel_distro() {
- state $res;
- return $res if defined $res;
-
- my $path = '/etc/product.id';
- $path = $::rpmdragora_options{'urpmi-root'}[0] . $path if defined($::rpmdragora_options{'urpmi-root'}[0]);
- $res = urpm::mirrors::parse_LDAP_namespace_structure(cat_($path))->{branch} eq 'Devel';
- return $res;
-}
-
-sub get_backport_media {
- my ($urpm) = @_;
- grep { $_->{name} =~ /backport/i &&
- $_->{name} !~ /debug|sources|testing/i } @{$urpm->{media}};
-}
-
-sub get_inactive_backport_media {
- my ($urpm) = @_;
- map { $_->{name} } grep { $_->{ignore} } get_backport_media($urpm);
-}
-
-sub get_update_medias {
- my ($urpm) = @_;
- if (is_it_a_devel_distro()) {
- grep { !$_->{ignore} } @{$urpm->{media}};
- } else {
- grep { !$_->{ignore} && $_->{update} } @{$urpm->{media}};
- }
-}
-
-sub open_urpmi_db {
- my (%urpmi_options) = @_;
- my $urpm = fast_open_urpmi_db();
- my $media = ref $::rpmdragora_options{media} ? join(',', @{$::rpmdragora_options{media}}) : '';
-
- my $searchmedia = $urpmi_options{update} ? undef : join(',', get_inactive_backport_media($urpm));
- $urpm->{lock} = urpm::lock::urpmi_db($urpm, undef, wait => $urpm->{options}{wait_lock}) if !$::env;
- my $previous = $::rpmdragora_options{'previous-priority-upgrade'};
- urpm::select::set_priority_upgrade_option($urpm, (ref $previous ? join(',', @$previous) : ()));
- urpm::media::configure($urpm, media => $media, MDK::Common::Func::if_($searchmedia, searchmedia => $searchmedia), %urpmi_options);
- $urpm;
-}
-
-1;
diff --git a/lib/AdminPanel/Rpmdragora/pkg.pm b/lib/AdminPanel/Rpmdragora/pkg.pm
deleted file mode 100644
index ba0b18b7..00000000
--- a/lib/AdminPanel/Rpmdragora/pkg.pm
+++ /dev/null
@@ -1,1085 +0,0 @@
-# vim: set et ts=4 sw=4:
-package ManaTools::Rpmdragora::pkg;
-#*****************************************************************************
-#
-# Copyright (c) 2002 Guillaume Cottenceau
-# Copyright (c) 2002-2007 Thierry Vignaud <tvignaud@mandriva.com>
-# Copyright (c) 2003, 2004, 2005 MandrakeSoft SA
-# Copyright (c) 2005-2007 Mandriva SA
-# Copyright (c) 2012-2015 Matteo Pasotti <matteo.pasotti@gmail.com>
-# Copyright (c) 2014-2015 Angelo Naselli <anaselli@linux.it>
-#
-# 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: pkg.pm 270160 2010-06-22 19:55:40Z jvictor $
-
-use strict;
-use Sys::Syslog;
-
-use MDK::Common::Func; #qw(before_leaving any);
-use MDK::Common::DataStructure; # qw (uniq difference2 member add2hash put_in_hash);
-use MDK::Common::System qw(arch);
-use MDK::Common::File; # qw(cat_);
-use MDK::Common::Various qw(chomp_);
-
-use POSIX qw(_exit ceil);
-use URPM;
-use utf8;
-use ManaTools::rpmdragora;
-use ManaTools::Rpmdragora::open_db;
-use ManaTools::Rpmdragora::gurpm;
-use ManaTools::Rpmdragora::formatting;
-use ManaTools::Rpmdragora::rpmnew;
-use ManaTools::Shared::RunProgram qw(run get_stdout);
-use ManaTools::rpmdragora;
-use urpm;
-use urpm::lock;
-use urpm::install;
-use urpm::signature;
-use urpm::get_pkgs;
-use urpm::select;
-use urpm::main_loop;
-use urpm::args qw();
-use urpm::util;
-use Carp;
-
-my $loc = ManaTools::rpmdragora::locale();
-
-use Exporter;
-our @ISA = qw(Exporter);
-our @EXPORT = qw(
- $priority_up_alread_warned
- download_callback
- extract_header
- find_installed_version
- get_pkgs
- perform_installation
- perform_removal
- run_rpm
- sort_packages
- );
-
-our $priority_up_alread_warned;
-
-sub sort_packages_biarch {
- sort {
- my ($na, $aa) = $a =~ /^(.*-[^-]+-[^-]+)\.([^.-]+)$/;
- my ($nb, $ab) = $b =~ /^(.*-[^-]+-[^-]+)\.([^.-]+)$/;
- !defined($na) ?
- (!defined($nb) ? 0 : 1) :
- (!defined($nb) ? -1 : $na cmp $nb || ($ab =~ /64$/) <=> ($aa =~ /64$/));
- } @_;
-}
-
-sub sort_packages_monoarch {
- sort { uc($a) cmp uc($b) } @_;
-}
-
-*sort_packages = MDK::Common::System::arch() =~ /x86_64/ ? \&sort_packages_biarch : \&sort_packages_monoarch;
-
-sub run_rpm {
- foreach (qw(LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION LC_ALL)) {
- local $ENV{$_} = $ENV{$_} . '.UTF-8' if $ENV{$_} && $ENV{$_} !~ /UTF-8/;
- }
- my @l = map { ensure_utf8($_); $_ } ManaTools::Shared::RunProgram::get_stdout(@_);
- wantarray() ? @l : join('', @l);
-}
-
-
-sub extract_header {
- my ($pkg, $urpm, $xml_info, $o_installed_version) = @_;
- my %fields = (
- info => 'description',
- files => 'files',
- changelog => 'changelog',
- );
- # already extracted:
- return if $pkg->{$fields{$xml_info}};
-
- my $p = $pkg->{pkg};
-
- if (!$p) {
- warn ">> ghost package '$pkg' has no URPM object!!!\n";
- return;
- }
-
- my $name = $p->fullname;
- # fix extracting info for SRPMS and RPM GPG keys:
- $name =~ s!\.src!!;
-
- if ($p->flag_installed && !$p->flag_upgrade) {
- my @files = map { MDK::Common::Various::chomp_($_) } run_rpm("rpm -ql $name");
- MDK::Common::DataStructure::add2hash($pkg, { files => [ @files ? @files : $loc->N("(none)") ],
- description => rpm_description(scalar(run_rpm("rpm -q --qf '%{description}' $name"))),
- changelog => format_changelog_string($o_installed_version, scalar(run_rpm("rpm -q --changelog $name"))) });
- } else {
- my $medium = pkg2medium($p, $urpm);
- my ($local_source, %xml_info_pkgs, $bar_id);
- my $_statusbar_clean_guard = MDK::Common::Func::before_leaving { $bar_id and statusbar_msg_remove($bar_id) };
- my $dir = urpm::file_from_local_url($medium->{url});
-
- print "p->filename: ". $p->filename."\n";
- $local_source = "$dir/" . $p->filename if $dir;
- print "local_source: " . ($local_source ? $local_source : "") . "\n";
-
- if ($local_source && -e $local_source) {
- $bar_id = statusbar_msg($loc->N("Getting information from %s...", $dir), 0);
- $urpm->{log}("getting information from rpms from $dir");
- } else {
- my $gurpm;
- $bar_id = statusbar_msg($loc->N("Getting '%s' from XML meta-data...", $xml_info), 0);
- my $_gurpm_clean_guard = MDK::Common::Func::before_leaving { undef $gurpm };
- if (my $xml_info_file = eval { urpm::media::any_xml_info($urpm, $medium, $xml_info, undef, sub {
- $gurpm ||= ManaTools::Rpmdragora::gurpm->new(
- text => $loc->N("Please wait"),
- );
- download_callback($gurpm, @_)
- or goto header_non_available;
- }) }) {
- require urpm::xml_info;
- require urpm::xml_info_pkg;
- $urpm->{log}("getting information from $xml_info_file");
- my %nodes = eval { urpm::xml_info::get_nodes($xml_info, $xml_info_file, [ $name ]) };
- goto header_non_available if $@;
- MDK::Common::DataStructure::put_in_hash($xml_info_pkgs{$name} ||= {}, $nodes{$name});
- } else {
- if ($xml_info eq 'info') {
- $urpm->{info}($loc->N("No xml info for medium \"%s\", only partial result for package %s", $medium->{name}, $name));
- } else {
- $urpm->{error}($loc->N("No xml info for medium \"%s\", unable to return any result for package %s", $medium->{name}, $name));
- }
- }
- }
-
- #- even if non-root, search for a header in the global cachedir
- if ($local_source && -s $local_source) {
- $p->update_header($local_source) or do {
- warn "Warning, could not extract header for $name from $medium!";
- goto header_non_available;
- };
- my @files = $p->files;
- @files = $loc->N("(none)") if !@files;
- MDK::Common::DataStructure::add2hash($pkg, { description => rpm_description($p->description),
- files => \@files,
- url => $p->url,
- changelog => format_changelog_changelogs($o_installed_version, $p->changelogs) });
- $p->pack_header; # needed in order to call methods on objects outside ->traverse
- } elsif ($xml_info_pkgs{$name}) {
- if ($xml_info eq 'info') {
- MDK::Common::DataStructure::add2hash($pkg, { description => rpm_description($xml_info_pkgs{$name}{description}),
- url => $xml_info_pkgs{$name}{url}
- });
- } elsif ($xml_info eq 'files') {
- my @files = map { MDK::Common::Various::chomp_($loc->to_utf8($_)) } split("\n", $xml_info_pkgs{$name}{files});
- MDK::Common::DataStructure::add2hash($pkg, { files => scalar(@files) ? \@files : [ $loc->N("(none)") ] });
- } elsif ($xml_info eq 'changelog') {
- MDK::Common::DataStructure::add2hash($pkg, {
- changelog => format_changelog_changelogs($o_installed_version,
- @{$xml_info_pkgs{$name}{changelogs}})
- });
- }
- } else {
- goto header_non_available;
- }
- return;
- header_non_available:
- MDK::Common::DataStructure::add2hash($pkg, { summary => $p->summary || $loc->N("(Not available)"), description => undef });
- }
-}
-
-sub find_installed_version {
- my ($p) = @_;
-
- my $version = $loc->N("(none)");
- open_rpm_db()->traverse_tag_find('name', $p->name, sub { $version = $_[0]->EVR; return ($version ? 1 : 0) }) if $p;
- return $version;
-}
-
-my $canceled;
-sub download_callback {
- my ($gurpm, $mode, $file, $percent, $total, $eta, $speed) = @_;
- $canceled = 0;
-
- if ($mode eq 'start') {
- $gurpm->label($loc->N("Downloading package `%s'...", urpm::util::basename($file)));
-# $gurpm->validate_cancel(but($loc->N("Cancel")), sub { $canceled = 1 });
- } elsif ($mode eq 'progress') {
- $gurpm->label(
- join("\n",
- $loc->N("Downloading package `%s'...", urpm::util::basename($file)),
- (defined $total && defined $eta ?
- $loc->N(" %s%% of %s completed, ETA = %s, speed = %s", $percent, $total, $eta, $speed)
- : $loc->N(" %s%% completed, speed = %s", $percent, $speed)
- ) =~ /^\s*(.*)/
- ),
- );
- #$gurpm->progress($percenti/100);
- $gurpm->progress(ceil($percent));
- } elsif ($mode eq 'end') {
- $gurpm->progress(100);
-# $gurpm->invalidate_cancel;
- }
- !$canceled;
-}
-
-
-# -=-=-=---=-=-=---=-=-=-- install packages -=-=-=---=-=-=---=-=-=-
-
-my (@update_medias, $is_update_media_already_asked);
-
-sub warn_about_media {
- my ($w, %options) = @_;
-
- return 0 if $::MODE ne 'update';
- return 0 if $::rpmdragora_options{'no-media-update'};
-
- # we use our own instance of the urpmi db in order not to mess up with skip-list managment (#31092):
- # and no need to fully configure urpmi since we may have to do it again anyway because of new media:
- my $urpm = fast_open_urpmi_db();
-
- my $_lock = urpm::lock::urpmi_db($urpm, undef, wait => $urpm->{options}{wait_lock});
-
- # build media list:
- @update_medias = get_update_medias($urpm);
-
- # do not update again media after installing/removing some packages:
- $::rpmdragora_options{'no-media-update'} ||= 1;
-
- if (@update_medias > 0) {
- if (!$options{skip_updating_mu} && !$is_update_media_already_asked) {
- $is_update_media_already_asked = 1;
- if (!$::rpmdragora_options{'no-confirmation'}) {
- my $choice = interactive_msg($loc->N("Confirmation"),
- $loc->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, dont_ask_again => 1,
-# TODO widget => gtknew('CheckButton', text => $loc->N("Do not ask me next time"),
-# active_ref => \$::rpmdragora_options{'no-confirmation'}
-# )
- );
- $::rpmdragora_options{'no-confirmation'} = $choice->{dont_ask_again};
- return(-1) if !$choice->{value};
- }
- writeconf();
- urpm::media::select_media($urpm, map { $_->{name} } @update_medias);
- update_sources($urpm, noclean => 1, medialist => [ map { $_->{name} } @update_medias ]);
- }
- } else {
- if (MDK::Common::Func::any { $_->{update} } @{$urpm->{media}}) {
- interactive_msg($loc->N("Already existing update media"),
-$loc->N("You already have at least one update medium configured, but
-all of them are currently disabled. You should run the Software
-Media Manager to enable at least one (check it in the \"%s\"
-column).
-
-Then, restart \"%s\".", $loc->N("Enabled"), $ManaTools::rpmdragora::myname_update));
- return (-1);
- }
- my ($mirror) = choose_mirror($urpm, transient => $w->{real_window} || $::main_window,
- message => join("\n\n",
- $loc->N("You have no configured update media. MageiaUpdate cannot operate without any update media."),
- $loc->N("I need to contact the Mageia website to get the mirror list.
-Please check that your network is currently running.
-
-Is it ok to continue?"),
- ),
- );
- my $m = ref($mirror) ? $mirror->{url} : '';
- $m or interactive_msg($loc->N("How to choose manually your mirror"),
-$loc->N("You may also choose your desired mirror manually: to do so,
-launch the Software Media Manager, and then add a `Security
-updates' medium.
-
-Then, restart %s.", $ManaTools::rpmdragora::myname_update)), return (-1);
- add_distrib_update_media($urpm, $mirror, only_updates => 0);
- }
- return 0;
-}
-
-
-sub get_parallel_group() {
- $::rpmdragora_options{parallel} ? $::rpmdragora_options{parallel}[0] : undef;
-}
-
-my ($count, $level, $limit, $new_stage, $prev_stage, $total);
-
-sub init_progress_bar {
- my ($urpm) = @_;
- undef $_ foreach $count, $prev_stage, $new_stage, $limit;
- $level = 5;
- $total = @{$urpm->{depslist}};
-}
-
-sub reset_pbar_count {
- undef $prev_stage;
- $count = 0;
- $limit = $_[0];
-}
-
-sub update_pbar {
- my ($gurpm) = @_;
- return if !$total; # don't die if there's no source
- $count++;
- $new_stage = $level+($limit-$level)*$count/$total;
- $prev_stage = 0 if(!defined($prev_stage));
- if ($prev_stage + 1 < $new_stage) {
- $prev_stage = $new_stage;
- $gurpm->progress(ceil($new_stage));
- }
-}
-
-
-sub get_installed_packages {
- my ($urpm, $db, $all_pkgs, $gurpm) = @_;
-
- $urpm->{global_config}{'prohibit-remove'} = '' if(!defined($urpm->{global_config}{'prohibit-remove'}));
- my @base = ("basesystem", split /,\s*/, $urpm->{global_config}{'prohibit-remove'});
- my (%base, %basepackages, @installed_pkgs, @processed_base);
- reset_pbar_count(33);
- while (defined(local $_ = shift @base)) {
- exists $basepackages{$_} and next;
- $db->traverse_tag(m|^/| ? 'path' : 'whatprovides', [ $_ ], sub {
- update_pbar($gurpm);
- my $name = $_[0]->fullname;
- # workaround looping in URPM:
- return if MDK::Common::DataStructure::member($name, @processed_base);
- push @processed_base, $name;
- push @{$basepackages{$_}}, $name;
- push @base, $_[0]->requires_nosense;
- });
- }
- foreach (values %basepackages) {
- my $n = @$_; #- count number of times it's provided
- foreach (@$_) {
- $base{$_} = \$n;
- }
- }
- # costly:
- $db->traverse(sub {
- my ($pkg) = @_;
- update_pbar($gurpm);
- my $fullname = urpm_name($pkg);
- return if $fullname =~ /@/;
- $all_pkgs->{$fullname} = {
- pkg => $pkg, urpm_name => $fullname,
- } if !($all_pkgs->{$fullname} && $all_pkgs->{$fullname}{description});
- if (my $name = $base{$fullname}) {
- $all_pkgs->{$fullname}{base} = \$name;
- $pkg->set_flag_base(1) if $$name == 1;
- }
- push @installed_pkgs, $fullname;
- $pkg->set_flag_installed;
- $pkg->pack_header; # needed in order to call methods on objects outside ->traverse
- });
- @installed_pkgs;
-}
-
-urpm::select::add_packages_to_priority_upgrade_list('rpmdragora', 'perl-Glib', 'perl-Gtk2');
-
-my ($priority_state, $priority_requested);
-our $need_restart;
-
-our $probe_only_for_updates;
-
-sub get_updates_list {
- my ($urpm, $db, $state, $requested, $requested_list, $requested_strict, $all_pkgs, %limit_preselect) = @_;
-
- $urpm->request_packages_to_upgrade(
- $db,
- $state,
- $requested,
- %limit_preselect
- );
-
- my %common_opts = (
- callback_choices => \&ManaTools::Rpmdragora::gui::callback_choices,
- priority_upgrade => $urpm->{options}{'priority-upgrade'},
- );
-
- if ($urpm->{options}{'priority-upgrade'}) {
- $need_restart =
- urpm::select::resolve_priority_upgrades_after_auto_select($urpm, $db, $state,
- $requested, %common_opts);
- }
-
- # list of updates (including those matching /etc/urpmi/skip.list):
- @$requested_list = sort map {
- my $name = urpm_name($_);
- $all_pkgs->{$name} = { pkg => $_ };
- $name;
- } @{$urpm->{depslist}}[keys %$requested];
-
- # list of pure updates (w/o those matching /etc/urpmi/skip.list but with their deps):
- if ($probe_only_for_updates && !$need_restart) {
- @$requested_strict = sort map {
- urpm_name($_);
- } $urpm->resolve_requested($db, $state, $requested, callback_choices => \&ManaTools::Rpmdragora::gui::callback_choices);
-
- if (my @l = grep { $state->{selected}{$_->id} }
- urpm::select::_priority_upgrade_pkgs($urpm, $urpm->{options}{'priority-upgrade'})) {
- if (!$need_restart) {
- $need_restart =
- urpm::select::_resolve_priority_upgrades($urpm, $db, $state, $state->{selected},
- \@l, %common_opts);
- }
- }
- }
-
- if ($need_restart) {
- $requested_strict = [ map { scalar $_->fullname } @{$urpm->{depslist}}[keys %{$state->{selected}}] ];
- # drop non priority updates:
- @$requested_list = ();
- }
-
- # list updates including skiped ones + their deps in MageiaUpdate:
- @$requested_list = MDK::Common::DataStructure::uniq(@$requested_list, @$requested_strict);
-
- # do not pre select updates in rpmdragora:
- @$requested_strict = () if !$probe_only_for_updates;
-}
-
-sub get_pkgs {
- my (%options) = @_;
- my $w = $::main_window;
-
- myexit (-1) if (warn_about_media($w, %options) == -1);
-
- my $gurpm = ManaTools::Rpmdragora::gurpm->new(
- text => $loc->N("Please wait"),
- );
- my $_gurpm_clean_guard = MDK::Common::Func::before_leaving { undef $gurpm };
-
- my $urpm = open_urpmi_db(update => $probe_only_for_updates && !is_it_a_devel_distro());
-
- my $_drop_lock = MDK::Common::Func::before_leaving { undef $urpm->{lock} };
-
- $priority_up_alread_warned = 0;
-
- # update media list in case warn_about_media() added some:
- @update_medias = get_update_medias($urpm);
-
- $gurpm->label($loc->N("Reading updates description"));
- #- parse the description file
- my $update_descr = urpm::get_updates_description($urpm, @update_medias);
- $gurpm->progress(100);
-
- my $_unused = $loc->N("Please wait, finding available packages...");
-
-# # find out installed packages:
-
- init_progress_bar($urpm);
-
- $gurpm->label($loc->N("Please wait, listing base packages..."));
- $gurpm->progress(ceil($level));
-
- my $db = eval { open_rpm_db() };
- if (my $err = $@) {
- interactive_msg($loc->N("Error"), $loc->N("A fatal error occurred: %s.", $err));
- return;
- }
-
- my $sig_handler = sub { undef $db; exit 3 };
- local $SIG{INT} = $sig_handler;
- local $SIG{QUIT} = $sig_handler;
-
- $gurpm->label($loc->N("Please wait, finding installed packages..."));
- $level = 33;
- $gurpm->progress(ceil($level));
- reset_pbar_count(66);
- my (@installed_pkgs, %all_pkgs);
- if (!$probe_only_for_updates) {
- @installed_pkgs = get_installed_packages($urpm, $db, \%all_pkgs, $gurpm);
- }
-
- if (my $group = get_parallel_group()) {
- urpm::media::configure($urpm, parallel => $group);
- }
-
- # find out availlable packages:
-
- $urpm->{state} = {};
-
- $gurpm->label($loc->N("Please wait, finding available packages..."));
- $level = 66;
- $gurpm->progress(ceil($level));
-
- check_update_media_version($urpm, @update_medias);
-
- my $requested = {};
- my $state = {};
- my (@requested, @requested_strict);
-
- if ($compute_updates->[0] || $::MODE eq 'update') {
- my %filter;
- if ($options{pure_updates}) {
- # limit to packages from update-media (dependencies can still come from other media)
- %filter = (idlist => [ map { $_->{start} .. $_->{end} } @update_medias ]);
- }
- get_updates_list($urpm, $db, $state, $requested, \@requested, \@requested_strict, \%all_pkgs, %filter);
- }
-
- if ($need_restart) {
- $priority_state = $state;
- $priority_requested = $requested;
- } else {
- ($priority_state, $priority_requested) = ();
- }
-
- if (!$probe_only_for_updates) {
- $urpm->compute_installed_flags($db); # TODO/FIXME: not for updates
- $urpm->{depslist}[$_]->set_flag_installed foreach keys %$requested; #- pretend it's installed
- }
- $urpm->{rpmdragora_state} = $state; #- Don't forget it
- $level = 70;
- $gurpm->progress(ceil($level));
-
- my %l;
- reset_pbar_count(100);
- foreach my $pkg (@{$urpm->{depslist}}) {
- update_pbar($gurpm);
- $pkg->flag_upgrade or next;
- my $key = $pkg->name . $pkg->arch;
- $l{$key} = $pkg if !$l{$key} || $l{$key}->compare_pkg($pkg);
- }
- my @installable_pkgs = map { my $n = $_->fullname; $all_pkgs{$n} = { pkg => $_ }; $n } values %l;
- undef %l;
-
- my @inactive_backports;
- my @active_backports;
- my @backport_medias = get_backport_media($urpm);
-
- foreach my $medium (@backport_medias) {
- update_pbar($gurpm);
-
- # The 'searchmedia' flag differentiates inactive backport medias
- # (because that option was passed to urpm::media::configure to
- # temporarily enable them)
-
- my $backports =
- $medium->{searchmedia} ? \@inactive_backports : \@active_backports;
- if (defined($medium->{start}) || defined($medium->{end})) {
- foreach my $pkg_id ($medium->{start} .. $medium->{end}) {
- next if !$pkg_id;
- my $pkg = $urpm->{depslist}[$pkg_id];
- $pkg->flag_upgrade or next;
- my $name = $pkg->fullname;
- push @$backports, $name;
- $all_pkgs{$name} = { pkg => $pkg, is_backport => 1 };
- }
- }
- }
- my @updates = @requested;
- # selecting updates by default but skipped ones (MageiaUpdate only):
- foreach (@requested_strict) {
- $all_pkgs{$_}{selected} = 1;
- }
-
- # urpmi only care about the first medium where it found the package,
- # so there's no need to list the same package several time:
- @installable_pkgs = MDK::Common::DataStructure::uniq(MDK::Common::DataStructure::difference2(\@installable_pkgs, \@updates));
-
- my @meta_pkgs = grep { /^task-|^basesystem/ } keys %all_pkgs;
-
- my @gui_pkgs = map { chomp; $_ } MDK::Common::File::cat_('/usr/share/rpmdrake/gui.lst');
- # add meta packages to GUI packages list (which expect basic names not fullnames):
- push @gui_pkgs, map { (split_fullname($_))[0] } @meta_pkgs;
-
- +{ urpm => $urpm,
- all_pkgs => \%all_pkgs,
- installed => \@installed_pkgs,
- installable => \@installable_pkgs,
- updates => \@updates,
- meta_pkgs => \@meta_pkgs,
- gui_pkgs => [ grep { my $p = $all_pkgs{$_}{pkg}; $p && MDK::Common::DataStructure::member(($p->fullname)[0], @gui_pkgs) } keys %all_pkgs ],
- update_descr => $update_descr,
- backports => [ @inactive_backports, @active_backports ],
- inactive_backports => \@inactive_backports
- };
-}
-
-sub _display_READMEs_if_needed {
- my $urpm = shift;
- return if !$urpm->{readmes};
-
- my %Readmes = %{$urpm->{readmes}};
- return if ! scalar keys %Readmes;
-
- my $appTitle = yui::YUI::app()->applicationTitle();
-
- ## set new title to get it in dialog
- yui::YUI::app()->setApplicationTitle($loc->N("Upgrade information"));
- my $factory = yui::YUI::widgetFactory;
-
- ## | [msg-label] |
- ## | |
- ## | pkg-list |
- ## | |
- ## | info on selected pkg |(1)
- ## | |
- ## | [ok] |
- ####
- # (1) info on pkg list:
- # selected package readmi.urpmi
-
- my $dialog = $factory->createPopupDialog;
- my $vbox = $factory->createVBox( $dialog );
- my $msgBox = $factory->createLabel($vbox, $loc->N("These packages come with upgrade information"), 1);
- my $tree = $factory->createTree($vbox, $loc->N("Select a package"));
- $factory->createVSpacing($vbox, 1);
- my $infoBox = $factory->createRichText($vbox, "", 0);
- $tree->setWeight($yui::YD_HORIZ, 2);
- $infoBox->setWeight($yui::YD_HORIZ, 4);
- $tree->setWeight($yui::YD_VERT, 10);
- $infoBox->setWeight($yui::YD_VERT, 10);
- $factory->createVSpacing($vbox, 1);
- my $hbox = $factory->createHBox( $vbox );
- my $align = $factory->createHCenter($hbox);
- my $okButton = $factory->createPushButton($align, $loc->N("&Ok"));
- $okButton->setDefaultButton(1);
-
- # adding packages to the list
- my $itemColl = new yui::YItemCollection;
- foreach my $f (sort keys %Readmes) {
- my $item = new yui::YTreeItem ("$Readmes{$f}");
- my $child = new yui::YTreeItem ($item, "$f");
- $child->DISOWN();
- $itemColl->push($item);
- $item->DISOWN();
- }
- $tree->addItems($itemColl);
- $tree->setImmediateMode(1);
-
- while(1) {
- my $event = $dialog->waitForEvent();
- my $eventType = $event->eventType();
-
- #event type checking
- if ($eventType == $yui::YEvent::CancelEvent) {
- last;
- }
- elsif ($eventType == $yui::YEvent::WidgetEvent) {
- ### widget
- my $widget = $event->widget();
- if ($widget == $tree) {
- my $content = "";
- my $item = $tree->selectedItem();
- if ($item && !$item->hasChildren()) {
- my $filename = $tree->currentItem()->label();
- $content = scalar MDK::Common::File::cat_($filename);
- $content = $loc->N("(none)") if !$content; # should not happen
- ensure_utf8($content);
- $content =~ s/\n/<br>/g;
- }
- $infoBox->setValue($content);
- }
- elsif ($widget == $okButton) {
- last;
- }
- }
- }
-
- destroy $dialog;
-
- # restore original title
- yui::YUI::app()->setApplicationTitle($appTitle) if $appTitle;
-
- return;
-}
-
-sub perform_parallel_install {
- my ($urpm, $group, $w, $statusbar_msg_id) = @_;
- my @pkgs = map { MDK::Common::Func::if_($_->flag_requested, urpm_name($_)) } @{$urpm->{depslist}};
-
- my @error_msgs;
- my $res = !ManaTools::Shared::RunProgram::run('urpmi', '2>', \@error_msgs, '-v', '--X', '--parallel', $group, @pkgs);
-
- if ($res) {
- $$statusbar_msg_id = statusbar_msg(
- #$loc->N("Everything installed successfully"),
- $loc->N("All requested packages were installed successfully."),
- );
- } else {
- interactive_msg(
- $loc->N("Problem during installation"),
- $loc->N("There was a problem during the installation:\n\n%s", join("\n", @error_msgs)),
- scroll => 1,
- );
- }
- open_rpm_db('force_sync');
- $w->set_sensitive(1);
- return 0;
-}
-
-sub perform_installation { #- (partially) duplicated from /usr/sbin/urpmi :-(
- my ($urpm, $pkgs) = @_;
-
- my @error_msgs;
- my $statusbar_msg_id;
- my $gurpm;
- local $urpm->{fatal} = sub {
- my $fatal_msg = $_[1];
- printf STDERR "Fatal: %s\n", $fatal_msg;
- undef $gurpm;
- interactive_msg($loc->N("Installation failed"),
- $loc->N("There was a problem during the installation:\n\n%s", $fatal_msg));
- goto return_with_exit_code;
- };
- local $urpm->{error} = sub { printf STDERR "Error: %s\n", $_[0]; push @error_msgs, $_[0] };
-
- my $w = $::main_window;
- #$w->set_sensitive(0);
- #my $_restore_sensitive = MDK::Common::Func::before_leaving { $w->set_sensitive(1) };
-
- # my $_flush_guard = Gtk2::GUI_Update_Guard->new;
-
- if (my $group = get_parallel_group()) {
- return perform_parallel_install($urpm, $group, $w, \$statusbar_msg_id);
- }
-
- my ($lock, $rpm_lock);
- if (!$::env) {
- $lock = urpm::lock::urpmi_db($urpm, undef, wait => $urpm->{options}{wait_lock});
- $rpm_lock = urpm::lock::rpm_db($urpm, 'exclusive');
- }
- my $state = $priority_state || $probe_only_for_updates ? { } : $urpm->{rpmdragora_state};
-
- my $bar_id = statusbar_msg($loc->N("Checking validity of requested packages..."), 0);
-
- # FIXME: THIS SET flag_requested on all packages!!!!
- # select packages to install / enssure selected pkg set is consistant:
- my %saved_flags;
- my $requested = { map {
- $saved_flags{$_->id} = $_->flag_requested;
- $_->id => undef;
- } grep { $_->flag_selected } @{$urpm->{depslist}} };
- urpm::select::resolve_dependencies(
- $urpm, $state, $requested,
- rpmdb => $::env && "$::env/rpmdb.cz",
- callback_choices => \&ManaTools::Rpmdragora::gui::callback_choices,
- );
- statusbar_msg_remove($bar_id);
-
- my ($local_sources, $blist) = urpm::get_pkgs::selected2local_and_blists($urpm, $state->{selected});
- if (!$local_sources && (!$blist || !@$blist)) {
- interactive_msg(
- $loc->N("Unable to get source packages."),
- $loc->N("Unable to get source packages, sorry. %s",
- @error_msgs ? $loc->N("\n\nError(s) reported:\n%s", join("\n", @error_msgs)) : ''),
- scroll => 1,
- );
- goto return_with_exit_code;
- }
-
- my @to_install = @{$urpm->{depslist}}[keys %{$state->{selected}}];
- my @pkgs = map { scalar($_->fullname) } sort(grep { $_->flag_selected } @to_install);
-
- @{$urpm->{ask_remove}} = sort(urpm::select::removed_packages($urpm->{state}));
- my @to_remove = map { MDK::Common::Func::if_($pkgs->{$_}{selected} && !$pkgs->{$_}{pkg}->flag_upgrade, $pkgs->{$_}{urpm_name}) } keys %$pkgs;
-
- my $r = format_list(map { scalar(urpm::select::translate_why_removed_one($urpm, $urpm->{state}, $_)) } @to_remove);
-
- my ($size, $filesize) = $urpm->selected_size_filesize($state);
- my $install_count = int(@pkgs);
- my $to_install = $install_count == 0 ? '' :
- ($priority_state ? '<b>' . $loc->N("Rpmdragora or one of its priority dependencies needs to be updated first. Rpmdragora will then restart.") . '</b>' . "\n\n" : '') .
- ($loc->P("The following package is going to be installed:", "The following %d packages are going to be installed:", $install_count, $install_count)
- . "\n\n" . format_list(map { s!.*/!!; $_ } @pkgs));
- my $remove_count = scalar(@to_remove);
- interactive_msg(($to_install ? $loc->N("Confirmation") : $loc->N("Some packages need to be removed")),
- join("\n\n",
- ($r ?
- (!$to_install ? ($loc->P("Remove one package?", "Remove %d packages?", $remove_count, $remove_count), $r) :
- (($remove_count == 1 ?
- $loc->N("The following package has to be removed for others to be upgraded:")
- : $loc->N("The following packages have to be removed for others to be upgraded:")), $r), MDK::Common::Func::if_($to_install, $to_install))
- : $to_install),
- format_size($size),
- format_filesize($filesize),
- $loc->N("Is it ok to continue?")),
- scroll => 1,
- yesno => 1, min_size => {lines => 18},) or return 1;
-
- my $_umount_guard = MDK::Common::Func::before_leaving { urpm::removable::try_umounting_removables($urpm) };
-
- # select packages to uninstall for !update mode:
- perform_removal($urpm, { map { $_ => $pkgs->{$_} } @to_remove }) if !$probe_only_for_updates;
-
- $gurpm = ManaTools::Rpmdragora::gurpm->new(
- text => $loc->N("Please wait"),
- title => $loc->N("Initializing..."),
- );
- # my $_gurpm_clean_guard = MDK::Common::Func::before_leaving { undef $gurpm };
- my $something_installed;
-
- if (@to_install && $::rpmdragora_options{auto_orphans}) {
- urpm::orphans::compute_future_unrequested_orphans($urpm, $state);
- if (my @orphans = map { scalar $_->fullname } @{$state->{orphans_to_remove}}) {
- interactive_msg($loc->N("Orphan packages"), $loc->P("The following orphan package will be removed.",
- "The following orphan packages will be removed.", scalar(@orphans))
- . "\n" . urpm::orphans::add_leading_spaces(join("\n", @orphans) . "\n"), scroll => 1);
- }
- }
-
- urpm::orphans::mark_as_requested($urpm, $state, 0);
-
- my ($progress, $total, @rpms_upgrade);
- my $transaction;
- my ($progress_nb, $transaction_progress_nb, $remaining, $done);
- my $callback_inst = sub {
- my ($urpm, $type, $id, $subtype, $amount, $total) = @_;
- my $pkg = defined $id ? $urpm->{depslist}[$id] : undef;
- if ($subtype eq 'start') {
- if ($type eq 'trans') {
- print(1 ? $loc->N("Preparing package installation...") : $loc->N("Preparing package installation transaction..."));
- $gurpm->label($loc->N("Preparing package installation..."));
- } elsif (defined $pkg) {
- $something_installed = 1;
- print($loc->N("Installing package `%s' (%s/%s)...", $pkg->name, $transaction_progress_nb, scalar(@{$transaction->{upgrade}}))."\n" . $loc->N("Total: %s/%s", $progress_nb, $install_count));
- $gurpm->label($loc->N("Installing package `%s' (%s/%s)...", $pkg->name, ++$transaction_progress_nb, scalar(@{$transaction->{upgrade}}))
- . "\n" . $loc->N("Total: %s/%s", ++$progress_nb, $install_count));
- }
- } elsif ($subtype eq 'progress') {
- $gurpm->progress($total ? ceil(($amount/$total)*100) : 100);
- # print("Progress: ".($total ? ($amount/$total)*100 : 100)."\n");
- }
- };
-
- # FIXME: sometimes state is lost:
- my @ask_unselect = urpm::select::unselected_packages($state);
-
- # fix flags for orphan computing:
- foreach (keys %{$state->{selected}}) {
- my $pkg = $urpm->{depslist}[$_];
- $pkg->set_flag_requested($saved_flags{$pkg->id});
- }
- my $exit_code =
- urpm::main_loop::run($urpm, $state, 1, \@ask_unselect,
- {
- completed => sub {
- # explicitly destroy the progress window when it's over; we may
- # have sg to display before returning (errors, rpmnew/rpmsave, ...):
- undef $gurpm;
-
- undef $lock;
- undef $rpm_lock;
- },
- inst => $callback_inst,
- trans => $callback_inst,
- ask_yes_or_no => sub {
- # handle 'allow-force' and 'allow-nodeps' options:
- my ($title, $msg) = @_;
- local $::main_window = $gurpm->{real_window};
- interactive_msg($title, $msg, yesno => 1, scroll => 1,
- );
- },
- message => sub {
- my ($title, $message) = @_;
- interactive_msg($title, $message, scroll => 1);
- },
- # cancel installation when 'cancel' button is pressed:
- trans_log => sub { download_callback($gurpm, @_) or goto return_with_exit_code },
- post_extract => sub {
- my ($set, $transaction_sources, $transaction_sources_install) = @_;
- $transaction = $set;
- $transaction_progress_nb = 0;
- $done += grep { !/\.src\.rpm$/ } values %$transaction_sources; #updates
- $total = keys(%$transaction_sources_install) + keys %$transaction_sources;
- push @rpms_upgrade, keys %$transaction_sources;
- $done += grep { !/\.src\.rpm$/ } values %$transaction_sources_install; # installs
- },
- pre_removable => sub {
- # Gtk2::GUI_Update_Guard->new use of alarm() kill us when
- # running system(), thus making DVD being ejected and printing
- # wrong error messages (#30463)
-
- local $SIG{ALRM} = sub { die "ALARM" };
- $remaining = alarm(0);
- },
-
- post_removable => sub { alarm $remaining },
- copy_removable => sub {
- my ($medium) = @_;
- interactive_msg(
- $loc->N("Change medium"),
- $loc->N("Please insert the medium named \"%s\"", $medium),
- yesno => 1, text => { no => $loc->N("Cancel"), yes => $loc->N("Ok") },
- );
- },
- pre_check_sig => sub { $gurpm->label($loc->N("Verifying package signatures...")) },
- check_sig => sub { $gurpm->progress(ceil(++$progress/$total)*100) },
- bad_signature => sub {
- my ($msg, $msg2) = @_;
- local $::main_window = $gurpm->{real_window};
- $msg =~ s/:$/\n\n/m; # FIXME: to be fixed in urpmi after 2008.0
- interactive_msg(
- $loc->N("Warning"), "$msg\n\n$msg2", yesno => 1, MDK::Common::Func::if_(10 < ($msg =~ tr/\n/\n/), scroll => 1),
- );
- },
- post_download => sub {
- $canceled and goto return_with_exit_code;
-# $gurpm->invalidate_cancel_forever;
- },
- need_restart => sub {
- my ($need_restart_formatted) = @_;
- # FIXME: offer to restart the system
- interactive_msg($loc->N("Warning"), join("\n", values %$need_restart_formatted), scroll => 1);
- },
- trans_error_summary => sub {
- my ($nok, $errors) = @_;
- interactive_msg(
- $loc->N("Problem during installation"),
- MDK::Common::Func::if_($nok, $loc->N("%d installation transactions failed", $nok) . "\n\n") .
- $loc->N("There was a problem during the installation:\n\n%s",
- join("\n\n", @$errors, @error_msgs)),
- scroll => 1,
- );
- },
- need_restart => sub {
- my ($need_restart_formatted) = @_;
- interactive_msg($loc->N("Warning"),
- join("\n\n", values %$need_restart_formatted));
- },
- success_summary => sub {
- if (!($done || @to_remove)) {
- interactive_msg($loc->N("Error"),
- $loc->N("Unrecoverable error: no package found for installation, sorry."));
- return;
- }
- my $id = statusbar_msg($loc->N("Inspecting configuration files..."), 0);
- my %pkg2rpmnew;
- foreach my $id (@rpms_upgrade) {
- my $pkg = $urpm->{depslist}[$id];
- next if $pkg->arch eq 'src';
- $pkg2rpmnew{$pkg->fullname} = [ grep { -r "$_.rpmnew" || -r "$_.rpmsave" } $pkg->conf_files ];
- }
- statusbar_msg_remove($id);
- rpmnew_dialog($loc->N("The installation is finished; everything was installed correctly.
-
-Some configuration files were created as `.rpmnew' or `.rpmsave',
-you may now inspect some in order to take actions:"),
- %pkg2rpmnew)
- and statusbar_msg($loc->N("All requested packages were installed successfully."), 1);
- statusbar_msg($loc->N("Looking for \"README\" files..."), 1);
- _display_READMEs_if_needed($urpm);
- },
- already_installed_or_not_installable => sub {
- my ($msg1, $msg2) = @_;
- my $msg = join("\n", @$msg1, @$msg2);
- return if !$msg; # workaround missing state
- interactive_msg($loc->N("Error"), $msg);
- },
- },
- );
-
- #- restart rpmdragora if needed, keep command line for that.
- if ($need_restart && !$exit_code && $something_installed) {
- Sys::Syslog::syslog('info|local1', "restarting rpmdragora");
- #- it seems to work correctly with exec instead of system, provided we stop timers
- #- added --previous-priority-upgrade to allow checking if yet if
- #- priority-upgrade list has changed. and make sure we don't uselessly restart
- my @argv = ('--previous-priority-upgrade=' . $urpm->{options}{'priority-upgrade'},
- grep { !/^--no-priority-upgrade$|--previous-priority-upgrade=/ } @ManaTools::Rpmdragora::init::ARGV_copy);
- # remove "--emmbedded <id>" from argv:
- my $i = 0;
- foreach (@argv) {
- splice @argv, $i, 2 if /^--embedded$/;
- $i++;
- }
- alarm(0);
- # reMDK::Common::DataStructure::member not to ask again questions and the like:
- writeconf();
- exec($0, @argv);
- exit(0);
- }
-
- my $_s1 = $loc->N("RPM transaction %d/%d", 0, 0);
- my $_s2 = $loc->N("Unselect all");
- my $_s3 = $loc->N("Details");
-
- statusbar_msg_remove($statusbar_msg_id); #- XXX maybe remove this
-
- if ($exit_code == 0 && !$::rpmdragora_options{auto_orphans}) {
- if (urpm::orphans::check_unrequested_orphans_after_auto_select($urpm)) {
- if (my $msg = urpm::orphans::get_now_orphans_gui_msg($urpm)) {
- interactive_msg($loc->N("Orphan packages"), $msg, scroll => 1);
- }
- }
- }
-
- return_with_exit_code:
- return !($something_installed || scalar(@to_remove));
-}
-
-
-# -=-=-=---=-=-=---=-=-=-- remove packages -=-=-=---=-=-=---=-=-=-
-
-sub perform_removal {
- my ($urpm, $pkgs) = @_;
- my @toremove = map { MDK::Common::Func::if_($pkgs->{$_}{selected}, $pkgs->{$_}{urpm_name}) } keys %$pkgs;
- return if !@toremove;
- my $gurpm = ManaTools::Rpmdragora::gurpm->new(
- text => $loc->N("Please wait")
- );
- my $_gurpm_clean_guard = MDK::Common::Func::before_leaving { undef $gurpm };
-
- my $may_be_orphans = 1;
- urpm::orphans::unrequested_orphans_after_remove($urpm, \@toremove)
- or $may_be_orphans = 0;
-
- my $progress = -1;
- local $urpm->{log} = sub {
- my $str = $_[0];
- print $str;
- $progress++;
- return if $progress <= 0; # skip first "creating transaction..." message
- $gurpm->label($str); # display "removing package %s"
- $gurpm->progress(ceil(min(99, scalar($progress/@toremove)*100)));
- #gtkflush();
- };
-
- my @results;
- slow_func_statusbar(
- $loc->N("Please wait, removing packages..."),
- $::main_window,
- sub {
- @results = $::rpmdragora_options{parallel}
- ? urpm::parallel::remove($urpm, \@toremove)
- : urpm::install::install($urpm, \@toremove, {}, {},
- callback_report_uninst => sub { $gurpm->label($_[0]) },
- );
- open_rpm_db('force_sync');
- },
- );
- if (@results) {
- interactive_msg(
- $loc->N("Problem during removal"),
- $loc->N("There was a problem during the removal of packages:\n\n%s", join("\n", @results)),
- MDK::Common::Func::if_(@results > 1, scroll => 1),
- );
- return 1;
- } else {
- if ($may_be_orphans && !$::rpmdragora_options{auto_orphans}) {
- if (my $msg = urpm::orphans::get_now_orphans_gui_msg($urpm)) {
- interactive_msg($loc->N("Information"), $msg, scroll => 1);
- }
- }
- return 0;
- }
-}
-
-1;
diff --git a/lib/AdminPanel/Rpmdragora/rpmnew.pm b/lib/AdminPanel/Rpmdragora/rpmnew.pm
deleted file mode 100644
index 659c0b29..00000000
--- a/lib/AdminPanel/Rpmdragora/rpmnew.pm
+++ /dev/null
@@ -1,363 +0,0 @@
-# vim: set et ts=4 sw=4:
-package ManaTools::Rpmdragora::rpmnew;
-#*****************************************************************************
-#
-# Copyright (c) 2002 Guillaume Cottenceau
-# Copyright (c) 2002-2007 Thierry Vignaud <tvignaud@mandriva.com>
-# Copyright (c) 2003, 2004, 2005 MandrakeSoft SA
-# Copyright (c) 2005-2007 Mandriva SA
-# Copyright (c) 2013 - 2015 Matteo Pasotti <matteo.pasotti@gmail.com>
-# Copyright (c) 2014 - 2015 Angelo Naselli <anaselli@linux.it>
-#
-# 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: rpmnew.pm 263914 2009-12-03 17:41:02Z tv $
-
-use strict;
-use Text::Diff;
-use MDK::Common::Math qw(sum);
-use MDK::Common::File qw(renamef);
-use MDK::Common::Various qw(chomp_);
-
-use ManaTools::rpmdragora;
-use ManaTools::Rpmdragora::init;
-use ManaTools::Rpmdragora::pkg;
-use ManaTools::Rpmdragora::open_db;
-use ManaTools::Rpmdragora::formatting;
-
-use yui;
-
-use Exporter;
-our @ISA = qw(Exporter);
-our @EXPORT = qw(rpmnew_dialog do_merge_if_needed);
-
-my $loc = ManaTools::rpmdragora::locale();
-
-# /var/lib/nfs/etab /var/lib/nfs/rmtab /var/lib/nfs/xtab /var/cache/man/whatis
-my %ignores_rpmnew = map { $_ => 1 } qw(
- /etc/adjtime
- /etc/fstab
- /etc/group
- /etc/ld.so.conf
- /etc/localtime
- /etc/modules
- /etc/passwd
- /etc/security/fileshare.conf
- /etc/shells
- /etc/sudoers
- /etc/sysconfig/alsa
- /etc/sysconfig/autofsck
- /etc/sysconfig/harddisks
- /etc/sysconfig/harddrake2/previous_hw
- /etc/sysconfig/init
- /etc/sysconfig/installkernel
- /etc/sysconfig/msec
- /etc/sysconfig/nfs
- /etc/sysconfig/pcmcia
- /etc/sysconfig/rawdevices
- /etc/sysconfig/saslauthd
- /etc/sysconfig/syslog
- /etc/sysconfig/usb
- /etc/sysconfig/xinetd
-);
-
-
-#=============================================================
-
-=head2 _rpmnewFile
-
-=head3 INPUT
-
- $filename: configuration file name
-
-=head3 OUTPUT
-
- $rpmnew_filename: new configuration file name
-
-=head3 DESCRIPTION
-
- This function evaluate the new configration file generated by
- the update
-
-=cut
-
-#=============================================================
-sub _rpmnewFile ($) {
- my $filename = shift;
-
- my ($rpmnew, $rpmsave) = ("$filename.rpmnew", "$filename.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;
-
- return $rpmnew;
-}
-
-#=============================================================
-
-=head2 _performDiff
-
-=head3 INPUT
-
- $file: configuration file name
- $diffBox: YWidget that will show the difference
-
-=head3 DESCRIPTION
-
- This function gets the configuration file perfomrs
- the difference with the new one and shows it into the
- $diffBox
-
-=cut
-
-#=============================================================
-sub _performDiff ($$) {
- my ($file, $diffBox) = @_;
-
- my $rpmnew = _rpmnewFile($file);
-
- foreach (qw(LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION LC_ALL)) {
- local $ENV{$_} = $ENV{$_} . '.UTF-8' if $ENV{$_} && $ENV{$_} !~ /UTF-8/;
- }
-
- my $diff = diff $file, $rpmnew, { STYLE => "Unified" };
- $diff = $loc->N("(none)") if !$diff;
-
- my @lines = split ("\n", $diff);
- ## adding color lines to diff
- foreach my $line (@lines) {
- if (substr ($line, 0, 1) eq "+") {
- $line =~ s|^\+(.*)|<font color="green">+$1</font>|;
- }
- elsif (substr ($line, 0, 1) eq "-") {
- $line =~ s|^\-(.*)|<font color="red">-$1</font>|;
- }
- elsif (substr ($line, 0, 1) eq "@") {
- $line =~ s|(.*)|<font color="blue">$1</font>|;
- }
- else {
- $line =~ s|(.*)|<font color="black">$1</font>|;
- }
- }
- $diff = join("<br>", @lines);
-
- ensure_utf8($diff);
- $diffBox->setValue($diff);
-
- return;
-}
-
-#=============================================================
-
-=head2 rpmnew_dialog
-
-=head3 INPUT
-
- $msg: message to be shown during the choice
- %o2r: HASH containing {
- the package name => ARRAY of configration files
- }
-
-=head3 OUTPUT
-
- 1 if nothing to do or 0 after user interaction
-
-=head3 DESCRIPTION
-
- This function shows the configuration files difference and
- asks for action to be performed
-
-=cut
-
-#=============================================================
-sub rpmnew_dialog {
- my ($msg, %p2r) = @_;
-
- @{$p2r{$_}} = grep { !$ignores_rpmnew{$_} } @{$p2r{$_}} foreach keys %p2r;
- my $sum_rpmnew = MDK::Common::Math::sum(map { int @{$p2r{$_}} } keys %p2r);
- $sum_rpmnew == 0 and return 1;
-
- my $appTitle = yui::YUI::app()->applicationTitle();
-
- ## set new title to get it in dialog
- yui::YUI::app()->setApplicationTitle($loc->N("Installation finished"));
-
- my $factory = yui::YUI::widgetFactory;
-
- ## | [msg-label] |
- ## | |
- ## | pkg-tree |
- ## | |
- ## | info on selected pkg |(1)
- ## | Remove( ) Use ( ) Do nothing (*) |
- ## | |
- ## | [ok] |
- ####
- # (1) info on pkg list:
- # selected configuration file diff between rpmnew/rpmsave and used one
-
- my $dialog = $factory->createPopupDialog;
- my $vbox = $factory->createVBox( $dialog );
- my $msgBox = $factory->createLabel($vbox, $msg, 1);
- $factory->createVSpacing($vbox, 1);
- # Tree for groups
- my $tree = $factory->createTree($vbox, $loc->N("Select a package"));
- $tree->setWeight($yui::YD_VERT,10);
- $factory->createVSpacing($vbox, 1);
- my $infoBox = $factory->createRichText($vbox, "", 0);
- $infoBox->setWeight($yui::YD_HORIZ, 20);
- $infoBox->setWeight($yui::YD_VERT, 20);
- $factory->createVSpacing($vbox, 1);
- my $radiobuttongroup = $factory->createRadioButtonGroup($vbox);
- my $rbbox = $factory->createHBox($radiobuttongroup);
- my $rdnBtn = {
- remove_rpmnew => $loc->N("Remove new file"),
- use_rpmnew => $loc->N("Use new file"),
- do_onthing => $loc->N("Do nothing"),
- };
-
- my %radiobutton = ();
- my @rdnbtn_order = ('remove_rpmnew', 'use_rpmnew', 'do_onthing');
- foreach my $btn_name (@rdnbtn_order) {
- $radiobutton{$btn_name} = $factory->createRadioButton($rbbox, $rdnBtn->{$btn_name});
- $radiobutton{$btn_name}->setValue(1) if $btn_name eq 'do_onthing';
- $radiobutton{$btn_name}->setNotify(1);
- $radiobuttongroup->addRadioButton($radiobutton{$btn_name});
- }
- $radiobuttongroup->setEnabled(0);
- my $hbox = $factory->createHBox( $vbox );
- my $align = $factory->createHCenter($hbox);
- my $okButton = $factory->createPushButton($align, $loc->N("&Ok"));
- $okButton->setDefaultButton(1);
-
- # adding packages to the list
- my $itemColl = new yui::YItemCollection;
- my $num = 0;
- my %file_action = ();
- foreach my $p (sort keys %p2r) {
- if (scalar @{$p2r{$p}}) {
- my $item = new yui::YTreeItem ("$p");
- foreach my $f (@{$p2r{$p}}) {
- my $child = new yui::YTreeItem ($item, "$f");
- $child->DISOWN();
- $file_action{$f} = 'do_onthing';
- }
- $itemColl->push($item);
- $item->DISOWN();
- }
- }
-
- $tree->addItems($itemColl);
- $tree->setImmediateMode(1);
- $tree->rebuildTree();
-
- while(1) {
- my $event = $dialog->waitForEvent();
- my $eventType = $event->eventType();
-
- #event type checking
- if ($eventType == $yui::YEvent::CancelEvent) {
- last;
- }
- elsif ($eventType == $yui::YEvent::WidgetEvent) {
- ### widget
- my $widget = $event->widget();
- if ($widget == $tree) {
- #change info
- my $item = $tree->selectedItem();
- if ($item && !$item->hasChildren()) {
- my $filename = $tree->currentItem()->label();
- _performDiff($filename, $infoBox);
- $radiobuttongroup->setEnabled(1);
- #$radiobuttongroup->uncheckOtherButtons ($radiobutton{$file_action{$filename}});
- yui::YUI::ui()->blockEvents();
- $radiobutton{$file_action{$filename}}->setValue(1);
- yui::YUI::ui()->unblockEvents();
- }
- else {
- $infoBox->setValue("");
- $radiobuttongroup->setEnabled(0);
- }
- }
- elsif ($widget == $okButton) {
- # TODO
- foreach my $file (keys %file_action) {
- my $rpmnew = _rpmnewFile($file);
- if ($file_action{$file} eq 'remove_rpmnew') {
- eval { unlink "$rpmnew"};
- }
- elsif ($file_action{$file} eq 'use_rpmnew') {
- MDK::Common::File::renamef($rpmnew, $file);
- }
- # else do_onthing
- }
- last;
- }
- else {
- # radio buttons
- RDNBTN: foreach my $btn_name (@rdnbtn_order) {
- if ($widget == $radiobutton{$btn_name}) {
- my $filename = $tree->currentItem()->label();
- $file_action{$filename} = $btn_name;
- last RDNBTN;
- }
- }
- }
- }
- }
-
- destroy $dialog;
-
- # restore original title
- yui::YUI::app()->setApplicationTitle($appTitle) if $appTitle;
-
- return 0;
-}
-
-
-#=============================================================
-
-=head2 do_merge_if_needed
-
-=head3 DESCRIPTION
-
- This function look for new configuration file versions
- and ask for actions using the rpmnew_dialog
-
-=cut
-
-#=============================================================
-sub do_merge_if_needed() {
- if ($rpmdragora_options{'merge-all-rpmnew'}) {
- my %pkg2rpmnew;
- my $wait = wait_msg($loc->N("Please wait, searching..."));
- print "Searching .rpmnew and .rpmsave files...\n";
- # costly:
- open_rpm_db()->traverse(sub {
- my $n = my_fullname($_[0]);
- $pkg2rpmnew{$n} = [ grep { m|^/etc| && (-r "$_.rpmnew" || -r "$_.rpmsave") } map { chomp_($_) } $_[0]->conf_files ];
- });
- print "done.\n";
- remove_wait_msg($wait);
-
- rpmnew_dialog('', %pkg2rpmnew) and print "Nothing to do.\n";
- }
-
- return;
-}
-
-1;