63
Download apt-get packages and recursive dependencies · GitHub
source link: https://gist.github.com/Mister-Meeseeks/77d76cef1b6204fdb05ca0cde1ceb95f
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Download apt-get packages and recursive dependencies · GitHub
Instantly share code, notes, and snippets.
Download apt-get packages and recursive dependencies
#!/bin/bash -eu | |
# Uses apt-get to download packages and all recursive dependencies to an apt | |
# repository compatible directory. | |
# | |
# Usage: | |
# aptRecurse [-o OUT_DIRECTORY] PACKAGE_NAME [PACKAGE_NAME]... | |
# | |
# (Credit to this StackOverflow comment | |
# https://stackoverflow.com/a/45489718/868777) | |
archiveDir=. | |
while getopts "o:" opt ; do | |
case $opt in | |
o) archiveDir="$OPTARG" | |
esac | |
done | |
shift $(( $OPTIND - 1 )) | |
packages="$@" | |
function listDepends() { | |
apt-cache depends --recurse --no-recommends --no-suggests \ | |
--no-conflicts --no-breaks --no-replaces --no-enhances \ | |
$packages \ | |
| grep "^\w" | |
} | |
function downloadPacks() { | |
apt-get download $@ | |
} | |
function declarePacks() { | |
dpkg-scanpackages -m . | gzip -c > Packages.gz | |
} | |
cd $archiveDir | |
downloadPacks $(listDepends) | |
declarePacks |
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK