-
Notifications
You must be signed in to change notification settings - Fork 3
/
y-bin-download-next
executable file
·90 lines (79 loc) · 1.62 KB
/
y-bin-download-next
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env bash
[ -z "$DEBUG" ] || set -x
set -eo pipefail
[ $# -eq 0 ] && >&2 echo "First arg must be an y-bin yaml path" && exit 1
yaml=$1
[ $# -eq 1 ] && >&2 echo "Second arg must be a bin name" && exit 1
name=$2
[ $# -eq 2 ] && >&2 echo "Third arg must be a version" && exit 1
version=$3
durl=$(yq e ".$name.templates.download" $yaml)
sha256url=$(yq e ".$name.templates.sha256" $yaml)
[ $sha256url != null ] || [ $durl != null ] || echo "Neither sha256 url nor download url found for $name in $yaml"
[ $sha256url != null ] || [ $durl != null ] || exit 1
echo "$name":
echo " version: $version"
echo " templates:"
echo " download: $durl"
[ $sha256url = null ] || echo " sha256: $sha256url"
echo " sha256:"
function checksum {
check=$(checksum_download)
if [ $sha256url != null ]; then
url=$(eval echo $sha256url)
curl -sLS $url | grep $check >/dev/null || exit 1
fi
echo $check
}
function checksum_download {
url=$(eval echo $durl)
curl -sLS $url | sha256sum - | sed 's/ -//'
}
os=darwin
aarch=x86_64
aarch64=x64
arch=amd64
xarch=x86_64
osx=osx
osmac=macos
osmac_=macos
Os=Darwin
arm=""
xarm=x
echo -n " darwin_amd64: " && checksum
os=darwin
aarch=aarch64
aarch64=aarch64
arch=arm64
xarch=arm64
osx=osx
osmac=macos
osmac_=macos
Os=Darwin
arm=arm
xarm=arm
echo -n " darwin_arm64: " && checksum
os=linux
aarch=x86_64
aarch64=x64
arch=amd64
xarch=x86_64
osx=linux
osmac=linux
osmac_=""
Os=Linux
arm=""
xarm=x
echo -n " linux_amd64: " && checksum
os=linux
aarch=aarch64
aarch64=aarch64
arch=arm64
xarch=arm64
osx=linux
osmac=linux
osmac_=""
Os=Linux
arm=arm
xarm=arm
echo -n " linux_arm64: " && checksum