Automatic port replacement
Joshua Root
jmr at macports.org
Sun Feb 18 18:47:17 UTC 2024
On 19/2/2024 00:49, Karl-Michael Schindler wrote:
> I have a series of cross compilers which conflict with each other. Therefore, only one should be installed and installing one should replace the installed one with a Y/n question. How can I achieve this?
>
> This is my current snippet with non-essentials removed:
>
> foreach subarch {25 35 4 5 51 6} {
> subport “fpc-cross-avr${subarch}-embedded" {
> conflicts {
> fpc-cross-avr25-embedded
> fpc-cross-avr35-embedded
> fpc-cross-avr4-embedded
> fpc-cross-avr5-embedded
> fpc-cross-avr51-embedded
> fpc-cross-avr6-embedded
> }
> replaced_by {
> fpc-cross-avr25-embedded
> fpc-cross-avr35-embedded
> fpc-cross-avr4-embedded
> fpc-cross-avr5-embedded
> fpc-cross-avr51-embedded
> fpc-cross-avr6-embedded
> }
> build.args CPU_TARGET=avr OS_TARGET=embedded SUBARCH=avr${subarch}
> destroot.args CPU_TARGET=avr OS_TARGET=embedded SUBARCH=avr${subarch}
> }
> }
>
> But it does not work as intended. Any hints?
The braces mean that you're only passing a single value to conflicts and
replaced_by. If you want to split the setting of a multi-valued option
over multiple lines, use backslash line continuations.
You can't use multiple values for replaced_by currently, and if we did
add support for that, the semantics would probably be that all the
listed ports should be installed as the replacement for the current
port. You don't want to set replaced_by in a port that you intend to be
installable in its own right.
The best solution would be to make the subports not conflicting, but if
that can't be achieved, you probably want something like this:
set subarchs [list 25 35 4 5 51 6]
set subnames [lmap s ${subarchs} {string cat fpc-cross-avr${s}-embedded}]
foreach subarch ${subarchs} subname ${subnames} {
subport ${subname} {
conflicts {*}[ldelete ${subnames} ${subname}]
build.args CPU_TARGET=avr OS_TARGET=embedded
SUBARCH=avr${subarch}
destroot.args CPU_TARGET=avr OS_TARGET=embedded
SUBARCH=avr${subarch}
}
}
- Josh
More information about the macports-dev
mailing list