Given a package, determine the list of dependencies and download them.
Put here: download-debian-dependencies.sh
I didn't complete the download part, because I would realised that I would need to build recursive dependency-checking.
I'm exploring other methods to accomplish things like this (most notably apt-offline), but this was some tinkering out of boredom.
In particular, I adapted some code to iterate through a CSV string without getting horribly messy using external tools. get_dependencies()
can also be rewritten to remove its dependency on grep and sed.
Tested on:
- Lubuntu 13.04
- Bash, version 4.2.45(1)-release (x86_64-pc-linux-gnu)
-
apt 0.9.7.7ubuntu4 for amd64 compiled on Apr 12 2013 23:49:01
#!/bin/bash get_dependencies() { # I use `apt-cache show` instead of `apt-cache depends` because it's a single line, which is much easier to process. LIST=$( \ \apt-cache show \ ` # The package to examine ` \ $1 |\ ` # Only show the dependencies.` \ \grep Depends:\ |\ ` # But remove that string.` \ \sed 's/Depends:\ //' |\ ` # Remove anything in brackets. ` \ \sed 's/\((.*)\)//' |\ ` # Remove whitespace ` \ \sed 's/\ //g' ) } process_list() { LIST=${LIST}, while ! [[ $LIST == "" ]]; do # Get the first element __=${LIST%%\,*} # Remove the first element, and its trailing comma LIST=${LIST#*\,} # Do stuff. \echo $__ done } get_dependencies PROGRAM_NAME process_list $LIST
Last updated 2019-08-09 at 19:20:11