Revision: 87310 http://trac.macports.org/changeset/87310 Author: pixilla@macports.org Date: 2011-11-16 14:54:37 -0800 (Wed, 16 Nov 2011) Log Message: ----------- group/php5pear-1.0.tcl: - Install a temporary pear installer into worksrcpath for each port. - This leaves a resident pear command for a later accomplishment. Modified Paths: -------------- trunk/dports/_resources/port1.0/group/php5pear-1.0.tcl Modified: trunk/dports/_resources/port1.0/group/php5pear-1.0.tcl =================================================================== --- trunk/dports/_resources/port1.0/group/php5pear-1.0.tcl 2011-11-16 22:38:31 UTC (rev 87309) +++ trunk/dports/_resources/port1.0/group/php5pear-1.0.tcl 2011-11-16 22:54:37 UTC (rev 87310) @@ -43,71 +43,158 @@ options php5pear.package options php5pear.channel -options php5pear.bin-pre -options php5pear.bin -options php5pear.bin-post +options php5pear.cmd-pre +options php5pear.cmd-pear +options php5pear.cmd-phar +options php5pear.cmd-php +options php5pear.cmd-post options php5pear.cmd options php5pear.destroot +options php5pear.sourceroot +options php5pear.instpath +options php5pear.pearpath +options php5pear.installer +options php5pear.packagexml -proc php5pear.setup {php5pear.package version {php5pear.channel "pear.php.net"}} { - global worksrcpath distname extract.suffix master_sites prefix - global php5pear.bin-pre php5pear.bin php5pear.bin-post php5pear.cmd +proc php5pear.setup {php5pear.package version {php5pear.channel "pear.php.net"} {php5pear.packagexml "package.xml"}} { + global worksrcpath distname extract.suffix master_sites prefix destroot distpath + global php5pear.cmd-pre php5pear.cmd-pear php5pear.cmd-phar php5pear.cmd-php php5pear.cmd-post + global php5pear.cmd php5pear.instpath php5pear.pearpath + global php5pear.installer name php5pear.sourceroot - php5pear.package ${php5pear.package} - php5pear.channel ${php5pear.channel} - name pear-${php5pear.package} - version ${version} - categories php - distname ${php5pear.package}-${version} - extract.suffix .tgz - homepage http://${php5pear.channel}/package/${php5pear.package} - master_sites http://${php5pear.channel}/get - livecheck.type regex - livecheck.url http://${php5pear.channel}/package/${php5pear.package}/download - livecheck.regex "http://download.${php5pear.channel}/package/${php5pear.package}-((?!\.tgz).*)${extract.suffix}" + # The pear name for the package. + php5pear.package ${php5pear.package} + # The pear channel for the package. + php5pear.channel ${php5pear.channel} + # The name of the packages xml file used by pear to build the package. + # Note: so far the two knowns names are package.xml and package2.xml. + php5pear.packagexml ${php5pear.packagexml} - supported_archs noarch - use_parallel_build yes - depends_lib path:bin/phpize:php5 port:php5-pear + name pear-${php5pear.package} + version ${version} + categories php + distname ${php5pear.package}-${version} + extract.suffix .tgz + homepage http://${php5pear.channel}/package/${php5pear.package} + master_sites http://${php5pear.channel}/get + livecheck.type regex + livecheck.url http://${php5pear.channel}/package/${php5pear.package}/download + livecheck.regex "http://download.${php5pear.channel}/package/${php5pear.package}-((?!\.tgz).*)${extract.suffix}" - php5pear.destroot ${worksrcpath}/packagingroot - php5pear.bin-pre TZ=UTC - php5pear.bin ${prefix}/libexec/php/bin/pear - php5pear.bin-post -C ${prefix}/libexec/php/etc/pear.conf \ - -c ${prefix}/libexec/php/etc/pear.conf + dist_subdir pear + supported_archs noarch + use_parallel_build yes + depends_lib path:bin/phpize:php5 port:php5-pear + + # List of ports that pear-PEAR depends on. + if { + ${name} != "pear-Archive_Tar" && + ${name} != "pear-Console_Getopt" && + ${name} != "pear-Structures_Graph" && + ${name} != "pear-XML_Util" && + ${name} != "pear-PEAR" + } { + depends_lib-append port:pear-PEAR + } - extract.mkdir yes - extract { - copy ${distpath}/${distname}${extract.suffix} ${worksrcpath} - } + # Where the pear installer is installed for each port. + php5pear.installer ${worksrcpath}/installer + # The base paths for our pear.conf. + php5pear.instpath ${prefix}/lib/php + php5pear.pearpath ${php5pear.instpath}/pear + # Where we expand our source files. + php5pear.sourceroot ${worksrcpath}/packagesource + # Where we instruct pear to install our package. + php5pear.destroot ${worksrcpath}/packagingroot - configure { - set fp [open "${prefix}/libexec/php/etc/pear.conf" r] - set ccount [regexp -all "${php5pear.channel}" [read $fp]] - close $fp - if { ! $ccount && "${php5pear.channel}" != "pear.php.net" } { - system "curl -s http://${php5pear.channel}/channel.xml -o ${worksrcpath}/channel.xml" - system "${php5pear.bin-pre} ${php5pear.bin} ${php5pear.bin-post} channel-add ${worksrcpath}/channel.xml" - } else { - system "${php5pear.bin-pre} ${php5pear.bin} ${php5pear.bin-post} channel-update ${php5pear.channel}" - } + # The pear command we will use. + php5pear.cmd-pear ${php5pear.installer}/bin/pear + # The phar file that contains our pear installer. + php5pear.cmd-phar ${prefix}/lib/php/pear/install-pear-nozlib.phar + # The php binary we will use. + php5pear.cmd-php ${prefix}/bin/php + # Args placed before the php or pear commands. + php5pear.cmd-pre cd ${php5pear.sourceroot} && TZ=UTC \ + PHP_PEAR_INSTALL_DIR=${php5pear.installer}/pear \ + PHP_PEAR_BIN_DIR=${php5pear.installer}/bin \ + PHP_PEAR_PHP_BIN=${php5pear.cmd-php} \ + PHP_PEAR_CFG_DIR=${php5pear.installer}/pear/cfg \ + PHP_PEAR_DOC_DIR=${php5pear.installer}/pear/docs \ + PHP_PEAR_DATA_DIR=${php5pear.installer}/pear/data \ + PHP_PEAR_WWW_DIR=${php5pear.installer}/pear/www \ + PHP_PEAR_TEST_DIR=${php5pear.installer}/pear/tests \ + PHP_PEAR_SYSCONF_DIR=${php5pear.installer} + # Args placed after php or pear commands. + php5pear.cmd-post -c ${php5pear.installer}/pear.conf \ + -C ${php5pear.installer}/pear.conf + + extract.mkdir yes + extract.post_args "| tar --strip-components 1 -x -f - -C '${php5pear.sourceroot}'" + + pre-extract { + xinstall -d ${php5pear.sourceroot} + } + + post-extract { + # Get the name of our package xml file. + php5pear.packagexml [lindex [exec tar -tzf ${distpath}/${distname}${extract.suffix} | grep package.*\.xml] 0] + # The "--strip-components 1" causes the lose of our package file so we will extract it now. + system "tar -z -x -v -f '${distpath}/${distname}${extract.suffix}' - -C '${php5pear.sourceroot}' ${php5pear.packagexml}" + # Install the pear command using the phar file. + system "${php5pear.cmd-pre} ${php5pear.cmd-php} ${php5pear.cmd-phar}" + } + + post-patch { + # Some ports use a "." baseinstalldir which can cause issues creating pears packagingroot directory. + reinplace "s|baseinstalldir=\"\.\"|baseinstalldir=\"/\"|g" \ + ${php5pear.sourceroot}/${php5pear.packagexml} + } + + configure { + # Setup pears conf file. + # The order of appears to be important, we get errors if we set php_dir before adding channels + # and the directory is not writable. + xinstall -d "${php5pear.installer}/pear/php" + system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-set auto_discover 1" + if { "${php5pear.channel}" != "pear.php.net" } { + system "curl -s http://${php5pear.channel}/channel.xml -o ${worksrcpath}/channel.xml" + system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} channel-add ${worksrcpath}/channel.xml" + system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-set default_channel ${php5pear.channel}" } - - build { - system "${php5pear.bin-pre} ${php5pear.bin} ${php5pear.bin-post} config-show" - system "cd ${worksrcpath} && ${php5pear.bin-pre} ${php5pear.bin} ${php5pear.bin-post} install --nodeps --offline --ignore-errors --packagingroot=${php5pear.destroot} ${distname}${extract.suffix}" + # Change the install directories to the final destinations + system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-set php_dir ${php5pear.pearpath}" + system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-set bin_dir ${php5pear.pearpath}/bin" + system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-set doc_dir ${php5pear.pearpath}/docs" + system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-set data_dir ${php5pear.pearpath}/data" + system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-set www_dir ${php5pear.pearpath}/www" + system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-set test_dir ${php5pear.pearpath}/tests" + system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-show" + } + + build { + # Get the name of our package xml file. + php5pear.packagexml [lindex [exec tar -tzf ${distpath}/${distname}${extract.suffix} | grep package.*\.xml] 0] + # Install our package into our pears packagingroot. + system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} install -n -f -P '${php5pear.destroot}' ${php5pear.packagexml}" + } + + destroot { + copy ${php5pear.destroot}${php5pear.instpath} ${destroot}${prefix}/lib + # Remove all invisible "dot" files. + fs-traverse -ignoreErrors item "${destroot}${php5pear.instpath}" { + if {[string first . [file tail ${item}] 0] == 0} { + # Using system rm because I could not find a way to delete dot files with [file delete]. + system "rm -R ${item}" + } } - - destroot { - xinstall -d ${destroot}${prefix}/lib/php/pear - foreach path [glob -nocomplain -directory ${php5pear.destroot}${prefix}/libexec/php/pear *] { - copy ${path} ${destroot}${prefix}/lib/php/pear - } - if { [file exists "${destroot}${prefix}/lib/php/pear/generate_package_xml.php"] } { - file rename "${destroot}${prefix}/lib/php/pear/generate_package_xml.php" "${destroot}${prefix}/lib/php/pear/conflict-${php5pear.package}-generate_package_xml.php" - } - if { [file exists "${destroot}${prefix}/lib/php/pear/package.php"] } { - file rename "${destroot}${prefix}/lib/php/pear/package.php" "${destroot}${prefix}/lib/php/pear/conflict-${php5pear.package}-package.php" - } + if { [file exists "${destroot}${php5pear.pearpath}/generate_package_xml.php"] } { + # Some pear packages contain package creation files so we remove them. + delete "${destroot}${php5pear.pearpath}/generate_package_xml.php" } + if { [file exists "${destroot}${php5pear.pearpath}/package.php"] } { + # Some pear packages contain package creation files so we remove them. + delete "${destroot}${php5pear.pearpath}/package.php" + } + } + }
participants (1)
-
pixilla@macports.org