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