Hi Chris,

Chris Rawnsley wrote on Sun, Apr 19, 2020 at 01:34:28PM +0100:

> I am looking for a way to show a package's dependencies.

As far as i know, the normal ways to do that are:

  # direct run dependencies only
  cd /usr/ports/mail/mutt; make run-depends-list
  cd /usr/ports/mail/mutt; make show=RUN_DEPENDS

  # direct library package dependencies only
  cd /usr/ports/mail/mutt; make lib-depends-list
  cd /usr/ports/mail/mutt; make show=LIB_DEPENDS

  # direct run and library package dependencies only
  pkg_info -qf mutt | grep ^@depend
  grep -F '|mail/mutt|' /usr/local/share/ports-INDEX | cut -d \| -f 8

  # direct build dependencies only
  grep -F '|mail/mutt|' /usr/local/share/ports-INDEX | cut -d \| -f 9
  cd /usr/ports/mail/mutt; make build-depends-list


  # all run dependencies, recursive
  cd /usr/ports/mail/mutt; make print-run-depends
  cd /usr/ports/mail/mutt; make full-run-depends
  cd /usr/ports/mail/mutt; make show-run-depends
  cd /usr/ports/mail/mutt; make run-dir-depends

  # all shared library dependencies, recursive
  pkg_info -qf mutt | grep ^@wantlib

  # direct run and package library dependencies, and all shared libs recursive
  pkg_info -qS mutt

  # all build dependencies, recursive
  cd /usr/ports/mail/mutt; make print-build-depends
  cd /usr/ports/mail/mutt; make full-build-depends
  cd /usr/ports/mail/mutt; make build-dir-depends

  # all dependencies, recursive
  cd /usr/ports/mail/mutt; make full-all-depends
  cd /usr/ports/mail/mutt; make all-dir-depends

The above list is not complete.  For example, i skipped ways to
inspect test dependencies, and i refrained from explaining
possibilities that use the port "databases/sqlports", which
is very powerful.  Finally, i may have missed some ways this
can be done.

All this is kind of typical for the pkg tools: one question typically
allows several different answers.  There typically isn't one single,
canonical way of doing something.  There typically isn't one unified
output format, but several different ways to represent information
in the output.  Part of that is due to the unavoidable complexity
of the system.  Other parts may be influenced by the fact that
espie@ is not tedu@.

> Does such a command such as this already exist? I guessed that the
> pkg_* tools would have this covered but I was not able to find it
> in the manpages.

Yes, finding stuff in the pkg/ports manual pages sometimes isn't
easy due to their size and complexity - even though they are typically
concise, at times even terse.

> In making the above example, I created a proof of concept shell
> script that demonstrates the desired behaviour.

We certainly don't need yet more ways to do the same, and certainly
not by creating wrappers around what is already there.  Besides,
directly inspecting the contents of /var/db/pkg/ by anything that
is not part of the pkg tools is fragile and not acceptable.

All that said, it might be useful if, in addition to -S, pkg_add(1)
could recursively list run-time dependencies.  That isn't possible
for packages that are not installed, but it should be possible to
implement for installed packages.  The current situation is
arguably not ideal for users since i don't see a way to recursively
get run-time dependencies without either

 * going to /usr/ports/ and running make(1)
 * using databases/sqlports
 * writing your own script recursively calling "pkg_info -qS",
   then postprocessing with sort(1) and uniq(1)

Yours,
  Ingo

Reply via email to