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

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

_resources/port1.0/group:

  • Use command_exec in favor system.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 10.0 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 89609 2012-02-03 23:25:15Z 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
45# Args placed before the php or pear commands.
46options php5pear.env
47default php5pear.env    {
48    "TZ=UTC \
49    HOME=${php5pear.installer} \
50    PHP_PEAR_INSTALL_DIR=${php5pear.installer}/pear \
51    PHP_PEAR_BIN_DIR=${php5pear.installer}/bin \
52    PHP_PEAR_PHP_BIN=${php5pear.cmd-php} \
53    PHP_PEAR_CFG_DIR=${php5pear.installer}/pear/cfg \
54    PHP_PEAR_DOC_DIR=${php5pear.installer}/pear/docs \
55    PHP_PEAR_DATA_DIR=${php5pear.installer}/pear/data \
56    PHP_PEAR_WWW_DIR=${php5pear.installer}/pear/www \
57    PHP_PEAR_TEST_DIR=${php5pear.installer}/pear/tests \
58    PHP_PEAR_SYSCONF_DIR=${php5pear.installer}"
59}
60
61# Args placed after php or pear commands.
62options php5pear.configure.pre_args
63default php5pear.configure.pre_args   {
64    "-c ${php5pear.installer}/pear.conf \
65    -C ${php5pear.installer}/pear.conf"
66}
67
68# Where we instruct pear to install our package.
69options php5pear.destroot
70default php5pear.destroot       {${worksrcpath}/packagingroot}
71
72# Where the pear installer is installed for each port.
73options php5pear.installer
74default php5pear.installer      {${worksrcpath}/installer}
75
76# Where we expand our source files.
77options php5pear.sourceroot
78default php5pear.sourceroot     {${worksrcpath}/packagesource}
79
80# The base paths for our pear.conf.
81options php5pear.instpath
82default php5pear.instpath       {${prefix}/lib/php}
83options php5pear.pearpath
84default php5pear.pearpath       {${php5pear.instpath}/pear}
85
86# The pear command we will use.
87options php5pear.cmd-pear
88default php5pear.cmd-pear       {${php5pear.installer}/bin/pear}
89
90# The phar file that contains our pear installer.
91options php5pear.cmd-phar
92default php5pear.cmd-phar       {${prefix}/lib/php/pear/install-pear-nozlib.phar}
93
94# The php binary we will use.
95options php5pear.cmd-php
96default php5pear.cmd-php        {${prefix}/bin/php}
97
98# The pear channel for our package.
99options php5pear.channel
100
101# The name of the package xml file inside the pear package archive.
102options php5pear.packagexml
103default php5pear.packagexml     {[lindex [exec tar -tzf ${php5pear.packagefile} | grep package.*\.xml] 0]}
104
105# Package name.
106options php5pear.package
107
108# Package file.
109options php5pear.packagefile
110default php5pear.packagefile    {"${distpath}/[lindex $distfiles 0]"}
111
112proc php5pear.setup {package_name package_version {package_channel "pear.php.net"}} {
113    global name extract.suffix version
114    global php5pear.env php5pear.cmd-pear php5pear.destroot php5pear.sourceroot
115    global php5pear.channel php5pear.package php5pear.packagexml
116   
117    # The pear name for the package.
118    php5pear.package        ${package_name}
119    # The pear channel for the package.
120    php5pear.channel        ${package_channel}
121   
122    name                    pear-${php5pear.package}
123    version                 ${package_version}
124    categories              php
125    distname                ${php5pear.package}-${version}
126    extract.suffix          .tgz
127    homepage                http://${php5pear.channel}/package/${php5pear.package}
128    master_sites            http://${php5pear.channel}/get
129    dist_subdir             pear
130    supported_archs         noarch
131    use_parallel_build      yes
132    depends_lib             path:bin/phpize:php5 port:php5-pear
133   
134    # List of ports that pear-PEAR depends on.
135    # Add some pear-PEAR deps to make programmatic creation of pear Portfiles easier.
136    if {
137        ${name} != "pear-Archive_Tar" &&
138        ${name} != "pear-Console_Getopt" &&
139        ${name} != "pear-Structures_Graph" &&
140        ${name} != "pear-XML_Util" &&
141        ${name} != "pear-PEAR"
142    } {
143        depends_lib-append  port:pear-PEAR
144    } elseif {
145        ${name} == "pear-PEAR"
146    } {
147        depends_lib-append  port:pear-Archive_Tar \
148                            port:pear-Console_Getopt \
149                            port:pear-Structures_Graph \
150                            port:pear-XML_Util
151                           
152    }
153   
154    extract.post_args-append   -C '${php5pear.sourceroot}' --strip-components 1
155
156    pre-extract {
157        xinstall -d "${php5pear.sourceroot}"
158    }
159   
160    post-extract {
161        # The "--strip-components 1" causes the loss of our package file so we will extract it now.
162        extract.post_args-delete    --strip-components 1
163        extract.post_args-append    ${php5pear.packagexml}
164        command_exec                extract
165    }
166   
167    post-patch {
168        # Some ports use a "." baseinstalldir which can cause issues creating pears packagingroot directory.
169        reinplace "s|baseinstalldir=\"\.\"|baseinstalldir=\"/\"|g" \
170          ${php5pear.sourceroot}/${php5pear.packagexml}
171    }
172   
173    configure.env           ${php5pear.env}
174    configure.dir           ${php5pear.sourceroot}
175    configure {
176        # Install the pear command using the phar file.
177        configure.cmd           ${php5pear.cmd-php}
178        configure.pre_args      ${php5pear.cmd-phar}
179        command_exec configure
180        configure.cmd           ${php5pear.cmd-pear}
181        configure.pre_args      -c ${php5pear.installer}/pear.conf \
182                                -C ${php5pear.installer}/pear.conf
183        # Set up pear's conf file.
184        # The order appears to be important; we get errors if we set php_dir before adding channels
185        # and the directory is not writable.
186        xinstall -d "${php5pear.installer}/pear/php"
187        set pear_config [list]
188        lappend pear_config         "config-set auto_discover 1"
189        if { "${php5pear.channel}" != "pear.php.net" } {
190            lappend pear_config         "channel-discover ${php5pear.channel}"
191            lappend pear_config         "config-set default_channel ${php5pear.channel}"
192        }
193        # Change the install directories to the final destinations
194        lappend pear_config         "config-set php_dir ${php5pear.pearpath}"
195        lappend pear_config         "config-set bin_dir ${php5pear.pearpath}/bin"
196        lappend pear_config         "config-set cfg_dir ${php5pear.pearpath}/cfg"
197        lappend pear_config         "config-set doc_dir ${php5pear.pearpath}/docs"
198        lappend pear_config         "config-set data_dir ${php5pear.pearpath}/data"
199        lappend pear_config         "config-set www_dir ${php5pear.pearpath}/www"
200        lappend pear_config         "config-set test_dir ${php5pear.pearpath}/tests"
201        lappend pear_config         "config-show"
202        foreach pear_args $pear_config {
203            configure.args          "${pear_args}"
204            command_exec configure
205        }
206    }
207   
208    build {
209        build.env           ${php5pear.env}
210        build.dir           ${php5pear.sourceroot}
211        build.cmd           ${php5pear.cmd-pear}
212        build.target        install
213        build.args          "-n -f -P '${php5pear.destroot}' ${php5pear.packagexml}"
214        command_exec build
215    }
216
217    destroot {
218        copy ${php5pear.destroot}${php5pear.instpath} ${destroot}${prefix}/lib
219        # Remove all invisible "dot" files.
220        fs-traverse -ignoreErrors item "${destroot}${php5pear.instpath}" {
221            if {[string first . [file tail ${item}] 0] == 0} {
222                if {[file tail ${item}] != "." && [file tail ${item}] != ".."} {
223                    puts "Removing dot file ${item}"
224                    delete ${item}
225                }
226            }
227        }
228        if { [file exists "${destroot}${php5pear.pearpath}/generate_package_xml.php"] } {
229            # Some pear packages contain package creation files so we remove them.
230            delete "${destroot}${php5pear.pearpath}/generate_package_xml.php"
231        }
232        if { [file exists "${destroot}${php5pear.pearpath}/package.php"] } {
233            # Some pear packages contain package creation files so we remove them.
234            delete "${destroot}${php5pear.pearpath}/package.php"
235        }
236    }
237
238    livecheck.type          regex
239    livecheck.url           http://${php5pear.channel}/package/${php5pear.package}/download
240    livecheck.regex         http://download.${php5pear.channel}/package/
241    livecheck.regex-append  "${php5pear.package}-((?!\\${extract.suffix}).*)\\${extract.suffix}"
242}
Note: See TracBrowser for help on using the repository browser.