From 21b7551db1452f05322209b8f4d9c9064e8eefeb Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Tue, 27 Jul 2004 06:06:53 +0000 Subject: Make the leading "file://" optional in local media URLs. --- urpm.pm | 12 ++++++------ urpmi.addmedia | 6 +++--- urpmq | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/urpm.pm b/urpm.pm index ddd6412d..e1759706 100644 --- a/urpm.pm +++ b/urpm.pm @@ -483,7 +483,7 @@ sub configure { foreach (grep { !$_->{ignore} && (!$options{update} || $_->{update}) } @{$urpm->{media} || []}) { delete @$_{qw(start end)}; if ($_->{virtual}) { - my $path = $_->{url} =~ m|^file:/*(/[^/].*[^/])/*$| && $1; + my $path = $_->{url} =~ m{^(?:file:/*)?(/[^/].*[^/])/*$} && $1; if ($path) { if ($_->{synthesis}) { $urpm->{log}(N("examining synthesis file [%s]", "$path/$_->{with_hdlist}")); @@ -618,7 +618,7 @@ sub add_medium { #- creating the medium info. if ($options{virtual}) { - $url =~ m{^file:/} or $urpm->{fatal}(1, N("virtual medium needs to be local")); + $url =~ m{^(?:file:)?/} or $urpm->{fatal}(1, N("virtual medium needs to be local")); $medium = { name => $name, url => $url, @@ -640,7 +640,7 @@ sub add_medium { } #- local media have priority, other are added at the end. - if ($url =~ m!^file:/!) { + if ($url =~ m{^(?:file:)?/}) { $medium->{priority} = 0.5; } else { $medium->{priority} = 1 + @{$urpm->{media}}; @@ -882,7 +882,7 @@ sub reconfig_urpmi { } } #- check that the new url exists before committing changes (local mirrors) - if ($medium->{$k} =~ m#^file:/*(/[^/].*[^/])/*$# && !-e $1) { + if ($medium->{$k} =~ m#^(?:file:/*)?(/[^/].*[^/])/*$# && !-e $1) { $medium->{$k} = $orig{$k} for @reconfigurable; $reconfigured = 0; $urpm->{log}(N("...reconfiguration failed")); @@ -951,7 +951,7 @@ sub update_media { #- to speed up the process, we only read the synthesis at the beginning. delete @$medium{qw(start end)}; if ($medium->{virtual}) { - my ($path) = $medium->{url} =~ m|^file:/*(/[^/].*[^/])/*$|; + my ($path) = $medium->{url} =~ m{^(?:file:)?/*(/[^/].*[^/])/*$}; if ($path) { my $with_hdlist_file = "$path/$medium->{with_hdlist}"; if ($medium->{synthesis}) { @@ -1828,7 +1828,7 @@ this could happen if you mounted manually the directory when creating the medium } elsif ($medium->{synthesis}) { if ($second_pass) { if ($medium->{virtual}) { - my ($path) = $medium->{url} =~ m|^file:/*(/[^/].*[^/])/*$|; + my ($path) = $medium->{url} =~ m{^(?:file:/*)?(/[^/].*[^/])/*$}; my $with_hdlist_file = "$path/$medium->{with_hdlist}"; if ($path) { $urpm->{log}(N("examining synthesis file [%s]", $with_hdlist_file)); diff --git a/urpmi.addmedia b/urpmi.addmedia index ca73dc57..7e93498a 100755 --- a/urpmi.addmedia +++ b/urpmi.addmedia @@ -37,7 +37,7 @@ sub usage { # Translator: only what is between can be translated. my $usage = N("usage: urpmi.addmedia [options] [with ] where is one of - file:// with + [file:/]/ with ftp://:@/ with ftp:/// with http:/// with @@ -109,7 +109,7 @@ sub main { #- allow not to give name immediately. $options{distrib} or $url or ($url, $name) = ($name, ''); - my ($type) = $url =~ m,^([^:]*)://, or $options{distrib} or usage; + my ($type) = $url =~ m,^(([^:]*):/)?/, or $options{distrib} or usage; if ($< != 0) { $urpm->{fatal}(1, N("Only superuser is allowed to add media")); @@ -227,7 +227,7 @@ sub main { } } - #- try to umount removable device which may have been mounted. + #- try to umount removable devices which may have been mounted. $urpm->try_umounting_removables; } diff --git a/urpmq b/urpmq index 77d27984..476b8224 100755 --- a/urpmq +++ b/urpmq @@ -311,7 +311,7 @@ if ($urpm::args::options{list_aliases}) { require packdrake; my $packer = new packdrake( $urpm->{media}[$_]{virtual} ? - ("$urpm->{media}[$_]{url}/$urpm->{media}[$_]{with_hdlist}" =~ m!^file:/*(/.*)!)[0] : + ("$urpm->{media}[$_]{url}/$urpm->{media}[$_]{with_hdlist}" =~ m!^(?:file:/*)?(/[^/].*)!)[0] : "$urpm->{statedir}/$urpm->{media}[$_]{hdlist}"); $packer->extract_archive(undef, @headers); } else { @@ -339,7 +339,7 @@ if ($urpm::args::options{list_aliases}) { require packdrake; my $packer = new packdrake( $urpm->{media}[$_]{virtual} ? - ("$urpm->{media}[$_]{url}/$urpm->{media}[$_]{with_hdlist}" =~ m!^file:/*(/.*)!)[0] : + ("$urpm->{media}[$_]{url}/$urpm->{media}[$_]{with_hdlist}" =~ m!^(?:file:/*)?(/[^/].*)!)[0] : "$urpm->{statedir}/$urpm->{media}[$_]{hdlist}"); $packer->extract_archive($< == 0 ? "$urpm->{cachedir}/headers" : $tmp_header_dir, @headers); } elsif (!%downloads) { -- cgit v1.2.1