source: trunk/dports/_resources/port1.0/group/php5pear-1.0.tcl @ 89391

Last change on this file since 89391 was 89391, checked in by pixilla@…, 8 years ago

_resources/port1.0/group/php5pear-1.0.tcl:

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 9.6 KB
Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2# $Id: php5pear-1.0.tcl 89391 2012-01-27 22:51:04Z pixilla@macports.org $
3#
4# Copyright (c) 2011 The MacPorts Project
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions are
9# met:
10#
11# 1. Redistributions of source code must retain the above copyright
12#    notice, this list of conditions and the following disclaimer.
13# 2. Redistributions in binary form must reproduce the above copyright
14#    notice, this list of conditions and the following disclaimer in the
15#    documentation and/or other materials provided with the distribution.
16# 3. Neither the name of The MacPorts Project nor the names of its
17#    contributors may be used to endorse or promote products derived from
18#    this software without specific prior written permission.
19#
20# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31#
32#
33# This PortGroup automatically sets up the standard environment for installing
34# a PHP PEAR class.
35#
36# Usage:
37#
38#   PortGroup           php5pear 1.0
39#   php5pear.setup      package version channel
40#
41# where package is the name of the PEAR package (e.g. AUTH), version is its
42# version, and channel is the channel hosting the package (default: pear.php.net).
43#
44
45options php5pear.package
46options php5pear.channel
47options php5pear.cmd-pre
48options php5pear.cmd-pear
49options php5pear.cmd-phar
50options php5pear.cmd-php
51options php5pear.cmd-post
52options php5pear.cmd
53options php5pear.destroot
54options php5pear.sourceroot
55options php5pear.instpath
56options php5pear.pearpath
57options php5pear.installer
58options php5pear.packagexml
59
60proc php5pear.setup {php5pear.package version {php5pear.channel "pear.php.net"} {php5pear.packagexml "package.xml"}} {
61    global worksrcpath distname extract.suffix master_sites prefix destroot distpath
62    global php5pear.cmd-pre php5pear.cmd-pear php5pear.cmd-phar php5pear.cmd-php php5pear.cmd-post
63    global php5pear.cmd php5pear.instpath php5pear.pearpath
64    global php5pear.installer name php5pear.sourceroot
65   
66    # The pear name for the package.
67    php5pear.package    ${php5pear.package}
68    # The pear channel for the package.
69    php5pear.channel    ${php5pear.channel}
70    # The name of the package's xml file used by pear to build the package.
71    # Note: so far the two known names are package.xml and package2.xml.
72    php5pear.packagexml ${php5pear.packagexml}
73   
74    name                pear-${php5pear.package}
75    version             ${version}
76    categories          php
77    distname            ${php5pear.package}-${version}
78    extract.suffix      .tgz
79    homepage            http://${php5pear.channel}/package/${php5pear.package}
80    master_sites        http://${php5pear.channel}/get
81    livecheck.type      regex
82    livecheck.url       http://${php5pear.channel}/package/${php5pear.package}/download
83    livecheck.regex     "http://download.${php5pear.channel}/package/${php5pear.package}-((?!\.tgz).*)${extract.suffix}"
84   
85    dist_subdir         pear
86    supported_archs     noarch
87    use_parallel_build  yes
88    depends_lib         path:bin/phpize:php5 port:php5-pear
89   
90    # List of ports that pear-PEAR depends on.
91    if {
92        ${name} != "pear-Archive_Tar" &&
93        ${name} != "pear-Console_Getopt" &&
94        ${name} != "pear-Structures_Graph" &&
95        ${name} != "pear-XML_Util" &&
96        ${name} != "pear-PEAR"
97    } {
98        depends_lib-append    port:pear-PEAR
99    }
100   
101    # Where the pear installer is installed for each port.
102    php5pear.installer  ${worksrcpath}/installer
103    # The base paths for our pear.conf.
104    php5pear.instpath   ${prefix}/lib/php
105    php5pear.pearpath   ${php5pear.instpath}/pear
106    # Where we expand our source files.
107    php5pear.sourceroot ${worksrcpath}/packagesource   
108    # Where we instruct pear to install our package.
109    php5pear.destroot   ${worksrcpath}/packagingroot   
110   
111    # The pear command we will use.
112    php5pear.cmd-pear   ${php5pear.installer}/bin/pear
113    # The phar file that contains our pear installer.
114    php5pear.cmd-phar   ${prefix}/lib/php/pear/install-pear-nozlib.phar
115    # The php binary we will use.
116    php5pear.cmd-php    ${prefix}/bin/php
117    # Args placed before the php or pear commands.
118    php5pear.cmd-pre \
119        cd ${php5pear.sourceroot} && \
120        TZ=UTC \
121        HOME=${php5pear.installer} \
122        PHP_PEAR_INSTALL_DIR=${php5pear.installer}/pear \
123        PHP_PEAR_BIN_DIR=${php5pear.installer}/bin \
124        PHP_PEAR_PHP_BIN=${php5pear.cmd-php} \
125        PHP_PEAR_CFG_DIR=${php5pear.installer}/pear/cfg \
126        PHP_PEAR_DOC_DIR=${php5pear.installer}/pear/docs \
127        PHP_PEAR_DATA_DIR=${php5pear.installer}/pear/data \
128        PHP_PEAR_WWW_DIR=${php5pear.installer}/pear/www \
129        PHP_PEAR_TEST_DIR=${php5pear.installer}/pear/tests \
130        PHP_PEAR_SYSCONF_DIR=${php5pear.installer}
131    # Args placed after php or pear commands.
132    php5pear.cmd-post \
133        -c ${php5pear.installer}/pear.conf \
134        -C ${php5pear.installer}/pear.conf
135   
136    extract.mkdir       yes
137    extract.post_args   "| tar --strip-components 1 -x -f - -C '${php5pear.sourceroot}'"
138   
139    pre-extract {
140        xinstall -d ${php5pear.sourceroot}
141    }
142   
143    post-extract {
144        # Get the name of our package xml file.
145        php5pear.packagexml [lindex [exec tar -tzf ${distpath}/${distname}${extract.suffix} | grep package.*\.xml] 0]
146        # The "--strip-components 1" causes the loss of our package file so we will extract it now.
147        system "tar -z -x -v -f '${distpath}/${distname}${extract.suffix}' -C '${php5pear.sourceroot}' ${php5pear.packagexml}"
148        # Install the pear command using the phar file.
149        system "${php5pear.cmd-pre} ${php5pear.cmd-php} ${php5pear.cmd-phar}"
150    }
151   
152    post-patch {
153        # Some ports use a "." baseinstalldir which can cause issues creating pears packagingroot directory.
154        reinplace "s|baseinstalldir=\"\.\"|baseinstalldir=\"/\"|g" \
155          ${php5pear.sourceroot}/${php5pear.packagexml}
156    }
157   
158    configure {
159        # Set up pear's conf file.
160        # The order appears to be important; we get errors if we set php_dir before adding channels
161        # and the directory is not writable.
162        xinstall -d "${php5pear.installer}/pear/php"
163        system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-set auto_discover 1"
164        if { "${php5pear.channel}" != "pear.php.net" } {
165            system "curl -s http://${php5pear.channel}/channel.xml -o ${worksrcpath}/channel.xml"
166            system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} channel-add ${worksrcpath}/channel.xml"
167            system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-set default_channel ${php5pear.channel}"
168        }
169        # Change the install directories to the final destinations
170        system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-set php_dir ${php5pear.pearpath}"
171        system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-set bin_dir ${php5pear.pearpath}/bin"
172        system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-set doc_dir ${php5pear.pearpath}/docs"
173        system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-set data_dir ${php5pear.pearpath}/data"
174        system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-set www_dir ${php5pear.pearpath}/www"
175        system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-set test_dir ${php5pear.pearpath}/tests"
176        system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-show"
177    }
178   
179    build {
180        # Get the name of our package xml file.
181        php5pear.packagexml [lindex [exec tar -tzf ${distpath}/${distname}${extract.suffix} | grep package.*\.xml] 0]
182        # Install our package into our pear's packagingroot.
183        system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} install -n -f -P '${php5pear.destroot}' ${php5pear.packagexml}"
184    }
185   
186    destroot {
187        copy ${php5pear.destroot}${php5pear.instpath} ${destroot}${prefix}/lib
188        # Remove all invisible "dot" files.
189        fs-traverse -ignoreErrors item "${destroot}${php5pear.instpath}" {
190            if {[string first . [file tail ${item}] 0] == 0} {
191                # Using system rm because I could not find a way to delete dot files with [file delete].
192                system "rm -R ${item}"
193            }
194        }
195        if { [file exists "${destroot}${php5pear.pearpath}/generate_package_xml.php"] } {
196            # Some pear packages contain package creation files so we remove them.
197            delete "${destroot}${php5pear.pearpath}/generate_package_xml.php"
198        }
199        if { [file exists "${destroot}${php5pear.pearpath}/package.php"] } {
200            # Some pear packages contain package creation files so we remove them.
201            delete "${destroot}${php5pear.pearpath}/package.php"
202        }
203    }
204}
Note: See TracBrowser for help on using the repository browser.