812cef9335
Improve image building to get closer to support zuul package mirrors Change-Id: I57285b242ddc50e8e902ad2820982a2d4b351bc3
41 lines
995 B
Bash
Executable File
41 lines
995 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Install host-level package dependencies
|
|
# needed for local testing
|
|
set -x
|
|
|
|
if [[ ! -z $(uname -a | grep Ubuntu) ]]
|
|
then
|
|
apt update
|
|
installed_pkgs=$(apt list --installed | cut -d'/' -f1)
|
|
set -a added_pkgs
|
|
for reqfile in $(ls requirements-host*.txt)
|
|
do
|
|
for l in $(grep -vE '(^ *#)|(^$)' "${reqfile}")
|
|
do
|
|
# Do extra magic to support a list of alternative packages separated by '|'
|
|
# none of the packages are found, install the first one listed
|
|
IFS='|' read -a pkgalts <<< "${l}"
|
|
pkgfound=0
|
|
for a in "${pkgalts[@]}"
|
|
do
|
|
if grep -qE "^${a}$" <<< "${installed_pkgs}"
|
|
then
|
|
pkgfound=1
|
|
break
|
|
fi
|
|
done
|
|
if [[ "${pkgfound}" -eq 0 ]]
|
|
then
|
|
added_pkgs+=("${pkgalts[0]}")
|
|
fi
|
|
done
|
|
done
|
|
if [[ ${#added_pkgs[@]} -gt 0 ]]
|
|
then
|
|
apt install -y --no-install-recommends "${added_pkgs[@]}"
|
|
fi
|
|
else
|
|
echo "Only support testing on Ubuntu hosts at this time."
|
|
fi
|