You are not logged in.

#1 2023-01-22 18:24:13

D3vil0p3r
Member
Registered: 2022-11-05
Posts: 167

[SOLVED] Pacman - List all nested dependencies of a package

Hello, is there a pacman argument that allows to check recursively the dependencies of a NON installed package?

Usually a first level dependency listing could be done by "pacman -Si". I prepared the following script for listing in each row the dependencies of the dependencies in a PKGBUILD

#!/bin/sh

if [ ! -f PKGBUILD ]; then
    echo "PKGBUILD not found in the current directory."
    exit 1
fi

read -p "Type the name of dependency you want to check: " target

deps=$(grep "^depends=" PKGBUILD | awk -F"=" '{print $2}' | sed -e "s/[()']//g" -e "s/ /\n/g" | sed '/^$/d')

echo "Checking for nested dependencies"
while read -r dep
do
    list=$(pacman -Si $dep | grep "Depends On" | sed -e "s/Depends On      : //g" -e "s/  /\n/g" | awk '!seen[$0]++' | awk -F"=" '{print $1}' | awk -F".so" '{print $1}') #Extract sub-dependencies for each package dep
    while read -r subdep
    do
        if [ $target == "$subdep" ]; then
            echo "The PKGBUILD dependency "$dep" contains the provided dependency $target."
        fi
    done <<< $list
    
    if [ $target == "$dep" ]; then
        echo "The typed dependency "$dep" is directly inside the PKGBUILD ad dependency."
    fi
done <<< $deps

I know that I could get the result of using a further nested loop for each sub-dependency but I was looking for something more efficient (i.e., a pacman argument if exists).

Thanks

Last edited by D3vil0p3r (2023-01-22 18:45:46)

Offline

#2 2023-01-22 18:26:01

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,465

Re: [SOLVED] Pacman - List all nested dependencies of a package

pactree, from pacman-contrib, can do this. It has a switch to use the sync databases instead of the local databases.

Online

#3 2023-01-22 18:45:24

D3vil0p3r
Member
Registered: 2022-11-05
Posts: 167

Re: [SOLVED] Pacman - List all nested dependencies of a package

Thank you @Scimmia. I see "pactree -s <pkgname>"

Offline

#4 2023-01-22 19:13:03

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,446
Website

Re: [SOLVED] Pacman - List all nested dependencies of a package

If you also only care about dependencies in that tree that are also not installed, you can just use pacman:

pacman -S --print-format %n $pkg

"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Online

Board footer

Powered by FluxBB