summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-02-27 17:37:37 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-02-27 17:37:37 +0000
commit6ad8276603af8eaba9f53a821bda3ae19cfdd76f (patch)
treebc59987ba3dacb0cb0e6e3f8b6dc9362b22d6547
parent444eed89d799da4686b90b70e81deafe10b40ae5 (diff)
downloadurpmi-6ad8276603af8eaba9f53a821bda3ae19cfdd76f.tar
urpmi-6ad8276603af8eaba9f53a821bda3ae19cfdd76f.tar.gz
urpmi-6ad8276603af8eaba9f53a821bda3ae19cfdd76f.tar.bz2
urpmi-6ad8276603af8eaba9f53a821bda3ae19cfdd76f.tar.xz
urpmi-6ad8276603af8eaba9f53a821bda3ae19cfdd76f.zip
- all tools:
o cdrom:// replaces removable://
-rw-r--r--.perl_checker1
-rw-r--r--NEWS2
-rw-r--r--pod/urpmi.addmedia.8.pod8
-rw-r--r--pod/urpmi.update.8.pod2
-rw-r--r--pod/urpmihowto.8.pod4
-rw-r--r--urpm.pm17
-rw-r--r--urpm/media.pm62
-rw-r--r--urpm/removable.pm98
-rwxr-xr-xurpmi.addmedia4
9 files changed, 108 insertions, 90 deletions
diff --git a/.perl_checker b/.perl_checker
index fe2ca85e..f0e41fff 100644
--- a/.perl_checker
+++ b/.perl_checker
@@ -19,3 +19,4 @@ open
encoding
XML::LibXML::Reader
Config::IniFiles
+Carp
diff --git a/NEWS b/NEWS
index 9f2cf62e..5ab2827a 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+- all tools:
+ o cdrom:// replaces removable://
- urpmi:
o fix using proxy with curl (#38143)
diff --git a/pod/urpmi.addmedia.8.pod b/pod/urpmi.addmedia.8.pod
index 9b99121d..fd95fbb5 100644
--- a/pod/urpmi.addmedia.8.pod
+++ b/pod/urpmi.addmedia.8.pod
@@ -74,13 +74,9 @@ where <I<name>> is a human-readable name for the new media (e.g.
"local updates"). <I<path>> is the location of the media directory on your
machine (e.g. C<media/main>).
-=item B<urpmi.addmedia> [I<options>] <I<name>> removable://<I<path>>
+=item B<urpmi.addmedia> [I<options>] <I<name>> cdrom://<I<path>>
-<I<path>> is the location of the media directory on your machine when the
-removable device is mounted. This works for removable drives, but also for
-ISO images mounted on a loop device. urpmi will then be able to re-mount
-the ISO image to the specified path (but the ISO image must be mounted
-when you run C<urpmi.addmedia>).
+<I<path>> is the location of the media directory in the CDROM or DVD.
=back
diff --git a/pod/urpmi.update.8.pod b/pod/urpmi.update.8.pod
index b4939d6b..7c23e4cb 100644
--- a/pod/urpmi.update.8.pod
+++ b/pod/urpmi.update.8.pod
@@ -80,7 +80,7 @@ Note that the rsync options will also be used for ssh media.
=item B<-a>
-Select all media that are not using a removable device to update them.
+Select all non-static media to update them.
=item B<-f>
diff --git a/pod/urpmihowto.8.pod b/pod/urpmihowto.8.pod
index 60255c9e..7b10d43b 100644
--- a/pod/urpmihowto.8.pod
+++ b/pod/urpmihowto.8.pod
@@ -108,9 +108,7 @@ In this synopsis, C<< <name> >> is the name of the new media,
C<< <url> >> the URL where the RPMs are to be found.
Supported URLs can be C<http://>, C<ftp://>, C<rsync://>, C<ssh://> (this
-will use rsync over ssh), C<file://>, and C<removable://> (C<removable://>
-works like C<file://>, but instructs urpmi that the directory is mounted
-from a removable media, such as a CD or a DVD.) If the media requires
+will use rsync over ssh), C<file://>, and C<cdrom://>. If the media requires
authentication, you can use the usual URL syntax:
<scheme>://<login>:<pass>@host/path
diff --git a/urpm.pm b/urpm.pm
index aec79d5e..43cd4004 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -202,16 +202,27 @@ sub file_from_local_url {
}
sub file_from_local_medium {
my ($medium, $o_url) = @_;
- file_from_local_url($o_url || $medium->{url});
+ my $url = $o_url || $medium->{url};
+ if ($url =~ m!^cdrom://(.*)!) {
+ my $rel = $1;
+ $medium->{mntpoint} or do { require Carp; Carp::croak("cdrom is not mounted yet!\n") };
+ "$medium->{mntpoint}/$rel";
+ } else {
+ file_from_local_url($url);
+ }
}
sub is_local_url {
my ($url) = @_;
- file_from_local_url($url);
+ file_from_local_url($url) || is_cdrom_url($url);
}
sub is_local_medium {
my ($medium) = @_;
is_local_url($medium->{url});
}
+sub is_cdrom_url {
+ my ($url) = @_;
+ protocol_from_url($url) eq 'cdrom';
+}
sub db_open_or_die {
my ($urpm, $root, $b_write_perm) = @_;
@@ -399,7 +410,7 @@ B<media>: [ {
start => int, end => int, name => string, url => string,
virtual => bool, media_info_dir => string, with_synthesis => string,
no-media-info => bool,
- removable => string, downloader => string,
+ iso => string, downloader => string,
ignore => bool, update => bool, modified => bool, really_modified => bool,
unknown_media_info => bool,
} ],
diff --git a/urpm/media.pm b/urpm/media.pm
index 2317d80a..f421ad7a 100644
--- a/urpm/media.pm
+++ b/urpm/media.pm
@@ -233,8 +233,7 @@ sub add_existing_medium {
check_existing_medium($urpm, $medium);
- #- probe removable device.
- probe_removable_device($urpm, $medium);
+ _migrate_removable_device($urpm, $medium);
#- clear URLs for trailing /es.
$medium->{url} and $medium->{url} =~ s|(.*?)/*$|$1|;
@@ -390,32 +389,22 @@ sub remove_user_media_info_files {
}
#- probe device associated with a removable device.
-sub probe_removable_device {
+sub _migrate_removable_device {
my ($urpm, $medium) = @_;
- if ($medium->{url} && $medium->{url} =~ /^removable/) {
- #- try to find device name in url scheme, this is deprecated, use medium option "removable" instead
- if ($medium->{url} =~ /^removable_?([^_:]*)/) {
- $medium->{removable} ||= $1 && "/dev/$1";
- }
- } else {
- delete $medium->{removable};
- return;
- }
+ # always drop {removable}, it is obsolete
+ # (nb: for iso files, {removable} has already been renamed into {iso} internally)
+ delete $medium->{removable};
- #- try to find device to open/close for removable medium.
- if (my $dir = file_from_local_medium($medium)) {
- if (my $entry = urpm::sys::find_a_mntpoint($dir)) {
- if ($medium->{removable} && $medium->{removable} ne $entry->{device}) {
- $urpm->{log}(N("using different removable device [%s] for \"%s\"",
- $entry->{device}, $medium->{name}));
- }
- $medium->{removable} = $entry->{device};
+ if ($medium->{url} && $medium->{url} =~ /^removable/) {
+ $medium->{url} =~ s!^removable(.*?)://!/!;
+ #- handle device name in url scheme, this is deprecated
+ if ($medium->{url} =~ s!/(mnt|media)/cd\w+/?!cdrom://!i) {
+ # success!
} else {
- $urpm->{error}(N("unable to retrieve pathname for removable medium \"%s\"", $medium->{name}));
+ $urpm->{error}(N("failed to migrate removable device, ignoring media"));
+ $medium->{ignore} = 1;
}
- } else {
- $urpm->{error}(N("unable to retrieve pathname for removable medium \"%s\"", $medium->{name}));
}
}
@@ -679,7 +668,7 @@ sub add_medium {
if ($options{virtual}) {
$medium->{virtual} = 1;
} else {
- probe_removable_device($urpm, $medium);
+ _migrate_removable_device($urpm, $medium);
}
if (!$medium->{url} && $options{mirrorlist}) {
@@ -739,9 +728,11 @@ sub add_distrib_media {
my $distribconf;
- if (my $dir = $url && urpm::file_from_local_url($url)) {
- urpm::removable::try_mounting_($urpm, $dir)
- or $urpm->{error}(N("unable to mount the distribution medium")), return ();
+ if ($url && urpm::is_local_url($url)) {
+ my $m = { url => $url };
+ urpm::removable::try_mounting_medium($urpm, $m) or return ();
+ my $dir = file_from_local_medium($m);
+
$distribconf = MDV::Distribconf->new($dir, undef);
$distribconf->load
or $urpm->{error}(N("this location doesn't seem to contain any distribution")), return ();
@@ -800,7 +791,7 @@ sub add_distrib_media {
$is_update_media or next;
}
- my $use_copied_synthesis = $urpm->{options}{use_copied_hdlist} || $distribconf->getvalue($media, 'use_copied_hdlist');
+ my $use_copied_synthesis = urpm::is_cdrom_url($url) || $urpm->{options}{use_copied_hdlist} || $distribconf->getvalue($media, 'use_copied_hdlist');
my $with_synthesis = $use_copied_synthesis && offset_pathname(
$url,
$distribconf->getpath($media, 'path'),
@@ -941,10 +932,10 @@ sub _probe_with_try_list {
sub may_reconfig_urpmi {
my ($urpm, $medium) = @_;
- $medium->{url} or return; # we should handle mirrorlist?
+ $medium->{url} && !urpm::is_cdrom_url($medium->{url}) or return; # we should handle mirrorlist?
my $f;
- if (my $dir = file_from_local_medium($medium)) {
+ if (my $dir = file_from_file_url($medium->{url})) {
$f = reduce_pathname("$dir/reconfig.urpmi");
} else {
unlink($f = "$urpm->{cachedir}/partial/reconfig.urpmi");
@@ -1237,18 +1228,11 @@ sub _is_statedir_MD5SUM_uptodate {
sub _update_medium__parse_if_unmodified__local {
my ($urpm, $medium, $options) = @_;
- my $dir = $options->{probe_with} ne 'rpms' && _valid_synthesis_dir($medium)
- ? _synthesis_dir($medium) : file_from_local_medium($medium);
-
- if (!-d $dir) {
+ if ($options->{probe_with} ne 'rpms') {
#- the directory given does not exist and may be accessible
#- by mounting some other directory. Try to figure it out and mount
#- everything that might be necessary.
- urpm::removable::try_mounting($urpm,
- $dir,
- $medium->{iso},
- ) or $urpm->{error}(N("unable to access medium \"%s\",
-this could happen if you mounted manually the directory when creating the medium.", $medium->{name})), return;
+ urpm::removable::try_mounting_medium($urpm, $medium) or return;
}
#- try to probe for possible with_synthesis parameter, unless
diff --git a/urpm/removable.pm b/urpm/removable.pm
index cae0acaa..a0e7897c 100644
--- a/urpm/removable.pm
+++ b/urpm/removable.pm
@@ -18,6 +18,53 @@ sub is_iso {
$removable_dev && $removable_dev =~ /\.iso$/i;
}
+sub _file_or_synthesis_dir {
+ my ($medium, $o_url) = @_;
+
+ urpm::media::_valid_synthesis_dir($medium) && !$o_url ?
+ urpm::media::_synthesis_dir($medium) :
+ file_from_local_medium($medium, $o_url);
+}
+
+#- side-effects: $medium->{mntpoint}
+sub look_for_mounted_cdrom {
+ my ($urpm, $medium, $o_url) = @_;
+
+ my @mntpoints = map { $_->{mntpoint} }
+ grep { $_->{fs} eq 'iso9660' || $_->{fs} eq 'udf' } urpm::sys::read_mtab();
+ foreach (@mntpoints) {
+ # set it, then verify
+ $medium->{mntpoint} = $_;
+ if (-r _file_or_synthesis_dir($medium, $o_url)) {
+ $urpm->{log}("using cdrom mounted in $_");
+ return 1;
+ }
+ }
+ 0;
+}
+
+#- side-effects:
+#- + those of _try_mounting_medium ($medium->{mntpoint})
+sub try_mounting_medium {
+ my ($urpm, $medium, $o_url) = @_;
+
+ my $rc = _try_mounting_medium($urpm, $medium, $o_url);
+ $rc or $urpm->{error}(N("unable to access medium \"%s\".", $medium->{name}));
+ $rc;
+}
+
+#- side-effects:
+#- + those of look_for_mounted_cdrom ($medium->{mntpoint})
+sub _try_mounting_medium {
+ my ($urpm, $medium, $o_url) = @_;
+
+ if (urpm::is_cdrom_url($medium->{url})) {
+ look_for_mounted_cdrom($urpm, $medium, $o_url);
+ } else {
+ -r _file_or_synthesis_dir($medium, $o_url);
+ }
+}
+
#- side-effects:
#- + those of try_mounting_ ($urpm->{removable_mounted}, "mount")
#- + those of try_mounting_iso ($urpm->{removable_mounted}, "mount")
@@ -100,12 +147,12 @@ sub try_umounting_removables {
}
#- side-effects:
-#- + those of try_mounting_ ($urpm->{removable_mounted}, "mount")
+#- + those of try_mounting_medium ($medium->{mntpoint})
sub _mount_and_check_notfound {
- my ($urpm, $blist, $dir) = @_;
+ my ($urpm, $blist, $medium) = @_;
- try_mounting_($urpm, $dir);
- -e $dir or return 2;
+ my ($first_url) = values %{$blist->{list}};
+ try_mounting_medium($urpm, $medium, $first_url) or return 1;
_check_notfound($blist);
}
@@ -146,23 +193,20 @@ sub _mount_it {
my ($urpm, $blist, $o_ask_for_medium) = @_;
my $medium = $blist->{medium};
- my $dir = file_from_local_medium($medium);
-
#- the directory given does not exist and may be accessible
#- by mounting some other directory. Try to figure it out and mount
#- everything that might be necessary.
- while (_mount_and_check_notfound($urpm, $blist, $dir)) {
+ while (_mount_and_check_notfound($urpm, $blist, $medium)) {
$o_ask_for_medium
or $urpm->{fatal}(4, N("medium \"%s\" is not available", $medium->{name}));
+ my $dir; # TODO
try_umounting($urpm, $dir);
system("/usr/bin/eject '$medium->{removable}' 2>/dev/null");
$o_ask_for_medium->(remove_internal_name($medium->{name}), $medium->{removable})
or $urpm->{fatal}(4, N("medium \"%s\" is not available", $medium->{name}));
}
-
- $dir;
}
#- side-effects: none
@@ -198,7 +242,7 @@ sub _do_the_copy {
sub _examine_removable_medium_ {
my ($urpm, $blist, $sources, $o_ask_for_medium) = @_;
- my $dir = _mount_it($urpm, $blist, $o_ask_for_medium);
+ _mount_it($urpm, $blist, $o_ask_for_medium);
while (my ($i, $url) = each %{$blist->{list}}) {
my $filepath = _filepath($blist->{medium}, $url) or next;
@@ -217,9 +261,10 @@ sub _examine_removable_medium_ {
sub try_mounting_non_cdroms {
my ($urpm, $list) = @_;
- my @used_media = map { $_->{medium} } _create_blists($urpm->{media}, $list);
+ my $blist = _create_blists($urpm->{media}, $list);
+ my @used_media = map { $_->{medium} } @$blist;
- foreach my $medium (grep { !$_->{removable} } @used_media) {
+ foreach my $medium (grep { !urpm::is_cdrom_url($_->{url}) } @used_media) {
try_mounting_non_cdrom($urpm, $medium);
}
}
@@ -238,22 +283,6 @@ sub try_mounting_non_cdrom {
}
#- side-effects: none
-sub _get_cdroms {
- my ($blists) = @_;
-
- my %removables;
-
- foreach (@$blists) {
- #- examine non removable device but that may be mounted.
- if (my $device = $_->{medium}{removable}) {
- next if $device =~ m![^a-zA-Z0-9_./-]!; #- bad path
- push @{$removables{$device} ||= []}, $_;
- }
- }
- values %removables;
-}
-
-#- side-effects: none
sub _create_blists {
my ($media, $list) = @_;
@@ -290,15 +319,12 @@ sub copy_packages_of_removable_media {
my ($urpm, $list, $sources, $o_ask_for_medium) = @_;
my $blists = _create_blists($urpm->{media}, $list);
+ #- If more than one media uses this device, we have to sort
+ #- needed packages to copy the needed rpm files.
+ my @l = _sort_media(grep { urpm::is_cdrom_url($_->{medium}{url}) } @$blists);
- foreach my $l (_get_cdroms($blists)) {
-
- #- Here we have only removable devices.
- #- If more than one media uses this device, we have to sort
- #- needed packages to copy the needed rpm files.
- foreach my $blist (_sort_media(@$l)) {
- _examine_removable_medium($urpm, $blist, $sources, $o_ask_for_medium);
- }
+ foreach my $blist (@l) {
+ _examine_removable_medium($urpm, $blist, $sources, $o_ask_for_medium);
}
1;
diff --git a/urpmi.addmedia b/urpmi.addmedia
index 8a508360..1085b24f 100755
--- a/urpmi.addmedia
+++ b/urpmi.addmedia
@@ -31,7 +31,7 @@ use urpm::util 'member';
sub usage {
my $m = shift;
my $usage =
- #-PO: The URI types strings 'file:', 'ftp:', 'http:', and 'removable:' must not be translated!
+ #-PO: The URI types strings 'file:', 'ftp:', 'http:', and 'cdrom:' must not be translated!
#-PO: neither the ``with''. Only what is between <brackets> can be translated.
N("usage: urpmi.addmedia [options] <name> <url>
where <url> is one of
@@ -39,7 +39,7 @@ where <url> is one of
ftp://<login>:<password>\@<host>/<path>
ftp://<host>/<path>
http://<host>/<path>
- removable://<path>
+ cdrom://<path>
usage: urpmi.addmedia [options] --distrib --mirrorlist <url>
usage: urpmi.addmedia [options] --mirrorlist <url> <name> <relative path>