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

pkgname=grep
pkgver=3.11
pkgrel=01
pkgdesc='A string search utility'
url='https://www.gnu.org/software/grep/'
depends=('glibc' 'pcre2')
makedepends=('texinfo')
source=("https://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.xz"{,.sig})

prepare() {
  cd $pkgname-$pkgver
  # apply patch from the source array (should be a pacman feature)
  local src
  for src in "${source[@]}"; do
    src="${src%%::*}"
    src="${src##*/}"
    [[ $src = *.patch ]] || continue
    msg2 "Applying patch $src..."
    patch -Np1 < "../$src"
  done
}

build() {
  cd $pkgname-$pkgver
  # configure option --without-included-regex removed in 3.7
  # see: https://lists.gnu.org/archive/html/bug-grep/2021-08/msg00028.html
  ./configure --prefix=/usr
  make
}

check() {
  cd $pkgname-$pkgver
  make check
}

package() {
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install
}

#---- arch license gpg-key & sha256sums ----

arch=(x86_64)

license=('GPL3')

validpgpkeys=('155D3FC500C834486D1EEA677FD9FCCB000BEEEE') # Jim Meyering

sha256sums=(1db2aedde89d0dea42b16d9528f894c8d15dae4e190b59aecc78f5a951276eab  # grep-3.11.tar.xz
	89ec23ffd59b68822732dc8204fc89883c3af30a90ae390feb94346d9d09a589) # grep-3.11.tar.xz.sig

##  3187a4688eb73aff2cc69cda00a0773cf97cc52e301d6229b03fac0f62b29b0d  grep-3.11-01-x86_64.pkg.tar.lz
