From 6ab6e4c33dbe826782ae71640af778f32793f610 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Mon, 3 Mar 2008 17:22:05 +0000 Subject: - urpmq: o --list: speed it up (2.5x faster, and 6x faster with names.) - all tools: o restore generation of /var/lib/urpmi/names., but it is now done in urpmq/urpmi/urpmf (and so only if used as root) --- urpm/media.pm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'urpm/media.pm') diff --git a/urpm/media.pm b/urpm/media.pm index 9533b4f7..7bee8551 100644 --- a/urpm/media.pm +++ b/urpm/media.pm @@ -617,6 +617,8 @@ sub parse_media { $urpm->{searchmedia} = 1; $urpm->{log}(N("Search start: %s end: %s", $_->{start}, $_->{end})); } + + $< == 0 and _generate_medium_names($urpm, $_); } } @@ -1038,6 +1040,22 @@ sub reconfig_urpmi { $reconfigured; } +#- names. is used by external progs (namely for bash-completion) +sub _generate_medium_names { + my ($urpm, $medium) = @_; + + -e statedir_names($urpm, $medium) and return; + + my $fh = urpm::sys::open_safe($urpm, ">", statedir_names($urpm, $medium)) or return; + + foreach ($medium->{start} .. $medium->{end}) { + my $pkg = $urpm->{depslist}[$_] or + $urpm->{error}(N("Error generating names file: dependency %d not found", $_)), return; + + print $fh $urpm->{depslist}[$_]->name . "\n"; + } +} + sub _guess_synthesis_suffix { my ($url) = @_; $url =~ m!\bmedia/(\w+)/*\Z! && $1; @@ -1510,6 +1528,9 @@ sub _update_medium_ { } $medium->{modified} = 0; + # generated on first _parse_media() + unlink statedir_names($urpm, $medium); + _get_pubkey_and_descriptions($urpm, $medium, $options{nopubkey}); $medium->{'key-ids'} ||= _read_cachedir_pubkey($urpm, $medium, $options{wait_lock}); -- cgit v1.2.1