Get version number of another port from inside Portfile?
Clemens Lang
cal at macports.org
Sun May 28 20:51:45 UTC 2023
Hi,
On Thu, May 25, 2023 at 12:13:41AM -0400, Jason Liu wrote:
> I'm working on a Portfile where the source code needs to gather a list
> of all of the dependencies' version numbers into a file before it will
> compile. The project has a utility python script that will gather
> these version numbers, but it assumes that all of the dependencies
> have been downloaded locally and will be compiled from within the
> project. However, all of the dependencies are already available
> through MacPorts. So my question is: Is there some sort of convenient
> way to obtain the version number of another port from inside a
> Portfile?
There is using the `registry_active` command. See the documentation of
the "deactivate hack" in the wiki at [1] to see how to use it.
Note that the result of this will not be stable. We typically and often
update versions and revisions of dependencies without an effect on the
ports that depend on them (e.g., if we fix a CVE in OpenSSL, most ports
that depend on OpenSSL don't care).
The information you'd get would thus be a snapshot at best, and if
something at runtime attempts to check this snapshot against what's
really present on the system, this will yield differences. If your
proposed port does something like this, I'd recommend patching the code
to not do such a check instead, and rely on MacPorts' dependency
management to ensure that all required dependencies are present.
[1] https://trac.macports.org/wiki/PortfileRecipes#deactivatehack
HTH,
Clemens
More information about the macports-dev
mailing list