Using platforms in 2.8.0
Joshua Root
jmr at macports.org
Sat Oct 22 08:50:11 UTC 2022
MacPorts 2.8.0 lets you specify which OS versions your ports work on via
the platforms option. This indicates a port that works on darwin
versions from 10.x to 19.x inclusive:
platforms {darwin >= 10 < 20}
Most ports will probably only need one comparison, but you can have as
many as you need. Operators supported are ==, !=, >, <, >= and <=. For
== and !=, a string comparison that allows globs is used. For the rest,
vercmp is used. If any comparison doesn't match, known_fail is set to yes.
Note that the comparison is against ${os.version}, not ${os.major}, so
you'll usually want to use e.g. < 20 for the upper bound rather than <=
19 (the latter would exclude all 19.x versions).
These are all valid:
platforms {darwin >= 11}
platforms {darwin < 19} freebsd
platforms {darwin >= 16 != 18.2.* < 23} {linux != *}
The second one indicates FreeBSD support in a purely informational way,
as per the usage of the platforms option in older MacPorts versions. The
last one indicates that it doesn't work on Linux and will set known_fail
there. Again, most ports will probably only use something like the first
example, but the flexibility is there if you need it.
All of the above can be used without making your Portfile incompatible
with 2.7. There is another way that platforms can be used:
platforms any
platforms {darwin any}
The first one indicates that the port will install identical files no
matter what platform it is built on, and will set the platform in the
archive filename to "any_any". The second one indicates that the port
will install identical files when built on any version of Darwin, but
may install different files when built on other platforms, and sets the
platform in the archive filename to "darwin_any" when on Darwin.
These will usually only be applicable to noarch ports, though rare
exceptions may exist. Ports that install only data files or scripts will
often be able to use "any". Python scripts are an exception because
Python uses a framework layout on Darwin only, so they will be "{darwin
any}".
Since the archive filename is changed, using this will of course prevent
users on older MacPorts versions from using the archives. So we would
normally wait 2 weeks after the release of 2.8.0 before starting to use
this feature.
However, with the release of Ventura in a couple days, it may pay to set
these platforms values on as many eligible ports as possible, both to
make the archives available to Ventura users even before we have a
Ventura buildbot worker up and running, and to reduce the load on that
worker once it is up.
- Josh
More information about the macports-dev
mailing list