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