diff options
author | Guillaume Cottenceau <gc@mandriva.com> | 2003-02-21 15:21:46 +0000 |
---|---|---|
committer | Guillaume Cottenceau <gc@mandriva.com> | 2003-02-21 15:21:46 +0000 |
commit | 822aaf5dc31ddcf1ad68f34087ea27f767c85c9e (patch) | |
tree | 3944a9926b37e36f67de35824f7eed2343e94b8b | |
parent | 93e9abfce70235258322062c1996a45fc8ba42aa (diff) | |
download | rpmdrake-822aaf5dc31ddcf1ad68f34087ea27f767c85c9e.tar rpmdrake-822aaf5dc31ddcf1ad68f34087ea27f767c85c9e.tar.gz rpmdrake-822aaf5dc31ddcf1ad68f34087ea27f767c85c9e.tar.bz2 rpmdrake-822aaf5dc31ddcf1ad68f34087ea27f767c85c9e.tar.xz rpmdrake-822aaf5dc31ddcf1ad68f34087ea27f767c85c9e.zip |
some code cleanup thx to titi & perl checker
-rwxr-xr-x | edit-urpm-sources.pl | 24 | ||||
-rwxr-xr-x | rpmdrake | 47 | ||||
-rw-r--r-- | rpmdrake.pm | 4 | ||||
-rw-r--r-- | rpmdrake.spec | 1 |
4 files changed, 38 insertions, 38 deletions
diff --git a/edit-urpm-sources.pl b/edit-urpm-sources.pl index 400e3d8c..25807245 100755 --- a/edit-urpm-sources.pl +++ b/edit-urpm-sources.pl @@ -50,7 +50,6 @@ my $urpm; my ($mainw, $remove, $edit, $list_tv); sub add_callback { - my ($mode, $rebuild_ui, $name_entry, $url_entry, $hdlist_entry, $count_nbs); my $w = ugtk2->new(N("Add a source"), grab => 1, center => 1, transient => $mainw->{rwindow}); my %radios_infos = (local => { name => N("Local files"), url => N("Path:"), dirsel => 1 }, ftp => { name => N("FTP server"), url => N("URL:"), loginpass => 1 }, @@ -62,15 +61,16 @@ sub add_callback { my @modes_buttons = gtkradio($radios_infos{local}{name}, map { $radios_infos{$_}{name} } @radios_names_ordered); my $notebook = Gtk2::Notebook->new; $notebook->set_show_tabs(0); $notebook->set_show_border(0); + my $count_nbs; mapn { my $info = $radios_infos{$_[0]}; my $url_entry = sub { gtkpack_(Gtk2::HBox->new(0, 0), - 1, $info->{url_entry} = gtkentry, + 1, $info->{url_entry} = gtkentry(), if_($info->{dirsel}, 0, gtksignal_connect(Gtk2::Button->new(but(N("Browse..."))), clicked => sub { $info->{url_entry}->set_text(ask_dir()) })), if_($info->{securitysel}, 0, gtksignal_connect(Gtk2::Button->new(but(N("Choose a mirror..."))), - clicked => sub { my $m = choose_mirror; + clicked => sub { my $m = choose_mirror(); if ($m) { my ($r) = cat_('/etc/mandrake-release') =~ /release\s(\S+)/; $info->{url_entry}->set_text("$m/$r/RPMS/"); @@ -81,13 +81,13 @@ sub add_callback { my $loginpass_entries = sub { map { my $entry_name = $_->[0]; [ gtkpack_(Gtk2::HBox->new(0, 0), - 1, Gtk2::Label->new(''), + 1, Gtk2::Label->new, 0, gtksignal_connect($info->{$_->[0].'_check'} = Gtk2::CheckButton->new($_->[1]), clicked => sub { $info->{$entry_name.'_entry'}->set_sensitive($_[0]->get_active); $info->{pass_check}->set_active($_[0]->get_active); $info->{login_check}->set_active($_[0]->get_active); }), - 1, Gtk2::Label->new('')), + 1, Gtk2::Label->new), gtkset_visibility(gtkset_sensitive($info->{$_->[0].'_entry'} = gtkentry(), 0), $_->[2]) ] } ([ 'login', N("Login:"), 1 ], [ 'pass', N("Password:"), 0 ]) }; @@ -96,14 +96,14 @@ sub add_callback { $notebook->append_page(my $book = create_packtable({}, [ N("Name:"), $info->{name_entry} = gtkentry($_[0] eq 'security' and 'update_source') ], [ $info->{url}, $url_entry->() ], - [ N("Relative path to synthesis/hdlist:"), $info->{hdlist_entry} = gtkentry ], + [ N("Relative path to synthesis/hdlist:"), $info->{hdlist_entry} = gtkentry() ], if_($info->{loginpass}, $loginpass_entries->()))); $book->show; } \@radios_names_ordered, \@modes_buttons; my $checkok = sub { my $info = $radios_infos{$radios_names_ordered[$notebook->get_current_page]}; - my ($name, $url, $hdlist) = map { $info->{$_.'_entry'}->get_text } qw(name url hdlist); + my ($name, $url) = map { $info->{$_.'_entry'}->get_text } qw(name url); $name eq '' || $url eq '' and interactive_msg('rpmdrake', N("You need to fill up at least the two first entries.")), return 0; if (member($name, map { $_->{name} } @{$urpm->{media}})) { $info->{name_entry}->select_region(0, -1); @@ -196,7 +196,7 @@ sub edit_callback { gtksignal_connect(Gtk2::Button->new(N("Cancel")), clicked => sub { $w->{retval} = 0; Gtk2->main_quit })))); $w->{rwindow}->set_size_request(600, -1); if ($w->main) { - my ($name, $update, $ignore) = map { $medium->{$_} } qw(name update ignore); + my ($name, $update) = map { $medium->{$_} } qw(name update); $url =~ m|^removable://| and (interactive_msg(N("You need to insert the medium to continue"), N("In order to save the changes, you need to insert the medium in the drive."), yesno => 1, text => { yes => N("Ok"), no => N("Cancel") }) or return 0); @@ -262,8 +262,8 @@ sub mainwindow { $list_tv->append_column(Gtk2::TreeViewColumn->new_with_attributes(N("Enabled?"), my $tr = Gtk2::CellRendererToggle->new, 'active' => 0)); $list_tv->append_column(Gtk2::TreeViewColumn->new_with_attributes(N("Source"), Gtk2::CellRendererText->new, 'text' => 1)); - $tr->signal_connect('toggled', sub { - my ($cell, $path) = @_; + $tr->signal_connect(toggled => sub { + my (undef, $path) = @_; my $iter = $list->get_iter_from_string($path); invbool(\$urpm->{media}[$path]{ignore}); $list->set($iter, [ 0, !$urpm->{media}[$path]{ignore} ]); @@ -299,7 +299,7 @@ sub mainwindow { } -readconf; +readconf(); if (!member(basename($0), @$already_splashed)) { interactive_msg('rpmdrake', @@ -318,6 +318,6 @@ if (mainwindow()) { $urpm->write_config; } -writeconf; +writeconf(); myexit 0; @@ -52,9 +52,9 @@ $0 =~ m|/MandrakeUpdate$| and $MODE = 'update'; $::isStandalone = 1; my $w; -sub interactive_msg_ { interactive_msg (@_, if_(exists $w->{rwindow}, transient => $w->{rwindow})) }; +sub interactive_msg_ { interactive_msg(@_, if_(exists $w->{rwindow}, transient => $w->{rwindow})) }; sub interactive_list_ { interactive_list(@_, if_(exists $w->{rwindow}, transient => $w->{rwindow})) }; -sub wait_msg_ { wait_msg (@_, if_(exists $w->{rwindow}, transient => $w->{rwindow})) }; +sub wait_msg_ { wait_msg(@_, if_(exists $w->{rwindow}, transient => $w->{rwindow})) }; sub ctreefy { $_[0] =~ s,/,|,g; $_[0] } @@ -82,7 +82,6 @@ sub split_fullname { $_[0] =~ /^(.*)-([^-]+-[^-]+)$/ } sub my_fullname { my ($name, $version, $release) = $_[0]->fullname; "$name-$version-$release" } sub parse_compssUsers_flat { - my ($urpm) = @_; my (%compssUsers, $category); my $compss = '/var/lib/urpmi/compssUsers.flat'; -r $compss or $compss = '/usr/share/rpmdrake/compssUsers.flat.default'; @@ -177,6 +176,7 @@ sub do_search($$$$$$$) { gtksignal_connect(Gtk2::Button->new(but(N("Stop"))), clicked => sub { $searchstop = 1 })))); $searchw->sync; + local *SF; open SF, 'parsehdlist --fileswinfo --description --summary '.join(' ', map { "\'$_\'" } @hdlists).' |'; my ($pkg, $progresscount); while (<SF>) { @@ -250,7 +250,7 @@ sub run_treeview_dialog { return $found; }; my $callback_choices = sub { - my ($urpm, $db, $state, $choices) = @_; + my (undef, $db, $state, $choices) = @_; foreach my $pkg (@$choices) { foreach ($pkg->requires_nosense) { /locales-/ or next; @@ -263,13 +263,13 @@ sub run_treeview_dialog { }; my $choices_auto; my $callback_choices_auto = sub { - my ($urpm, $db, $state, $choices) = @_; + my (undef, $db, $state, $choices) = @_; member(my_fullname($_), @$choices_auto) and return $_ foreach @$choices; return $choices->[0]; #- theoretically unreachable, but at least try to fallback on something usable }; my $closure_removal = sub { $urpm->{state}{ask_remove} = {}; - my $db = db; + my $db = db(); foreach (@_) { $db->traverse_tag('name', [ (split_fullname($_))[0] ], sub { my_fullname($_[0]) eq $_ or return; @@ -412,7 +412,7 @@ or you already installed all of them.")); @nodes = difference2(\@nodes, \@bad_i18n_pkgs); } slow_func($tree->window, - sub { $urpm->resolve_requested(db, $urpm->{state}, { map { $pkgs->{$_}{pkg}->id => 1 } @nodes }, + sub { $urpm->resolve_requested(db(), $urpm->{state}, { map { $pkgs->{$_}{pkg}->id => 1 } @nodes }, callback_choices => $callback_choices, no_flag_update => 1, keep_state => 1) }); my $pkg_sel_after_selection = sub { $urpm->deselect_unwanted_packages($urpm->{state}{selected}); @@ -432,7 +432,7 @@ or you already installed all of them.")); $choices_auto = \@nodes_with_deps; $urpm->{state}{selected} = {}; slow_func($tree->window, - sub { $urpm->resolve_requested(db, $urpm->{state}, { map { $pkgs->{$_}{pkg}->id => 1 } @nodes }, + sub { $urpm->resolve_requested(db(), $urpm->{state}, { map { $pkgs->{$_}{pkg}->id => 1 } @nodes }, callback_choices => $callback_choices_auto) }); $pkg_sel_after_selection->(); if (my @cant = difference2(\@nodes, \@nodes_with_deps)) { @@ -447,7 +447,7 @@ or you already installed all of them.")); } else { $urpm->{state}{unselected} = {}; slow_func($tree->window, - sub { $urpm->resolve_unrequested(db, $urpm->{state}, + sub { $urpm->resolve_unrequested(db(), $urpm->{state}, { map { $pkgs->{$_}{pkg}->id => undef } @nodes }, no_flag_update => 1) }); @nodes_with_deps = map { my_fullname($urpm->{depslist}[$_]) } keys %{$urpm->{state}{unselected}}; @@ -458,7 +458,7 @@ or you already installed all of them.")); goto packages_unselection_ok; } slow_func($tree->window, - sub { $urpm->resolve_unrequested(db, $urpm->{state}, + sub { $urpm->resolve_unrequested(db(), $urpm->{state}, { map { $pkgs->{$_}{pkg}->id => undef } @nodes }) }); @nodes_with_deps = map { my_fullname($urpm->{depslist}[$_]) } keys %{$urpm->{state}{unselected}}; packages_unselection_ok: @@ -571,7 +571,7 @@ or you already installed all of them.")); my %radios_infos = (mandrake_choices => { name => N("Mandrake choices"), flat => 0 }, flat => { name => N("All packages, alphabetical"), flat => 1 }, by => { name => N("All packages,"), flat => 0 }); - $compssUsers = parse_compssUsers_flat($urpm); + $compssUsers = parse_compssUsers_flat(); my @radios_names_ordered = qw(mandrake_choices flat by); $compssUsers or shift @radios_names_ordered; @modes_buttons = gtkradio($radios_infos{mandrake_choices}{name}, map { $radios_infos{$_}{name} } @radios_names_ordered); @@ -635,7 +635,7 @@ or you already installed all of them.")); reset_selection => sub { if ($MODE ne 'remove') { $urpm->{state}{unselected} = {}; - $urpm->resolve_unrequested(db, $urpm->{state}, + $urpm->resolve_unrequested(db(), $urpm->{state}, { map { if_($pkgs->{$_}{selected}, $pkgs->{$_}{pkg}->id => undef) } keys %$pkgs }); } $pkgs->{$_}{selected} = 0 foreach keys %$pkgs; @@ -769,7 +769,7 @@ sub get_installable_pkgs { if ($updates) { my $urpm = new urpm; $urpm->configure(); - my ($statedir, $cachedir) = map { $urpm->{$_} } qw(statedir cachedir); + my $statedir = $urpm->{statedir}; @update_medias = grep { !$_->{ignore} && $_->{update} } @{$urpm->{media}}; undef $urpm; if (@update_medias > 0) { @@ -786,7 +786,7 @@ Is it ok to continue?"), yesno => 1) or myexit(-1); } } else { mu_retry_another_mirror: - my $m = choose_mirror; + my $m = choose_mirror(); $m or interactive_msg_(N("How to choose manually your mirror"), N("You may also choose your desired mirror manually: to do so, launch the Software Sources Manager, and then add a `Security @@ -836,7 +836,7 @@ Do you want to try another mirror?", $r), yesno => 1) and goto mu_retry_another_ $urpm->configure; @update_medias = grep { !$_->{ignore} && $_->{update} } @{$urpm->{media}}; - $urpm->compute_installed_flags(db); + $urpm->compute_installed_flags(db()); foreach my $pkg (@{$urpm->{depslist}}) { $pkg->flag_upgrade or next; @@ -849,7 +849,7 @@ Do you want to try another mirror?", $r), yesno => 1) and goto mu_retry_another_ } sub dialog_rpmnew { - my ($exitstatus, $msg, %p2r) = @_; + my ($msg, %p2r) = @_; # /var/lib/nfs/etab /var/lib/nfs/rmtab /var/lib/nfs/xtab /var/cache/man/whatis my @ignores_rpmnew = qw(/etc/group /etc/passwd /etc/localtime /etc/shells /etc/adjtime /etc/ld.so.conf /etc/modules /etc/security/fileshare.conf /etc/sudoers /etc/sysconfig/alsa /etc/sysconfig/autofsck /etc/sysconfig/harddisks @@ -868,7 +868,7 @@ sub dialog_rpmnew { -r $rpmnew or $rpmfile = 'rpmsave'; -r $rpmnew && -r $rpmsave && (stat $rpmsave)[9] > (stat $rpmnew)[9] and $rpmfile = 'rpmsave'; $rpmfile eq 'rpmsave' and $rpmnew = $rpmsave; - my ($vbox, %texts); + my %texts; gtkadd($d->{window}, gtkpack_(Gtk2::VBox->new(0, 5), 1, create_vpaned( @@ -983,8 +983,7 @@ sub perform_installation { #- (partially) duplicated from /usr/sbin/urpmi :-( and $pkg2rpmnew{$1} = [ grep { m|^/etc| && (-r "$_.rpmnew" || -r "$_.rpmsave") } map { chomp_($_) } `rpm -ql $1` ]; } - dialog_rpmnew($exitstatus, - N("The installation is finished; %s.\n\nSome configuration files were created as `.rpmnew' or `.rpmsave',\nyou may now inspect some in order to take actions:", $exitstatus ? N("some packages failed to install\ncorrectly") + dialog_rpmnew(N("The installation is finished; %s.\n\nSome configuration files were created as `.rpmnew' or `.rpmsave',\nyou may now inspect some in order to take actions:", $exitstatus ? N("some packages failed to install\ncorrectly") : N("everything was installed correctly")), %pkg2rpmnew) && !$exitstatus and interactive_msg_(N("Everything installed successfully"), @@ -1018,11 +1017,11 @@ sub get_installed_pkgs { my $wait = wait_msg_(N("Please wait, reading packages database...")); my @base = qw(basesystem); my (%base, %basepackages); - my $db = db; + my $db = db(); my $sig_handler = sub { undef $db; exit 3 }; local $SIG{INT} = $sig_handler; local $SIG{QUIT} = $sig_handler; - while (defined($_ = shift @base)) { + while (defined(local $_ = shift @base)) { exists $basepackages{$_} and next; $db->traverse_tag(/^\// ? 'path' : 'whatprovides', [ $_ ], sub { push @{$basepackages{$_}}, my_fullname($_[0]); @@ -1079,7 +1078,7 @@ if ($options{'merge-all-rpmnew'}) { }); print "done.\n"; $typical_width = 280; - dialog_rpmnew(0, '', %pkg2rpmnew) and print "Nothing to do.\n"; + dialog_rpmnew('', %pkg2rpmnew) and print "Nothing to do.\n"; myexit(0); } @@ -1112,11 +1111,11 @@ you want to install on your computer.")) } if ($MODE eq 'remove') { - run_treeview_dialog(sub { get_installed_pkgs }, \&perform_removal); + run_treeview_dialog(sub { get_installed_pkgs() }, \&perform_removal); } elsif ($MODE eq 'update') { run_treeview_dialog(sub { get_installable_pkgs(1, @_) }, \&perform_installation); } else { - run_treeview_dialog(sub { get_installable_pkgs }, \&perform_installation); + run_treeview_dialog(sub { get_installable_pkgs() }, \&perform_installation); } writeconf(); diff --git a/rpmdrake.pm b/rpmdrake.pm index e05d6ba2..f679d3bf 100644 --- a/rpmdrake.pm +++ b/rpmdrake.pm @@ -261,7 +261,7 @@ sub mirrors { $url =~ m|\.\Q$_\E/| and $land = $_ foreach keys %u2l; $url =~ m|\W\Q$_\E/| and $land = $sites2countries{$_} foreach keys %sites2countries; each_index { $_ eq $land and $goodness ||= 100-$::i } (map { if_($tz =~ /^$_$/, @{$t2l{$_}}) } keys %t2l), @$us; - { url => $url, land => $u2l{$land} || N("United States"), goodness => $goodness + rand }; + { url => $url, land => $u2l{$land} || N("United States"), goodness => $goodness + rand() }; } else { () } } cat_($mirrorslist); unlink $mirrorslist; @@ -319,7 +319,7 @@ by Mandrake Linux Official Updates.")), return ''; $iter and $iter->free; } Gtk2->main_quit }) - } ([ N("Ok"), 1], [ N("Cancel"), 0 ])), + } ([ N("Ok"), 1 ], [ N("Cancel"), 0 ])), )); my %roots; $tree_model->append_set($roots{$_->{land}} ||= $tree_model->append_set(undef, [ 0 => $_->{land} ]), diff --git a/rpmdrake.spec b/rpmdrake.spec index abb88aa2..64c2e22b 100644 --- a/rpmdrake.spec +++ b/rpmdrake.spec @@ -121,6 +121,7 @@ rm -rf $RPM_BUILD_ROOT the PO (#1233) - rpmdrake: - fix locking of CD after installation (#1311) +- some code cleanup thx to titi & perl checker * Thu Feb 13 2003 Guillaume Cottenceau <gc@mandrakesoft.com> 2.1-6mdk - grpmi: if there was an error during installation, propose to |