On 24/6/2026 14:45, Ryan Carsten Schmidt wrote:
Josh, could you tell me more about your preferred method of handling ports that 
need to be available in different versions on different systems?

In https://trac.macports.org/ticket/74078#comment:55 you said:

I don't want to start a debate again, but just to be clear, my
preferred solution is to have separate ports (or subports) providing
the different versions of the software, with a stub port that depends
on the correct versioned port according to the OS version.

I'm not trying to debate; I just don't think I understand your method well 
enough to implement it. Maybe you could talk me through it with an example like 
libheif.

Sure. A basic example would be like this:

name    foo
...
if {${os.major} >= 18} {
        depends_lib port:foo-latest
} else {
        depends_lib port:foo-1.0
}

subport foo-latest {
        version 2.0
        ...
}
subport foo-1.0 {
        version 1.0
        ...
}

Before this month's update, we had a libheif port offering 1.18.2 to macOS 10.6 
and earlier and 1.21.2 to macOS 10.7 and later. Under your method, would this 
have been two or three separate ports, what would they have been called, and 
what files would each install? Are they all simultaneously installable or do 
some of them conflict with one another?

Following the scheme above, there would have been 3 ports: a stub port called libheif, and then libheif-latest and libheif-1.18 which both install the actual libheif files. Those two could conflict, since there's no reason to install both on any given OS version, or they could be made to install in non-conflicting locations if you prefer.

Then on June 1 the port was updated to 1.23.0. Based on the assumption that 
this would work on all systems that 1.21.2 worked on, how would this update 
have been handled using your method?

libheif-latest would be updated from 1.21.2 to 1.23.0.

As it turns out, 1.23.0 has problems building on macOS 10.15 and later, so we 
now have a port that offers 1.18.2 to macOS 10.6 and earlier, 1.22.2 to macOS 
10.7 thru 10.14, and 1.23.0 to macOS 10.15 and later. How would this change be 
done with your method?

A new libheif-1.22 subport would be created, libheif-latest would be marked as 'replaced_by libheif-1.22' on the appropriate OS versions, and the libheif port would be updated to depend on libheif-1.22 on those same OS versions.

Or are there existing ports that embody your method that I could look at?
Something pretty close is done by ld64, though it also uses variants.

- Josh

Reply via email to