# Maintainer (arch): Antonio Rojas <arojas@archlinux.org>
# Maintainer (arch): Josip Ponjavic <josipponjavic at gmail dot com>
# Contributor: Balló György <ballogyor+arch at gmail dot com>
# Contributor: bill-auger <bill-auger@programmer.net>


# parabola changes and rationale:
#  - build without qt6-webengine
#  - build from source-ball rather than VCS
#    $_commit is current VCS 'master' branch - apparently, upstream does not publish releases


pkgname=signon-ui
pkgver=0.17+20231016
pkgrel=3
pkgrel+=.parabola1
_commit=eef943f0edf3beee8ecb85d4a9dae3656002fc24
pkgdesc='UI component responsible for handling the user interactions which can happen during the login process of an online account'
arch=(x86_64)
arch+=(armv7h i686)
url='https://launchpad.net/online-accounts-signon-ui'
license=(GPL-3.0-only)
depends=(gcc-libs
         glib2
         glibc
         libaccounts-qt
         libnotify
         libproxy
         qt6-base
         qt6-declarative
         qt6-webengine
         signond)
depends=( ${depends[*]/qt6-webengine/} ) # blacklisted
makedepends=(git)
makedepends=( ${makedepends[*]/git/} ) # build from source-ball
source=(https://gitlab.com/accounts-sso/signon-ui/-/archive/${_commit}/signon-ui-${_commit}.tar.gz)
sha256sums=(0906a1adee88e331e9dcf1f2d5978c24f8564fb734f5c114c88bddb63196d3d4)


prepare() {
  # link source-ball directory as VCS directory (minimize diff)
  ln -s ${pkgname}{-${_commit},}


  ## upstream patching ##

  cd $pkgname

  # Do not install tests
  sed -e 's|src \\|src|' -e '/tests/d' -i signon-ui.pro


  ## parabola patching ##

  # build without webengine
  sed -i 's|^    QT += webengine.*$|    # build without webengine\n    QT += core|' src/signon-ui.pro
  sed -i 's|^#include <QtWebEngine.*$|  // build without webengine|'                src/main.cpp
  sed -i 's|^    QtWebEngine.*::initialize();$|    // build without webengine|'     src/main.cpp
}

build() {
  cd $pkgname

  qmake6 \
    PREFIX=/usr \
    LIBDIR=/usr/lib
  make
}

package() {
  cd $pkgname

  make INSTALL_ROOT="$pkgdir" install
}
