Skip to content

Instantly share code, notes, and snippets.

@critiqjo
Created January 9, 2016 20:25
Show Gist options
  • Save critiqjo/c151755f1ef0d3a26ce5 to your computer and use it in GitHub Desktop.
Save critiqjo/c151755f1ef0d3a26ce5 to your computer and use it in GitHub Desktop.
Pacman recursive dependency list
#!/bin/bash
total=( $1 )
len0=0
len1=${#total[*]}
while [ $len0 -ne $len1 ]; do
len0=$len1
t1=( "${total[@]}" )
t2=( `pacman -Qi "${t1[@]}" 2>/dev/null | \
sed -n 's/Depends On.*: \(.*\)$/\1/p'` )
t3=( "${t1[@]}" "${t2[@]}" )
total=( $(echo "$(printf "\n%s" "${t3[@]}")" | \
sed -e '/^None$/d' -e 's/^\([^><=]\+\).*/\1/' | \
sort | uniq) )
len1=${#total[*]}
done
pacman -Q "${total[@]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment