app=sane-backends
version=1.0.31
build=1sml
homepage="http://www.sane-project.org/"
download="https://gitlab.com/sane-project/backends/uploads/8bf1cae2e1803aefab9e5331550e5d5d/sane-backends-1.0.31.tar.gz"
desc="Tools and libraries to access data from image-scanning devices"
requires="cairo curl glib libxml2 libpng libnl libjpeg-turbo openssl python3"

build() {
  mkandenterbuilddir
  rm -rf $app-$version

  tar xf $srcdir/$app-$version.tar.?z*
  cd $app-$version 
  fixbuilddirpermissions

  applypatch $srcdir/sane-frontends-1.0.14-sane_cap_always_settable.diff

  ./configure \
    --prefix="" \
    --sbindir=/bin \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --enable-locking \
    --with-group=scanner \
    --with-usb \
    --without-api-spec

  make
  make install DESTDIR=$pkg 

  cp COPYING LICENSE $pkgdocs/

  install -Dm 644 tools/sane-backends.pc $pkg/lib/pkgconfig/sane-backends.pc

  # Fix wrong permissions
  chown -R root:root $pkg/var
  chmod 755 $pkg/var
  chmod 1777 $pkg/var/lock 
  chown root:scanner $pkg/var/lock/sane
  chmod 775 $pkg/var/lock/sane

  cp $srcdir/dll.conf.additions $pkg/etc/sane.d/dll.conf

  # Move config files:
  ( cd $pkg/etc/sane.d
    for file in *.conf ; do
    mv $file ${file}.new
    done
  )

  mkfinalpkg
}

sha512sums="
a7857007f88850dc7e7090566e75287fd8dc1c8d5809614c435af3f7039a47b5c225efd6172187dca32ef37a9ce9afe2271be851381cefedb2051975c3ee88b5  sane-backends-1.0.31.tar.xz
4fc80e093c312b8c0ee020cdddb12667a383dbefd445fac41f9a34be25e9c4f5f8d1e35fe60b621f717fd7eb46ccff31dd2fa06c02f77bdc67ece5820bdad09f  sane-frontends-1.0.14-sane_cap_always_settable.diff
"
