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