9d5d87
From 16089db168d6f62a6ba88d1d160946b8c756acbc Mon Sep 17 00:00:00 2001
9d5d87
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
9d5d87
Date: Thu, 30 Oct 2014 13:19:16 +0100
9d5d87
Subject: [PATCH] Attemp to create site library directories on first time
9d5d87
MIME-Version: 1.0
9d5d87
Content-Type: text/plain; charset=UTF-8
9d5d87
Content-Transfer-Encoding: 8bit
9d5d87
9d5d87
Some vendors configures site library directories into /usr/local, but
9d5d87
they do not provide the directory on their systems because an
9d5d87
administrator can have a read-only network-mounted file system there.
9d5d87
9d5d87
When running CPAN for the first time, CPAN cannot find the site
9d5d87
directories and falls back to local::lib. To restore the user
9d5d87
expectations with writable /usr/local, this patch tries to create the
9d5d87
missing directories before checking for their presents.
9d5d87
9d5d87
Signed-off-by: Petr Písař <ppisar@redhat.com>
9d5d87
---
9d5d87
 lib/CPAN/FirstTime.pm | 18 ++++++++++++++++++
9d5d87
 1 file changed, 18 insertions(+)
9d5d87
9d5d87
diff --git a/lib/CPAN/FirstTime.pm b/lib/CPAN/FirstTime.pm
9d5d87
index fb6b7eb..79035b8 100644
9d5d87
--- a/lib/CPAN/FirstTime.pm
9d5d87
+++ b/lib/CPAN/FirstTime.pm
9d5d87
@@ -2059,6 +2059,24 @@ sub _print_urllist {
9d5d87
 }
9d5d87
 
9d5d87
 sub _can_write_to_libdirs {
9d5d87
+    for ($Config{installsitelib}, $Config{installsitearch}) {
9d5d87
+        if (!-d $_) {
9d5d87
+            $CPAN::Frontend->mywarn(sprintf(
9d5d87
+                    qq{Perl site library directory "%s" does not exist.\n},
9d5d87
+                $_));
9d5d87
+            File::Path::make_path($_, { error => \my $failure });
9d5d87
+            if (@$failure) {
9d5d87
+                $CPAN::Frontend->mywarn(sprintf(
9d5d87
+                        qq{Perl site library directory "%s" } .
9d5d87
+                        qq{could not been created: %s.\n},
9d5d87
+                    $_, ${$$failure[0]}{$_}));
9d5d87
+            } else {
9d5d87
+                $CPAN::Frontend->mywarn(sprintf(
9d5d87
+                        qq{Perl site library directory "%s" created.\n},
9d5d87
+                    $_));
9d5d87
+            }
9d5d87
+        }
9d5d87
+    }
9d5d87
     return -w $Config{installprivlib}
9d5d87
         && -w $Config{installarchlib}
9d5d87
         && -w $Config{installsitelib}
9d5d87
-- 
9d5d87
2.5.5
9d5d87