[135550] trunk/dports/_resources/port1.0/group/muniversal-1.0.tcl
larryv at macports.org
larryv at macports.org
Sat Apr 25 19:54:47 PDT 2015
Revision: 135550
https://trac.macports.org/changeset/135550
Author: larryv at macports.org
Date: 2015-04-25 19:54:46 -0700 (Sat, 25 Apr 2015)
Log Message:
-----------
muniversal-1.0: Set options with `option` proc (#47388)
A portfile command sets its associated option to a list composed of its
arguments. Accessing the associated global variable then yields that
list. Thus, for a portfile option `foo`,
foo 1 2 3
set bar $foo
foo $bar
does not restore `foo` to a list containing 1, 2, and 3. Instead, `foo`
is set to a list containing a list containing 1, 2, and 3. One way to
correct this is with `eval`:
foo 1 2 3
set bar $foo
eval foo $bar
The use of `eval` is generally discouraged because it's very easy to
create subtle injection bugs/vulnerabilities.[1] Tcl 8.5 argument
expansion permits an alternative:
foo 1 2 3
set bar $foo
foo {*}$bar
It's not particularly obvious when the double substitution[2] provided
by `eval`/`{*}` is required. This has caused much confusion in both base
and portfile code.
Another option (more palatable in base code) is to dispense with the
portfile command magic altogether and use the `option` proc directly.
option foo {1 2 3}
set bar [option foo]
option foo $bar
The `option` proc behaves more or less like `set` and is thus easier to
understand, if more verbose.
This is the approach I've taken to handling the bugs reported in #47388
and #47420. The muniversal-1.0 portgroup looks nothing like a portfile
at this point, so I think the use of portfile commands just muddles the
reader's mental model of what's going on. The simplicity of `option` is
preferable here.
[1] http://wiki.tcl.tk/1017
[2] http://wiki.tcl.tk/1535
Modified Paths:
--------------
trunk/dports/_resources/port1.0/group/muniversal-1.0.tcl
Modified: trunk/dports/_resources/port1.0/group/muniversal-1.0.tcl
===================================================================
--- trunk/dports/_resources/port1.0/group/muniversal-1.0.tcl 2015-04-26 00:34:58 UTC (rev 135549)
+++ trunk/dports/_resources/port1.0/group/muniversal-1.0.tcl 2015-04-26 02:54:46 UTC (rev 135550)
@@ -290,10 +290,10 @@
set configure_dir_save ${configure.dir}
if { [string match "${worksrcpath}/*" ${configure.dir}] } {
# The configure directory is inside the source directory, so put in the new source directory name.
- configure.dir [string map "${worksrcpath} ${worksrcpath}-${arch}" ${configure.dir}]
+ option configure.dir [string map "${worksrcpath} ${worksrcpath}-${arch}" ${configure.dir}]
} else {
# The configure directory is outside the source directory, so give it a new name by appending ${arch}.
- configure.dir ${configure.dir}-${arch}
+ option configure.dir ${configure.dir}-${arch}
if { ![file exists ${configure.dir}] } {
file mkdir ${configure.dir}
}
@@ -302,10 +302,10 @@
set autoreconf_dir_save ${autoreconf.dir}
if { [string match "${worksrcpath}/*" ${autoreconf.dir}] } {
# The autoreconf directory is inside the source directory, so put in the new source directory name.
- autoreconf.dir [string map "${worksrcpath} ${worksrcpath}-${arch}" ${autoreconf.dir}]
+ option autoreconf.dir [string map "${worksrcpath} ${worksrcpath}-${arch}" ${autoreconf.dir}]
} else {
# The autoreconf directory is outside the source directory, so give it a new name by appending ${arch}.
- autoreconf.dir ${autoreconf.dir}-${arch}
+ option autoreconf.dir ${autoreconf.dir}-${arch}
if { ![file exists ${autoreconf.dir}] } {
file mkdir ${autoreconf.dir}
}
@@ -314,15 +314,15 @@
portconfigure::configure_main
# Undo changes to the configure related variables
- autoreconf.dir {*}${autoreconf_dir_save}
- configure.dir {*}${configure_dir_save}
- configure.compiler {*}${configure_compiler_save}
- configure.f90 {*}${configure_f90_save}
- configure.f77 {*}${configure_f77_save}
- configure.fc {*}${configure_fc_save}
- configure.cc {*}${configure_cc_save}
- configure.cxx {*}${configure_cxx_save}
- configure.objc {*}${configure_objc_save}
+ option autoreconf.dir ${autoreconf_dir_save}
+ option configure.dir ${configure_dir_save}
+ option configure.compiler ${configure_compiler_save}
+ option configure.f90 ${configure_f90_save}
+ option configure.f77 ${configure_f77_save}
+ option configure.fc ${configure_fc_save}
+ option configure.cc ${configure_cc_save}
+ option configure.cxx ${configure_cxx_save}
+ option configure.objc ${configure_objc_save}
if { [info exists merger_configure_args(${arch})] } {
configure.args-delete $merger_configure_args(${arch})
}
@@ -370,10 +370,10 @@
set build_dir_save ${build.dir}
if { [string match "${worksrcpath}/*" ${build.dir}] } {
# The build directory is inside the source directory, so put in the new source directory name.
- build.dir [string map "${worksrcpath} ${worksrcpath}-${arch}" ${build.dir}]
+ option build.dir [string map "${worksrcpath} ${worksrcpath}-${arch}" ${build.dir}]
} else {
# The build directory is outside the source directory, so give it a new name by appending ${arch}.
- build.dir ${build.dir}-${arch}
+ option build.dir ${build.dir}-${arch}
if { ![file exists ${build.dir}] } {
file mkdir ${build.dir}
}
@@ -381,7 +381,7 @@
portbuild::build_main
- build.dir ${build_dir_save}
+ option build.dir ${build_dir_save}
if { [info exists merger_build_args(${arch})] } {
build.args-delete $merger_build_args(${arch})
}
@@ -396,7 +396,7 @@
ui_info "$UI_PREFIX [format [msgcat::mc "Staging %1\$s into destroot for architecture %2\$s"] ${subport} ${arch}]"
copy ${destroot} ${workpath}/destroot-${arch}
set destdirSave ${destroot.destdir}
- destroot.destdir [string map "${destroot} ${workpath}/destroot-${arch}" ${destroot.destdir}]
+ option destroot.destdir [string map "${destroot} ${workpath}/destroot-${arch}" ${destroot.destdir}]
if { [info exists merger_destroot_env(${arch})] } {
destroot.env-append $merger_destroot_env(${arch})
@@ -407,10 +407,10 @@
set destroot_dir_save ${destroot.dir}
if { [string match "${worksrcpath}/*" ${destroot.dir}] } {
# The destroot directory is inside the source directory, so put in the new source directory name.
- destroot.dir [string map "${worksrcpath} ${worksrcpath}-${arch}" ${destroot.dir}]
+ option destroot.dir [string map "${worksrcpath} ${worksrcpath}-${arch}" ${destroot.dir}]
} else {
# The destroot directory is outside the source directory, so give it a new name by appending ${arch}.
- destroot.dir ${destroot.dir}-${arch}
+ option destroot.dir ${destroot.dir}-${arch}
if { ![file exists ${destroot.dir}] } {
file mkdir ${destroot.dir}
}
@@ -418,14 +418,14 @@
portdestroot::destroot_main
- destroot.dir ${destroot_dir_save}
+ option destroot.dir ${destroot_dir_save}
if { [info exists merger_destroot_args(${arch})] } {
destroot.args-delete $merger_destroot_args(${arch})
}
if { [info exists merger_destroot_env(${arch})] } {
destroot.env-delete $merger_destroot_env(${arch})
}
- destroot.destdir ${destdirSave}
+ option destroot.destdir ${destdirSave}
}
delete ${destroot}
@@ -719,10 +719,10 @@
set test_dir_save ${test.dir}
if { [string match "${worksrcpath}/*" ${test.dir}] } {
# The test directory is inside the source directory, so put in the new source directory name.
- test.dir [string map "${worksrcpath} ${worksrcpath}-${arch}" ${test.dir}]
+ option test.dir [string map "${worksrcpath} ${worksrcpath}-${arch}" ${test.dir}]
} else {
# The test directory is outside the source directory, so give it a new name by appending ${arch}.
- test.dir ${test.dir}-${arch}
+ option test.dir ${test.dir}-${arch}
if { ![file exists ${test.dir}] } {
file mkdir ${test.dir}
}
@@ -730,7 +730,7 @@
porttest::test_main
- test.dir ${test_dir_save}
+ option test.dir ${test_dir_save}
}
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20150425/00fea8ae/attachment.html>
More information about the macports-changes
mailing list