-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch_checksums.sh
executable file
·51 lines (45 loc) · 1.04 KB
/
fetch_checksums.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
source_url() {
echo "https://www.nasm.us/pub/nasm/releasebuilds/$1/nasm-$1.tar.gz"
}
mac_url() {
echo "https://www.nasm.us/pub/nasm/releasebuilds/$1/macosx/nasm-$1-macosx.zip"
}
print_checksum() {
url=$1
if checksum=$(curl -sLf "$url" | sha256sum | awk '{print $1;}'); then
format_checksum $url $checksum
fi
}
format_checksum() {
url=$1
checksum=$2
echo " \"$url\":"
echo " \"$checksum\","
}
set -e
set -o pipefail
declare -a versions
PRINT_MAC="True"
PRINT_SOURCE="True"
if [ -n "$1" ]; then
if [ $1 == "mac" ]; then
PRINT_SOURCE=""
fi
if [ $1 == "source" ]; then
PRINT_MAC=""
fi
fi
versions=( $(curl -L https://www.nasm.us/pub/nasm/releasebuilds/ --stderr - | grep -P '(?<=href=")\d+\.\d+\.\d+(rc\d+)?' -o) )
echo "NASM_URLS = {"
for v in "${versions[@]}"; do
if [ -n "$PRINT_SOURCE" ]; then
url=$(source_url $v)
print_checksum $url
fi
if [ -n "$PRINT_MAC" ]; then
url=$(mac_url $v)
print_checksum $url
fi
done
echo "}"