From 9aafb7915e4524b88ccb7d0ca00fba62d495a9db Mon Sep 17 00:00:00 2001
From: Mathieu Parent <mathieu.parent@nantesmetropole.fr>
Date: Thu, 16 May 2013 17:43:24 +0200
Subject: [PATCH 6/6] phppear: PECL support requires version 1.4

---
 checks/phppear |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/checks/phppear b/checks/phppear
index 7a3e6cd..94f682f 100644
--- a/checks/phppear
+++ b/checks/phppear
@@ -61,6 +61,28 @@ sub run {
           tag 'pear-package-feature-requires-newer-pkg-php-tools', '(>= 1~)', 'for package name overrides'
         }
       }
+      # package.xml parsing
+      my $package_xml_unpacked = $info->unpacked('package.xml');
+      if (-f $package_xml_unpacked && ! -l $package_xml_unpacked) {
+        # Wild guess package type as in PEAR_PackageFile_v2::getPackageType()
+        my $package_type = 'unknown';
+        open(my $package_xml_fd, '<', $package_xml_unpacked);
+        while (<$package_xml_fd>) {
+          if (/^\s*<(php|extsrc|extbin|zendextsrc|zendextbin)release\s*\/?>/ ){
+            $package_type = $1;
+            last;
+          }
+          if (/^\s*<bundle\s*\/?>/ ){
+            $package_type = 'bundle';
+            last;
+          }
+        }
+        if ($package_type eq 'extsrc') { # PECL package
+          if (!$bdepends->implies('pkg-php-tools (>= 1.4~)')) {
+            tag 'pear-package-feature-requires-newer-pkg-php-tools', '(>= 1.4~)', 'for PECL support'
+          }
+        }
+      }
     }
   }
   # PEAR channel
-- 
1.7.10.4

