File tree Expand file tree Collapse file tree 2 files changed +41
-12
lines changed Expand file tree Collapse file tree 2 files changed +41
-12
lines changed Original file line number Diff line number Diff line change @@ -9,4 +9,6 @@ toolname=$(basename "$plugin_dir")
99# shellcheck source=../lib/utils.bash
1010source " ${plugin_dir} /lib/utils.bash"
1111
12+ validate_platform
13+
1214list_all_versions " ${toolname} " | sort_versions | xargs echo
Original file line number Diff line number Diff line change @@ -7,6 +7,9 @@ GH_REPO="muttleyxd/clang-tools-static-binaries"
77GH_REPO_URL=" https://github.com/${GH_REPO} "
88TOOL_NAME=" clang-tools-static"
99TOOL_TEST=" clang-format"
10+ USE_KERNEL=
11+ USE_ARCH=
12+ USE_PLATFORM=
1013
1114fail () {
1215 echo -e " asdf-$TOOL_NAME : $* "
@@ -32,7 +35,7 @@ list_github_tags() {
3235}
3336
3437fetch_all_assets () {
35- curl -H " Accept: application/vnd.github.v3+json" \
38+ curl -s - H " Accept: application/vnd.github.v3+json" \
3639 https://api.github.com/repos/${GH_REPO} /releases |
3740 jq -r ' .[0].assets[] | "\(.name) \(.browser_download_url)"'
3841}
@@ -60,30 +63,54 @@ get_arch() {
6063
6164 case $arch in
6265 x86_64)
63- platform= " amd64"
66+ echo -n " amd64"
6467 ;;
65- * )
66- fail " Unsupported arch $arch "
67- exit 1
68+ esac
69+
70+ echo -n " $"
71+ }
72+
73+ validate_platform () {
74+
75+ if [ -n " ${USE_PLATFORM} " ]; then
76+ return
77+ fi
78+
79+ local kernel arch
80+ kernel=$( uname -s)
81+ arch=$( uname -m)
82+
83+ case $kernel in
84+ Darwin)
85+ USE_KERNEL=macosx
86+ USE_ARCH=amd64
87+ ;;
88+ Linux)
89+ case $arch in
90+ x86_64)
91+ USE_KERNEL=linux
92+ USE_ARCH=amd64
93+ ;;
94+ esac
6895 ;;
6996 esac
7097
71- echo -n " $arch "
98+ if [ -z " ${USE_KERNEL} " ] || [ -z " ${USE_ARCH} " ]; then
99+ fail " Unsupported platform '${kernel} -${arch} '"
100+ fi
72101
102+ USE_PLATFORM=" ${USE_KERNEL} -${USE_ARCH} "
73103}
74104
75105list_all_versions () {
76106
77- local toolname= $1
107+ validate_platform
78108
79- local platform arch
80- platform=$( get_platform)
81- arch=$( get_arch)
109+ local toolname=$1
82110
83111 fetch_all_assets |
84112 grep " $toolname " |
85- grep " $platform " |
86- grep " $arch " |
113+ grep " $USE_PLATFORM " |
87114 grep -v " sha" |
88115 awk ' {print $1}' |
89116 sed " s/^${toolname} -\(.*\)_.*/\1/"
You can’t perform that action at this time.
0 commit comments