# Maintainer: AndyRTR <andyrtr@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>

pkgname=system-config-printer
pkgver=1.5.15
pkgrel=1
pkgdesc="A CUPS printer configuration tool and status applet"
url="https://github.com/OpenPrinting/system-config-printer"
arch=('x86_64')
license=('GPL')
depends=('python-pycups' 'python-dbus' 'python-pycurl' 'libnotify'
         'python-requests' 'python-gobject' 'gtk3' 'python-cairo')
makedepends=('intltool' 'xmlto' 'docbook-xsl' 'desktop-file-utils' 'libsecret')
optdepends=('libsecret: password management'
            'python-pysmbc: SMB browser support'
            'cups-pk-helper: PolicyKit helper to configure cups with fine-grained privileges')
source=(https://github.com/OpenPrinting/system-config-printer/releases/download/v${pkgver}/system-config-printer-${pkgver}.tar.xz{,.asc})
sha256sums=('fbd226ce215bf014213dded81b43b9d4d90470524f5bf7cd21ecc71d4aefa689'
            'SKIP')
validpgpkeys=('7ADB58203CA5F046F28025B215AA6A7F4D4227D7') # "Zdenek Dohnal (Associate Software Engineer) <zdohnal@redhat.com>"

build() {
  cd ${pkgname}-${pkgver}

  ./configure --prefix=/usr \
    --sbindir=/usr/bin \
    --sysconfdir=/etc \
    --with-systemdsystemunitdir=/usr/lib/systemd/system \
    --with-udevdir=/usr/lib/udev \
    --with-udev-rules
  make
}

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR="$pkgdir" install

  # Compile *.pyc
  find "$pkgdir" -name '*.py' -exec python -mpy_compile {} +
  # Compile *.pyo
  find "$pkgdir" -name '*.py' -exec python -O -mpy_compile {} +
  
  # fix dbus policy location
  install -dm755 "$pkgdir"/usr/share/dbus-1/system.d
  mv "$pkgdir"/etc/dbus-1/system.d/* "$pkgdir"/usr/share/dbus-1/system.d
  rm -rf "$pkgdir"/etc/dbus-1
}
