diff options
-rwxr-xr-x | edit-urpm-sources.pl | 63 | ||||
-rw-r--r-- | rpmdrake.pm | 21 |
2 files changed, 63 insertions, 21 deletions
diff --git a/edit-urpm-sources.pl b/edit-urpm-sources.pl index cbbbe1e2..42c04ec0 100755 --- a/edit-urpm-sources.pl +++ b/edit-urpm-sources.pl @@ -130,16 +130,38 @@ sub add_callback { }; my $nb = $count_nbs++; gtksignal_connect($_[1], 'clicked' => sub { $_[0]->get_active and $notebook->set_current_page($nb) }); + my $with_hdlist_checkbut_entry = $checkbut_entry->( + 'hdlist', N("Relative path to synthesis/hdlist:"), 1, + sub { $info->{distrib_check} and $_[0]->get_active and $info->{distrib_check}->set_active(0) }, + N("If left blank, synthesis/hdlist will be automatically probed"), + ); $notebook->append_page( my $book = create_packtable( {}, [ gtkset_alignment(Gtk2::Label->new(N("Name:")), 1, 0.5), - $info->{name_entry} = gtkentry($_[0] eq 'security' ? 'update_source' : '') ], + $info->{name_entry} = gtkentry($_[0] eq 'security' ? 'update_source' : '') ], [ gtkset_alignment(Gtk2::Label->new($info->{url}), 1, 0.5), $url_entry->() ], - $checkbut_entry->('hdlist', N("Relative path to synthesis/hdlist:"), 1, undef, - N("If left blank, synthesis/hdlist will be automatically probed")), - if_($info->{loginpass}, $loginpass_entries->()) + $with_hdlist_checkbut_entry, + if_($info->{loginpass}, $loginpass_entries->()), + if_( + !$info->{securitysel}, + sub { + [ gtkpack_( + Gtk2::HBox->new(0, 0), + 1, Gtk2::Label->new, + 0, gtksignal_connect( + $info->{distrib_check} = Gtk2::CheckButton->new(N("Create media for a whole distribution")), + clicked => sub { + if ($_[0]->get_active) { + $info->{hdlist_entry}->set_sensitive(0); + $info->{hdlist_check}->set_active(0); + } + }, + ) + ) ]; + }->() + ), ) ); $book->show; @@ -176,7 +198,12 @@ really want to replace it?"), yesno => 1) or return 0; $w->{retval} = { nb => $notebook->get_current_page }; $type = $radios_names_ordered[$w->{retval}{nb}]; my $info = $radios_infos{$type}; - %i = (name => $info->{name_entry}->get_text, url => $info->{url_entry}->get_text, hdlist => $info->{hdlist_entry}->get_text); + %i = ( + name => $info->{name_entry}->get_text, + url => $info->{url_entry}->get_text, + hdlist => $info->{hdlist_entry}->get_text, + distrib => $info->{distrib_check} ? $info->{distrib_check}->get_active : 0, + ); %make_url = (local => "file:/$i{url}", http => $i{url}, security => $i{url}, removable => "removable:/$i{url}"); $i{url} =~ s|^ftp://||; $make_url{ftp} = sprintf "ftp://%s%s", @@ -194,16 +221,24 @@ really want to replace it?"), yesno => 1) or return 0; ); if ($w->main) { - if (member($i{name}, map { $_->{name} } @{$urpm->{media}})) { - standalone::explanations("Removing medium $i{name}"); - $urpm->select_media($i{name}); - $urpm->remove_selected_media; + if ($i{distrib}) { + add_medium_and_check( + $urpm, + { nolock => 1, distrib => 1 }, + $i{name}, $make_url{$type}, $i{hdlist}, probe_with => 'synthesis', + ); + } else { + if (member($i{name}, map { $_->{name} } @{$urpm->{media}})) { + standalone::explanations("Removing medium $i{name}"); + $urpm->select_media($i{name}); + $urpm->remove_selected_media; + } + add_medium_and_check( + $urpm, + { probe_with => $probe, nolock => 1 }, + $i{name}, $make_url{$type}, $i{hdlist}, update => $type eq 'security', + ); } - add_medium_and_check( - $urpm, - { probe_with => $probe, nolock => 1 }, - $i{name}, $make_url{$type}, $i{hdlist}, update => $type eq 'security', - ); return 1; } return 0; diff --git a/rpmdrake.pm b/rpmdrake.pm index c3f1bf29..cb6e5438 100644 --- a/rpmdrake.pm +++ b/rpmdrake.pm @@ -669,13 +669,18 @@ sub update_sources_interactive { sub add_medium_and_check { my ($urpm, $options) = splice @_, 0, 2; - + my @newnames = ($_[0]); #- names of added media my $fatal_msg; my @error_msgs; local $urpm->{fatal} = sub { printf STDERR "Fatal: %s\n", $_[1]; $fatal_msg = to_utf8($_[1]); goto fatal_error }; local $urpm->{error} = sub { printf STDERR "Error: %s\n", $_[0]; push @error_msgs, to_utf8($_[0]) }; - standalone::explanations("Adding medium @_"); - $urpm->add_medium(@_); + if ($options->{distrib}) { + standalone::explanations("Adding distrib media @_"); + @newnames = $urpm->add_distrib_media(@_); + } else { + standalone::explanations("Adding medium @_"); + $urpm->add_medium(@_); + } if (@error_msgs) { interactive_msg('rpmdrake', N("Unable to add medium, errors reported:\n\n%s", @@ -683,9 +688,11 @@ sub add_medium_and_check { return 0; } - urpm::download::set_proxy_config($_, $options->{proxy}{$_}, $_[0]) foreach keys %{$options->{proxy} || {}}; + for my $name (@newnames) { + urpm::download::set_proxy_config($_, $options->{proxy}{$_}, $name) foreach keys %{$options->{proxy} || {}}; + } - if (update_sources_check($urpm, $options, N_("Unable to add medium, errors reported:\n\n%s"), $_[0])) { + if (update_sources_check($urpm, $options, N_("Unable to add medium, errors reported:\n\n%s"), @newnames)) { $urpm->write_config; $options->{proxy} and urpm::download::dump_proxy_config(); } else { @@ -693,8 +700,8 @@ sub add_medium_and_check { return 0; } - my ($medium) = grep { $_->{name} eq $_[0] } @{$urpm->{media}}; - if ($medium) { + my %newnames; @newnames{@newnames} = (); + if (any { exists $newnames{$_->{name}} } @{$urpm->{media}}) { return 1; } else { interactive_msg('rpmdrake', N("Unable to create medium.")); |