@@ -31,6 +31,25 @@ python_exec="python3"
3131base_dir=$( dirname $( realpath $0 ) )
3232running_os=$( $base_dir /detect_os)
3333
34+ # Install System packages
35+ # Args:
36+ # - Comma separated list of packages, can also be space separated and work
37+ install_system_pkgs () {
38+ packages=$1
39+ package_list=$( echo ${packages} | sed " s/,/ /g" )
40+
41+ if [[ -z " $package_list " ]]; then
42+ return 0 # Nothing to do
43+ fi
44+
45+ for package in $package_list ; do
46+ $install_cmd install -y $package
47+ if [ $? -ne 0 ]; then
48+ exit_out " $install_cmd install of $package failed" 1
49+ fi
50+ done
51+ }
52+
3453# Fetches dependencies from a wrapper JSON file
3554# Args:
3655# - Wrapper file path
@@ -43,6 +62,10 @@ parse_json()
4362 json_file=$1
4463 platform=$2
4564
65+ if ! command -v jq > /dev/null; then
66+ install_system_pkgs jq
67+ fi
68+
4669 packages=$( jq -r " .dependencies.$platform | @csv" $json_file 2> /dev/null)
4770
4871 if [[ $? -ne 0 ]]; then
@@ -229,15 +252,7 @@ if [[ -n "$pip_packages" ]] && [[ "$python_exec" == "python3" ]]; then
229252 packages=$( append_packages $packages $pip_os_pkg )
230253fi
231254
232- if [[ $packages != " " ]]; then
233- package_list=` echo ${packages} | sed " s/,/ /g" `
234- for package in $package_list ; do
235- $install_cmd install -y $package
236- if [ $? -ne 0 ]; then
237- exit_out " $install_cmd install of $package failed" 1
238- fi
239- done
240- fi
255+ install_system_pkgs " $packages "
241256
242257if [[ -n " $pip_packages " ]]; then
243258 install_pip_pkgs
0 commit comments