#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobextra/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=libgit2
pkgver=1.5.0
pkgrel=02
epoch=1
pkgdesc="A linkable library for Git"
arch=(x86_64)
url="https://github.com/libgit2/libgit2"
depends=(glibc http-parser openssl pcre zlib)
makedepends=(cmake libssh2 python)
provides=(libgit2.so)
#options=(debug)   ## uncomment this to have the debug pkg produced
source=($pkgname-$pkgver.tar.gz::https://github.com/$pkgname/$pkgname/archive/v$pkgver.tar.gz
	$pkgname-1.5.0-remove_http-parse_incompatible_tests.patch)

prepare() {
  # remove tests that are only compatible with the (modified) vendored version
  # of http-parser, but not with upstream http-parser
  patch -d $pkgname-$pkgver -Np1 -i ../$pkgname-1.5.0-remove_http-parse_incompatible_tests.patch
}

build() {
  cmake -DCMAKE_INSTALL_PREFIX=/usr \
        -DCMAKE_BUILD_TYPE=None \
        -DUSE_HTTP_PARSER=system \
        -DUSE_SSH=ON \
        -DTHREADSAFE=ON \
        -Wno-dev \
        -B build \
        -S $pkgname-$pkgver
  cmake --build build
}

check() {
  # NOTE: disable tests requiring the internet and relying on non-existent resources
  ctest --test-dir build --output-on-failure -E "invasive|online"
}

package() {
  depends+=(libssh2.so)

  DESTDIR="$pkgdir" cmake --install build
  install -vDm 644 $pkgname-$pkgver/{AUTHORS,README.md} -t "$pkgdir/usr/share/doc/$pkgname"

}

#---- license gpg-key sha256sums ----

license=(GPL2)

sha256sums=(8de872a0f201b33d9522b817c92e14edb4efad18dae95cf156cf240b2efff93e # libgit2-1.5.0.tar.gz
	8e232d3ac6ba756d6055aaccca9d5704417fe77f53ad91898ffbe1b1439523aa) # libgit2-1.5.0-remove_http-parse_incompatible_tests.patch

 
