# Maintainer (Hyperbola): André Silva <emulatorman@hyperbola.info>
# Contributor (Hyperbola): Márcio Silva <coadde@hyperbola.info>
# Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe>

pkgname=octopi
pkgver=0.11.0
pkgrel=2
pkgrel+=.parabola1
pkgdesc="A powerful Pacman frontend using Qt5 libs, without nonfree pacaur, pikaur, trizen and yay recommendation"
arch=('x86_64')
arch+=('i686' 'armv7h')
url="https://tintaescura.com/projects/octopi/"
license=('GPL')
depends=('alpm_octopi_utils' 'pkgfile' 'qtermwidget' 'sudo')
makedepends=('qt5-tools')
optdepends=('pacmanlogviewer: to view pacman log files'
            'gksu: for XFCE, Gnome, LXDE, Cinnamon'
            'lxqt-sudo: for LXQT')
provides=("octopi-cachecleaner=$pkgver" "octopi-notifier=$pkgver" "octopi-repoeditor=$pkgver")
conflicts=('octopi-cachecleaner' 'octopi-notifier' 'octopi-repoeditor'
           'octopi-git' 'octopi-kde-git')
source=("octopi-${pkgver}.tar.gz::https://github.com/aarnt/octopi/archive/v${pkgver}.tar.gz"
        'octopi-repoeditor.desktop')
sha256sums=('0f97626b244d51fca4a67cae208e49dd856cb61e96de6357f5827f9bedead3f4'
            '131f16745df685430db55e54ede6da66aed9b02ca00d6d873a002b2a3e1c90ef')

_subdirs=(helper repoeditor cachecleaner sudo notifier)

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  cp resources/images/octopi_green.png resources/images/octopi.png
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  echo "Starting build..."
  qmake-qt5 PREFIX=/usr QMAKE_CFLAGS="${CFLAGS}" QMAKE_CXXFLAGS="${CXXFLAGS}" QMAKE_LFLAGS="${LDFLAGS}" octopi.pro
  make

  for _subdir in ${_subdirs[@]}; do
    pushd $_subdir
    echo "Building octopi-$_subdir..."
    qmake-qt5 PREFIX=/usr QMAKE_CFLAGS="${CFLAGS}" QMAKE_CXXFLAGS="${CXXFLAGS}" QMAKE_LFLAGS="${LDFLAGS}" "octopi-$_subdir.pro"
    make
    popd
  done
}

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

  make INSTALL_ROOT="${pkgdir}" install

  for _subdir in ${_subdirs[@]}; do
    pushd $_subdir
    make INSTALL_ROOT="${pkgdir}" install
    popd
  done

  install -D -m644 "$srcdir"/octopi-repoeditor.desktop "$pkgdir"/usr/share/applications/octopi-repoeditor.desktop
}
