| |
@@ -19,10 +19,28 @@
|
| |
set -e
|
| |
|
| |
baseurl=http://pkgs.fedoraproject.org/repo/pkgs
|
| |
- pkgname=$(basename $PWD)
|
| |
+ pkgname=$(basename "$PWD")
|
| |
if [[ -s sources ]]; then
|
| |
- while read md5sum tarball; do
|
| |
- curl -H Pragma: -o ./$tarball -R -S --fail $baseurl/$pkgname/$tarball/$md5sum/$tarball
|
| |
- done < sources
|
| |
- md5sum -c sources
|
| |
+ # Read first word of first line. For old MD5 format it's the 32 character
|
| |
+ # hash. Otherwise let's assume the sources have the BSD format where lines
|
| |
+ # start with hash type.
|
| |
+ hashtype="$(head -n1 sources | cut -d' ' -f1 | tr '[:upper:]' '[:lower:]')"
|
| |
+ if [ "${#hashtype}" -ne 32 ]; then
|
| |
+ # The format is
|
| |
+ # SHA512 (filename) = ABCDEF
|
| |
+ # We don't care about the equals sign. We also assume all hashes are
|
| |
+ # the same type, so we don't need to read it again for each line.
|
| |
+ while read -r _ filename _ hash; do
|
| |
+ # Remove parenthesis around tarball name
|
| |
+ tarball=${filename:1:-1}
|
| |
+ curl -H Pragma: -o "./$tarball" -R -S --fail "$baseurl/$pkgname/$tarball/$hashtype/$hash/$tarball"
|
| |
+ done < sources
|
| |
+ "${hashtype}sum" -c sources
|
| |
+ else
|
| |
+ # Ok, we're working with MD5.
|
| |
+ while read -r md5sum tarball; do
|
| |
+ curl -H Pragma: -o "./$tarball" -R -S --fail "$baseurl/$pkgname/$tarball/$md5sum/$tarball"
|
| |
+ done < sources
|
| |
+ md5sum -c sources
|
| |
+ fi
|
| |
fi
|
| |
This patch adds logic to test format of the file and then constructs the URL appropriately. The command to verify downloaded files is updated to check the actually used hash.
Assuming I'm correct that Koji uses this script to download sources, this change is needed to make sure people can still build. It avoids this failure.