diff options
author | Rafael Garcia-Suarez <rgarciasuarez@mandriva.com> | 2006-06-12 09:43:54 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@mandriva.com> | 2006-06-12 09:43:54 +0000 |
commit | bf7ba492507bebb59b15a6f39c9e8c8433fb983d (patch) | |
tree | 910b41f451fd2fef58e6402c95e96c74bfa2ed5f | |
parent | e611acef4e04ec5a84a967fef1da4d48a7d0bbb9 (diff) | |
download | urpmi-bf7ba492507bebb59b15a6f39c9e8c8433fb983d.tar urpmi-bf7ba492507bebb59b15a6f39c9e8c8433fb983d.tar.gz urpmi-bf7ba492507bebb59b15a6f39c9e8c8433fb983d.tar.bz2 urpmi-bf7ba492507bebb59b15a6f39c9e8c8433fb983d.tar.xz urpmi-bf7ba492507bebb59b15a6f39c9e8c8433fb983d.zip |
Make options --interactive and --all-media independent in urpmi.addmedia.
Plus spelling fixes.
-rw-r--r-- | urpm.pm | 45 | ||||
-rwxr-xr-x | urpmi.addmedia | 33 |
2 files changed, 42 insertions, 36 deletions
@@ -767,6 +767,7 @@ sub add_medium { #- - limit_rate, compress : for downloading files #- - initial_number : when adding several numbered media, start with this number #- - probe_with : if eq 'synthesis', use synthesis instead of hdlists +#- ask_media : callback to know whether each media should be added #- other options are passed to add_medium() sub add_distrib_media { my ($urpm, $name, $url, %options) = @_; @@ -774,21 +775,22 @@ sub add_distrib_media { #- make sure configuration has been read. # (Olivier Thauvin): Is this a workaround ? $urpm->{media} or $urpm->read_config; - + my $distribconf = MDV::Distribconf->new($url); if (my ($dir) = $url =~ m!^(?:removable[^:]*:/|file:/)?(/.*)!) { - $urpm->try_mounting($url) or $urpm->{error}(N("unable to access first installation medium")), return (); - + $urpm->try_mounting($url) + or $urpm->{error}(N("unable to access first installation medium")), return (); + $distribconf->load() or $urpm->{error}(N("this url seems to not contains any distrib")), return (); } else { unlink "$urpm->{cachedir}/partial/media.cfg"; - # Workaround, settree not implement for now - # $distribconf->settree('mandriva'); - $distribconf->{infodir} = "media/media_info"; - $distribconf->{mediadir} = "media"; + # Workaround, settree not implement for now + # $distribconf->settree('mandriva'); + $distribconf->{infodir} = "media/media_info"; + $distribconf->{mediadir} = "media"; eval { $urpm->{log}(N("retrieving media.cfg file...")); @@ -807,8 +809,8 @@ sub add_distrib_media { }; $@ and $urpm->{error}(N("...retrieving failed: %s", $@)); if (-e "$urpm->{cachedir}/partial/media.cfg") { - $distribconf->parse_mediacfg("$urpm->{cachedir}/partial/media.cfg") or - $urpm->{error}(N("unable to parse media.cfg")), return(); + $distribconf->parse_mediacfg("$urpm->{cachedir}/partial/media.cfg") + or $urpm->{error}(N("unable to parse media.cfg")), return(); } else { $urpm->{error}(N("unable to access first installation medium (no hdlists file found)")); return (); @@ -821,20 +823,20 @@ sub add_distrib_media { my @newnames; #- at this point, we have found a media.cfg file, so parse it #- and create all necessary media according to it. - my $medium = $options{initial_number} || 1; + my $medium = $options{initial_number} || 1; my @media_list_toadd; foreach my $media ($distribconf->listmedia()) { my $skip = 0; - # if one of value is set, we skip the media by default - foreach (qw(suppl askmedia noauto)) { - $distribconf->getvalue($media, $_) and do { - $skip = 1; - last; - }; - } + # if one of those values is set, by default, we skip adding the media + foreach (qw(suppl askmedia noauto)) { + $distribconf->getvalue($media, $_) and do { + $skip = 1; + last; + }; + } if ($options{ask_media}) { - if($options{ask_media}->( + if ($options{ask_media}->( $distribconf->getvalue($media, 'name'), !$skip, )) { @@ -844,7 +846,7 @@ sub add_distrib_media { } } $skip and next; - + my $media_name = $distribconf->getvalue($media, 'name') || ''; push @newnames, $urpm->add_medium( @@ -853,10 +855,9 @@ sub add_distrib_media { offset_pathname( $url, $distribconf->getpath($media, 'path') - ) . '/' . $distribconf->getpath($media, + ) . '/' . $distribconf->getpath($media, ($options{probe_with} eq 'synthesis' ? 'synthesis' : 'hdlist') ), - index_name => $name ? undef : 0, no_reload_config => 1, #- no need to reload config each time, since we don't update the media %options, @@ -3503,3 +3504,5 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. =cut + +# ex: set ts=8 sts=4 sw=4 noet: diff --git a/urpmi.addmedia b/urpmi.addmedia index dec67346..bed458f3 100755 --- a/urpmi.addmedia +++ b/urpmi.addmedia @@ -56,8 +56,8 @@ and [options] are from hdlist file. ") . N(" --distrib - automatically create all media from an installation medium. -") . N(" --interactive - with --distrib, ask confirmation for each media before addition -") . N(" --all-media - with --distrib, add all medium include not automatic one +") . N(" --interactive - with --distrib, ask confirmation for each media +") . N(" --all-media - with --distrib, add every listed media ") . N(" --from - use specified url for list of mirrors, the default is %s ", $urpm::cfg::mirrors) . N(" --virtual - create virtual media wich are always up-to-date, @@ -125,18 +125,21 @@ if ($options{distrib}) { $with || $relative_hdlist and usage N("no need to give <relative path of hdlist> with --distrib"); - my $add_media_callback = $options{interactive} || $options{allmedia} ? - sub { - my ($medianame, $default) = @_; - my $yesexpr = N("Yy"); - my $answer = message_input( - N("\nDo you want to add media '%s'", $medianame) . ($default ? N(" (Y/n) ") : N(" (y/N) ")), - $options{allmedia} ? $yesexpr : undef, - boolean => 1 - ); - return($answer ? $answer =~ /[$yesexpr]/ : $default); - } : undef; - + my $add_media_callback = $options{interactive} ? + sub { + my ($medianame, $add_by_default) = @_; + my $yesexpr = N("Yy"); + $add_by_default = 1 if $options{allmedia}; + my $answer = message_input( + N("\nDo you want to add media '%s'", $medianame) . ($add_by_default ? N(" (Y/n) ") : N(" (y/N) ")), + undef, + boolean => 1, + ); + return $answer ? $answer =~ /[$yesexpr]/ : $add_by_default; + } : $options{allmedia} ? sub { + 1; + } : undef; + $urpm->add_distrib_media( $name, $url, @@ -144,7 +147,7 @@ if ($options{distrib}) { update => $options{update}, probe_with => $options{probe_with}, nolock => $options{nolock}, - ask_media => $add_media_callback, + ask_media => $add_media_callback, ); local $SIG{INT} = sub { remove_failed($urpm, grep { $_->{modified} } @{$urpm->{media}}); |