Created
March 16, 2016 05:11
-
-
Save bfatemi/3efe802318ebd7ba1891 to your computer and use it in GitHub Desktop.
Snippet to get the dependencies and size of those dependencies for any package install
This file contains hidden or 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/bash | |
LIST=$1 | |
PACKAGE_LIST=$(dpkg --get-selections | awk '{ print $1 }' | grep -v -e "-dbg" | cut -f1 -d":") | |
getsize () { | |
size=$(apt-cache --no-all-versions show $1 | grep Installed-Size | awk '{ print $2 }') | |
((NEEDED+=$size)) | |
} | |
for package in $LIST; do | |
getsize $package | |
DEPENDENCIES=$(apt-cache depends $package | grep Depends | awk '{ print $2 }') | |
for dependency in $DEPENDENCIES; do | |
if [[ ! $PACKAGE_LIST =~ [^.[:alnum:]-]"$dependency"[^.[:alnum:]-] ]]; then | |
getsize $dependency | |
fi | |
done | |
done | |
echo "$NEEDED kb" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment