# Maintainer: Celestia Ludenberg <ash8820@proton.me>
# Contributor: Antergos NeXT Team

pkgname=cnchi
pkgver=0.17.1
pkgrel=2
pkgdesc="Antergos NeXT graphical installer (GTK4)"
arch=('any')
url="https://github.com/Antergos-NeXT/cnchi-next"
license=('GPL3')
depends=(
  'gtk4'
  'python'
  'python-cairo'
  'python-gobject'
  'python-dbus'
  'python-requests'
  'python-chardet'
  'python-feedparser'
  'python-idna'
  'python-mako'
  'python-geoip2'
  'python-maxminddb'
  'python-passlib'
  'pyalpm'
  'python-pyparted'
  'parted'
  'dosfstools'
  'mtools'
  'ntfs-3g'
  'upower'
  'gocryptfs'
  'iso-codes'
  'webkitgtk-6.0'
)
optdepends=('python-libnacl: Lembrame settings sync feature')
makedepends=('git')
install=cnchi.install
source=("${pkgname}::git+https://github.com/Antergos-NeXT/cnchi-next.git#branch=cnchi-dev")
sha256sums=('SKIP')

package() {
  cd "${srcdir}/${pkgname}"

  # Install Cnchi Python modules
  install -dm755 "${pkgdir}/usr/share/cnchi"
  cp -r src/* "${pkgdir}/usr/share/cnchi/"
  cp -r data "${pkgdir}/usr/share/cnchi/"
  cp -r ui "${pkgdir}/usr/share/cnchi/"
  cp -r scripts "${pkgdir}/usr/share/cnchi/"
  cp -r po "${pkgdir}/usr/share/cnchi/"
  cp -r utils "${pkgdir}/usr/share/cnchi/"
  cp run "${pkgdir}/usr/share/cnchi/"
  cp cnchi.desktop "${pkgdir}/usr/share/cnchi/"
  cp requirements.txt "${pkgdir}/usr/share/cnchi/"

  # Create executable wrapper
  install -dm755 "${pkgdir}/usr/bin"
  cat > "${pkgdir}/usr/bin/cnchi" << 'EOF'
#!/bin/bash
exec /usr/bin/python3 /usr/share/cnchi/cnchi.py "$@"
EOF
  chmod 755 "${pkgdir}/usr/bin/cnchi"

  # Desktop file
  install -dm755 "${pkgdir}/usr/share/applications"
  cp cnchi.desktop "${pkgdir}/usr/share/applications/"

  # Icons
  install -dm755 "${pkgdir}/usr/share/icons"
  cp -r data/icons/* "${pkgdir}/usr/share/icons/" 2>/dev/null || true

  # License  
  install -dm755 "${pkgdir}/usr/share/licenses/${pkgname}"
  cp COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
}
