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