@@ -12,6 +12,7 @@ fail() {
12
12
}
13
13
14
14
list_all_versions () {
15
+ local current_script_path plugin_dir v
15
16
current_script_path=${BASH_SOURCE[0]}
16
17
plugin_dir=$( dirname " $( dirname " $current_script_path " ) " )
17
18
v=" $plugin_dir /versions.txt"
@@ -27,22 +28,40 @@ list_all_versions() {
27
28
}
28
29
29
30
download_release () {
30
- local version filename
31
- version=" $1 "
31
+ local version dirname filename
32
+ version=$1
32
33
dirname=$( dirname " $2 " )
33
34
filename=$( basename " $2 " )
34
35
35
36
printf " * Downloading %s release %s...\n" " $TOOL_NAME " " $version "
36
- pip3 download --dest " $dirname " " $filename ==$version " || fail " Could not download from pip"
37
+ ensure_pip3
38
+ pip3 download --dest " $dirname " " $filename ==$version " || fail " could not download from pip"
39
+ }
40
+
41
+ ensure () {
42
+ local check=$1
43
+ local msg=$2
44
+
45
+ if ! eval " $check " > /dev/null; then
46
+ fail " $msg (${check} == $? )"
47
+ fi
48
+ }
49
+
50
+ ensure_pip3 () {
51
+ ensure " which pip3" " it appears pip is not available"
52
+ }
53
+
54
+ ensure_wheel () {
55
+ ensure " pip show wheel" " it appears wheel is not available"
37
56
}
38
57
39
58
install_version () {
40
- local install_type=" $1 "
41
- local version=" $2 "
42
- local install_path=" $3 "
59
+ local install_type=$1
60
+ local version=$2
61
+ local install_path=$3
43
62
44
63
if [ " $install_type " != " version" ]; then
45
- fail " asdf- $TOOL_NAME supports release installs only"
64
+ fail " supports release installs only"
46
65
fi
47
66
48
67
(
@@ -56,17 +75,17 @@ install_version() {
56
75
install_localstack " $install_path "
57
76
unpack_deps " $install_path "
58
77
59
- [ -x " $install_path /bin/$tool_cmd " ] || fail " Expected $install_path /$tool_cmd to be executable."
78
+ [ -x " $install_path /bin/$tool_cmd " ] || fail " expected $install_path /$tool_cmd to be executable."
60
79
61
80
printf " %s %s installation was successful!\n" " $TOOL_NAME " " $version "
62
81
) || (
63
82
rm -rf " $install_path "
64
- fail " An error occurred while installing $TOOL_NAME $version ."
83
+ fail " an error occurred while installing $TOOL_NAME $version ."
65
84
)
66
85
}
67
86
68
87
install_localstack () {
69
- install_path=" $1 "
88
+ local install_path=$1
70
89
71
90
localstack_client_tar_gz=$( find " $install_path " -name " localstack-client*" )
72
91
tar zxf " $localstack_client_tar_gz " --strip-components=1 -C " $install_path "
@@ -76,8 +95,9 @@ install_localstack() {
76
95
}
77
96
78
97
unpack_deps () {
79
- install_path=" $1 "
98
+ local install_path=$1
80
99
100
+ ensure_wheel
81
101
unpack_dep " $install_path " boto3 boto3
82
102
unpack_dep " $install_path " botocore botocore
83
103
unpack_dep " $install_path " jmespath jmespath
@@ -88,9 +108,9 @@ unpack_deps() {
88
108
}
89
109
90
110
unpack_dep () {
91
- install_path=" $1 "
92
- dep=" $2 "
93
- dep_name=" $3 "
111
+ local install_path=$1
112
+ local dep=$2
113
+ local dep_name=$3
94
114
95
115
dep_whl=$( find " $install_path " -name " $dep -*" )
96
116
wheel unpack " $dep_whl " --dest " $install_path "
0 commit comments