From d306a62a151da775832bf9a1b307e686100ea8b2 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Wed, 15 Nov 2006 18:43:23 +0000 Subject: create recover_url_from_list() out of probe_medium() --- urpm.pm | 56 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 24 deletions(-) (limited to 'urpm.pm') diff --git a/urpm.pm b/urpm.pm index 29208e5c..f83b335e 100644 --- a/urpm.pm +++ b/urpm.pm @@ -220,6 +220,36 @@ sub remove_passwords_and_write_private_netrc { chmod 0600, $urpm->{private_netrc}; } +#- handle deprecated way of saving passwords +sub recover_url_from_list { + my ($urpm, $medium) = @_; + + my %probe; + if (-r statedir_list($urpm, $medium)) { + if (my $listfile = $urpm->open_safe("<", statedir_list($urpm, $medium))) { + local $_; + while (<$listfile>) { + #- /./ is end of url marker in list file (typically generated by a + #- find . -name "*.rpm" > list + #- for exportable list file. + m|^(.*)/\./| and $probe{$1} = undef; + m|^(.*)/[^/]*$| and $probe{$1} = undef; + } + } + } + foreach (sort { length($a) <=> length($b) } keys %probe) { + if ($medium->{url}) { + if ($medium->{url} ne substr($_, 0, length($medium->{url}))) { + $medium->{ignore} or $urpm->{error}(N("inconsistent list file for \"%s\", medium ignored", $medium->{name})); + $medium->{ignore} = 1; + last; + } + } else { + $medium->{url} = $_; + } + } +} + #- Loads /etc/urpmi/urpmi.cfg and performs basic checks. #- Does not handle old format: [with ] #- options : @@ -380,30 +410,8 @@ sub probe_medium { #- there is a little more to do at this point as url is not known, inspect directly list file for it. unless ($medium->{url}) { - my %probe; - if (-r statedir_list($urpm, $medium)) { - if (my $listfile = $urpm->open_safe("<", statedir_list($urpm, $medium))) { - local $_; - while (<$listfile>) { - #- /./ is end of url marker in list file (typically generated by a - #- find . -name "*.rpm" > list - #- for exportable list file. - m|^(.*)/\./| and $probe{$1} = undef; - m|^(.*)/[^/]*$| and $probe{$1} = undef; - } - } - } - foreach (sort { length($a) <=> length($b) } keys %probe) { - if ($medium->{url}) { - if ($medium->{url} ne substr($_, 0, length($medium->{url}))) { - $medium->{ignore} or $urpm->{error}(N("inconsistent list file for \"%s\", medium ignored", $medium->{name})); - $medium->{ignore} = 1; - last; - } - } else { - $medium->{url} = $_; - } - } + recover_url_from_list($urpm, $medium); + unless ($options{nocheck_access}) { unless ($medium->{url}) { $medium->{ignore} or $urpm->{error}(N("unable to inspect list file for \"%s\", medium ignored", $medium->{name})); -- cgit v1.2.1