A declarative host provisioning system.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hostdeps.sh 995B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/bash
  2. # Install host-level package dependencies
  3. # needed for local testing
  4. set -x
  5. if [[ ! -z $(uname -a | grep Ubuntu) ]]
  6. then
  7. apt update
  8. installed_pkgs=$(apt list --installed | cut -d'/' -f1)
  9. set -a added_pkgs
  10. for reqfile in $(ls requirements-host*.txt)
  11. do
  12. for l in $(grep -vE '(^ *#)|(^$)' "${reqfile}")
  13. do
  14. # Do extra magic to support a list of alternative packages separated by '|'
  15. # none of the packages are found, install the first one listed
  16. IFS='|' read -a pkgalts <<< "${l}"
  17. pkgfound=0
  18. for a in "${pkgalts[@]}"
  19. do
  20. if grep -qE "^${a}$" <<< "${installed_pkgs}"
  21. then
  22. pkgfound=1
  23. break
  24. fi
  25. done
  26. if [[ "${pkgfound}" -eq 0 ]]
  27. then
  28. added_pkgs+=("${pkgalts[0]}")
  29. fi
  30. done
  31. done
  32. if [[ ${#added_pkgs[@]} -gt 0 ]]
  33. then
  34. apt install -y --no-install-recommends "${added_pkgs[@]}"
  35. fi
  36. else
  37. echo "Only support testing on Ubuntu hosts at this time."
  38. fi