Programmatically finding dependencies for a Portfile

Artur Szostak aszostak at
Thu May 28 05:44:57 PDT 2015


Given a Portfile, I am trying to programmatically find all of its direct dependencies. My approach is to execute an appropriate TcL script in port-tclsh to produce a listing of such dependencies. I am able to handle Portfiles with the example script indicated below, but only for Portfiles that do not have any subports. It is not clear to me how to handle dependencies for subports. The structure returned by mportinfo seems to only have a list of subport names, not their dependencies.
package require macports
set mport [mportopen "file:///tmp/testport" [list] [list]]
array unset portinfo
array set portinfo [mportinfo $mport]
mportclose $mport
array set depsdict {depends_build build depends_lib lib depends_run run}
foreach deptype [array names depsdict] {
    if {[info exists portinfo($deptype)] && \
        [string length $portinfo($deptype)] > 0} \
        foreach dependency $portinfo($deptype) {
            puts "$depsdict($deptype) $dependency"

How can I access the dependencies for the subports?
Is there any developers manual that I could refer to?
Is the API and structures documented anywhere?

Kind regards.


More information about the macports-dev mailing list