[MacPorts] #15712: Add versions to platforms
MacPorts
noreply at macports.org
Thu Apr 12 21:09:32 UTC 2018
#15712: Add versions to platforms
--------------------------+----------------------------
Reporter: raimue | Owner: larryv
Type: enhancement | Status: assigned
Priority: Normal | Milestone: MacPorts 2.6.0
Component: base | Version:
Resolution: | Keywords:
Port: |
--------------------------+----------------------------
Comment (by raimue):
You would have to use `platforms-append` like we do for any other option
that comes from PortGroups. Why would we want to handle `platforms`
differently than other options?
{{{
# PortGroup ...
platforms {darwin > 10}
# Portfile
platforms-append {darwin < 10} {darwin 11}
}}}
Overall, we mostly care whether the current platform is supported or not.
There is no need for complicated blacklists or whitelists. There is
usually only a need to express a maximum or minimum version requirement
for each platform.
To find out if the current platform is compatible, we walk through this
full list of requirements as explained [#comment:20 above]. We check each
item of this list (`{darwin > 10} {darwin < 10} {darwin 11}`) against the
current platform.
Let me write some pseudo-code for the algorithm:
{{{
state = MAYBE
foreach item in $platforms
supported = check_if_supported(current_platform, current_version,
item)
if supported == YES
state = YES
else if supported == NO
if state == MAYBE
state = NO
endif
else
// MAYBE is ignored
endif
endforeach
define check_if_supported(current_platform, current_version, item)
platform, operator, version = split(item)
if current_platform != platform
return MAYBE
endif
if current_version operator version // think of: 1.5 < 2.0
return YES
else
return NO
endif
enddefine
}}}
If we end with `state == NO`, the current platform is definitely not
supported. If we end with `state == MAYBE`, this build might work and we
warn the user, but continue. If we end with `state == yes`, we obviously
just continue.
The example list from above would always evaluate to `YES` on macOS except
for `darwin 10` (or `darwin 10.0.0`, depending on how we compare the
version).
I do not see a use case when you would need to broaden the list of
supported versions later. If a PortGroup says that it requires `darwin <
10`, under what circumstances would the port need to say that an older
version is actually supported? Then the requirement in the PortGroup was
likely bogus and needs to be fixed. And even then, you can still override
it in the Portfile by just using `platforms` (without `-append`) or delete
the specific item with a `-delete` or `-replace`. It is just like any
other option.
I do not understand why you also bring dependencies into this... They can
declare whatever they want and yes, it might stop us from installing
dependents. But this has no influence on the way we specify `platforms` in
this port. We will check whether the current platform is supported each
time we want to install ports, so we automatically do it for the
dependency. If it does not support it, we stop at this point and all the
dependents cannot be installed. To give an appropriate error message we
have to evaluate this for each port separately anway, so I do not see when
we would have to merge anything.
--
Ticket URL: <https://trac.macports.org/ticket/15712#comment:30>
MacPorts <https://www.macports.org/>
Ports system for macOS
More information about the macports-tickets
mailing list