# Maintainer: Maxime Gauduin <alucryd@archlinux.org>
# Maintainer: Alexander Epaneshnikov <alex19ep@archlinux.org>
# Contributor: Ethan Skinner <aur@etskinner.com>
# Contributor: Grégoire Seux <grego_aur@familleseux.net>
# Contributor: Dean Galvin <deangalvin3@gmail.com>
# Contributor: NicoHood <archlinux@nicohood.de>

pkgname=home-assistant
pkgdesc='Open source home automation that puts local control and privacy first'
pkgver=2026.4.2
pkgrel=1
epoch=1
arch=('any')
url='https://home-assistant.io/'
license=('Apache-2.0')
depends=(
  'bluez-libs'
  'ffmpeg'
  'gcc'
  'lapack'
  'libffi'
  'libjpeg-turbo'
  'libtiff'
  'openjpeg2'
  'openssl'
  'python'
  'tzdata'
  'zlib'
)
makedepends=(
  'git'
  'python-build'
  'python-setuptools'
  'python-wheel'
)
install=$pkgname.install
source=(
  "$pkgname-$pkgver.tar.gz::https://github.com/home-assistant/core/archive/refs/tags/$pkgver.tar.gz"
  'remove-setuptools-constraint.patch'
  'home-assistant.service'
  'home-assistant.sysusers'
  'home-assistant.tmpfiles'
)
b2sums=('5ba2cb98003c775ca0fe1cfaf6c1b3826e5d66c425467c483faee7a5423b3eefcc9ac659158c7030405c8a64b40d6151a1775736bf5d9736af02f94b850b1ccd'
        '913c766df2ed4a4f5984c3ea75746e380f370ba9b3d6009d329b2089d1f00a538a18608f037593d43bbbc3f9a2c88d2290dfdef3a15094575c28b5a55e8ec1a9'
        '20b1847203eb236c58ce29b6d502fbad2804479dc31edc8f6a5da0a5a0bfaa22519f7262afe503d06c6c2efd26ee7819a549efb0096b661ed6eb277b441533f9'
        '8a023a2215712044fb5115d1b81e55fad2c74f2e836cfe7f3f1e7c3778e4903c25ba7e429aedfd74b566be542aa50ea0d486b616c6d5b0315d993a9599e454f8'
        'ffb45bcc9cc396282f417a066c01f1137f25cc8ccd55f484b442d136ca3eb8569949a88e99f5cc3f4af4ee0ed60392711c5cda772e364b3959ba6e64e6bbfea5')

prepare() {
  # update version in service file
  sed "s/@VERSION@/${pkgver}/" -i home-assistant.service

  # allow any setuptools version to be used
  # also fix FTBFS due to requiring a later version of setuptools
  cd core-$pkgver
  patch -p1 -i "$srcdir/remove-setuptools-constraint.patch"
}

build() {
  cd core-$pkgver
  python -m script.translations develop --all
  python -m build --wheel --no-isolation
}

package() {
  install -Dm644 core-$pkgver/dist/*.whl -t "$pkgdir"/usr/share/home-assistant/
  install -Dm644 home-assistant.service -t "$pkgdir"/usr/lib/systemd/system/
  install -Dm644 home-assistant.sysusers "$pkgdir"/usr/lib/sysusers.d/home-assistant.conf
  install -Dm644 home-assistant.tmpfiles "$pkgdir"/usr/lib/tmpfiles.d/home-assistant.conf
}

# vim: ts=2 sw=2 et:
