# Maintainer (arch): Antonio Rojas <arojas@archlinux.org>
# Maintainer (arch): Felix Yan <felixonmars@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>
# Maintainer: Andreas Grapentin <andreas@grapentin.org>
# Contributor: André Silva <emulatorman@hyperbola.info>
# Contributor: jc_gargma <jc_gargma@iserlohn-fortress.net>
# Contributor: SolveFinder <kwopleq@proton.me>


# parabola changes and rationale:
# - remove unrar support


pkgname=ark
pkgver=24.02.0
pkgrel=1
pkgrel+=.parabola1
pkgdesc='Archiving Tool'
arch=(x86_64)
arch+=(armv7h i686)
url='https://apps.kde.org/ark/'
# license=(GPL-2.0-or-later) # TODO:
license=(GPL)
depends=(gcc-libs
         glibc
         kcolorscheme
         kcompletion
         kconfig
         kconfigwidgets
         kcoreaddons
         kcrash
         kdbusaddons
         kfilemetadata
         ki18n
         kio
         kjobwidgets
         kparts
         kpty
         kservice
         kwidgetsaddons
         kwindowsystem
         kxmlgui
         libarchive
         libzip
         qt6-base
         sh
         zlib)
makedepends=(extra-cmake-modules
             kdoctools)
optdepends=('arj: ARJ format support'
            'lrzip: LRZ format support'
            'lzop: LZO format support'
            'p7zip: 7Z format support'
            'unarchiver: RAR format support')
groups=(kde-applications
        kde-utilities)
source=(https://download.kde.org/stable/release-service/$pkgver/src/$pkgname-$pkgver.tar.xz{,.sig})
sha256sums=('ff11fe9352d8aa80207a21f3e024e18b4035cbbe689abaad20a91fe36c455469'
            'SKIP')
validpgpkeys=(CA262C6C83DE4D2FB28A332A3A6A4DB839EAA6D7  # Albert Astals Cid <aacid@kde.org>
              F23275E4BF10AFC1DF6914A6DBD2CE893E2D1C87  # Christoph Feck <cfeck@kde.org>
              D81C0CB38EB725EF6691C385BB463350D6EF31EF) # Heiko Becker <heiko.becker@kde.org>

# parabola mksource over-rides
mksource=(       ${source[*]}       )
mksha256sums=(   ${sha256sums[*]}   )
mkvalidpgpkeys=( ${validpgpkeys[*]} )
source=(https://repo.parabola.nu/other/${pkgname}-libre/${pkgname}-${pkgver}.parabola.tar.gz{,.sig})
sha256sums=('c80182f0b2ad75eec6cfdbf81eaa408556cda268b199d70e7932a690c85d1261'
            'SKIP')
validpgpkeys=('3954A7AB837D0EA9CFA9798925DB7D9B5A8D4B40') # bill-auger


mksource() {
  # Remove unrar plugin
  sed -i '/clirarplugin/d' "$pkgname-$pkgver/plugins/CMakeLists.txt"
  sed -i 's/unar or unrar/unar/' "$pkgname-$pkgver/plugins/cliunarchiverplugin/CMakeLists.txt"
  rm -rv $pkgname-$pkgver/plugins/clirarplugin
}

build() {
  cmake -B build -S $pkgname-$pkgver \
    -DBUILD_TESTING=OFF
  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build
}
