Skip to content

Instantly share code, notes, and snippets.

@hauptmech
Last active January 18, 2016 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hauptmech/19eae1b1a54e2eb2791b to your computer and use it in GitHub Desktop.
Save hauptmech/19eae1b1a54e2eb2791b to your computer and use it in GitHub Desktop.
List AUR packages in dependency order so that they can be rebuilt
#!/bin/bash
#
# Get all AUR dependencies in the order which they must be built.
#
# Author: hauptmech@gmail.com
# Keep track of packages we've seen already
declare new_pkg=''
# Only dive deeper if we haven't seen this pkg before
function recurse_if_not_seen_before {
if [[ ! $new_pkg =~ $1 ]]; then
new_pkg="$new_pkg $1"
depth_first_dependency_list $1
fi
}
# Recursively dive into AUR packages so we can install them in order
function depth_first_dependency_list {
for item in `package-query -Qm -f %D $1`; do
recurse_if_not_seen_before $item
done
# Get the name of this package. Will be empty if a non AUR package
# Necessary because this item might be a non-aur dependency of an aur package
RES=`package-query -Qm -f %n $1`
# Only echo non empty names to avoid empty lines
if [[ ! -z $RES ]]; then
echo $RES
fi
}
# Main code
# Handle multiple packages given as arguments or via pipe
if [[ ! -z $1 ]]; then
for item in $*; do
recurse_if_not_seen_before $item
done;
else
while read item
do
recurse_if_not_seen_before $item
done < /dev/stdin
fi
pacman -Qmq | grep ros-indigo | ./aur_in_dependency_order.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment