Ignore:
Timestamp:
May 5, 2012, 1:46:25 AM (7 years ago)
Author:
ryandesign@…
Message:

php port:

  • use php portgroup always, not just in extension subports
  • move some procs from php port to php portgroup and rename them

php portgroup:

  • rename "version(s)" to "branch(es)" for consistency with php port and perl5 portgroup
  • setting php.branches in extension ports is now mandatory, like in the python portgroup; there is no longer a default
  • branches are now set in dotted decimal format, like in the perl5 portgroup
  • subports are now created in an option proc attached to php.branches, like in the python portgroup
  • remove unnecessary php.source option
  • add php.suffix option
  • replace ${name} with ${subport} and PHP with ${php} in some user-facing messages
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dports/_resources/port1.0/group/php-1.0.tcl

    r92545 r92727  
    3838#   PortGroup                   php 1.0
    3939#   php.setup                   extension version source
     40#   php.branches                5.3 5.4
    4041#
    4142# where extension is the name of the extension (e.g. APC), version is its
     
    4344# don't use source.
    4445#
     46# php.branches must be set to the list of PHP branches for which this extension
     47# should be made available.
     48#
    4549# If this is a Zend extension, use
    4650#
     
    5155
    5256# Options that relate to the PHP extension.
    53 default build.dir               {[lindex ${php.build_dirs} 0]}
    54 default configure.dir           {[lindex ${php.build_dirs} 0]}
    55 default destroot.dir            {[lindex ${php.build_dirs} 0]}
     57options php.branches
    5658options php.build_dirs
    5759default php.build_dirs          {[php.build_dirs_proc]}
    58 options php.bundled
    59 default php.bundled             {[string equal ${name} "php"]}
     60options php.default_branch
     61default php.default_branch      {[lindex ${php.branches} end]}
    6062options php.extension_ini
    6163default php.extension_ini       {${php.rootname}.ini}
     
    6365options php.rootname
    6466default php.rootname            {[lindex ${php.extensions} 0]}
    65 options php.source
    66 default php.source              standalone
    6767options php.type
    6868default php.type                php
    69 options php.versions
    70 default php.versions            {{54}}
    71 
    72 # Options that relate to the version of PHP.
     69option_proc php.branches        php._set_branches
     70
     71# Options that relate to the branch of PHP being used by a subport.
    7372options php
    74 default php                     {php${php.version}}
     73default php                     {php${php.suffix}}
     74options php.branch
     75default php.branch              {[php.branch_from_subport]}
    7576options php.config
    76 default php.config              {${prefix}/bin/php-config${php.version}}
     77default php.config              {${prefix}/bin/php-config${php.suffix}}
    7778options php.extension_dir
    7879default php.extension_dir       {[exec ${php.config} --extension-dir 2>/dev/null]}
     
    8283default php.ini_dir             {${prefix}/var/db/${php}}
    8384options php.ize
    84 default php.ize                 {${prefix}/bin/phpize${php.version}}
    85 options php.version
    86 
     85default php.ize                 {${prefix}/bin/phpize${php.suffix}}
     86options php.suffix
     87default php.suffix              {[php.suffix_from_branch ${php.branch}]}
     88
     89# Private options you don't need to worry about.
     90options php._bundled
     91default php._bundled            {[string equal ${name} "php"]}
     92
     93
     94proc php._set_branches {option action args} {
     95    if {"set" != ${action}} {
     96        return
     97    }
     98   
     99    # Sort the values so we can use lindex 0 and end to get the min and max branches respectively.
     100    option ${option} [lsort -command vercmp [option ${option}]]
     101   
     102    global php.default_branch php.rootname php._bundled name subport
     103    if {[regexp {^php-} ${name}]} {
     104        # Create subport for each PHP branch.
     105        foreach branch [option ${option}] {
     106            subport php[php.suffix_from_branch ${branch}]-${php.rootname} {
     107                # Legacy dist_subdir to match old php5- port layout.
     108                if {!${php._bundled}} {
     109                    if {[lindex [split [lindex [option ${option}] 0] .] 0] == "5"} {
     110                        dist_subdir php5-${php.rootname}
     111                    }
     112                }
     113            }
     114        }
     115       
     116        # Set up stub port.
     117        if {${name} == ${subport}} {
     118            supported_archs     noarch
     119            distfiles
     120            depends_run         port:php[php.suffix_from_branch ${php.default_branch}]-${php.rootname}
     121            patch {}
     122            use_configure       no
     123            build {}
     124            destroot {
     125                xinstall -d -m 755 ${destroot}${prefix}/share/doc/${subport}
     126                system "echo \"${subport} is a stub port\" > ${destroot}${prefix}/share/doc/${subport}/README"
     127            }
     128        }
     129    }
     130}
    87131
    88132proc php.setup {extensions version {source ""}} {
    89     global php php.build_dirs php.bundled php.config php.extension_ini php.extensions php.homepage php.ini_dir php.rootname php.source php.version php.versions
     133    global php php.branch php.branches php.build_dirs php.config php.extension_ini php.extensions php.homepage php.ini_dir php.rootname php._bundled
    90134    global destroot name subport
    91135   
     
    93137    set php.extensions          ${extensions}
    94138   
    95     php.source                  ${source}
    96    
    97     # Sort versions so we can use lindex 0 and end to get the min and max versions respectively.
    98     set php.versions            [lsort ${php.versions}]
    99    
    100139    if {![info exists name]} {
    101140        name                    php-${php.rootname}
     
    104143    categories                  php
    105144   
    106     if {[regexp {^php-} ${name}]} {
    107         foreach v ${php.versions} {
    108             subport php${v}-${php.rootname} {}
    109         }
    110     }
    111    
    112     regexp {^php(\d+)} ${subport} -> php.version
    113    
    114     if {${name} == ${subport}} {
    115         supported_archs         noarch
    116         distfiles
    117         depends_lib-append      port:php[lindex ${php.versions} end]-${php.rootname}
    118         patch {}
    119         use_configure           no
    120         build {}
    121         destroot {
    122             xinstall -d -m 755 ${destroot}${prefix}/share/doc/${subport}
    123             system "echo \"${name} is a stub port\" > ${destroot}${prefix}/share/doc/${subport}/README"
    124         }
    125     } else {
     145    if {${name} != ${subport}} {
    126146        # Set up distfiles for non-bundled extensions.
    127         if {!${php.bundled}} {
     147        if {!${php._bundled}} {
    128148            distname            ${php.rootname}-${version}
    129             # Legacy dist_subdir to match old php5- port layout.
    130             if {[string index [lindex ${php.versions} 0] 0] == "5"} {
    131                 dist_subdir     php5-${php.rootname}
    132             }
    133149        }
    134150       
    135151        depends_lib-append      port:${php}
     152       
     153        # These are set only for the convenience of subports that want to access
     154        # these variables directly, e.g. the ${php}-openssl subport which wants
     155        # to move a file in ${build.dir} in a post-extract block.
     156        configure.dir           [lindex ${php.build_dirs} 0]
     157        build.dir               [lindex ${php.build_dirs} 0]
     158        destroot.dir            [lindex ${php.build_dirs} 0]
    136159       
    137160        configure.pre_args-append --with-php-config=${php.config}
     
    144167            set php_debug_variant [regexp {/debug-[^/]+$} ${php.extension_dir}]
    145168            if {${php_debug_variant} && ![variant_isset debug]} {
    146                 ui_error "${name} cannot be installed without the debug variant because PHP is installed with the debug variant."
     169                ui_error "${subport} cannot be installed without the debug variant because ${php} is installed with the debug variant."
    147170                return -code error "incompatible variant selection"
    148171            } elseif {[variant_isset debug] && !${php_debug_variant}} {
    149                 ui_error "${name} cannot be installed with the debug variant because PHP is installed without the debug variant."
     172                ui_error "${subport} cannot be installed with the debug variant because ${php} is installed without the debug variant."
    150173                return -code error "incompatible variant selection"
    151174            }
     
    185208            set fp [open ${destroot}${php.ini_dir}/${php.extension_ini} w]
    186209            puts $fp "; Do not edit this file; it is automatically generated by MacPorts."
    187             puts $fp "; Any changes you make will be lost if you upgrade or uninstall ${name}."
    188             puts $fp "; To configure PHP, edit ${php.ini}."
     210            puts $fp "; Any changes you make will be lost if you upgrade or uninstall ${subport}."
     211            puts $fp "; To configure ${php}, edit ${php.ini}."
    189212            foreach extension ${php.extensions} {
    190213                puts $fp "${extension_prefix}${extension}.so"
     
    204227                        if {${php_ini_extension_dir} != ${php.extension_dir}} {
    205228                            if {0 == ${count}} {
    206                                 ui_msg "Your php.ini contains a line that will prevent ${name}"
    207                                 ui_msg "and other PHP extensions from working. To fix this,"
     229                                ui_msg "Your php.ini contains a line that will prevent ${subport}"
     230                                ui_msg "and other ${php} extensions from working. To fix this,"
    208231                                ui_msg "edit ${php.ini} and delete this line:"
    209232                                ui_msg ""
     
    232255    }
    233256   
    234     if {${php.bundled}} {
     257    if {${php._bundled}} {
    235258        homepage                http://www.php.net/${php.rootname}
    236259       
    237260        pre-extract {
     261            # Speed up extraction by extracting only the modules we're going to be building.
    238262            foreach extension ${php.extensions} {
    239263                extract.post_args-append ${worksrcdir}/ext/${extension}
     
    244268            set php_version [exec ${php.config} --version 2>/dev/null]
    245269            if {${version} != ${php_version}} {
    246                 ui_error "${name} ${version} requires PHP ${version} but you have PHP ${php_version}."
    247                 return -code error "incompatible PHP installation"
     270                ui_error "${subport} @${version} requires ${php} @${version} but you have ${php} @${php_version}."
     271                return -code error "incompatible ${php} installation"
    248272            }
    249273        }
     
    253277}
    254278
     279# Return the list of directories we need to phpize / configure / make in.
    255280proc php.build_dirs_proc {} {
    256     global php.extensions php.bundled worksrcpath
    257     if {${php.bundled}} {
     281    global php.extensions php._bundled worksrcpath
     282    if {${php._bundled}} {
    258283        set dirs {}
    259284        foreach extension ${php.extensions} {
     
    264289    return ${worksrcpath}
    265290}
     291
     292# Calculate suffix from given branch.
     293proc php.suffix_from_branch {branch} {
     294    return [strsed ${branch} {g/\\.//}]
     295}
     296
     297# Calculate branch from given suffix.
     298proc php.branch_from_suffix {suffix} {
     299    return [string index ${suffix} 0].[string range ${suffix} 1 end]
     300}
     301
     302# Calculate branch from subport.
     303proc php.branch_from_subport {} {
     304    global php.default_branch subport
     305   
     306    # For the subports, get the branch from ${subport}.
     307    regexp {^php(\d+)} ${subport} -> suffix
     308    if {[info exists suffix]} {
     309        return [php.branch_from_suffix ${suffix}]
     310    }
     311   
     312    # For the stub port, use the default branch.
     313    return ${php.default_branch}
     314}
Note: See TracChangeset for help on using the changeset viewer.