File: check_packages

package info (click to toggle)
obs-3d-effect 0.1.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 532 kB
  • sloc: ansic: 345; makefile: 23; cpp: 16
file content (52 lines) | stat: -rwxr-xr-x 1,607 bytes parent folder | download | duplicates (11)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
if (( ! ${+commands[packagesbuild]} )) {
  autoload -Uz log_info log_status mkcd

  if (( ! ${+commands[curl]} )) {
    log_error 'curl not found. Please install curl.'
    return 2
  }

  if (( ! ${+project_root} )) {
    log_error "'project_root' not set. Please set before running ${0}."
    return 2
  }

  local -a curl_opts=()
  if (( ! ${+CI} )) {
    curl_opts+=(--progress-bar)
  } else {
    curl_opts+=(--show-error --silent)
  }
  curl_opts+=(--location -O ${@})

  log_info 'Installing Packages.app...'

  pushd
  mkcd ${project_root:h}/obs-build-dependencies

  local packages_url='http://s.sudre.free.fr/Software/files/Packages_1210_1.dmg'
  local packages_hash='6afdd25386295974dad8f078b8f1e41cabebd08e72d970bf92f707c7e48b16c9'

  if [[ ! -f Packages_1210_1.dmg ]] {
    log_status 'Download Packages.app'
    curl ${curl_opts} ${packages_url}
  }

  local image_checksum
  read -r image_checksum _ <<< "$(sha256sum Packages_1210_1.dmg)"

  if [[ ${packages_hash} != ${image_checksum} ]] {
    log_error "Checksum mismatch of Packages.app download.
Expected : ${packages_hash}
Actual   : ${image_checksum}"
    return 2
  }

  hdiutil attach -noverify Packages_1210_1.dmg &> /dev/null && log_status 'Packages_1210_1.dmg image mounted.'

  log_info 'Installing Packages.app...'
  packages_volume=$(hdiutil info -plist | grep '<string>/Volumes/Packages' | sed 's/.*<string>\(\/Volumes\/[^<]*\)<\/string>/\1/')

  sudo installer -pkg "${packages_volume}/packages/Packages.pkg" -target / && rehash
  hdiutil detach ${packages_volume} &> /dev/null && log_status 'Packages.dmg image unmounted.'
}