Skip to content

Instantly share code, notes, and snippets.

@InvisibleRain
Created May 27, 2023 14:51
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 InvisibleRain/d88434eb698f24050291a02918605abd to your computer and use it in GitHub Desktop.
Save InvisibleRain/d88434eb698f24050291a02918605abd to your computer and use it in GitHub Desktop.
Download package dependecies recursively on debian-like systems
#!/bin/bash
set -e
# If argument is non-empty and the package exitst
if [[ -n $1 ]] && [[ $(apt show $1) ]]; then
dir=$HOME/$1
#rm -rf $dir # Uncomment for development
mkdir $dir
cd $dir
apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances $1 | \
grep "^\w" | \
sort -u | \
sudo xargs apt-get download
sudo chown $USER *
echo -e "\n\nDownloaded all deps into $dir"
# Return to the previous dir
cd - > /dev/null
else
echo 'usage: "./download-deps.sh package-name"'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment