#!/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 |---------------------------------------

pkgbase=unrar
pkgname=(unrar libunrar)
pkgver=6.2.6
pkgrel=01
epoch=1
arch=(x86_64)
url='https://www.rarlab.com/rar_add.htm'
source=(https://www.rarlab.com/rar/unrarsrc-$pkgver.tar.gz)

#prepare() {
#  sed -e '/CXXFLAGS=/d' -e '/LDFLAGS=/d' -i unrar/makefile # Use system build flags
#}

build() {
  cp -a unrar libunrar
  export LDFLAGS+=' -pthread'
  make -C libunrar lib
  make -C unrar -j1
}

package_unrar() {
  pkgdesc='The RAR uncompression program'
  depends=(gcc-libs)
  cd unrar
  install -Dm755 unrar -t "$pkgdir"/usr/bin/
  # install license
  install -Dm644 license.txt "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

package_libunrar() {
  pkgdesc='Library and header file for applications that use libunrar'
  depends=(gcc-libs)
  cd libunrar
  install -Dm755 libunrar.so -t "$pkgdir"/usr/lib/
  install -Dm644 dll.hpp -t "$pkgdir"/usr/include/unrar/
  # install license
  install -Dm644 license.txt "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

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

license=(custom)

sha256sums=(0c2d4cbc8b34d0e3bec7b474e0f52bbcc6c4320ec089b4141223ee355f63c318) # unrarsrc-6.2.6.tar.gz

##  c67e80bc698f09d6c0475abc48effeceb44a79420efbd848aacd88d104e777cd  unrar-1:6.2.6-01-x86_64.pkg.tar.lz
##  d753610bdb5575a4b05ef67d0b00fde1f49a79b0f320f33ec2ec65edbe1652cb  libunrar-1:6.2.6-01-x86_64.pkg.tar.lz

