aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MANIFEST3
-rw-r--r--lib/AdminPanel/Module/DisplayManager.pm23
-rw-r--r--lib/AdminPanel/Rpmdragora/edit_urpm_sources.pm16
-rw-r--r--lib/AdminPanel/Rpmdragora/formatting.pm2
-rw-r--r--lib/AdminPanel/Rpmdragora/gui.pm88
-rw-r--r--lib/AdminPanel/Rpmdragora/gurpm.pm2
-rw-r--r--lib/AdminPanel/Rpmdragora/icon.pm9
-rw-r--r--lib/AdminPanel/Rpmdragora/init.pm3
-rw-r--r--lib/AdminPanel/Rpmdragora/localization.pm35
-rw-r--r--lib/AdminPanel/Rpmdragora/open_db.pm12
-rw-r--r--lib/AdminPanel/Rpmdragora/pkg.pm24
-rw-r--r--lib/AdminPanel/Rpmdragora/rpmnew.pm5
-rw-r--r--lib/AdminPanel/Rpmdragora/widgets.pm52
-rw-r--r--lib/AdminPanel/Shared.pm88
-rw-r--r--lib/AdminPanel/Shared/RunProgram.pm352
-rw-r--r--lib/AdminPanel/Shared/Services.pm56
-rw-r--r--lib/AdminPanel/Shared/TimeZone.pm5
-rw-r--r--lib/AdminPanel/rpmdragora.pm21
-rwxr-xr-xmodules/rpmdragora/dragora-urpm-addmedia3
-rwxr-xr-xmodules/rpmdragora/dragora-urpm-sources.pl2
-rwxr-xr-xmodules/rpmdragora/dragoraUpdate2
-rwxr-xr-xmodules/rpmdragora/rpmdragora21
22 files changed, 528 insertions, 296 deletions
diff --git a/MANIFEST b/MANIFEST
index 05ed13ef..cfb299fe 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -45,11 +45,9 @@ lib/AdminPanel/Rpmdragora/gui.pm
lib/AdminPanel/Rpmdragora/gurpm.pm
lib/AdminPanel/Rpmdragora/icon.pm
lib/AdminPanel/Rpmdragora/init.pm
-lib/AdminPanel/Rpmdragora/localization.pm
lib/AdminPanel/Rpmdragora/open_db.pm
lib/AdminPanel/Rpmdragora/pkg.pm
lib/AdminPanel/Rpmdragora/rpmnew.pm
-lib/AdminPanel/Rpmdragora/widgets.pm
lib/AdminPanel/SettingsReader.pm
lib/AdminPanel/Shared.pm
lib/AdminPanel/Shared/GUI.pm
@@ -60,6 +58,7 @@ lib/AdminPanel/Shared/Proxy.pm
lib/AdminPanel/Shared/Services.pm
lib/AdminPanel/Shared/TimeZone.pm
lib/AdminPanel/Shared/Users.pm
+lib/AdminPanel/Shared/RunProgram.pm
Makefile.PL
MANIFEST This list of files
MODULE_HACKING
diff --git a/lib/AdminPanel/Module/DisplayManager.pm b/lib/AdminPanel/Module/DisplayManager.pm
index b877e307..e6a060d0 100644
--- a/lib/AdminPanel/Module/DisplayManager.pm
+++ b/lib/AdminPanel/Module/DisplayManager.pm
@@ -1,21 +1,21 @@
# vim: set et ts=4 sw=4:
#*****************************************************************************
-#
+#
# Copyright (c) 2013-2014 Matteo Pasotti <matteo.pasotti@gmail.com>
-#
+#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2, as
# published by the Free Software Foundation.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
+#
#*****************************************************************************
package AdminPanel::Module::DisplayManager;
@@ -36,6 +36,7 @@ use AdminPanel::Shared::GUI;
use lib qw(/usr/lib/libDrakX);
use network::network;
use MDK::Common::System qw(getVarsFromSh addVarsInSh);
+use MDK::Common::Func qw(find);
extends qw( AdminPanel::Module );
@@ -197,13 +198,13 @@ sub _manageProxyDialog {
my $factory = yui::YUI::widgetFactory;
my $optional = yui::YUI::optionalWidgetFactory;
-
+
my $label_width = 25;
my $inputfield_width = 45;
my ($dm_NAME) = apcat($self->conffile) =~ /^DISPLAYMANAGER=(.*)/m;
- my $dm = (AdminPanel::Shared::find { uc($_->{NAME}) eq uc($dm_NAME) } @{$self->dmlist});
-
+ my $dm = (MDK::Common::Func::find { uc($_->{NAME}) eq uc($dm_NAME) } @{$self->dmlist});
+
$self->dialog($factory->createMainDialog());
my $layout = $factory->createVBox($self->dialog);
@@ -212,7 +213,7 @@ sub _manageProxyDialog {
my $headRight = $factory->createHBox($factory->createRight($hbox_header));
my $logoImage = $factory->createImage($headLeft, $appIcon);
- my $labelAppDescription = $factory->createLabel($headRight,$newTitle);
+ my $labelAppDescription = $factory->createLabel($headRight,$newTitle);
$logoImage->setWeight($yui::YD_HORIZ,0);
$labelAppDescription->setWeight($yui::YD_HORIZ,3);
@@ -232,7 +233,7 @@ sub _manageProxyDialog {
my $rbbox = $factory->createVBox($rb_group);
foreach my $d (@{$self->dmlist()})
{
- my $rowentry = $factory->createHBox($factory->createLeft($rbbox));
+ my $rowentry = $factory->createHBox($factory->createLeft($rbbox));
my $rb = $factory->createRadioButton($rowentry, $d->{NAME});
$rb->setWeight($yui::YD_HORIZ, 1);
my $desc = $factory->createLabel($rowentry, $self->loc->N($d->{DESCRIPTION}));
@@ -258,7 +259,7 @@ sub _manageProxyDialog {
while(1) {
my $event = $self->dialog->waitForEvent();
my $eventType = $event->eventType();
-
+
#event type checking
if ($eventType == $yui::YEvent::CancelEvent) {
last;
diff --git a/lib/AdminPanel/Rpmdragora/edit_urpm_sources.pm b/lib/AdminPanel/Rpmdragora/edit_urpm_sources.pm
index 584da656..7ea1d93f 100644
--- a/lib/AdminPanel/Rpmdragora/edit_urpm_sources.pm
+++ b/lib/AdminPanel/Rpmdragora/edit_urpm_sources.pm
@@ -28,8 +28,11 @@ use strict;
use File::ShareDir ':ALL';
use File::HomeDir qw(home);
-use lib qw(/usr/lib/libDrakX);
-use common;
+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 AdminPanel::Shared;
use AdminPanel::Shared::Locales;
use AdminPanel::rpmdragora;
@@ -38,16 +41,13 @@ use AdminPanel::Rpmdragora::open_db;
use AdminPanel::Rpmdragora::formatting;
use AdminPanel::Shared::GUI;
use URPM::Signature;
-use MDK::Common::Math qw(max);
-use MDK::Common::File;
-use MDK::Common::DataStructure qw(member put_in_hash);
use urpm::media;
use urpm::download;
use urpm::lock;
use Exporter;
our @ISA = qw(Exporter);
-our @EXPORT = qw(run);
+our @EXPORT_OK = qw(run);
my $urpm;
@@ -435,7 +435,7 @@ sub options_callback() {
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'};
+ my $verify_rpm_value = $urpm->{global_config}{'verify-rpm'} || 0;
my $itemColl = new yui::YItemCollection;
my $cnt = 0;
@@ -1985,7 +1985,7 @@ sub OLD_mainwindow() {
[ $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 = formatAlaTeX(translate($::license));
+ 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,
diff --git a/lib/AdminPanel/Rpmdragora/formatting.pm b/lib/AdminPanel/Rpmdragora/formatting.pm
index feeca73d..b4844556 100644
--- a/lib/AdminPanel/Rpmdragora/formatting.pm
+++ b/lib/AdminPanel/Rpmdragora/formatting.pm
@@ -27,9 +27,9 @@ package AdminPanel::Rpmdragora::formatting;
use strict;
use utf8;
use POSIX qw(strftime);
+use MDK::Common::Various qw(internal_error);
use AdminPanel::Shared::Locales;
use AdminPanel::rpmdragora;
-use MDK::Common::Various; # included for internal_error subroutine
use urpm::msg;
diff --git a/lib/AdminPanel/Rpmdragora/gui.pm b/lib/AdminPanel/Rpmdragora/gui.pm
index cd6ba4bf..6fe64dc0 100644
--- a/lib/AdminPanel/Rpmdragora/gui.pm
+++ b/lib/AdminPanel/Rpmdragora/gui.pm
@@ -30,29 +30,32 @@ package AdminPanel::Rpmdragora::gui;
############################################################
use strict;
-our @ISA = qw(Exporter);
-use lib qw(/usr/lib/libDrakX);
-use common;
+use Sys::Syslog;
use utf8;
-use HTML::Entities;
-# TO WORKAROUND LOCALIZATION ISSUE
-use AdminPanel::Rpmdragora::localization;
+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 AdminPanel::rpmdragora;
use AdminPanel::Rpmdragora::open_db;
use AdminPanel::Rpmdragora::formatting;
use AdminPanel::Rpmdragora::init;
-use AdminPanel::Rpmdragora::icon;
+use AdminPanel::Rpmdragora::icon qw(get_icon_path);
use AdminPanel::Rpmdragora::pkg;
use AdminPanel::Shared;
use AdminPanel::Shared::GUI;
use AdminPanel::Shared::Locales;
+use AdminPanel::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
@@ -191,13 +194,13 @@ sub get_main_text {
my ($medium, $fullname, $name, $summary, $is_update, $update_descr) = @_;
my $txt = get_string_from_keywords($medium, $fullname);
- my $notice = if_($txt, format_field($loc->N("Notice: ")) . $txt . "\n");
+ my $notice = MDK::Common::Func::if_($txt, format_field($loc->N("Notice: ")) . $txt . "\n");
ensure_utf8($notice);
my $hdr = format_header(join(' - ', $name, $summary)) . "\n";
ensure_utf8($hdr);
- my $update = if_($is_update, # is it an update?
+ my $update = MDK::Common::Func::if_($is_update, # is it an update?
format_field($loc->N("Importance: ")) . format_update_field($update_descr->{importance}) . "\n",
format_field($loc->N("Reason for update: ")) . format_update_field(rpm_description($update_descr->{pre})) . "\n",
);
@@ -1024,57 +1027,12 @@ sub ask_browse_tree_given_widgets_for_rpmdragora {
yui::YUI::app()->normalCursor();
};
-# $common->{display_info} = sub {
-# gtktext_insert($w->{info}, get_info($_[0], $w->{tree}->window));
-# $w->{info}->scroll_to_iter($w->{info}->get_buffer->get_start_iter, 0, 0, 0, 0);
-# 0;
-# };
-
- my $fast_toggle = sub {
- 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 ($AdminPanel::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}),
- toggle_nodes($w->{tree}->window, $w->{detail_list_model}, \&set_leaf_state, $item->selected, $common->{table_item_list}[$item->index()]);
- update_size($common);
- };
- #$w->{detail_list}->get_selection->signal_connect(changed => sub {
- #my ($model, $iter) = $_[0]->get_selected;
- #$model && $iter or return;
- # $common->{display_info}($model->get($iter, $pkg_columns{text}));
- #});
- # WARNING: รจ interessante!
- #($w->{detail_list}->get_column(0)->get_cell_renderers)[0]->signal_connect(toggled => sub {
- # my ($_cell, $path) = @_; #text_
- # my $iter = $w->{detail_list_model}->get_iter_from_string($path);
- # $fast_toggle->($iter) if $iter;
- # 1;
- #});
$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};
- #OLD $w->{w}->main;
+
$w->{w};
}
@@ -1148,7 +1106,7 @@ sub pkgs_provider {
my @media = keys %$descriptions;
[ grep {
my ($name) = split_fullname($_);
- my $medium = find { $descriptions->{$_}{$name} } @media;
+ my $medium = MDK::Common::Func::find { $descriptions->{$_}{$name} } @media;
$medium && $descriptions->{$medium}{$name}{importance} eq $importance } @{$h->{updates}} ];
};
}
@@ -1406,7 +1364,7 @@ sub toggle_nodes {
my ($msg) = @_;
statusbar_msg_remove($bar_id);
deps_msg($loc->N("Some additional packages need to be removed"),
- formatAlaTeX($msg) . "\n\n",
+ MDK::Common::String::formatAlaTeX($msg) . "\n\n",
\@nodes, \@nodes_with_deps) or @nodes_with_deps = ();
};
@@ -1455,7 +1413,7 @@ sub toggle_nodes {
@nodes_with_deps = map { urpm_name($_) } @requested;
statusbar_msg_remove($bar_id);
if (!deps_msg($loc->N("Additional packages needed"),
- formatAlaTeX($loc->N("To satisfy dependencies, the following package(s) also need to be installed:\n\n")) . "\n\n",
+ 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);
@@ -1474,7 +1432,7 @@ sub toggle_nodes {
my @ask_unselect = urpm::select::unselected_packages($urpm->{state});
my @reasons = map {
my $cant = $_;
- my $unsel = find { $_ eq $cant } @ask_unselect;
+ 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);
@@ -1517,7 +1475,7 @@ sub toggle_nodes {
exists $pkgs->{$_} or next;
if (!$pkgs->{$_}{pkg}) { #- can't be removed # FIXME; what about next packages in the loop?
undef $pkgs->{$_}{selected};
- log::explanations("can't be removed: $_");
+ Sys::Syslog::syslog('info|local1', "can't be removed: $_");
} else {
$pkgs->{$_}{selected} = $new_state;
}
@@ -1555,7 +1513,7 @@ sub do_action__real {
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 = sum(map { if_($_->flag_selected && !$_->flag_installed, $_->size) } @{$urpm->{depslist}});
+ 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
@@ -1569,7 +1527,7 @@ Do you really want to install all the selected packages?"), yesno => 1)
my $res = $callback_action->($urpm, $pkgs);
if (!$res) {
$force_rebuild = 1;
- pkgs_provider($options->{tree_mode}, if_($AdminPanel::Rpmdragora::pkg::probe_only_for_updates, pure_updates => 1), skip_updating_mu => 1);
+ pkgs_provider($options->{tree_mode}, MDK::Common::Func::if_($AdminPanel::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');
@@ -1701,7 +1659,7 @@ or you already installed all of them."));
# 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_($_) } run_program::get_stdout('urpmi_rpm-find-leaves'));
+ map { chomp_($_) } AdminPanel::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]) } @_ },
@@ -1772,7 +1730,7 @@ 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};
- run_program::raw({ detach => 1, as_user => 1 }, 'www-browser', $url);
+ AdminPanel::Shared::RunProgram::raw({ detach => 1, as_user => 1 }, 'www-browser', $url);
}
#=============================================================
@@ -1795,7 +1753,7 @@ sub run_browser {
my ($user) = grep { $_->[2] eq $ENV{USERHELPER_UID} } list_passwd();
local $ENV{HOME} = $user->[7] if $user && $ENV{USERHELPER_UID};
- run_program::raw({ detach => 1, as_user => 1 }, 'www-browser', $url);
+ AdminPanel::Shared::RunProgram::raw({ detach => 1, as_user => 1 }, 'www-browser', $url);
}
#=============================================================
diff --git a/lib/AdminPanel/Rpmdragora/gurpm.pm b/lib/AdminPanel/Rpmdragora/gurpm.pm
index 0c7dd6f7..386c5bad 100644
--- a/lib/AdminPanel/Rpmdragora/gurpm.pm
+++ b/lib/AdminPanel/Rpmdragora/gurpm.pm
@@ -26,7 +26,7 @@ package AdminPanel::Rpmdragora::gurpm;
# $Id: gurpm.pm 255450 2009-04-03 16:00:16Z tv $
use strict;
-use lib qw(/usr/lib/libDrakX);
+
use yui;
use Time::HiRes;
use feature 'state';
diff --git a/lib/AdminPanel/Rpmdragora/icon.pm b/lib/AdminPanel/Rpmdragora/icon.pm
index 282555de..b4a97c09 100644
--- a/lib/AdminPanel/Rpmdragora/icon.pm
+++ b/lib/AdminPanel/Rpmdragora/icon.pm
@@ -25,17 +25,16 @@ package AdminPanel::Rpmdragora::icon;
# $Id: icon.pm 237459 2008-02-26 14:20:47Z tv $
use strict;
-our @ISA = qw(Exporter);
-use lib qw(/usr/lib/libDrakX);
-use POSIX;
-use common;
+use POSIX qw (isdigit);
use AdminPanel::rpmdragora;
use AdminPanel::Shared::Locales;
my $loc = AdminPanel::rpmdragora::locale();
-our @EXPORT = qw(get_icon_path);
+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',
diff --git a/lib/AdminPanel/Rpmdragora/init.pm b/lib/AdminPanel/Rpmdragora/init.pm
index 18b79056..c25af78a 100644
--- a/lib/AdminPanel/Rpmdragora/init.pm
+++ b/lib/AdminPanel/Rpmdragora/init.pm
@@ -27,11 +27,10 @@ package AdminPanel::Rpmdragora::init;
use strict;
use MDK::Common::Func 'any';
-use lib qw(/usr/lib/libDrakX);
-use common;
use English;
BEGIN { $::no_global_argv_parsing = 1 }
require urpm::args;
+use MDK::Common::Various qw(chomp_);
use AdminPanel::Privileges;
use AdminPanel::Shared::Locales;
diff --git a/lib/AdminPanel/Rpmdragora/localization.pm b/lib/AdminPanel/Rpmdragora/localization.pm
deleted file mode 100644
index fb199d93..00000000
--- a/lib/AdminPanel/Rpmdragora/localization.pm
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/bin/perl
-# vim: set et ts=4 sw=4:
-package AdminPanel::Rpmdragora::localization;
-#*****************************************************************************
-#
-# Copyright (c) 2013 Matteo Pasotti <matteo.pasotti@gmail.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2, as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-#*****************************************************************************
-use strict;
-use warnings;
-use diagnostics;
-use lib qw(/usr/lib/libDrakX);
-use common;
-
-Locale::gettext::bind_textdomain_codeset($_, 'UTF8') foreach 'libDrakX', if_(!$::isInstall, 'libDrakX-standalone'),
- if_($::isRestore, 'draksnapshot'), if_($::isInstall, 'urpmi'),
- 'drakx-net', 'drakx-kbd-mouse-x11', # shared translation
- @::textdomains;
-
-#========= UGLY WORKAROUND ============
-push @::textdomains, 'rpmdrake';
-#========= UGLY WORKAROUND ============
diff --git a/lib/AdminPanel/Rpmdragora/open_db.pm b/lib/AdminPanel/Rpmdragora/open_db.pm
index 615e8413..b8239d94 100644
--- a/lib/AdminPanel/Rpmdragora/open_db.pm
+++ b/lib/AdminPanel/Rpmdragora/open_db.pm
@@ -25,13 +25,17 @@ package AdminPanel::Rpmdragora::open_db;
# $Id: open_db.pm 268344 2010-05-06 13:06:08Z jvictor $
use strict;
-use common;
+use Sys::Syslog;
+
+use MDK::Common::File qw(cat_ mkdir_p);
+use MDK::Common::Func;
use AdminPanel::rpmdragora;
use URPM;
use urpm;
use urpm::args;
use urpm::select;
use urpm::media;
+use urpm::mirrors;
use feature 'state';
use Exporter;
@@ -52,7 +56,7 @@ my $loc = AdminPanel::rpmdragora::locale();
sub open_rpm_db {
my ($o_force) = @_;
my $host;
- log::explanations("opening the RPM database");
+ 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";
@@ -125,7 +129,7 @@ sub is_it_a_devel_distro() {
my $path = '/etc/product.id';
$path = $::rpmdragora_options{'urpmi-root'}[0] . $path if defined($::rpmdragora_options{'urpmi-root'}[0]);
- $res = common::parse_LDAP_namespace_structure(cat_($path))->{branch} eq 'Devel';
+ $res = urpm::mirrors::parse_LDAP_namespace_structure(cat_($path))->{branch} eq 'Devel';
return $res;
}
@@ -158,7 +162,7 @@ sub open_urpmi_db {
$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, if_($searchmedia, searchmedia => $searchmedia), %urpmi_options);
+ urpm::media::configure($urpm, media => $media, MDK::Common::Func::if_($searchmedia, searchmedia => $searchmedia), %urpmi_options);
$urpm;
}
diff --git a/lib/AdminPanel/Rpmdragora/pkg.pm b/lib/AdminPanel/Rpmdragora/pkg.pm
index 634bf69a..56cdbb8b 100644
--- a/lib/AdminPanel/Rpmdragora/pkg.pm
+++ b/lib/AdminPanel/Rpmdragora/pkg.pm
@@ -25,11 +25,13 @@ package AdminPanel::Rpmdragora::pkg;
# $Id: pkg.pm 270160 2010-06-22 19:55:40Z jvictor $
use strict;
-use MDK::Common::Func 'any';
-use MDK::Common::DataStructure;
-use MDK::Common::System;
-use MDK::Common::File;
-use MDK::Common::Various;
+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;
@@ -39,7 +41,7 @@ use AdminPanel::Rpmdragora::open_db;
use AdminPanel::Rpmdragora::gurpm;
use AdminPanel::Rpmdragora::formatting;
use AdminPanel::Rpmdragora::rpmnew;
-
+use AdminPanel::Shared::RunProgram qw(run get_stdout);
use AdminPanel::rpmdragora;
use urpm;
use urpm::lock;
@@ -90,7 +92,7 @@ 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($_); $_ } run_program::get_stdout(@_);
+ my @l = map { ensure_utf8($_); $_ } AdminPanel::Shared::RunProgram::get_stdout(@_);
wantarray() ? @l : join('', @l);
}
@@ -271,7 +273,7 @@ Is it ok to continue?"), yesno => 1
update_sources($urpm, noclean => 1, medialist => [ map { $_->{name} } @update_medias ]);
}
} else {
- if (any { $_->{update} } @{$urpm->{media}}) {
+ 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
@@ -470,7 +472,7 @@ sub get_pkgs {
my $_unused = $loc->N("Please wait, finding available packages...");
- # find out installed packages:
+# # find out installed packages:
init_progress_bar($urpm);
@@ -696,7 +698,7 @@ sub perform_parallel_install {
my @pkgs = map { MDK::Common::Func::if_($_->flag_requested, urpm_name($_)) } @{$urpm->{depslist}};
my @error_msgs;
- my $res = !run_program::run('urpmi', '2>', \@error_msgs, '-v', '--X', '--parallel', $group, @pkgs);
+ my $res = !AdminPanel::Shared::RunProgram::run('urpmi', '2>', \@error_msgs, '-v', '--X', '--parallel', $group, @pkgs);
if ($res) {
$$statusbar_msg_id = statusbar_msg(
@@ -975,7 +977,7 @@ you may now inspect some in order to take actions:"),
#- restart rpmdragora if needed, keep command line for that.
if ($need_restart && !$exit_code && $something_installed) {
- log::explanations("restarting rpmdragora");
+ 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
diff --git a/lib/AdminPanel/Rpmdragora/rpmnew.pm b/lib/AdminPanel/Rpmdragora/rpmnew.pm
index 3ab242f5..97e2b7a9 100644
--- a/lib/AdminPanel/Rpmdragora/rpmnew.pm
+++ b/lib/AdminPanel/Rpmdragora/rpmnew.pm
@@ -26,8 +26,9 @@ package AdminPanel::Rpmdragora::rpmnew;
use strict;
use Text::Diff;
-use MDK::Common::Math;
-use MDK::Common::File;
+use MDK::Common::Math qw(sum);
+use MDK::Common::File qw(renamef);
+use MDK::Common::Various qw(chomp_);
use AdminPanel::rpmdragora;
use AdminPanel::Rpmdragora::init;
diff --git a/lib/AdminPanel/Rpmdragora/widgets.pm b/lib/AdminPanel/Rpmdragora/widgets.pm
deleted file mode 100644
index 84844069..00000000
--- a/lib/AdminPanel/Rpmdragora/widgets.pm
+++ /dev/null
@@ -1,52 +0,0 @@
-# vim: set et ts=4 sw=4:
-package Gtk2::Mdv::TextView;
-#*****************************************************************************
-#
-# 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
-#
-# 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: widgets.pm 233986 2008-02-06 14:14:06Z tv $
-
-use strict;
-use MDK::Common::Func 'any';
-use lib qw(/usr/lib/libDrakX);
-
-use Time::HiRes;
-use feature 'state';
-
-
-sub new {
- my ($_class) = @_;
- my $w = gtknew('TextView', editable => 0);
- state $time;
- $w->signal_connect(size_allocate => sub {
- my ($w, $requisition) = @_;
- return if !ref($w->{anchors});
- return if Time::HiRes::clock_gettime() - $time < 0.200;
- $time = Time::HiRes::clock_gettime();
- foreach my $anchor (@{$w->{anchors}}) {
- $_->set_size_request($requisition->width-30, -1) foreach $anchor->get_widgets;
- }
- 1;
- });
- $w;
-}
-
-1;
diff --git a/lib/AdminPanel/Shared.pm b/lib/AdminPanel/Shared.pm
index 3ff641f1..dbb9e194 100644
--- a/lib/AdminPanel/Shared.pm
+++ b/lib/AdminPanel/Shared.pm
@@ -1,4 +1,3 @@
-#!/usr/bin/perl
# vim: set et ts=4 sw=4:
# Copyright 2012-2013 Angelo Naselli <anaselli@linux.it>
# Copyright 2013-2014 Matteo Pasotti <matteo.pasotti@gmail.com>
@@ -36,9 +35,15 @@ This module collects all the routines shared between AdminPanel and its modules.
=head1 EXPORT
trim
- member
md5sum
pathList2hash
+ distName
+ apcat
+ inArray
+ disable_x_screensaver
+ enable_x_screensaver
+ isRunning
+ isProcessRunning
=head1 SUPPORT
@@ -82,16 +87,17 @@ use yui;
use base qw(Exporter);
# TODO move GUI dialogs to Shared::GUI
-our @EXPORT = qw(
- trim
- md5sum
- pathList2hash
- distName
- apcat
- find
- inArray
- disable_x_screensaver
- enable_x_screensaver
+our @EXPORT_OK = qw(
+ trim
+ md5sum
+ pathList2hash
+ distName
+ apcat
+ inArray
+ disable_x_screensaver
+ enable_x_screensaver
+ isRunning
+ isProcessRunning
);
@@ -142,33 +148,6 @@ sub apcat {
#=============================================================
-=head2 find
-
-=head3 PARAMETERS
-
-$code the CODE to search for inside the LIST
-
-=head3 OUTPUT
-
-returns the first element where CODE returns true (or returns undef)
-
-=head3 EXAMPLE
-
-find { /foo/ } "fo", "fob", "foobar", "foobir"
-gives "foobar"
-
-=cut
-
-#============================================================
-
-sub find(&@) {
- my $f = shift;
- $f->($_) and return $_ foreach @_;
- undef;
-}
-
-#=============================================================
-
=head2 distName
=head3 OUTPUT
@@ -362,5 +341,36 @@ sub enable_x_screensaver() {
}
}
+#=============================================================
+
+=head2 isProcessRunning
+
+=head3 INPUT
+
+ $name: Process name
+ $o_user: user who the process belongs to
+
+=head3 OUTPUT
+
+ $pid: process identifier
+
+=head3 DESCRIPTION
+
+ Function returns the process identifier if the given
+ process is running
+
+=cut
+
+#=============================================================
+sub isProcessRunning {
+ my ($name, $o_user) = @_;
+ my $user = $o_user || $ENV{USER};
+ foreach (`ps -o '%P %p %c' -u $user`) {
+ my ($ppid, $pid, $n) = /^\s*(\d+)\s+(\d+)\s+(.*)/;
+ return $pid if $ppid != 1 && $pid != $$ && $n eq $name;
+ }
+ return;
+}
+
1; # End of AdminPanel::Shared
diff --git a/lib/AdminPanel/Shared/RunProgram.pm b/lib/AdminPanel/Shared/RunProgram.pm
new file mode 100644
index 00000000..4355fb9f
--- /dev/null
+++ b/lib/AdminPanel/Shared/RunProgram.pm
@@ -0,0 +1,352 @@
+package AdminPanel::Shared::RunProgram;
+
+use strict;
+use MDK::Common;
+use Sys::Syslog;
+use MDK::Common::File qw(cat_);
+
+use Exporter;
+our @ISA = qw(Exporter);
+our @EXPORT_OK = qw(
+ set_default_timeout
+ run_or_die
+ rooted_or_die
+ get_stdout
+ get_stdout_raw
+ rooted_get_stdout
+ run
+ raw
+ rooted
+);
+
+=head1 SYNOPSYS
+
+B<rAdminPanel::Shared::RunProgram> enables to:
+
+=over 4
+
+=item * run programs in foreground or in background,
+
+=item * to retrieve their stdout or stderr
+
+=item * ...
+
+=back
+
+Most functions exits in a normal form & a rooted one. e.g.:
+
+=over 4
+
+=item * C<run()> & C<rooted()>
+
+=item * C<get_stdout()> & C<rooted_get_stdout()>
+
+=back
+
+Most functions exits in a normal form & one that die. e.g.:
+
+=over 4
+
+=item * C<run()> & C<run_or_die()>
+
+=item * C<rooted()> & C<rooted_or_die()>
+
+=back
+
+=head1 Functions
+
+=over
+
+=cut
+
+1;
+
+my $default_timeout = 10 * 60;
+
+=item set_default_timeout($seconds)
+
+Alters defaults timeout (eg for harddrake service)
+
+=cut
+
+sub set_default_timeout {
+ my ($seconds) = @_;
+ $default_timeout = $seconds;
+}
+
+=item run_or_die($name, @args)
+
+Runs $name with @args parameterXs. Dies if it exit code is not 0.
+
+=cut
+
+sub run_or_die {
+ my ($name, @args) = @_;
+ run($name, @args) or die "$name failed\n";
+}
+
+=item rooted_or_die($root, $name, @args)
+
+Similar to run_or_die() but runs in chroot in $root
+
+=cut
+
+sub rooted_or_die {
+ my ($root, $name, @args) = @_;
+ rooted($root, $name, @args) or die "$name failed\n";
+}
+
+=item get_stdout($name, @args)
+
+Similar to run_or_die() but return stdout of program:
+
+=over 4
+
+=item * a list of lines in list context
+
+=item * a string of concatenated lines in scalar context
+
+=back
+
+=cut
+
+sub get_stdout {
+ my ($name, @args) = @_;
+ my @r;
+ run($name, '>', \@r, @args) or return;
+ wantarray() ? @r : join('', @r);
+}
+
+=item get_stdout_raw($options, $name, @args)
+
+Similar to get_stdout() but allow to pass options to raw()
+
+=cut
+
+sub get_stdout_raw {
+ my ($options, $name, @args) = @_;
+ my @r;
+ raw($options, $name, '>', \@r, @args) or return;
+ wantarray() ? @r : join('', @r);
+}
+
+=item rooted_get_stdout($root, $name, @args)
+
+Similar to get_stdout() but runs in chroot in $root
+
+=cut
+
+sub rooted_get_stdout {
+ my ($root, $name, @args) = @_;
+ my @r;
+ rooted($root, $name, '>', \@r, @args) or return;
+ wantarray() ? @r : join('', @r);
+}
+
+=item run($name, @args)
+
+Runs $name with @args parameters.
+
+=cut
+
+sub run {
+ raw({}, @_);
+}
+
+=item rooted($root, $name, @args)
+
+Similar to run() but runs in chroot in $root
+
+=cut
+
+sub rooted {
+ my ($root, $name, @args) = @_;
+ raw({ root => $root }, $name, @args);
+}
+
+=item raw($options, $name, @args)
+
+The function used by all the other, making every combination possible.
+Runs $name with @args parameters. $options is a hash ref that can contains:
+
+=over 4
+
+=item * B<root>: $name will be chrooted in $root prior to run
+
+=item * B<as_user>: $name will be run as $ENV{USERHELPER_UID} or with the UID of parent process. Implies I<setuid>
+
+=item * B<sensitive_arguments>: parameters will be hidden in logs (b/c eg there's a password)
+
+=item * B<detach>: $name will be run in the background. Default is foreground
+
+=item * B<chdir>: $name will be run in a different default directory
+
+=item * B<setuid>: contains a getpwnam(3) struct ; $name will be with droped privileges ;
+make sure environment is set right and keep a copy of the X11 cookie
+
+=item * B<timeout>: execution of $name will be aborted after C<timeout> seconds
+
+=back
+
+eg:
+
+=over 4
+
+=item * C<< AdminPanel::Shared::RunProgram::raw({ root => $::prefix, sensitive_arguments => 1 }, "echo -e $user->{password} | cryptsetup luksFormat $device"); >>
+
+=item * C<< AdminPanel::Shared::RunProgram::raw({ detach => 1 }, '/etc/rc.d/init.d/dm', '>', '/dev/null', '2>', '/dev/null', 'restart'); >>
+
+=back
+
+=cut
+
+sub raw {
+ my ($options, $name, @args) = @_;
+ my $root = $options->{root} || '';
+ my $real_name = ref($name) ? $name->[0] : $name;
+
+ my ($stdout_raw, $stdout_mode, $stderr_raw, $stderr_mode);
+ ($stdout_mode, $stdout_raw, @args) = @args if $args[0] =~ /^>>?$/;
+ ($stderr_mode, $stderr_raw, @args) = @args if $args[0] =~ /^2>>?$/;
+
+ my $home;
+ if ($options->{as_user}) {
+ my $uid;
+ $uid = $ENV{USERHELPER_UID} && getpwuid($ENV{USERHELPER_UID});
+ $uid ||= _get_parent_uid();
+ $options->{setuid} = getpwnam($uid) if $uid;
+ my ($full_user) = grep { $_->[2] eq $uid } list_passwd();
+ $home = $full_user->[7] if $full_user;
+ }
+ local $ENV{HOME} = $home if $home;
+
+ my $args = $options->{sensitive_arguments} ? '<hidden arguments>' : join(' ', @args);
+ Sys::Syslog::syslog('info|local1', "running: $real_name $args" . ($root ? " with root $root" : ""));
+
+ return if $root && $<;
+
+ $root ? ($root .= '/') : ($root = '');
+
+ my $tmpdir = sub {
+ my $dir = $< != 0 ? "$ENV{HOME}/tmp" : -d '/root' ? '/root/tmp' : '/tmp';
+ -d $dir or mkdir($dir, 0700);
+ $dir;
+ };
+ my $stdout = $stdout_raw && (ref($stdout_raw) ? $tmpdir->() . "/.drakx-stdout.$$" : "$root$stdout_raw");
+ my $stderr = $stderr_raw && (ref($stderr_raw) ? $tmpdir->() . "/.drakx-stderr.$$" : "$root$stderr_raw");
+
+ #- checking if binary exist to avoid clobbering stdout file
+ my $rname = $real_name =~ /(.*?)[\s\|]/ ? $1 : $real_name;
+ if (! ($rname =~ m!^/!
+ ? -x "$root$rname" || $root && -l "$root$rname" #- handle non-relative symlink which can be broken when non-rooted
+ : whereis_binary($rname, $root))) {
+ Sys::Syslog::syslog('warning', "program not found: $real_name");
+
+ return;
+ }
+
+ if (my $pid = fork()) {
+ if ($options->{detach}) {
+ $pid;
+ } else {
+ my $ok;
+ add2hash_($options, { timeout => $default_timeout });
+ eval {
+ local $SIG{ALRM} = sub { die "ALARM" };
+ my $remaining = $options->{timeout} && $options->{timeout} ne 'never' && alarm($options->{timeout});
+ waitpid $pid, 0;
+ $ok = $? == -1 || ($? >> 8) == 0;
+ alarm $remaining;
+ };
+ if ($@) {
+ Sys::Syslog::syslog('warning', "ERROR: killing runaway process (process=$real_name, pid=$pid, args=@args, error=$@)");
+ kill 9, $pid;
+ return;
+ }
+
+ if ($stdout_raw && ref($stdout_raw)) {
+ if (ref($stdout_raw) eq 'ARRAY') {
+ @$stdout_raw = cat_($stdout);
+ } else {
+ $$stdout_raw = cat_($stdout);
+ }
+ unlink $stdout;
+ }
+ if ($stderr_raw && ref($stderr_raw)) {
+ if (ref($stderr_raw) eq 'ARRAY') {
+ @$stderr_raw = cat_($stderr);
+ } else {
+ $$stderr_raw = cat_($stderr);
+ }
+ unlink $stderr;
+ }
+ $ok;
+ }
+ } else {
+ if ($options->{setuid}) {
+ require POSIX;
+ my ($logname, $home) = (getpwuid($options->{setuid}))[0,7];
+ $ENV{LOGNAME} = $logname if $logname;
+
+ # if we were root and are going to drop privilege, keep a copy of the X11 cookie:
+ if (!$> && $home) {
+ # FIXME: it would be better to remove this but most callers are using 'detach => 1'...
+ my $xauth = chomp_(`mktemp $home/.Xauthority.XXXXX`);
+ system('cp', '-a', $ENV{XAUTHORITY}, $xauth);
+ system('chown', $logname, $xauth);
+ $ENV{XAUTHORITY} = $xauth;
+ }
+
+ # drop privileges:
+ POSIX::setuid($options->{setuid});
+ }
+
+ sub _die_exit {
+ Sys::Syslog::syslog('warning', $_[0]);
+ POSIX::_exit(128);
+ }
+ if ($stderr && $stderr eq 'STDERR') {
+ } elsif ($stderr) {
+ $stderr_mode =~ s/2//;
+ open STDERR, "$stderr_mode $stderr" or _die_exit("AdminPanel::Shared::RunProgram cannot output in $stderr (mode `$stderr_mode')");
+ } elsif ($::isInstall) {
+ open STDERR, ">> /tmp/ddebug.log" or open STDOUT, ">> /dev/tty7" or _die_exit("AdminPanel::Shared::RunProgram cannot log, give me access to /tmp/ddebug.log");
+ }
+ if ($stdout && $stdout eq 'STDOUT') {
+ } elsif ($stdout) {
+ open STDOUT, "$stdout_mode $stdout" or _die_exit("AdminPanel::Shared::RunProgram cannot output in $stdout (mode `$stdout_mode')");
+ } elsif ($::isInstall) {
+ open STDOUT, ">> /tmp/ddebug.log" or open STDOUT, ">> /dev/tty7" or _die_exit("AdminPanel::Shared::RunProgram cannot log, give me access to /tmp/ddebug.log");
+ }
+
+ $root and chroot $root;
+ chdir($options->{chdir} || "/");
+
+ my $ok = ref $name ? do {
+ exec { $name->[0] } $name->[1], @args;
+ } : do {
+ exec $name, @args;
+ };
+ if (!$ok) {
+ _die_exit("exec of $real_name failed: $!");
+ }
+ }
+
+}
+
+=item get_parent_uid()
+
+Returns UID of the parent process.
+
+=cut
+
+sub _get_parent_uid() {
+ cat_('/proc/' . getppid() . '/status') =~ /Uid:\s*(\d+)/ ? $1 : undef;
+}
+
+
+
+#- Local Variables:
+#- mode:cperl
+#- tab-width:8
+#- End:
diff --git a/lib/AdminPanel/Shared/Services.pm b/lib/AdminPanel/Shared/Services.pm
index 1870e046..0b2c6973 100644
--- a/lib/AdminPanel/Shared/Services.pm
+++ b/lib/AdminPanel/Shared/Services.pm
@@ -9,14 +9,14 @@ AdminPanel::Shared::Services - shares the API to manage services
=head1 SYNOPSIS
use AdminPanel::Shared::Services;
-
+
my ($l, $on_services) = AdminPanel::Shared::Services::services();
=head1 DESCRIPTION
This module aims to share all the API to manage system services,
to be used from GUI applications or console.
-
+
From the original code drakx services.
=head1 EXPORT
@@ -83,14 +83,12 @@ use strict;
use diagnostics;
use Sys::Syslog;
-use File::Basename qw( basename );
use AdminPanel::Shared::Locales;
-use lib qw(/usr/lib/libDrakX);
use MDK::Common::Func qw(find);
-use MDK::Common::File qw(cat_);
+use MDK::Common::File qw(cat_ basename);
use MDK::Common::DataStructure qw(member);
-use run_program qw(rooted);
+use AdminPanel::Shared::RunProgram qw(rooted);
use base qw(Exporter);
@@ -138,7 +136,7 @@ THis function return the description for the given service
#=============================================================
sub description {
my %services = (
-acpid => $loc->N_("Listen and dispatch ACPI events from the kernel"),
+acpid => $loc->N_("Listen and dispatch ACPI events from the kernel"),
alsa => $loc->N_("Launch the ALSA (Advanced Linux Sound Architecture) sound system"),
anacron => $loc->N_("Anacron is a periodic command scheduler."),
apmd => $loc->N_("apmd is used for monitoring battery status and logging it via syslog.
@@ -155,10 +153,10 @@ cups => $loc->N_("Common UNIX Printing System (CUPS) is an advanced printer spoo
dm => $loc->N_("Launches the graphical display manager"),
fam => $loc->N_("FAM is a file monitoring daemon. It is used to get reports when files change.
It is used by GNOME and KDE"),
-g15daemon => $loc->N_("G15Daemon allows users access to all extra keys by decoding them and
-pushing them back into the kernel via the linux UINPUT driver. This driver must be loaded
-before g15daemon can be used for keyboard access. The G15 LCD is also supported. By default,
-with no other clients active, g15daemon will display a clock. Client applications and
+g15daemon => $loc->N_("G15Daemon allows users access to all extra keys by decoding them and
+pushing them back into the kernel via the linux UINPUT driver. This driver must be loaded
+before g15daemon can be used for keyboard access. The G15 LCD is also supported. By default,
+with no other clients active, g15daemon will display a clock. Client applications and
scripts can access the LCD via a simple API."),
gpm => $loc->N_("GPM adds mouse support to text-based Linux applications such the
Midnight Commander. It also allows mouse-based console cut-and-paste operations,
@@ -282,7 +280,7 @@ $enable: enable/disable service
=head3 DESCRIPTION
-This function enable/disable at boot the given service
+This function enable/disable at boot the given service
=cut
@@ -294,25 +292,25 @@ sub set_service {
if (MDK::Common::DataStructure::member($service, @xinetd_services)) {
$ENV{PATH} = "/usr/bin:/usr/sbin";
- run_program::rooted($::prefix, "/usr/sbin/chkconfig", $enable ? "--add" : "--del", $service);
+ AdminPanel::Shared::RunProgram::rooted($::prefix, "/usr/sbin/chkconfig", $enable ? "--add" : "--del", $service);
} elsif (_running_systemd() || _has_systemd()) {
# systemctl rejects any symlinked units. You have to enabled the real file
if (-l "/lib/systemd/system/$service.service") {
my $name = readlink("/lib/systemd/system/$service.service");
- $service = File::Basename::basename($name);
+ $service = MDK::Common::File::basename($name);
} else {
$service = $service . ".service";
}
$ENV{PATH} = "/usr/bin:/usr/sbin";
- run_program::rooted($::prefix, "/usr/bin/systemctl", $enable ? "enable" : "disable", $service);
+ AdminPanel::Shared::RunProgram::rooted($::prefix, "/usr/bin/systemctl", $enable ? "enable" : "disable", $service);
} else {
my $script = "/etc/rc.d/init.d/$service";
$ENV{PATH} = "/usr/bin:/usr/sbin";
- run_program::rooted($::prefix, "/usr/sbin/chkconfig", $enable ? "--add" : "--del", $service);
+ AdminPanel::Shared::RunProgram::rooted($::prefix, "/usr/sbin/chkconfig", $enable ? "--add" : "--del", $service);
#- FIXME: handle services with no chkconfig line and with no Default-Start levels in LSB header
if ($enable && MDK::Common::File::cat_("$::prefix$script") =~ /^#\s+chkconfig:\s+-/m) {
$ENV{PATH} = "/usr/bin:/usr/sbin";
- run_program::rooted($::prefix, "/usr/sbin/chkconfig", "--level", "35", $service, "on");
+ AdminPanel::Shared::RunProgram::rooted($::prefix, "/usr/sbin/chkconfig", "--level", "35", $service, "on");
}
}
}
@@ -322,26 +320,26 @@ sub _run_action {
if (_running_systemd()) {
if ($do_not_block) {
$ENV{PATH} = "/usr/bin:/usr/sbin";
- run_program::rooted($::prefix, '/usr//bin/systemctl', '--no-block', $action, "$service.service");
+ AdminPanel::Shared::RunProgram::rooted($::prefix, '/usr/bin/systemctl', '--no-block', $action, "$service.service");
}
else {
$ENV{PATH} = "/usr/bin:/usr/sbin";
- run_program::rooted($::prefix, '/usr/bin/systemctl', $action, "$service.service");
+ AdminPanel::Shared::RunProgram::rooted($::prefix, '/usr/bin/systemctl', $action, "$service.service");
}
} else {
$ENV{PATH} = "/usr/bin:/usr/sbin:/etc/rc.d/init.d/";
- run_program::rooted($::prefix, "/etc/rc.d/init.d/$service", $action);
+ AdminPanel::Shared::RunProgram::rooted($::prefix, "/etc/rc.d/init.d/$service", $action);
}
}
sub _running_systemd() {
$ENV{PATH} = "/usr/bin:/usr/sbin";
- run_program::rooted($::prefix, '/usr/bin/mountpoint', '-q', '/sys/fs/cgroup/systemd');
+ AdminPanel::Shared::RunProgram::rooted($::prefix, '/usr/bin/mountpoint', '-q', '/sys/fs/cgroup/systemd');
}
sub _has_systemd() {
$ENV{PATH} = "/usr/bin:/usr/sbin";
- run_program::rooted($::prefix, '/usr/bin/rpm', '-q', 'systemd');
+ AdminPanel::Shared::RunProgram::rooted($::prefix, '/usr/bin/rpm', '-q', 'systemd');
}
#=============================================================
@@ -364,7 +362,7 @@ sub xinetd_services() {
local $ENV{LANGUAGE} = 'C';
my @xinetd_services;
$ENV{PATH} = "/usr/bin:/usr/sbin";
- foreach (run_program::rooted_get_stdout($::prefix, '/usr/sbin/chkconfig', '--list', '--type', 'xinetd')) {
+ foreach (AdminPanel::Shared::RunProgram::rooted_get_stdout($::prefix, '/usr/sbin/chkconfig', '--list', '--type', 'xinetd')) {
if (my ($xinetd_name, $on_off) = m!^\t(\S+):\s*(on|off)!) {
push @xinetd_services, [ $xinetd_name, $on_off eq 'on' ];
}
@@ -378,19 +376,19 @@ sub _systemd_services() {
my %loaded;
# Running system using systemd
Sys::Syslog::syslog('info|local1', "Detected systemd running. Using systemctl introspection.");
- foreach (run_program::rooted_get_stdout($::prefix, '/usr/bin/systemctl', '--full', '--all', 'list-units')) {
+ foreach (AdminPanel::Shared::RunProgram::rooted_get_stdout($::prefix, '/usr/bin/systemctl', '--full', '--all', 'list-units')) {
if (my ($name) = m!^(\S+)\.service\s+loaded!) {
# We only look at non-template, non-linked service files in /lib
# We also check for any non-masked sysvinit files as these are
# also handled by systemd
if ($name !~ /.*\@$/g && (-e "$::prefix/lib/systemd/system/$name.service" or -e "$::prefix/etc/rc.d/init.d/$name") && ! -l "$::prefix/lib/systemd/system/$name.service") {
- push @services, [ $name, !!run_program::rooted($::prefix, '/usr/bin/systemctl', '--quiet', 'is-enabled', "$name.service") ];
+ push @services, [ $name, !!AdminPanel::Shared::RunProgram::rooted($::prefix, '/usr/bin/systemctl', '--quiet', 'is-enabled', "$name.service") ];
$loaded{$name} = 1;
}
}
}
# list-units will not list disabled units that can be enabled
- foreach (run_program::rooted_get_stdout($::prefix, '/usr/bin/systemctl', '--full', 'list-unit-files')) {
+ foreach (AdminPanel::Shared::RunProgram::rooted_get_stdout($::prefix, '/usr/bin/systemctl', '--full', 'list-unit-files')) {
if (my ($name) = m!^(\S+)\.service\s+disabled!) {
# We only look at non-template, non-linked service files in /lib
# We also check for any non-masked sysvinit files as these are
@@ -450,7 +448,7 @@ sub _legacy_services() {
if (!$::isInstall) {
$runlevel = (split " ", `/sbin/runlevel`)[1];
}
- foreach (run_program::rooted_get_stdout($::prefix, '/sbin/chkconfig', '--list', '--type', 'sysv')) {
+ foreach (AdminPanel::Shared::RunProgram::rooted_get_stdout($::prefix, '/sbin/chkconfig', '--list', '--type', 'sysv')) {
if (my ($name, $l) = m!^(\S+)\s+(0:(on|off).*)!) {
# If we expect to use systemd (i.e. installer) only show those
# sysvinit scripts which are not masked by a native systemd unit.
@@ -678,10 +676,10 @@ sub is_service_running ($) {
my $out;
if (_running_systemd()) {
$ENV{PATH} = "/usr/bin:/usr/sbin";
- $out = run_program::rooted($::prefix, '/usr/bin/systemctl', '--quiet', 'is-active', "$service.service");
+ $out = AdminPanel::Shared::RunProgram::rooted($::prefix, '/usr/bin/systemctl', '--quiet', 'is-active', "$service.service");
} else {
$ENV{PATH} = "/usr/bin:/usr/sbin";
- $out = run_program::rooted($::prefix, '/usr/sbin/service', $service, 'status');
+ $out = AdminPanel::Shared::RunProgram::rooted($::prefix, '/usr/sbin/service', $service, 'status');
}
return $out;
}
diff --git a/lib/AdminPanel/Shared/TimeZone.pm b/lib/AdminPanel/Shared/TimeZone.pm
index 969df940..552060b5 100644
--- a/lib/AdminPanel/Shared/TimeZone.pm
+++ b/lib/AdminPanel/Shared/TimeZone.pm
@@ -61,8 +61,9 @@ use File::Copy;
use AdminPanel::Shared::Locales;
use AdminPanel::Shared::Services;
-use MDK::Common::File;
-use MDK::Common::Func;
+use MDK::Common::File qw(cat_ output_p substInFile);
+use MDK::Common::Func qw(find if_);
+
#=============================================================
diff --git a/lib/AdminPanel/rpmdragora.pm b/lib/AdminPanel/rpmdragora.pm
index f954d028..e825d5e1 100644
--- a/lib/AdminPanel/rpmdragora.pm
+++ b/lib/AdminPanel/rpmdragora.pm
@@ -27,7 +27,9 @@
package AdminPanel::rpmdragora;
use warnings::register;
-use lib qw(/usr/lib/libDrakX);
+use urpm;
+use urpm::cfg;
+use urpm::mirrors;
use urpm::download ();
use urpm::prompt;
use urpm::media;
@@ -35,16 +37,12 @@ use urpm::media;
use MDK::Common;
use MDK::Common::System;
use MDK::Common::String;
-use MDK::Common::File;
-use urpm;
-use urpm::cfg;
+use MDK::Common::File qw(basename cat_ output);
use URPM;
use URPM::Resolve;
use strict;
-use c;
use POSIX qw(_exit);
-use common;
-use Locale::gettext;
+
use feature 'state';
use AdminPanel::Shared;
@@ -1031,7 +1029,7 @@ sub mirrors {
$res or die $loc->N("retrieval of [%s] failed", $file) . "\n";
return $canceled ? () : MDK::Common::File::cat_($file);
});
- my @mirrors = @{ mirror::list(common::parse_LDAP_namespace_structure(MDK::Common::File::cat_('/etc/product.id')), 'distrib') || [] };
+ my @mirrors = @{ mirror::list(urpm::mirrors::parse_LDAP_namespace_structure(MDK::Common::File::cat_('/etc/product.id')), 'distrib') || [] };
require AdminPanel::Shared::TimeZone;
my $tzo = AdminPanel::Shared::TimeZone->new();
@@ -1062,15 +1060,16 @@ sub mirrors {
sub open_help {
my ($mode) = @_;
- use run_program;
- run_program::raw({ detach => 1, as_user => 1 }, 'drakhelp', '--id', $mode ? "software-management-$mode" : 'software-management');
+ require AdminPanel::Shared::RunProgram;
+ AdminPanel::Shared::RunProgram::raw({ detach => 1, as_user => 1 }, 'drakhelp', '--id', $mode ? "software-management-$mode" : 'software-management');
my $_s = $loc->N("Help launched in background");
statusbar_msg($loc->N("The help window has been started, it should appear shortly on your desktop."), 1);
}
sub run_drakbug {
my ($id) = @_;
- run_program::raw({ detach => 1, as_user => 1 }, 'drakbug', '--report', $id);
+ require AdminPanel::Shared::RunProgram;
+ AdminPanel::Shared::RunProgram::raw({ detach => 1, as_user => 1 }, 'drakbug', '--report', $id);
}
#mygtk2::add_icon_path('/usr/share/mcc/themes/default/');
diff --git a/modules/rpmdragora/dragora-urpm-addmedia b/modules/rpmdragora/dragora-urpm-addmedia
index b49840f9..136c5067 100755
--- a/modules/rpmdragora/dragora-urpm-addmedia
+++ b/modules/rpmdragora/dragora-urpm-addmedia
@@ -51,9 +51,8 @@ use AdminPanel::Rpmdragora::formatting;
use AdminPanel::Shared::Locales;
use AdminPanel::Privileges;
-use lib qw(/usr/lib/libDrakX);
use urpm::media;
-use MDK::Common::Func;
+use MDK::Common::File qw(cat_);
my $loc = AdminPanel::rpmdragora::locale();
diff --git a/modules/rpmdragora/dragora-urpm-sources.pl b/modules/rpmdragora/dragora-urpm-sources.pl
index 1bd4d627..adf127b9 100755
--- a/modules/rpmdragora/dragora-urpm-sources.pl
+++ b/modules/rpmdragora/dragora-urpm-sources.pl
@@ -25,7 +25,7 @@
use AdminPanel::Rpmdragora::init;
use AdminPanel::rpmdragora;
-use AdminPanel::Rpmdragora::edit_urpm_sources;
+use AdminPanel::Rpmdragora::edit_urpm_sources qw(run);
use AdminPanel::Privileges;
use AdminPanel::Shared::Locales;
diff --git a/modules/rpmdragora/dragoraUpdate b/modules/rpmdragora/dragoraUpdate
index b9894c07..b1ab4002 100755
--- a/modules/rpmdragora/dragoraUpdate
+++ b/modules/rpmdragora/dragoraUpdate
@@ -25,8 +25,6 @@
use strict;
use MDK::Common::Func 'any';
-# use lib qw(/usr/lib/libDrakX);
-# use common;
use File::ShareDir ':ALL';
use AdminPanel::Rpmdragora::init;
diff --git a/modules/rpmdragora/rpmdragora b/modules/rpmdragora/rpmdragora
index 8beaf5e4..28e98d1e 100755
--- a/modules/rpmdragora/rpmdragora
+++ b/modules/rpmdragora/rpmdragora
@@ -27,16 +27,17 @@
# $Id: rpmdragora 267936 2010-04-26 16:40:21Z jvictor $
-use MDK::Common::Func 'any';
-use lib qw(/usr/lib/libDrakX);
-use common;
+use MDK::Common::Func qw(any if_);
use utf8;
-# TO WORKAROUND LOCALIZATION ISSUE
-use AdminPanel::Rpmdragora::localization;
+use MDK::Common::DataStructure qw(uniq intersection);
+use MDK::Common::Various qw(to_bool first);
+use MDK::Common::System qw(arch);
+
+use urpm::media;
+use urpm::msg;
use AdminPanel::Rpmdragora::init;
-use standalone; #- standalone must be loaded very first, for 'explanations', but after rpmdragora::init
use AdminPanel::rpmdragora;
use AdminPanel::Shared;
use AdminPanel::Shared::Locales;
@@ -45,11 +46,9 @@ use AdminPanel::Rpmdragora::gui;
use AdminPanel::Rpmdragora::rpmnew;
use AdminPanel::Rpmdragora::formatting;
use AdminPanel::Rpmdragora::pkg;
-use urpm::media;
use yui;
-use AdminPanel::Rpmdragora::widgets;
use feature 'state';
# OLD $ugtk2::wm_icon = get_icon('installremoverpm', "title-$MODE");
@@ -223,7 +222,7 @@ sub _do_search($$$$$$) {
if ($NVR_searches->[0]) {
next if !/$entry_rx/;
} else {
- next if first(split_fullname($_)) !~ /$entry_rx/;
+ next if MDK::Common::Various::first(split_fullname($_)) !~ /$entry_rx/;
}
push @search_results, $_;
# FIXME: should be done for all research types
@@ -396,7 +395,7 @@ sub run_treeview_dialog {
@$unsel < @$sel;
},
get_status => sub {
- $loc->N("Selected: %s / Free disk space: %s", formatXiB($size_selected), formatXiB($size_free*1024));
+ $loc->N("Selected: %s / Free disk space: %s", urpm::msg::formatXiB($size_selected), urpm::msg::formatXiB($size_free*1024));
},
rebuild_tree => sub { $tree->rebuildTree(); },
};
@@ -1192,7 +1191,7 @@ sub run_treeview_dialog {
# -=-=-=---=-=-=---=-=-=-- main -=-=-=---=-=-=---=-=-=-
-if (my $pid = is_running('rpmdragora')) {
+if (my $pid = AdminPanel::Shared::isProcessRunning('rpmdragora')) {
interactive_msg($loc->N("Warning"), $loc->N("rpmdragora is already running (pid: %s)", $pid), yesno => [ $loc->N("Quit") ]);
exit(0);
}