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