|
|
323c96 |
#!/bin/bash
|
|
|
323c96 |
set -x -e
|
|
|
323c96 |
|
|
|
323c96 |
# Took this from rhpkg-simple internally owned by lsedlar@redhat.com
|
|
|
323c96 |
pkgname=$(basename "$PWD")
|
|
|
323c96 |
# If running in a git checkout, there will be a config file with url to the
|
|
|
323c96 |
# remote. We can extract package namespace and name from it. If the file is
|
|
|
323c96 |
# missing (which it should not really be), let's default to rpms/ namespace.
|
|
|
323c96 |
ns_pkgname="rpms/$pkgname"
|
|
|
323c96 |
if [ -r .git/config ]; then
|
|
|
323c96 |
url=$(grep " *url *= *" .git/config | cut -d= -f2- | tr -d ' ')
|
|
|
323c96 |
namespace=$(basename "$(dirname "$url")")
|
|
|
323c96 |
ns_pkgname="$namespace/$pkgname"
|
|
|
323c96 |
fi
|
|
|
323c96 |
|
|
|
323c96 |
if [ -d SPECS ]; then
|
|
|
323c96 |
# We are in the SIG/Exploded SRPM layout so call get_sources.sh
|
|
|
323c96 |
exec /usr/bin/get_sources.sh
|
|
|
323c96 |
fi
|
|
|
323c96 |
|
|
|
323c96 |
|
|
|
323c96 |
## This part is also from rhpkg-simple
|
|
|
323c96 |
|
|
|
323c96 |
if [ -s sources ]; then
|
|
|
323c96 |
baseurl=https://sources.stream.rdu2.redhat.com/sources
|
|
|
323c96 |
|
|
|
323c96 |
# curl arguments:
|
|
|
323c96 |
# -L follow redirects
|
|
|
323c96 |
# -H Pragma: disable caching
|
|
|
323c96 |
# -o filename where to save results
|
|
|
323c96 |
# -R use timestamp from remote server
|
|
|
323c96 |
# -S display error if there is a problem
|
|
|
323c96 |
# --fail do now write HTML page when there is error
|
|
|
323c96 |
# --retry up to 5 retries for transient errors
|
|
|
323c96 |
# --max-time wait for up to 15 seconds on network error
|
|
|
323c96 |
|
|
|
323c96 |
# Read first word of first line. For old MD5 format it's the 32 character
|
|
|
323c96 |
# hash. Otherwise let's assume the sources have the BSD format where lines
|
|
|
323c96 |
# start with hash type.
|
|
|
323c96 |
hashtype="$(head -n1 sources | cut -d' ' -f1 | tr '[:upper:]' '[:lower:]')"
|
|
|
323c96 |
if [ "${#hashtype}" -ne 32 ]; then
|
|
|
323c96 |
# The format is
|
|
|
323c96 |
# SHA512 (filename) = ABCDEF
|
|
|
323c96 |
# We don't care about the equals sign. We also assume that all hashes
|
|
|
323c96 |
# are of the same type, so we don't have to read it again for each
|
|
|
323c96 |
# line.
|
|
|
323c96 |
while read -r _ filename _ hash || [[ -n "$filename" && -n "$hash" ]]; do
|
|
|
323c96 |
if [ -z "$filename" ] || [ -z "$hash" ]; then
|
|
|
323c96 |
continue
|
|
|
323c96 |
fi
|
|
|
323c96 |
# Remove parenthesis around tarball name
|
|
|
323c96 |
filename=${filename#(}
|
|
|
323c96 |
tarball=${filename%)}
|
|
|
323c96 |
curl -L -H Pragma: -o "./$tarball" -R -S --fail --retry 5 "$baseurl/$ns_pkgname/$tarball/$hashtype/$hash/$tarball"
|
|
|
323c96 |
done < sources
|
|
|
323c96 |
"${hashtype}sum" -c sources
|
|
|
323c96 |
else
|
|
|
323c96 |
# Ok, we're working with MD5.
|
|
|
323c96 |
while read -r md5sum tarball || [[ -n "$md5sum" && -n "$tarball" ]]; do
|
|
|
323c96 |
if [ -z "$md5sum" ] || [ -z "$tarball" ]; then
|
|
|
323c96 |
continue
|
|
|
323c96 |
fi
|
|
|
323c96 |
curl -L -H Pragma: -o "./$tarball" -R -S --fail --retry 5 "$baseurl/$ns_pkgname/$tarball/$md5sum/$tarball"
|
|
|
323c96 |
done < sources
|
|
|
323c96 |
md5sum -c sources
|
|
|
323c96 |
fi
|
|
|
323c96 |
fi
|