xscreensaver-data actually depends on libwww-perl to download images
from the web, disabled by default. The installed size of
xscreensaver-data is 1209KB, where libwww-perl depends on 18 others
packages totaling 5167KB.

I wrote a patch to dynamically load the LWP module at runtime and print
an error suggesting the user to install libwww-perl if not present.

I tested this patch only without libwww-perl installed: anyone wants to
test it on a system with libwww-perl?

Ciao
--- xscreensaver/bin/xscreensaver-getimage-file	2012-06-30 00:00:00.000000000 +0200
+++ xscreensaver-nolwp/bin/xscreensaver-getimage-file	2013-01-13 05:35:32.266695036 +0100
@@ -50,7 +50,6 @@
             # errors about UTF-8 all over the place without this.
 
 use Digest::MD5 qw(md5_base64);
-use LWP::Simple qw($ua);
 
 
 my $progname = $0; $progname =~ s@.*/@@g;
@@ -111,6 +110,10 @@
 my @all_files = ();         # list of "good" files we've collected
 my %seen_inodes;            # for breaking recursive symlink loops
 
+# LWP::Simple module is loaded runtime and the user agent is defined
+# here to avoid compilation errors.
+my $ua = undef;
+
 # For diagnostic messages:
 #
 my $dir_count = 1;          # number of directories seen
@@ -851,6 +854,7 @@
 
 sub main() {
   my $dir = undef;
+  my $lwp_support = 0;
 
   while ($_ = $ARGV[0]) {
     shift @ARGV;
@@ -882,6 +886,18 @@
     }
   }
 
+  # LWP::Simple module is loaded runtime, disabling URLs if not.
+  eval {
+    require LWP::Simple;
+    LWP::Simple->import(qw($ua));
+    $lwp_support = 1;
+  };
+
+  if (($dir =~ m/^https?:/si) && ($lwp_support == 0)) {
+    print STDERR "$progname: URLs not supported; install libwww-perl\n";
+    exit 1;
+  }
+
   my $file = find_random_file ($dir);
   print STDOUT "$file\n";
 }

Reply via email to