check_linux 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. autoload -Uz log_debug log_group
  2. log_group 'Check Linux build requirements'
  3. log_debug 'Checking Linux distribution name and version...'
  4. # Check for Ubuntu version 22.10 or later, which have srt and librist available via apt-get
  5. typeset -g -i UBUNTU_2210_OR_LATER=0
  6. if [[ -f /etc/os_release ]] {
  7. local dist_name
  8. local dist_version
  9. read -r dist_name dist_version <<< "$(source /etc/os_release; print "${NAME} ${VERSION_ID}")"
  10. autoload -Uz is-at-least
  11. if [[ ${dist_name} == Ubuntu ]] && is-at-least 22.10 ${dist_version}; then
  12. typeset -g -i UBUNTU_2210_OR_LATER=1
  13. fi
  14. }
  15. local -a dependencies=("${(fA)$(<${SCRIPT_HOME}/.Aptfile)}")
  16. local -a install_list
  17. local binary
  18. sudo apt-get update -qq
  19. for dependency (${dependencies}) {
  20. local -a tokens=(${=dependency//(,|:|\')/})
  21. if [[ ! ${tokens[1]} == package ]] continue
  22. if [[ ${#tokens} -gt 2 && ${tokens[3]} == bin ]] {
  23. binary=${tokens[4]}
  24. } else {
  25. binary=${tokens[2]}
  26. }
  27. if (( ! ${+commands[${binary}]} )) install_list+=(${tokens[2]})
  28. }
  29. log_debug "List of dependencies to install: ${install_list}"
  30. if (( #install_list )) {
  31. sudo apt-get -y --no-install-recommends install ${install_list}
  32. }
  33. rehash
  34. log_group