0

How can I list dependencies of a PKGBUILD file with shell script?

For example, in a google-chrome's PKGBUILD, I want the script to extract all dependencies (including makedependencies, dependencies and optdependencies) like this:

alsa-lib
gtk3
libcups
libxss
libxtst
nss
kdialog
...

I think this can be achieved with regex, but I don't know how...

1
  • 2
    Well, regex certainly won't work. A PKGBUILD is bash, the dependency arrays can contain anything including references to other variables or simply execute a program to find out the contents. In general, it's not a good idea to walk into a question with assumptions about what you expect the answer to involve.
    – eschwartz
    Oct 24, 2018 at 18:45

1 Answer 1

1

The PKGBUILD is already a bash script. You could source it, but that is dangerously insecure.

Instead, the .SRCINFO file was created, which is supposed to be parseable as a key-value file. You could use for example the "python-srcinfo" package to parse this in Python -- it is what we use as part of the https://aur.archlinux.org website itself. Alternatively, you could use awk from within bash for this -- one popular AUR helper, aurutils, uses this awk script to do .SRCINFO parsing: https://github.com/AladW/aurutils/blob/master/lib/aur-graph

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .