pkgname='libretools-distcc'
pkgver=1.0
license=('GPL')
url='https://parabola.nu'

pkgrel=1
arch=(any)

build() (
  cd "$srcdir"
  set -x

  # Check that the odaemon socket exists
  [[ -S /socket ]]

  # ... and that it works
  printf 'GET / HTTP/1.1\r\nHost: parabola.nu\r\n\r\n' | distcc-tool client parabola.nu 80 >http.txt
  [[ "$(sed 1q http.txt)" == HTTP/* ]]

  # ... and that idaemon talks to it
  socat TCP-CONNECT:"${DISTCC_HOSTS}" STDIO </dev/null >hello.txt
  [[ "$(cat hello.txt)" == 'Hello, I am a distcc server' ]]
)

package() {
  cd "$srcdir"
  install -Dm644 hello.txt "$pkgdir"/usr/share/hello.txt
  install -Dm644 http.txt "$pkgdir"/usr/share/http.txt
}
