File: check_linux

package info (click to toggle)
obs-downstream-keyer 0.3.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 560 kB
  • sloc: cpp: 1,957; ansic: 390; makefile: 24
file content (36 lines) | stat: -rwxr-xr-x 995 bytes parent folder | download | duplicates (38)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
autoload -Uz log_info log_status log_error log_debug log_warning

log_debug 'Checking for apt-get...'
if (( ! ${+commands[apt-get]} )) {
  log_error 'No apt-get command found. Please install apt'
  return 2
} else {
  log_debug "Apt-get located at ${commands[apt-get]}"
}

local -a dependencies=("${(f)$(<${SCRIPT_HOME}/.Aptfile)}")
local -a install_list
local binary

for dependency (${dependencies}) {
  local -a tokens=(${(s: :)dependency//(,|:|\')/})

  if [[ ! ${tokens[1]} == 'package' ]] continue

  if [[ ${#tokens} -gt 2 && ${tokens[3]} == 'bin' ]] {
    binary=${tokens[4]}
  } else {
    binary=${tokens[2]}
  }

  if (( ! ${+commands[${binary}]} )) install_list+=(${tokens[2]})
}

local -a _quiet=('' '--quiet')

log_debug "List of dependencies to install: ${install_list}"
if (( ${#install_list} )) {
  if (( ! ${+CI} )) log_warning 'Dependency installation via apt may require elevated privileges'

  sudo apt-get -y install ${install_list} ${_quiet[(( (_loglevel == 0) + 1 ))]}
}