Created
June 26, 2020 13:10
-
-
Save thomasdullien/da96376f609debaffbaaefa2eb182de7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DIRECTORIES="main contrib non-free restricted universe multiverse" | |
UBUNTU="http://mirror.hetzner.de/ubuntu/packages/pool/ http://ddebs.ubuntu.com/pool/"; | |
DEBIAN="http://mirror.hetzner.de/debian/packages/pool/ http://debug.mirrors.debian.org/debian-debug/pool/" | |
UBUNTU_DSC="http://archive.ubuntu.com/ubuntu/pool/" | |
DEBIAN_DSC="http://ftp.debian.org/debian/pool/" | |
if [[ $# -eq 0 ]] | |
then | |
echo "Choose 'all', 'debian', or 'ubuntu' as first argument." | |
exit 1 | |
fi | |
SERVERS="" | |
if [ $1 = "all" ] | |
then | |
SERVERS="$UBUNTU $DEBIAN" | |
DSC_SERVERS="$UBUNTU_DSC $DEBIAN_DSC" | |
fi | |
if [ $1 = "ubuntu" ] | |
then | |
SERVERS="$UBUNTU" | |
DSC_SERVERS="$UBUNTU_DSC" | |
fi | |
if [ $1 = "debian" ] | |
then | |
SERVERS="$DEBIAN" | |
DSC_SERVERS="$DEBIAN_DSC" | |
fi | |
echo $SERVERS | |
# Download the packages in the pool | |
for directory in $DIRECTORIES; do | |
# The first loop downloads the .deb packages. A second loop downloads the .dsc's (they are sometimes not mirrored). | |
for server in $SERVERS; do | |
GREPSTR="$directory\/.+\/" | |
for i in $(wget -r -l1 --spider $server$directory/ 2>&1 | grep http | cut -d' ' -f4 | sort | uniq | egrep $GREPSTR ); do echo wget -np -mirror -A\"*amd64*\" $i; done | |
done | |
# The second loop downloads the .dsc files. | |
for server in $DSC_SERVERS; do | |
GREPSTR="$directory\/.+\/" | |
for i in $(wget -r -l1 --spider $server$directory/ 2>&1 | grep http | cut -d' ' -f4 | sort | uniq | egrep $GREPSTR ); do echo wget -np -mirror -A\"*.dsc\" $i; done | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment