Solved How can I visually view a ports dependencies?

I want to study an Xorg KDE suite application that has a very large source structure.
I would like to look at a graphic or diagram showing depencies of a port.
For instance- texinfo is dependancy of x which is a depencancy of kdenlive.
Sort of a flow chart view.
Anything in ports to visually show a ports hierarchy?
 
I found two tools that look promising. I started with ports-mgmt/portgraph
mc.jpg
 
That's actually pretty neat, I'd been looking for such a thing a while ago and didn't find this apparently.
 
I am going to mark this solved. I am happy with my first choice.
portgraph -p misc/mc -rb -c 3 -u
The directory from where you run this program determines where the output resides.
It creates two files for every graph. The mc file is a graphviz showing dependencies. mc.svg is the graphical output.
The ports name is used for the filename.
There is also ports-mgmt/porttree for a ports overview. I did not get to it.
 
… also ports-mgmt/porttree for a ports overview. I did not get to it.

porttree(1)

Is there a way to exclude (B) build-only dependcies?

Or, for example, to only show (R) run dependencies?

Code:
root@mowa219-gjp4-8570p-freebsd:~ # time porttree --quiet x11/autorandr
Depending on
0       ┌x11/autorandr
1       ├devel/gmake (B)
2       │├devel/gettext-runtime (L)
3       ││├converters/libiconv (B)
4       ││└print/indexinfo (R)
        │└print/indexinfo (R) → 4
5       ├devel/pkgconf (B)
6       │└devel/kyua (T)
7       │ ├databases/sqlite3 (L)
8       │ │├devel/libedit (L)
9       │ │└lang/tcl86 (B)
10      │ ├devel/atf (BR)
11      │ ├devel/lutok (L)
        │ │├devel/atf (BR) → 10
        │ │├devel/pkgconf (B) → 5
12      │ │└lang/lua52 (L)
        │ │ └devel/libedit (L) → 8
        │ ├devel/pkgconf (B) → 5
        │ └lang/lua52 (L) → 12
13      ├devel/py-setuptools (BR)
14      │└lang/python38 (BRT)
        │ ├devel/gettext-runtime (L) → 2
15      │ ├devel/gettext-tools (B)
        │ │├converters/libiconv (B) → 3
        │ │├devel/gettext-runtime (L) → 2
16      │ │├devel/libtextstyle (BL)
        │ ││├converters/libiconv (B) → 3
        │ ││└print/indexinfo (R) → 4
        │ │└print/indexinfo (R) → 4
17      │ ├devel/libffi (L)
18      │ │├misc/dejagnu (T)
        │ ││├devel/gmake (B) → 1
19      │ ││├lang/expect (L)
20      │ │││├devel/autoconf (B)
21      │ ││││├devel/autoconf-wrapper (R)
        │ ││││├devel/gmake (B) → 1
22      │ ││││├devel/m4 (BR)
        │ │││││├converters/libiconv (B) → 3
        │ │││││├devel/gettext-runtime (L) → 2
        │ │││││├devel/gettext-tools (B) → 15
        │ │││││├print/indexinfo (R) → 4
23      │ │││││└print/texinfo (B)
        │ │││││ ├converters/libiconv (B) → 3
24      │ │││││ ├converters/p5-Text-Unidecode (BR)
25      │ │││││ │└lang/perl5.32 (BR)
        │ │││││ ├devel/gettext-runtime (L) → 2
        │ │││││ ├devel/gettext-tools (B) → 15
        │ │││││ ├devel/gmake (B) → 1
26      │ │││││ ├devel/p5-Locale-libintl (BR)
        │ │││││ │├converters/libiconv (L) → 3
        │ │││││ │├devel/gettext-runtime (L) → 2
        │ │││││ │├devel/gettext-tools (B) → 15
        │ │││││ │└lang/perl5.32 (BR) → 25
        │ │││││ ├lang/perl5.32 (BR) → 25
27      │ │││││ ├misc/help2man (B)
        │ │││││ │├devel/gettext-runtime (L) → 2
        │ │││││ │├devel/gettext-tools (B) → 15
        │ │││││ │├devel/gmake (B) → 1
28      │ │││││ │├devel/p5-Locale-gettext (BR)
        │ │││││ ││├devel/gettext-runtime (L) → 2
        │ │││││ ││├devel/gettext-tools (B) → 15
        │ │││││ ││└lang/perl5.32 (BR) → 25
        │ │││││ │├lang/perl5.32 (BR) → 25
        │ │││││ │└print/indexinfo (R) → 4
        │ │││││ ├print/indexinfo (BR) → 4
29      │ │││││ └textproc/p5-Unicode-EastAsianWidth (BR)
        │ │││││  └lang/perl5.32 (BR) → 25
        │ ││││├lang/perl5.32 (BR) → 25
        │ ││││├misc/help2man (B) → 27
        │ ││││├print/indexinfo (R) → 4
        │ ││││└print/texinfo (B) → 23
30      │ │││├devel/automake (B)
        │ ││││├devel/autoconf (BR) → 20
        │ ││││├lang/perl5.32 (BR) → 25
        │ ││││└print/indexinfo (R) → 4
        │ │││└lang/tcl86 (L) → 9
        │ ││├lang/tcl86 (L) → 9
        │ ││└print/indexinfo (R) → 4
        │ │└print/indexinfo (R) → 4
        │ ├devel/pkgconf (B) → 5
31      │ ├devel/readline (L)
        │ │└print/indexinfo (R) → 4
32      │ └math/mpdecimal (L)
        │  └devel/gmake (B) → 1
        ├lang/python38 (BRT) → 14
33      ├textproc/gsed (B)
        │├converters/libiconv (B) → 3
        │├devel/gettext-runtime (L) → 2
        │├devel/gettext-tools (B) → 15
        │├print/indexinfo (R) → 4
        │└print/texinfo (B) → 23
34      ├x11/libxcb (BR)
35      │├devel/libpthread-stubs (BR)
        │├devel/pkgconf (B) → 5
36      │├devel/xorg-macros (B)
        ││└devel/pkgconf (B) → 5
        │├lang/python38 (B) → 14
37      │├x11/libXau (BR)
        ││├devel/pkgconf (B) → 5
        ││├devel/xorg-macros (B) → 36
38      ││└x11/xorgproto (B)
        ││ ├devel/pkgconf (B) → 5
        ││ └devel/xorg-macros (B) → 36
39      │├x11/libXdmcp (BR)
        ││├devel/pkgconf (B) → 5
        ││├devel/xorg-macros (B) → 36
        ││└x11/xorgproto (BR) → 38
40      │└x11/xcb-proto (B)
        │ ├devel/pkgconf (B) → 5
        │ ├devel/xorg-macros (B) → 36
        │ ├lang/python38 (BRT) → 14
41      │ └textproc/libxml2 (B)
        │  ├converters/libiconv (B) → 3
        │  └devel/pkgconf (B) → 5
42      └x11/xrandr (R)
         ├devel/pkgconf (B) → 5
         ├devel/xorg-macros (B) → 36
43       ├x11/libX11 (BR)
         │├devel/pkgconf (B) → 5
         │├devel/xorg-macros (B) → 36
         │├x11/libxcb (BR) → 34
         │├x11/xorgproto (B) → 38
44       │└x11/xtrans (B)
         │ ├devel/pkgconf (B) → 5
         │ └devel/xorg-macros (B) → 36
45       ├x11/libXrandr (BR)
         │├devel/pkgconf (B) → 5
         │├devel/xorg-macros (B) → 36
         │├x11/libX11 (BR) → 43
46       │├x11/libXext (BR)
         ││├devel/pkgconf (B) → 5
         ││├devel/xorg-macros (B) → 36
         ││├x11/libX11 (BR) → 43
         ││├x11/libXau (BR) → 37
         ││└x11/xorgproto (B) → 38
47       │├x11/libXrender (BR)
         ││├devel/pkgconf (B) → 5
         ││├devel/xorg-macros (B) → 36
         ││├x11/libX11 (BR) → 43
         ││└x11/xorgproto (B) → 38
         │└x11/xorgproto (B) → 38
         └x11/libXrender (BR) → 47
95.275u 8.575s 0:33.61 308.9%   5+167k 17784+118io 0pf+0w
root@mowa219-gjp4-8570p-freebsd:~ #

<https://www.freshports.org/x11/autorandr/#dependencies>

Postscript

If not making good use of its cache, porttree might hog the CPUs for a while. The run shown at <https://forums.freebsd.org/posts/561276> took around half an hour, here's an htop view of things whilst it was busy:

1648111236481.png



Comparison: from portgraph -r -p x11/autorandr

autorandr.png

Code:
% portgraph --help
/usr/local/bin/portgraph produces a graph representing the dependencies needed for a given port
Options are:
-h or --help: Show this help
-l my_dir or --localbase my_dir: Sets my_dir as the directory where ports are located (/usr/ports by default)
-p my_port or --port my_port: Sets my_port as the port to produce the graph
(ports-mgmt/portgraph by default).
-b or --build: build-depends-list (if -b or -r is not present, -b is actived by default).
-r or --run: run-depends-list (if -b or -r is not present, -b is actived by default).
-f my_flavor or --flavor my_flavor: Sets the flavor for the port.
-c or --recursion: Sets the maximum recursion.
-u or --url: Adds a link to freshports.
-w or --with-pkg: Since pkg is always required, this is disabled  by default. You can enable it with this option.
-a or --all: Build a graph for each port
%
 
Last edited:
It would be nice if there were a program like this, but went through source code to list required and optional dependency files (library names) rather than focused on ports. The port that contains the files may be needed in order for the program to dig deeper, but it would switch to searching each source for files calls.

A program going through source code to search for file calls/libraries may be intensive, but it would only be a fraction as intensive as building.
 
<https://www.mavetju.org/unix/general.php> | ports-mgmt/pkg_tree | pkg_tree(7)

As far as I can tell, it defaults to presenting a combination of library and runtime dependencies (not build dependencies). With <https://www.freshports.org/editors/nano/#dependencies> as an example:

Code:
% pkg_tree nano
nano-6.0
|\__ indexinfo-0.3.1
 \__ gettext-runtime-0.21
%

To also show the dependencies of the dependencies, use the -v parameter:

Like, -v for verbose:

Code:
% pkg_tree -v nano
nano-6.0
|\__ indexinfo-0.3.1
 \__ gettext-runtime-0.21
       \__ indexinfo-0.3.1
%

Use the -r parameter to show requirements relation.

Like, -r for reverse:

Code:
% pkg_tree -r indexinfo | grep nano
|\__ nano-6.0
%

– and:

Code:
% pkg_tree -r indexinfo
indexinfo-0.3.1
|\__ libadplug-2.3.3
|\__ wget-1.21.3
|\__ R-4.1.3
|\__ gpgme-1.17.1
|\__ readline-8.1.2
|\__ pinentry-1.2.0
|\__ tex-dvipsk-2021.1
|\__ texlive-base-20210325
|\__ tex-web2c-20210325
|\__ tex-kpathsea-6.3.3
|\__ gdbm-1.23
|\__ findutils-4.9.0
|\__ libconfig-1.7.3
|\__ libgcrypt-1.9.4
|\__ libgpg-error-1.44
|\__ fftw3-3.3.10
|\__ nano-6.0
|\__ gsl-2.7.1
|\__ libunistring-1.0
|\__ bash-5.1.16
|\__ autoconf-2.69_3
|\__ ddrescue-1.25
|\__ hte-2.1.1.g20161206_3
|\__ diffutils-3.8
|\__ gmake-4.3_2
|\__ gnugrep-3.7
|\__ gsed-4.8
|\__ m4-1.4.19,1
|\__ source-highlight-3.1.9_1
|\__ gtar-1.34
|\__ mjpegtools-2.1.0_15
|\__ mtools-4.0.26_1
|\__ gnuchess-6.2.9
|\__ guile2-2.2.7_1
|\__ aalib-1.4.r5_13
|\__ libIDL-0.8.14_5
|\__ vcdimager-2.0.1_2
|\__ cln-1.3.6
|\__ libgtop-2.40.0
|\__ libidn-1.35
|\__ libcdio-2.1.0
|\__ gcc10-10.3.0
|\__ binutils-2.37_2,1
|\__ mpc-1.2.1
|\__ coreutils-8.32
|\__ mpfr-4.1.0_1
|\__ groff-1.22.4_4
|\__ aspell-0.60.8_1,1
|\__ gnupg-2.3.3_2
|\__ speech-dispatcher-0.10.2
|\__ gettext-tools-0.21
|\__ libksba-1.6.0
|\__ gnutls-3.6.16
|\__ libtextstyle-0.21
|\__ libassuan-2.5.5
|\__ libidn2-2.3.2
|\__ nettle-3.7.3
|\__ libtasn1-4.18.0
|\__ gmp-6.2.1
|\__ gettext-runtime-0.21
|\__ libffi-3.3_1
 \__ gnuit-4.9.5_5
%

I had difficulty understanding parts of the manual page, seeking --help (not a valid option) accidentally revealed a different presentation of usage:

Code:
% pkg_tree --help
/usr/local/bin/pkg_tree version [unknown] calling Getopt::Std::getopts (version 1.12 [paranoid]),
running under Perl version 5.32.1.

Usage: pkg_tree [-OPTIONS [-MORE_OPTIONS]] [--] [PROGRAM_ARG1 ...]

The following single-character options are accepted:
        Boolean (without arguments): -b -q -r -t -v

Options may be merged together.  -- stops processing of options.
  [Now continuing due to backward compatibility and excessive paranoia.
   See 'perldoc Getopt::Std' about $Getopt::Std::STANDARD_HELP_VERSION.]
3dc-0.8.1_4
|\__ libXpm-3.5.13
|\__ libXext-1.3.4,1
|\__ libX11-1.7.2,1
|\__ libXt-1.2.1,1
|\__ libXmu-1.1.3,1
|\__ libXaw-1.0.14,2
 \__ Xaw3d-1.5E_8
7-zip-21.07_1
 \__ libsysinfo-0.0.3_2
Andika-6.101
|\__ mkfontscale-1.2.1
 \__ fontconfig-2.13.94_2,1
Box2D-2.4.1
CoinMP-1.8.4_6
|\__ openblas-0.3.18,1
…

Also I looked at the source code, but still, I don't understand the -b, -q and -t options. Experimenting with them didn't help me.

Can someone provide definitive examples of the effect of each of those three options? Thanks.
 
When I ran these programs, portgraph worked quickly and the visual is easier to understand.

porttree took time to go through port directories, and the result was a list that was a little harder to sort through as well.

It seems that portgraph updated the output depending on changing optional dependencies, while porttree didn't show optional dependencies (at least not in default mode) when they were configured to be on.
 
From Hornpipe2 in 2016:


Related:

 
Back
Top