Skip to content

Instantly share code, notes, and snippets.

@osirisgothra
Created January 6, 2015 18:42
Show Gist options
  • Save osirisgothra/c2a8cfb3311e965e2091 to your computer and use it in GitHub Desktop.
Save osirisgothra/c2a8cfb3311e965e2091 to your computer and use it in GitHub Desktop.
install dependencies for a debian package via apt-get/cache (requires sh or bash, and of course, dpkg and apt tools)
#!/bin/bash
# install-depends.sh
# install dependencies example
# by: Gabriel T. Sharp <osirisgothra@hotmail.com>
# osirisgothra.github.com
if [[ -z $1 ]]; then
echo -ne "Enter a package name: "
read
set $REPLY
fi
if [[ $1 ]]; then
apt-get install --yes --no-remove `apt-cache depends --important "$1" | grep -Po '(?<=Depends: )[^\<>]*$' | tr '\n' ' '`
echo "apt-get remove --yes --no-remove `apt-cache depends --important "$1" | grep -Po '(?<=Depends: )[^\<>]*$' | tr '\n' ' '`" > uninstall-$1-.sh
else
echo "not installing a blank entry"
fi
@osirisgothra
Copy link
Author

This is the example file, pertaining to this question on ServerFault:
http://serverfault.com/questions/577942/install-only-dependencies-of-a-given-package-in-debian-or-ubuntu-apt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment