Blame SOURCES/CPAN-2.11-Attemp-to-create-site-library-directories-on-first-t.patch

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