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