@@ -54,18 +54,26 @@ download_and_checksum() {
54
54
}
55
55
download_and_extract () {
56
56
local url=" $1 "
57
- local checksum=" $2 "
58
- local bin_dir=" $3 "
59
- local bin_in_archive=" $4 " # path to bin in archive
57
+ shift
58
+ local checksum=" $1 "
59
+ shift
60
+ local bin_dir=" $1 "
61
+ shift
62
+ local bin_in_archive=(" $@ " ) # path to bin in archive
60
63
if [[ " ${bin_dir} " == " ${install_action_dir} /bin" ]]; then
61
64
init_install_action_bin_dir
62
65
fi
63
66
64
- local installed_bin
65
- # xbuild's binary name is "x", as opposed to the usual crate name
67
+ installed_bin=()
68
+ local tmp
66
69
case " ${tool} " in
67
- xbuild) installed_bin=" ${bin_dir} /x" ;;
68
- * ) installed_bin=" ${bin_dir} /$( basename " ${bin_in_archive} " ) " ;;
70
+ # xbuild's binary name is "x", as opposed to the usual crate name
71
+ xbuild) installed_bin=(" ${bin_dir} /x" ) ;;
72
+ * )
73
+ for tmp in " ${bin_in_archive[@]} " ; do
74
+ installed_bin+=(" ${bin_dir} /$( basename " ${tmp} " ) " )
75
+ done
76
+ ;;
69
77
esac
70
78
71
79
local tar_args=()
@@ -119,29 +127,35 @@ download_and_extract() {
119
127
download_and_checksum " ${url} " " ${checksum} "
120
128
if [[ ${# tar_args[@]} -gt 0 ]]; then
121
129
tar_args+=(" tmp" )
122
- local components
123
- components=$( tr <<< " ${bin_in_archive}" -cd ' /' | wc -c)
124
- if [[ " ${components} " != " 0" ]]; then
125
- tar_args+=(--strip-components " ${components} " )
126
- fi
127
- tar " ${tar_args[@]} " -C " ${bin_dir} " " ${bin_in_archive} "
130
+ tar " ${tar_args[@]} "
131
+ for tmp in " ${bin_in_archive[@]} " ; do
132
+ mv " ${tmp} " " ${bin_dir} /"
133
+ done
128
134
else
129
135
case " ${url} " in
130
136
* .zip)
131
137
unzip -q tmp " ${bin_in_archive# \. / } "
132
- mv " ${bin_in_archive} " " ${bin_dir} /"
138
+ for tmp in " ${bin_in_archive[@]} " ; do
139
+ mv " ${tmp} " " ${bin_dir} /"
140
+ done
141
+ ;;
142
+ * )
143
+ for tmp in " ${installed_bin[@]} " ; do
144
+ mv tmp " ${tmp} "
145
+ done
133
146
;;
134
- * ) mv tmp " ${installed_bin} " ;;
135
147
esac
136
148
fi
137
149
)
138
150
rm -rf " ${tmp_dir} "
139
151
140
152
case " ${host_os} " in
141
153
linux | macos)
142
- if [[ ! -x " ${installed_bin} " ]]; then
143
- chmod +x " ${installed_bin} "
144
- fi
154
+ for tmp in " ${installed_bin[@]} " ; do
155
+ if [[ ! -x " ${tmp} " ]]; then
156
+ chmod +x " ${tmp} "
157
+ fi
158
+ done
145
159
;;
146
160
esac
147
161
}
@@ -198,15 +212,31 @@ read_download_info() {
198
212
fi
199
213
checksum=$( call_jq <<< " ${download_info}" -r ' .checksum' )
200
214
url=$( call_jq <<< " ${download_info}" -r ' .url' )
215
+ local tmp
216
+ bin_in_archive=()
201
217
if [[ " ${url} " == " null" ]]; then
202
218
local template
203
219
template=$( call_jq -r " .template.${host_platform} " " ${manifest_dir} /${tool} .json" )
204
220
url=$( call_jq <<< " ${template}" -r ' .url' )
205
221
url=" ${url// \$\{ version\} / ${exact_version} } "
206
- bin_in_archive=$( call_jq <<< " ${template}" -r ' .bin' )
207
- bin_in_archive=" ${bin_in_archive// \$\{ version\} / ${exact_version} } "
222
+ tmp=$( call_jq <<< " ${template}" -r ' .bin' | sed -E " s/\\ $\\ {version\\ }/${exact_version} /g" )
223
+ if [[ " ${tmp} " == * " [" * ]]; then
224
+ # shellcheck disable=SC2207
225
+ bin_in_archive=($( call_jq <<< " ${template}" -r ' .bin[]' | sed -E " s/\\ $\\ {version\\ }/${exact_version} /g" ) )
226
+ fi
208
227
else
209
- bin_in_archive=$( call_jq <<< " ${download_info}" -r ' .bin' )
228
+ tmp=$( call_jq <<< " ${download_info}" -r ' .bin' )
229
+ if [[ " ${tmp} " == * " [" * ]]; then
230
+ # shellcheck disable=SC2207
231
+ bin_in_archive=($( call_jq <<< " ${download_info}" -r ' .bin[]' ) )
232
+ fi
233
+ fi
234
+ if [[ ${# bin_in_archive[@]} -eq 0 ]]; then
235
+ if [[ " ${tmp} " == " null" ]]; then
236
+ bin_in_archive=(" ${tool}${exe} " )
237
+ else
238
+ bin_in_archive=(" ${tmp} " )
239
+ fi
210
240
fi
211
241
if [[ " ${rust_crate} " == " null" ]]; then
212
242
if [[ " ${host_os} " == " windows" ]] || [[ ! -e /usr/local/bin ]]; then
@@ -217,17 +247,14 @@ read_download_info() {
217
247
else
218
248
bin_dir=" ${cargo_bin} "
219
249
fi
220
- if [[ " ${bin_in_archive} " == " null" ]]; then
221
- bin_in_archive=" ${tool}${exe} "
222
- fi
223
250
}
224
251
download_from_manifest () {
225
252
read_manifest " $@ "
226
253
download_from_download_info " $@ "
227
254
}
228
255
download_from_download_info () {
229
256
read_download_info " $@ "
230
- download_and_extract " ${url} " " ${checksum} " " ${bin_dir} " " ${bin_in_archive} "
257
+ download_and_extract " ${url} " " ${checksum} " " ${bin_dir} " " ${bin_in_archive[@] } "
231
258
}
232
259
install_cargo_binstall () {
233
260
local binstall_version
@@ -540,6 +567,7 @@ for tool in "${tools[@]}"; do
540
567
else
541
568
version=" latest"
542
569
fi
570
+ installed_bin=()
543
571
case " ${tool} " in
544
572
protoc)
545
573
info " installing ${tool} @${version} "
@@ -576,6 +604,7 @@ for tool in "${tools[@]}"; do
576
604
fi
577
605
)
578
606
rm -rf " ${tmp_dir} "
607
+ installed_bin=(" ${tool}${exe} " )
579
608
;;
580
609
valgrind)
581
610
info " installing ${tool} @${version} "
@@ -593,6 +622,7 @@ for tool in "${tools[@]}"; do
593
622
# Use snap to install the latest Valgrind
594
623
# https://snapcraft.io/install/valgrind/ubuntu
595
624
snap_install valgrind --classic
625
+ installed_bin=(" ${tool}${exe} " )
596
626
;;
597
627
cargo-binstall)
598
628
case " ${version} " in
@@ -651,41 +681,50 @@ for tool in "${tools[@]}"; do
651
681
;;
652
682
esac
653
683
654
- case " ${tool} " in
655
- xbuild) tool_bin=" x" ;;
656
- * ) tool_bin=" ${tool} " ;;
657
- esac
658
- installed_at=$( type -P " ${tool_bin}${exe} " || echo " " )
659
- if [[ -n " ${installed_at} " ]]; then
660
- tool_bin=" ${tool_bin}${exe} "
661
- else
684
+ tool_bin_stems=()
685
+ for tool_bin in " ${installed_bin[@]} " ; do
686
+ tool_bin=$( basename " ${tool_bin} " )
687
+ tool_bin_stem=" ${tool_bin% .exe} "
662
688
installed_at=$( type -P " ${tool_bin} " || echo " " )
663
- fi
664
- if [[ -n " ${installed_at} " ]]; then
665
- info " ${tool} installed at ${installed_at} "
666
- else
667
- warn " ${tool} should be installed at ${bin_dir: +" ${bin_dir} /" }${tool_bin}${exe} ; but ${tool_bin}${exe} not found in path"
668
- fi
669
- # cargo-udeps 0.1.30 and wasm-pack 0.12.0 do not support --version option.
670
- case " ${tool} " in
671
- biome) rx " ${tool_bin} " --version || true ;; # biome up to 1.2.2 exits with 1 on --version and --help
672
- cargo-careful | cargo-machete) ;; # cargo-careful 0.3.4 and cargo-machete 0.5.0 do not support neither --version nor --help option.
673
- cargo-* )
674
- case " ${tool} " in
675
- cargo-valgrind) rx " ${tool_bin} " " ${tool# cargo-} " --help ;; # cargo-valgrind 2.1.0's --version option just calls cargo's --version option
676
- * )
677
- if ! rx " ${tool_bin} " " ${tool# cargo-} " --version; then
678
- rx " ${tool_bin} " " ${tool# cargo-} " --help
679
- fi
680
- ;;
681
- esac
682
- ;;
683
- * )
684
- if ! rx " ${tool_bin} " --version; then
685
- rx " ${tool_bin} " --help
686
- fi
687
- ;;
688
- esac
689
+ if [[ -z " ${installed_at} " ]]; then
690
+ tool_bin=" ${tool_bin_stem} "
691
+ installed_at=$( type -P " ${tool_bin} " || echo " " )
692
+ fi
693
+ if [[ -n " ${installed_at} " ]]; then
694
+ info " ${tool_bin_stem} installed at ${installed_at} "
695
+ else
696
+ warn " ${tool_bin_stem} should be installed at ${bin_dir: +" ${bin_dir} /" }${tool_bin}${exe} ; but ${tool_bin}${exe} not found in path"
697
+ fi
698
+ tool_bin_stems+=(" ${tool_bin_stem} " )
699
+ done
700
+ for tool_bin_stem in " ${tool_bin_stems[@]} " ; do
701
+ # cargo-udeps 0.1.30 and wasm-pack 0.12.0 do not support --version flag.
702
+ case " ${tool_bin_stem} " in
703
+ # biome up to 1.2.2 exits with 1 on both --version and --help flags.
704
+ # cargo-machete up to 0.6.0 does not support --version flag.
705
+ biome | cargo-machete) rx " ${tool_bin_stem} " --version || true ;;
706
+ # these packages support neither --version nor --help flag.
707
+ cargo-careful | wasm-bindgen-test-runner) ;;
708
+ # wasm2es6js does not support --version flag and --help flag doesn't contains version info.
709
+ wasm2es6js) ;;
710
+ cargo-* )
711
+ case " ${tool_bin_stem} " in
712
+ # cargo-valgrind 2.1.0's --version flag just calls cargo's --version flag
713
+ cargo-valgrind) rx " ${tool_bin_stem} " " ${tool_bin_stem# cargo-} " --help ;;
714
+ * )
715
+ if ! rx " ${tool_bin_stem} " " ${tool_bin_stem# cargo-} " --version; then
716
+ rx " ${tool_bin_stem} " " ${tool_bin_stem# cargo-} " --help
717
+ fi
718
+ ;;
719
+ esac
720
+ ;;
721
+ * )
722
+ if ! rx " ${tool_bin_stem} " --version; then
723
+ rx " ${tool_bin_stem} " --help
724
+ fi
725
+ ;;
726
+ esac
727
+ done
689
728
echo
690
729
done
691
730
0 commit comments