Speed up module listing, switch tabs
authorJamie Cameron <jcameron@webmin.com>
Sun, 11 Jan 2009 07:47:43 +0000 (07:47 +0000)
committerJamie Cameron <jcameron@webmin.com>
Sun, 11 Jan 2009 07:47:43 +0000 (07:47 +0000)
cpan/CHANGELOG
cpan/cpan-lib.pl
cpan/index.cgi

index 7097469..bbc7c1c 100644 (file)
@@ -21,3 +21,6 @@ The module is now available when running Webmin inside a Solaris zone, but only
 ---- Changes since 1.390 ----
 Converted all code to use the new Webmin UI library, for a more consistent look.
 Modules can be forcibly compiled and install from the latest source instead of APT or YUM, using a new option on the main page.
+---- Changes since 1.440 ----
+Sped up the fetching of Perl modules installed from RPM and Debian packages.
+Switched the install and current modules tabs.
index 08bf4f0..fcc3899 100644 (file)
@@ -40,7 +40,8 @@ foreach $d (&expand_usr64($Config{'privlib'}),
        next if (!$d);
        next if ($donedir{$d});
        local $f;
-       open(FIND, "find '$d' -name .packlist -print |");
+       open(FIND, "find ".quotemeta($d)." -name .packlist -print |");
+       print STDERR "find ".quotemeta($d)." -name .packlist -print\n";
        while($f = <FIND>) {
                chop($f);
                local @st = stat($f);
@@ -73,7 +74,10 @@ foreach $d (&expand_usr64($Config{'privlib'}),
                        elsif ($l =~ /^([^\/]+)\.pm$/) {
                                # Module name only, with no path! Damn redhat..
                                local @rpath;
-                               open(FIND2, "find '$d' -name '$l' -print |");
+                               open(FIND2, "find ".quotemeta($d).
+                                           " -name '$l' -print |");
+                               print STDERR "find ".quotemeta($d).
+                                            " -name '$l' -print\n";
                                while(<FIND2>) {
                                        chop;
                                        push(@rpath, $_);
@@ -124,12 +128,12 @@ if (&foreign_check("software") && $config{'incpackages'}) {
                        next if ($donemod{$mod->{'name'}}++);
 
                        # Add the files in the RPM
-                       local $fn = &software::check_files(
-                               $software::packages{$i,'name'},
-                               $software::packages{$i,'version'});
-                       local $fi;
-                       for($fi=0; $fi<$fn; $fi++) {
-                               local $l = $software::files{$fi,'path'};
+                       # XXX call rpm -ql only, avoid -V step
+                       # XXX same for Debian
+                       # XXX list_package_files function, returns an array
+                       foreach my $l (&software::package_files(
+                                       $software::packages{$i,'name'},
+                                       $software::packages{$i,'version'})) {
                                if ($l =~ /\/((([A-Z][^\/]*\/)([^\/]+\/)?)?[^\/]+)\.pm$/) {
                                        local $mn = $1;
                                        $mn =~ s/\//::/g;
@@ -165,12 +169,8 @@ if (&foreign_check("software") && $config{'incpackages'}) {
                                          $software::packages{$i,'version'} };
 
                        # Add the files in the RPM
-                       local $fn = &software::check_files(
-                               $software::packages{$i,'name'},
-                               $software::packages{$i,'version'});
-                       local $fi;
-                       for($fi=0; $fi<$fn; $fi++) {
-                               local $l = $software::files{$fi,'path'};
+                       foreach my $l (&software::package_files(
+                                       $software::packages{$i,'name'})) {
                                if ($l =~ /\/((([A-Z][^\/]*\/)([^\/]+\/)?)?[^\/]+)\.pm$/) {
                                        local $mn = $1;
                                        $mn =~ s/\//::/g;
index e7eeca8..c88df40 100755 (executable)
@@ -18,15 +18,47 @@ $formno = 0;
 
 # Start tabs
 @mods = &list_perl_modules();
-@tabs = ( [ 'mods', $text{'index_tabmods'}, 'index.cgi?mode=mods' ],
+@tabs = (
          [ 'install', $text{'index_tabinstall'}, 'index.cgi?mode=install' ],
+         [ 'mods', $text{'index_tabmods'}, 'index.cgi?mode=mods' ],
          [ 'suggest', $text{'index_tabsuggest'}, 'index.cgi?mode=suggest' ],
        );
-if (!$in{'mode'}) {
-       $in{'mode'} = @mods ? 'mods' : 'install';
-       }
+$in{'mode'} ||= 'install';
 print &ui_tabs_start(\@tabs, 'mode', $in{'mode'}, 1);
 
+# Display install form
+print &ui_tabs_start_tab('mode', 'install');
+print "$text{'index_installmsg'}<p>\n";
+print &ui_form_start("download.cgi", "form-data");
+
+# Work out of packages should be refreshed
+@st = stat($packages_file);
+if (@st) {
+       $now = time();
+       $refreshopt = "<br>".&ui_checkbox("refresh", 1, $text{'index_refresh'},
+                       $st[9]+$config{'refresh_days'}*24*60*60 < $now);
+       }
+if ($config{'incyum'} && &can_list_packaged_modules()) {
+       $cpanopt = "<br>".&ui_checkbox("forcecpan", 1,
+                                      $text{'index_forcecpan'}, 0);
+       }
+
+@opts = ( [ 3, $text{'index_cpan'},
+           &ui_textbox("cpan", undef, 50)." ".
+           &ui_button("...", undef, 0, "onClick='window.ifield = document.forms[$formno].cpan; chooser = window.open(\"cpan.cgi\", \"chooser\", \"toolbar=no,menubar=no,scrollbars=yes,width=800,height=500\"); chooser.ifield = window.ifield;'").
+           $refreshopt.$cpanopt ],
+         [ 0, $text{'index_local'},
+           &ui_textbox("local", undef, 50)." ".
+           &file_chooser_button("local", 0) ],
+         [ 1, $text{'index_uploaded'},
+           &ui_upload("upload", 50) ],
+         [ 2, $text{'index_ftp'},
+           &ui_textbox("url", undef, 50) ]
+        );
+print &ui_radio_table("source", 3, \@opts);
+print &ui_form_end([ [ undef, $text{'index_installok'} ] ]);
+print &ui_tabs_end_tab();
+
 # Display perl modules
 print &ui_tabs_start_tab('mode', 'mods');
 if (@mods) {
@@ -70,39 +102,6 @@ else {
        }
 print &ui_tabs_end_tab();
 
-# Display install form
-print &ui_tabs_start_tab('mode', 'install');
-print "$text{'index_installmsg'}<p>\n";
-print &ui_form_start("download.cgi", "form-data");
-
-# Work out of packages should be refreshed
-@st = stat($packages_file);
-if (@st) {
-       $now = time();
-       $refreshopt = "<br>".&ui_checkbox("refresh", 1, $text{'index_refresh'},
-                       $st[9]+$config{'refresh_days'}*24*60*60 < $now);
-       }
-if ($config{'incyum'} && &can_list_packaged_modules()) {
-       $cpanopt = "<br>".&ui_checkbox("forcecpan", 1,
-                                      $text{'index_forcecpan'}, 0);
-       }
-
-@opts = ( [ 3, $text{'index_cpan'},
-           &ui_textbox("cpan", undef, 50)." ".
-           &ui_button("...", undef, 0, "onClick='window.ifield = document.forms[$formno].cpan; chooser = window.open(\"cpan.cgi\", \"chooser\", \"toolbar=no,menubar=no,scrollbars=yes,width=800,height=500\"); chooser.ifield = window.ifield;'").
-           $refreshopt.$cpanopt ],
-         [ 0, $text{'index_local'},
-           &ui_textbox("local", undef, 50)." ".
-           &file_chooser_button("local", 0) ],
-         [ 1, $text{'index_uploaded'},
-           &ui_upload("upload", 50) ],
-         [ 2, $text{'index_ftp'},
-           &ui_textbox("url", undef, 50) ]
-        );
-print &ui_radio_table("source", 3, \@opts);
-print &ui_form_end([ [ undef, $text{'index_installok'} ] ]);
-print &ui_tabs_end_tab();
-
 # Show button to install recommended Perl modules
 print &ui_tabs_start_tab('mode', 'suggest');
 @allrecs = &get_recommended_modules();