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