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