Skip to content

Instantly share code, notes, and snippets.

@bfatemi
Created March 16, 2016 05:11
Show Gist options
  • Save bfatemi/3efe802318ebd7ba1891 to your computer and use it in GitHub Desktop.
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
#!/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