Skip to content

Commit 49de877

Browse files
authored
Merge pull request #107 from redhat-performance/pkg-tool/jq
[pkg_tool] Install JQ when reading from wrapper_config
2 parents cf99b26 + 222aa68 commit 49de877

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

package_tool

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,25 @@ python_exec="python3"
3131
base_dir=$(dirname $(realpath $0))
3232
running_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)
230253
fi
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

242257
if [[ -n "$pip_packages" ]]; then
243258
install_pip_pkgs

0 commit comments

Comments
 (0)