Last active
April 2, 2017 14:45
-
-
Save elieux/a71d10b1c52d5e92b2c7 to your computer and use it in GitHub Desktop.
MSYS2 pacman repos mirroring script
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
#!/usr/bin/bash | |
ROOT="$(pwd)" | |
dl() { | |
local cookie="/tmp/pacman-mirror-cookie.txt" | |
touch "${cookie}" | |
local file | |
for file in "${@}" | |
do | |
wget --load-cookies="${cookie}" --save-cookies="${cookie}" --keep-session-cookies -nv -N "${file}" | |
done | |
} | |
verify() { | |
local file="${1}" | |
gpg --homedir "${ROOT}" --verify "${file}".sig "${file}" 2> /dev/null | |
} | |
mirror() { | |
local dir="${1}" | |
local db="${2}" | |
local url="${3}" | |
local srcurl="${4}" | |
mkdir -p "${dir}" | |
pushd "${dir}" > /dev/null | |
# download DB file | |
dl "${url}"/"${db}".db{,.sig} | |
verify "${db}".db || echo "Problem downloading ${db}.db!" | |
# download missing packages | |
local pkg srcpkg | |
bsdtar -xOf "${db}".db "*/desc" | grep -A 1 %FILENAME% | sed -e '/^%FILENAME%$/d' -e '/^--$/d' | while read pkg | |
do | |
srcpkg="${pkg%-*.pkg.tar.*}".src.tar.gz | |
verify "${pkg}" || dl "${url}"/"${pkg}"{,.sig} | |
verify "${srcpkg}" || dl "${srcurl}"/"${srcpkg}"{,.sig} | |
done | |
popd > /dev/null | |
} | |
dl "https://raw.githubusercontent.com/Alexpux/MSYS2-keyring/master/msys2.gpg" | |
gpg --homedir . --import msys2.gpg | |
base="http://downloads.sourceforge.net/project/msys2/REPOS" | |
mirror mingw32 mingw32 "${base}/MINGW/i686" "${base}/MINGW/Sources" | |
mirror mingw64 mingw64 "${base}/MINGW/x86_64" "${base}/MINGW/Sources" | |
mirror msys2-i686 msys "${base}/MSYS2/i686" "${base}/MSYS2/Sources" | |
mirror msys2-x86_64 msys "${base}/MSYS2/x86_64" "${base}/MSYS2/Sources" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment