[100496] trunk/dports/math/slepc/Portfile
Ryan Schmidt
ryandesign at macports.org
Mon Dec 17 23:51:34 PST 2012
On Dec 14, 2012, at 08:23, mmoll at macports.org wrote:
> Revision: 100496
> https://trac.macports.org/changeset/100496
> Author: mmoll at macports.org
> Date: 2012-12-14 06:23:42 -0800 (Fri, 14 Dec 2012)
> Log Message:
> -----------
> math/slepc: version bump, use conflicts_build port group, simplify check for fortran lib
>
> Modified Paths:
> --------------
> trunk/dports/math/slepc/Portfile
> variant arpack description {compile with ARPACK support} {
> pre-fetch {
> if {![file exists ${prefix}/lib/libparpack.a]} {
> - return -code error "Please install the openmpi variant of arpack first."
> + ui_error "Please install the openmpi or mpich2 variant of arpack first."
> }
> }
Note that while "ui_error" prints the error message to the screen, it does not end processing the port. If you want the port to exit here, which I think you do, then you need "return -code error" like you had before.
We also have the active_variants 1.1 portgroup but I'm not sure if it has provisions for requiring either/or variants. I think it's just designed to unconditionally require a variant.
> # This is a rather fragile way to figure out where the fortran library can be
> # found that is needed to link against libparpack.a:
> - if {[file exists ${prefix}/lib/gcc46]} {
> - set fortrandir ${prefix}/lib/gcc46
> - } else {
> - if {[file exists ${prefix}/lib/gcc45]} {
> - set fortrandir ${prefix}/lib/gcc45
> - } else {
> - if {[file exists ${prefix}/lib/gcc44]} {
> - set fortrandir ${prefix}/lib/gcc44
> - } else {
> - if {[file exists ${prefix}/lib/gcc43]} {
> - set fortrandir ${prefix}/lib/gcc43
> - } else {
> - if {[file exists ${prefix}/lib/gcc42]} {
> - set fortrandir ${prefix}/lib/gcc42
> - } else {
> - if {[file exists ${prefix}/lib/g95]} {
> - set fortrandir ${prefix}/lib/g95
> - } else {
> - return -code error "Please install a fortran compiler by installing one of the following ports: gcc42, gcc43, gcc44, gcc45, gcc46, or g95."
> - }
> - }
> - }
> - }
> + set fortrandirs {g95 gcc42 gcc43 gcc44 gcc45 gcc46 gcc47 gcc48}
> + set fortrandir ""
> + foreach dir ${fortrandirs} {
> + if {[file exists ${prefix}/lib/${dir}]} {
> + set fortrandir ${prefix}/lib/${dir}
> }
> }
> + if {${fortrandir} == ""} {
> + ui_error "Please install a fortran compiler by installing one of the following ports:\n\tgcc42, gcc43, gcc44, gcc45, gcc46, gcc47, gcc48, or g95."
> + }
Same here: "return -code error" should be used instead of—or in addition to—"ui_error". I typically write only short sentence fragments with "return -code error" (since MacPorts will take up half the line with its own output), and if I have more to say, I write some complete sentences in "ui_error" calls before that.
For example from the conflicts_build portgroup:
if {${subport} == ${badport}} {
ui_error "${subport} cannot be built while another version of ${badport} is active."
ui_error "Please deactivate the existing copy of ${badport} and try again."
} else {
ui_error "${subport} cannot be built while ${badport} is active."
ui_error "Please deactivate ${badport} and try again."
ui_error "You can reactivate ${badport} again later."
}
return -code error "${badport} is active"
More information about the macports-dev
mailing list