aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mandriva.org>2007-09-11 15:13:52 +0000
committerThierry Vignaud <tv@mandriva.org>2007-09-11 15:13:52 +0000
commit6fba00b7fd656cbcfb28fde414ec73c1d532ca9a (patch)
tree8f444e9b7fe428f3caa77b3efe2ba611a8cdbc0e
parent7318144585dce9df6bbce4e7d87ccf4ca4d26654 (diff)
downloadrpmdrake-6fba00b7fd656cbcfb28fde414ec73c1d532ca9a.tar
rpmdrake-6fba00b7fd656cbcfb28fde414ec73c1d532ca9a.tar.gz
rpmdrake-6fba00b7fd656cbcfb28fde414ec73c1d532ca9a.tar.bz2
rpmdrake-6fba00b7fd656cbcfb28fde414ec73c1d532ca9a.tar.xz
rpmdrake-6fba00b7fd656cbcfb28fde414ec73c1d532ca9a.zip
(open_rpm_db,open_urpmi_db) split them from Rpmdrake::pkg into
Rpmdrake::open_db (needed for next commits in order not to increase edit-urpm-sources startup time)
-rw-r--r--Rpmdrake/gui.pm1
-rw-r--r--Rpmdrake/open_db.pm87
-rw-r--r--Rpmdrake/pkg.pm56
-rw-r--r--Rpmdrake/rpmnew.pm3
-rwxr-xr-xrpmdrake1
5 files changed, 93 insertions, 55 deletions
diff --git a/Rpmdrake/gui.pm b/Rpmdrake/gui.pm
index 102b88be..6d72d2c0 100644
--- a/Rpmdrake/gui.pm
+++ b/Rpmdrake/gui.pm
@@ -32,6 +32,7 @@ use mygtk2 qw(gtknew); #- do not import gtkadd which conflicts with ugtk2 versio
use ugtk2 qw(:helpers :wrappers);
use rpmdrake;
+use Rpmdrake::open_db;
use Rpmdrake::formatting;
use Rpmdrake::init;
use Rpmdrake::icon;
diff --git a/Rpmdrake/open_db.pm b/Rpmdrake/open_db.pm
new file mode 100644
index 00000000..06c12d4e
--- /dev/null
+++ b/Rpmdrake/open_db.pm
@@ -0,0 +1,87 @@
+package Rpmdrake::open_db;
+#*****************************************************************************
+#
+# 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$
+
+use strict;
+use MDK::Common;
+use URPM;
+use urpm;
+
+use Exporter;
+our @ISA = qw(Exporter);
+our @EXPORT = qw(open_rpm_db open_urpmi_db);
+
+
+# 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;
+ log::explanations("opening the RPM database");
+ if ($::rpmdrake_options{parallel} && ((undef, $host) = @{$::rpmdrake_options{parallel}})) {
+ my $done if 0;
+ 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 {
+ URPM::DB::open($::rpmdrake_options{'rpm-root'}[0]) or die "Couldn't open RPM DB ($::rpmdrake_options{'rpm-root'}[0])";
+ }
+}
+
+sub open_urpmi_db() {
+ my $error_happened;
+ my $urpm = urpm->new;
+ $urpm->{options}{'split-level'} ||= 20;
+ $urpm->{options}{'split-length'} ||= 1;
+ $urpm->{options}{'verify-rpm'} = !$::rpmdrake_options{'no-verify-rpm'} if defined $::rpmdrake_options{'no-verify-rpm'};
+ $urpm->{options}{auto} = $::rpmdrake_options{auto} if defined $::rpmdrake_options{auto};
+ urpm::set_files($urpm, $::rpmdrake_options{'urpmi-root'}[0]) if $::rpmdrake_options{'urpmi-root'}[0];
+ urpm::args::set_root($urpm, $::rpmdrake_options{'rpm-root'}[0]) if $::rpmdrake_options{'rpm-root'}[0];
+
+ $urpm::args::rpmdrake_options{justdb} = $::rpmdrake_options{justdb};
+
+ $urpm->{fatal} = sub {
+ $error_happened = 1;
+ interactive_msg(N("Fatal error"),
+ N("A fatal error occurred: %s.", $_[1]));
+ };
+ my $media = ref $::rpmdrake_options{media} ? join(',', @{$::rpmdrake_options{media}}) : '';
+ urpm::media::read_config($urpm);
+
+ my $searchmedia = join(',', map { $_->{name} } grep { $_->{ignore} && $_->{name} =~ /backport/i } @{$urpm->{media}});
+ urpm::media::configure($urpm, media => $media, if_($searchmedia, searchmedia => $searchmedia));
+ if ($error_happened) {
+ touch('/etc/urpmi/urpmi.cfg');
+ exec('edit-urpm-sources.pl');
+ }
+ $urpm;
+}
+
+1;
diff --git a/Rpmdrake/pkg.pm b/Rpmdrake/pkg.pm
index bb20caa5..cdfc5abc 100644
--- a/Rpmdrake/pkg.pm
+++ b/Rpmdrake/pkg.pm
@@ -30,6 +30,7 @@ use common;
use POSIX qw(_exit);
use URPM;
use utf8;
+use Rpmdrake::open_db;
use Rpmdrake::gurpm;
use Rpmdrake::formatting;
use Rpmdrake::rpmnew;
@@ -47,7 +48,7 @@ use urpm::args qw();
use Exporter;
our @ISA = qw(Exporter);
-our @EXPORT = qw(extract_header find_installed_version formatlistpkg get_pkgs open_rpm_db parse_compssUsers_flat perform_installation perform_removal run_rpm);
+our @EXPORT = qw(extract_header find_installed_version formatlistpkg get_pkgs parse_compssUsers_flat perform_installation perform_removal run_rpm);
use mygtk2 qw(gtknew);
use ugtk2 qw(:all);
@@ -138,29 +139,6 @@ sub extract_header {
}
}
-# 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;
- log::explanations("opening the RPM database");
- if ($::rpmdrake_options{parallel} && ((undef, $host) = @{$::rpmdrake_options{parallel}})) {
- my $done if 0;
- 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 {
- URPM::DB::open($::rpmdrake_options{'rpm-root'}[0]) or die "Couldn't open RPM DB ($::rpmdrake_options{'rpm-root'}[0])";
- }
-}
-
-
sub find_installed_version {
my ($p) = @_;
my @version;
@@ -230,36 +208,6 @@ Then, restart %s.", $rpmdrake::myname_update)), myexit(-1);
}
-
-sub open_urpmi_db() {
- my $error_happened;
- my $urpm = urpm->new;
- $urpm->{options}{'split-level'} ||= 20;
- $urpm->{options}{'split-length'} ||= 1;
- $urpm->{options}{'verify-rpm'} = !$::rpmdrake_options{'no-verify-rpm'} if defined $::rpmdrake_options{'no-verify-rpm'};
- $urpm->{options}{auto} = $::rpmdrake_options{auto} if defined $::rpmdrake_options{auto};
- urpm::set_files($urpm, $::rpmdrake_options{'urpmi-root'}[0]) if $::rpmdrake_options{'urpmi-root'}[0];
- urpm::args::set_root($urpm, $::rpmdrake_options{'rpm-root'}[0]) if $::rpmdrake_options{'rpm-root'}[0];
-
- $urpm::args::rpmdrake_options{justdb} = $::rpmdrake_options{justdb};
-
- $urpm->{fatal} = sub {
- $error_happened = 1;
- interactive_msg(N("Fatal error"),
- N("A fatal error occurred: %s.", $_[1]));
- };
- my $media = ref $::rpmdrake_options{media} ? join(',', @{$::rpmdrake_options{media}}) : '';
- urpm::media::read_config($urpm);
-
- my $searchmedia = join(',', map { $_->{name} } grep { $_->{ignore} && $_->{name} =~ /backport/i } @{$urpm->{media}});
- urpm::media::configure($urpm, media => $media, if_($searchmedia, searchmedia => $searchmedia));
- if ($error_happened) {
- touch('/etc/urpmi/urpmi.cfg');
- exec('edit-urpm-sources.pl');
- }
- $urpm;
-}
-
sub get_parallel_group() {
$::rpmdrake_options{parallel} ? $::rpmdrake_options{parallel}[0] : undef;
}
diff --git a/Rpmdrake/rpmnew.pm b/Rpmdrake/rpmnew.pm
index dbbd7c47..ef51ca4a 100644
--- a/Rpmdrake/rpmnew.pm
+++ b/Rpmdrake/rpmnew.pm
@@ -29,6 +29,7 @@ use common;
use rpmdrake;
use Rpmdrake::init;
use Rpmdrake::pkg;
+use Rpmdrake::open_db;
use Rpmdrake::formatting;
use Gtk2::SourceView;
use File::MimeInfo::Magic;
@@ -188,7 +189,7 @@ sub do_merge_if_needed() {
my %pkg2rpmnew;
my $wait = wait_msg(N("Please wait, searching..."));
print "Searching .rpmnew and .rpmsave files...\n";
- Rpmdrake::pkg::open_rpm_db()->traverse(sub {
+ open_rpm_db()->traverse(sub {
my $n = my_fullname($_[0]);
$pkg2rpmnew{$n} = [ grep { m|^/etc| && (-r "$_.rpmnew" || -r "$_.rpmsave") } map { chomp_($_) } $_[0]->files ];
});
diff --git a/rpmdrake b/rpmdrake
index b32f23e8..04d385fb 100755
--- a/rpmdrake
+++ b/rpmdrake
@@ -32,6 +32,7 @@ use utf8;
use Rpmdrake::init;
use standalone; #- standalone must be loaded very first, for 'explanations', but after rpmdrake::init
use rpmdrake;
+use Rpmdrake::open_db;
use Rpmdrake::gui;
use Rpmdrake::rpmnew;
use Rpmdrake::formatting;