Blob Blame History Raw
From 99569b1f5c2dc647ee345028927af8c54cf0ea6d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20=C5=A0abata?= <contyk@redhat.com>
Date: Tue, 25 Aug 2015 15:58:57 +0200
Subject: [PATCH] faqpods: Check for vendorlib perlfaq if core perlfaq isn't
 available
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fedora 24 introduced the perl-perlfaq package which may replace the core
perl-perlfaq subpackage, installing its files into vendorlib.

This patch ensures faqpods can still find them.  Loosely based on
basepods.

Signed-off-by: Petr Ĺ abata <contyk@redhat.com>
---
 bin/faqpods | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/bin/faqpods b/bin/faqpods
index a36f7c1..c1ff4e2 100755
--- a/bin/faqpods
+++ b/bin/faqpods
@@ -7,13 +7,27 @@
 # ------ pragmas
 use strict;
 use warnings;
+use Config;
 
 our $VERSION = '2.0.0';
 
+my $foundcore = undef;
+
 open(PROG, "$^X -S basepods |") || die "can't fork: $!";
 while (<PROG>) {
-    print if /perlfaq/;
-} 
+    if (/perlfaq/) {
+        print $_;
+        $foundcore = 1;
+    }
+}
+
+unless ($foundcore) {
+    my $lib = $Config{'vendorlib'};
+    opendir(LIB, $lib) || die "$0: can't opendir $lib: $!\n";
+    while ($_ = readdir(LIB)) {
+        print "$lib/$_\n" if /perlfaq.*\.pod$/;
+    }
+}
 
 __END__
 
@@ -29,6 +43,9 @@ directory whose names start in C<perlfaq> will be printed to the standard
 output, one per line.  This is normally used in backticks to produce
 a list of filenames for other commands.
 
+Alternatively, C<vendorlib> CPAN perlfaq files, if any, are listed in
+case none are supplied by the core installation.
+
 =head1 EXAMPLES
 
     $ podgrep typeglob `faqpods`
-- 
2.4.3