# Maintainer: august <augustvontrips@gmail.com>
#
# AUR PKGBUILD for trackerkeeper. GENERATED by `trackerkeeper bake` — edit the template
# (packaging/templates/aur/PKGBUILD.j2), never this file. Builds the pure-Python
# wheel via the standard PEP 517 flow and installs it plus the .desktop /
# AppStream metainfo / scalable icon.
#
# pkgver is a placeholder here (the tag is the version); the aur.yml workflow
# stamps it from the release tag and refreshes the checksum via updpkgsums.
# arch=('any') — pure Python, no compiled extension.

pkgname=trackerkeeper
pkgver=0.0.0
pkgrel=1
pkgdesc='One dashboard for software & firmware updates across everything you own'
arch=('any')
url='https://github.com/wolfgangwarehaus/trackerkeeper'
license=('GPL-2.0-or-later')

depends=(
  'python'
  'pyside6'
)
optdepends=(
  'kwindowsystem: live glass blur behind the frosted chrome on KDE'
  'libnotify: desktop notifications'
)
makedepends=('python-build' 'python-installer' 'python-wheel' 'python-setuptools-scm')

# The release tag tarball (reproducible; preferred over a moving branch). 'SKIP'
# is the placeholder digest — aur.yml's updpkgsums refreshes it on publish.
source=("$pkgname-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz")
sha256sums=('SKIP')

build() {
  cd "$srcdir/$pkgname-$pkgver"
  # A git-archive tarball carries no .git, so setuptools-scm can't read the tag —
  # tell it the version explicitly (== pkgver, stamped from the release tag). The
  # dist-scoped form (…_FOR_<DIST>) is setuptools-scm v8's recommended pattern so
  # it can't bleed into another scm package built in the same environment. The
  # suffix is the DISTRIBUTION name ([project].name), not the app slug — they
  # differ when the slug is taken on PyPI (trackerkeeper-base → …_FOR_DOUGH_BASE).
  SETUPTOOLS_SCM_PRETEND_VERSION_FOR_TRACKERKEEPER="$pkgver" \
    python -m build --wheel --no-isolation
}

package() {
  cd "$srcdir/$pkgname-$pkgver"
  python -m installer --destdir="$pkgdir" dist/*.whl

  # Desktop entry + AppStream metadata + scalable icon (named by the app-id so the
  # .desktop Icon= key resolves).
  local appid=io.github.wolfgangwarehaus.trackerkeeper
  install -Dm644 "packaging/$appid.desktop" \
    "$pkgdir/usr/share/applications/$appid.desktop"
  install -Dm644 "packaging/$appid.metainfo.xml" \
    "$pkgdir/usr/share/metainfo/$appid.metainfo.xml"
  install -Dm644 "trackerkeeper/assets/trackerkeeper.svg" \
    "$pkgdir/usr/share/icons/hicolor/scalable/apps/$appid.svg"

  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
