Index: dports/_resources/port1.0/group/php5extension-1.0.tcl
===================================================================
--- dports/_resources/port1.0/group/php5extension-1.0.tcl	(revision 76008)
+++ dports/_resources/port1.0/group/php5extension-1.0.tcl	(working copy)
@@ -74,7 +74,6 @@
     
     php5extension.source        ${source}
     
-    name                        php5-[lindex ${php5extension.extensions} 0]
     version                     ${version}
     categories                  php
     distname                    [lindex ${php5extension.extensions} 0]-${version}
@@ -85,84 +84,117 @@
     
     variant debug description {Enable debug support (useful to analyze a PHP-related core dump)} {}
     
-    pre-configure {
-        set php_debug_variant [regexp {/debug-[^/]+$} ${php5extension.extension_dir}]
-        if {${php_debug_variant} && ![variant_isset debug]} {
-            ui_error "${name} cannot be installed without the debug variant because PHP is installed with the debug variant."
-            return -code error "incompatible variant selection"
-        } elseif {[variant_isset debug] && !${php_debug_variant}} {
-            ui_error "${name} cannot be installed with the debug variant because PHP is installed without the debug variant."
-            return -code error "incompatible variant selection"
+    if {"pear" != ${php5extension.source}} {
+        name                    php5-[lindex ${php5extension.extensions} 0]
+        pre-configure {
+            set php_debug_variant [regexp {/debug-[^/]+$} ${php5extension.extension_dir}]
+            if {${php_debug_variant} && ![variant_isset debug]} {
+                ui_error "${name} cannot be installed without the debug variant because PHP is installed with the debug variant."
+                return -code error "incompatible variant selection"
+            } elseif {[variant_isset debug] && !${php_debug_variant}} {
+                ui_error "${name} cannot be installed with the debug variant because PHP is installed without the debug variant."
+                return -code error "incompatible variant selection"
+            }
+            foreach dir ${php5extension.build_dirs} {
+                ui_debug "Generating configure script in [file tail ${dir}]"
+                system "cd ${dir} && ${prefix}/bin/phpize"
+            }
         }
-        foreach dir ${php5extension.build_dirs} {
-            ui_debug "Generating configure script in [file tail ${dir}]"
-            system "cd ${dir} && ${prefix}/bin/phpize"
+        
+        configure {
+            foreach configure.dir ${php5extension.build_dirs} {
+                ui_debug "Configuring in [file tail ${configure.dir}]"
+                portconfigure::configure_main
+            }
         }
-    }
-    
-    configure {
-        foreach configure.dir ${php5extension.build_dirs} {
-            ui_debug "Configuring in [file tail ${configure.dir}]"
-            portconfigure::configure_main
+        
+        build {
+            foreach build.dir ${php5extension.build_dirs} {
+                ui_debug "Building in [file tail ${build.dir}]"
+                portbuild::build_main
+            }
         }
-    }
-    
-    build {
-        foreach build.dir ${php5extension.build_dirs} {
-            ui_debug "Building in [file tail ${build.dir}]"
-            portbuild::build_main
+        
+        destroot.destdir            INSTALL_ROOT=${destroot}
+        
+        destroot {
+            foreach destroot.dir ${php5extension.build_dirs} {
+                ui_debug "Staging in [file tail ${destroot.dir}]"
+                portdestroot::destroot_main
+            }
+            xinstall -m 755 -d ${destroot}${php5extension.inidir}
+            if {"zend" == ${php5extension.type}} {
+                set extension_prefix "zend_extension=${php5extension.extension_dir}/"
+            } else {
+                set extension_prefix "extension="
+            }
+            set fp [open ${destroot}${php5extension.inidir}/${php5extension.ini} w]
+            puts $fp "; Do not edit this file; it is automatically generated by MacPorts."
+            puts $fp "; Any changes you make will be lost if you upgrade or uninstall ${name}."
+            puts $fp "; To configure PHP, edit ${php5extension.php_ini}."
+            foreach extension ${php5extension.extensions} {
+                puts $fp "${extension_prefix}${extension}.so"
+            }
+            close $fp
         }
-    }
-    
-    destroot.destdir            INSTALL_ROOT=${destroot}
-    
-    destroot {
-        foreach destroot.dir ${php5extension.build_dirs} {
-            ui_debug "Staging in [file tail ${destroot.dir}]"
-            portdestroot::destroot_main
-        }
-        xinstall -m 755 -d ${destroot}${php5extension.inidir}
-        if {"zend" == ${php5extension.type}} {
-            set extension_prefix "zend_extension=${php5extension.extension_dir}/"
-        } else {
-            set extension_prefix "extension="
-        }
-        set fp [open ${destroot}${php5extension.inidir}/${php5extension.ini} w]
-        puts $fp "; Do not edit this file; it is automatically generated by MacPorts."
-        puts $fp "; Any changes you make will be lost if you upgrade or uninstall ${name}."
-        puts $fp "; To configure PHP, edit ${php5extension.php_ini}."
-        foreach extension ${php5extension.extensions} {
-            puts $fp "${extension_prefix}${extension}.so"
-        }
-        close $fp
-    }
-    
-    post-install {
-        if {[file exists ${php5extension.php_ini}]} {
-            set count 0
-            set fp [open ${php5extension.php_ini} r]
-            while {![eof $fp]} {
-                set line [gets $fp]
-                regexp {^extension_dir *= *"?([^\"]*)"?} $line -> phpiniextensiondir
-                if {[info exists phpiniextensiondir]} {
-                    ui_debug "Found extension_dir ${phpiniextensiondir} in ${php5extension.php_ini}"
-                    if {${phpiniextensiondir} != ${php5extension.extension_dir}} {
-                        if {0 == ${count}} {
-                            ui_msg "Your php.ini contains a line that will prevent ${name}"
-                            ui_msg "and other PHP extensions from working. To fix this,"
-                            ui_msg "edit ${php5extension.php_ini} and delete this line:"
-                            ui_msg ""
+        
+        post-install {
+            if {[file exists ${php5extension.php_ini}]} {
+                set count 0
+                set fp [open ${php5extension.php_ini} r]
+                while {![eof $fp]} {
+                    set line [gets $fp]
+                    regexp {^extension_dir *= *"?([^\"]*)"?} $line -> phpiniextensiondir
+                    if {[info exists phpiniextensiondir]} {
+                        ui_debug "Found extension_dir ${phpiniextensiondir} in ${php5extension.php_ini}"
+                        if {${phpiniextensiondir} != ${php5extension.extension_dir}} {
+                            if {0 == ${count}} {
+                                ui_msg "Your php.ini contains a line that will prevent ${name}"
+                                ui_msg "and other PHP extensions from working. To fix this,"
+                                ui_msg "edit ${php5extension.php_ini} and delete this line:"
+                                ui_msg ""
+                            }
+                            ui_msg ${line}
+                            incr count
                         }
-                        ui_msg ${line}
-                        incr count
+                        unset phpiniextensiondir
                     }
-                    unset phpiniextensiondir
                 }
+                close $fp
             }
-            close $fp
         }
+
+    } else {
+
+        global prefix extract.suffix distname
+        global name_package php_dir
+
+        set name_package    [lindex ${php5extension.extensions} 0]
+        name                pear-[lindex ${php5extension.extensions} 0]
+        supported_archs     noarch
+        depends_lib-append  port:php5-pear
+        dist_subdir         pear
+        extract.suffix      .tgz
+
+        use_configure       no
+        
+        set php_dir ${prefix}/lib/php/pear
+        
+        extract {}
+        
+        build {
+            system "${php_dir}/pear.sh -d php_dir=${php_dir} -d doc_dir=${php_dir}/docs -d cache_dir=${worksrcpath}/tmp/pear/cache -d data_dir=${worksrcpath}/tmp/pear/data -d download_dir=${distpath} -d temp_dir=${worksrcpath}/tmp/pear/installer -d test_dir=${php_dir}/tests -d www_dir=${php_dir}/www install --loose --nodeps --offline --nobuild --ignore-errors --packagingroot=${worksrcpath}/packagingroot ${distpath}/${distname}${extract.suffix}"
+        }
+        
+        destroot {
+            xinstall -d ${destroot}${php_dir}
+            foreach file [glob -directory ${worksrcpath}/packagingroot/${php_dir} *] {
+                copy $file ${destroot}${php_dir}
+            }
+        }
+
     }
-    
+
     if {"pecl" == ${source}} {
         global php5extension.homepage
         set php5extension.homepage  http://pecl.php.net/package/[lindex ${php5extension.extensions} 0]/
@@ -174,6 +206,16 @@
         livecheck.type              regexm
         livecheck.url               ${php5extension.homepage}
         livecheck.regex             {>([0-9.]+)</a></th>\s*<[^>]+>stable<}
+    } elseif {"pear" == ${source}} {
+        global php5extension.homepage
+        set php5extension.homepage  http://pear.php.net/package/[lindex ${php5extension.extensions} 0]/
+        
+        homepage                    ${php5extension.homepage}
+        master_sites                http://pear.php.net/get/
+        extract.suffix              .tgz
+        
+        livecheck.url               http://pear.php.net/package/${name_package}/download
+        livecheck.regex             ${name_package}-(\\d+\[0-9a-z.\]*)${extract.suffix}
     } elseif {"bundled" == ${source}} {
         homepage                    http://www.php.net/[lindex ${php5extension.extensions} 0]
         master_sites                php
