From 0e345d483f0116470e3b5438696f5b7699fd20dd Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Mon, 26 Jul 2004 01:07:52 +0000 Subject: Media reconfiguration: for local media, verify that the new url points to an existing directory. --- urpm.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'urpm.pm') diff --git a/urpm.pm b/urpm.pm index c7b78cb3..614ae7a8 100644 --- a/urpm.pm +++ b/urpm.pm @@ -849,9 +849,11 @@ sub _probe_with_try_list { } #- read a reconfiguration file for urpmi, and reconfigure media accordingly +#- $rfile is the reconfiguration file (local), $name is the media name sub reconfig_urpmi { my ($urpm, $rfile, $name) = @_; my @replacements; + my @reconfigurable = qw(url with_hdlist clear_url); my $reconfigured = 0; open my $fh, $rfile or return undef; $urpm->{log}(N("reconfiguring urpmi for media \"%s\"", $name)); @@ -863,9 +865,11 @@ sub reconfig_urpmi { $f ||= 1; push @replacements, [ quotemeta $p, $r, $f ]; } + MEDIA: for my $medium (grep { $_->{name} eq $name } @{$urpm->{media}}) { + my %orig = map { $_ => $medium->{$_} } @reconfigurable; URLS: - for my $k (qw(url with_hdlist clear_url)) { + for my $k (@reconfigurable) { for my $r (@replacements) { if ($medium->{$k} =~ s/$r->[0]/$r->[1]/) { $reconfigured = 1; @@ -874,6 +878,13 @@ sub reconfig_urpmi { redo URLS if $r->[2] =~ /N/; } } + #- check that the new url exists before committing changes (local mirrors) + if ($medium->{$k} =~ m#^file:/*(/[^/].*[^/])/*$# && !-e $1) { + $medium->{$k} = $orig{$k} for @reconfigurable; + $reconfigured = 0; + $urpm->{log}(N("...reconfiguration failed")); + last MEDIA; + } } } close $fh; -- cgit v1.2.1