From 08f90b961222590a974642fda6dbb6a62465eaa7 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Tue, 11 Sep 2007 15:19:58 +0000 Subject: (fast_open_urpmi_db) split it out of open_urpmi_db() in order to factorize code into edit-urpm-sources and enable it to support --urpmi-root option callers don't have the pay the urpm::media::configure() heavy cost --- Rpmdrake/open_db.pm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Rpmdrake/open_db.pm b/Rpmdrake/open_db.pm index 06c12d4e..0e6a1d05 100644 --- a/Rpmdrake/open_db.pm +++ b/Rpmdrake/open_db.pm @@ -30,7 +30,7 @@ use urpm; use Exporter; our @ISA = qw(Exporter); -our @EXPORT = qw(open_rpm_db open_urpmi_db); +our @EXPORT = qw(fast_open_urpmi_db open_rpm_db open_urpmi_db); # because rpm blocks some signals when rpm DB is opened, we don't keep open around: @@ -55,8 +55,9 @@ sub open_rpm_db { } } -sub open_urpmi_db() { - my $error_happened; +# do not pay the urpm::media::configure() heavy cost: +my $error_happened; +sub fast_open_urpmi_db() { my $urpm = urpm->new; $urpm->{options}{'split-level'} ||= 20; $urpm->{options}{'split-length'} ||= 1; @@ -72,8 +73,14 @@ sub open_urpmi_db() { 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); + $urpm; +} + +sub open_urpmi_db() { + my $urpm = fast_open_urpmi_db(); + my $media = ref $::rpmdrake_options{media} ? join(',', @{$::rpmdrake_options{media}}) : ''; my $searchmedia = join(',', map { $_->{name} } grep { $_->{ignore} && $_->{name} =~ /backport/i } @{$urpm->{media}}); urpm::media::configure($urpm, media => $media, if_($searchmedia, searchmedia => $searchmedia)); -- cgit v1.2.1