Skip to content

Instantly share code, notes, and snippets.

@tuananh
Last active July 14, 2024 01:09
Show Gist options
  • Save tuananh/1e8e0f921410a830a7cd1161ff8bb189 to your computer and use it in GitHub Desktop.
Save tuananh/1e8e0f921410a830a7cd1161ff8bb189 to your computer and use it in GitHub Desktop.
apt find recursive dependencies of packages
#!/bin/bash
set -eu
declare -a all_deps=( )
for pkg_name in "$@"
do
declare -a deps=$(apt-cache depends -i --recurse $pkg_name | awk -F 'Depends: ' 'NF>1{ sub(/ .*/,"",$NF); print $NF }' | sort | uniq)
all_deps+=$deps
done
printf '%s\n' "${all_deps[@]}" | sort | uniq
@piranna
Copy link

piranna commented Jul 13, 2024

apt-cache depends accept several package names, so there's no need to do a loop

@piranna
Copy link

piranna commented Jul 14, 2024

It shows virtual packages instead of resolving them, how to do it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment