Created
August 4, 2012 05:19
-
-
Save fumiyas/3254766 to your computer and use it in GitHub Desktop.
apt-rdepends(1) clone(?): Recursively lists package dependencies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/ksh93 | |
## | |
## apt-rdepends(1) clone(?): Recursively lists package dependencies | |
## Copyright (c) 2012 SATOH Fumiyasu @ OSS Technology Corp. | |
## <http://www.osstech.co.jp/> | |
## | |
set -u | |
if [ $# -ne 1 ]; then | |
echo "Usage: $0 PACKAGE" | |
exit 1 | |
fi | |
pkg="$1"; shift | |
apt_rdepends_recurse() | |
{ | |
typeset pkg="$1"; shift | |
typeset rev_pkg="${1-}" | |
typeset dep_pkg pkg_tag pkg_tag_value | |
apt-cache show "$pkg" \ | |
|sed -n 's/^Depends: *//p' \ | |
|tr ',' '\n' \ | |
|awk '{printf $1; gsub("[-+.]", "_", $1); print " pkg_tag_"$1;}' \ | |
|while read dep_pkg pkg_tag; do | |
eval "pkg_tag_value=\${$pkg_tag-}" | |
if [[ -z "$pkg_tag_value" ]]; then | |
printf '%-30s %s\n' "$dep_pkg" ## "$rev_pkg" | |
eval "$pkg_tag=$dep_pkg" | |
apt_rdepends_recurse "$dep_pkg" "$pkg" | |
fi | |
done | |
; | |
} | |
apt_rdepends_recurse "$pkg" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment