Don't fail just because a single CPAN module is missing
authorJamie Cameron <jcameron@webmin.com>
Wed, 12 Jan 2011 22:35:12 +0000 (14:35 -0800)
committerJamie Cameron <jcameron@webmin.com>
Wed, 12 Jan 2011 22:35:12 +0000 (14:35 -0800)
https://www.virtualmin.com/node/16819

cpan/CHANGELOG
cpan/download.cgi
cpan/lang/en
cpan/uninstall_mods.cgi

index bbc7c1c..97532b3 100644 (file)
@@ -24,3 +24,5 @@ Modules can be forcibly compiled and install from the latest source instead of A
 ---- Changes since 1.440 ----
 Sped up the fetching of Perl modules installed from RPM and Debian packages.
 Switched the install and current modules tabs.
+---- Changes since 1.530 ----
+When upgrading multiple Perl modules from CPAN, don't give up because just one could not be found.
index 84e9922..433184e 100755 (executable)
@@ -125,11 +125,28 @@ elsif ($in{'source'} == 3) {
                        }
                }
        close(LIST);
+
+       # Fail if any modules are missing from CPAN
        for($i=0; $i<@cpan; $i++) {
                push(@missing, "<tt>$cpan[$i]</tt>") if (!$source[$i]);
                }
-       &install_error(&text('download_ecpan', join(" ", @missing)))
-               if (@missing);
+
+       if ($in{'missingok'}) {
+               # If missing modules are OK, exclude them from the sources list
+               for($i=0; $i<@cpan; $i++) {
+                       if (!$source[$i]) {
+                               splice(@source, $i, 1);
+                               splice(@cpan, $i, 1);
+                               $i--;
+                               }
+                       }
+               @cpan || &install_error(&text('download_ecpan',
+                                             join(" ", @missing)));
+               }
+       elsif (@missing) {
+               # Fail due to missing modules
+               &install_error(&text('download_ecpan', join(" ", @missing)));
+               }
        $source = join("<br>", @source);
 
        # Download the actual modules
@@ -285,6 +302,12 @@ for($i=0; $i<@mods; $i++) {
 print &ui_table_row(@mods > 1 ? $text{'download_mods'} : $text{'download_mod'},
                    $modmsg);
 
+# Missing modules
+if (@missing) {
+       print &ui_table_row($text{'download_missingok'},
+                           join(" ", @missing));
+       }
+
 # Source
 print &ui_table_row($text{'download_src'}, $source);
 
index 2e2969d..b466cd0 100644 (file)
@@ -61,6 +61,7 @@ download_missing=Missing $1 modules
 download_nomissing=All installed
 download_ebuild=One or more of the Perl modules needs $1 to be built, but this Perl module is not installed.
 download_yum=Installing Perl module $1 from package $2 ..
+download_missingok=Modules missing from CPAN
 
 install_title=Install Module
 install_untar=Untarring module file
index 59d2df4..eeaca93 100755 (executable)
@@ -9,7 +9,7 @@ require './cpan-lib.pl';
 
 if ($in{'upgrade'}) {
        # Just redirect to the install page from CPAN
-       &redirect("download.cgi?source=3&cpan=".
+       &redirect("download.cgi?missingok=1&source=3&cpan=".
                  &urlize(join(" ", @d)));
        exit;
        }