# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=sleuthkit
pkgver=4.12.1
pkgrel=0
pkgdesc="File system and media management forensic analysis tools"
arch="all"
license="custom"
depends="perl"
url="http://www.sleuthkit.org/sleuthkit"
makedepends="autoconf automake libtool sqlite-dev"
checkdepends="bash"
options="libtool"
subpackages="$pkgname-static $pkgname-dev $pkgname-libs $pkgname-doc"
source="https://github.com/sleuthkit/sleuthkit/archive/sleuthkit-$pkgver.tar.gz
	20_disable_failing_tests.patch
	30_fix-manpages.patch
	40_no_static_ldflags.patch
	50_disable_ant_clean.patch
	"
builddir="$srcdir"/$pkgname-$pkgname-$pkgver
# secfixes:
#   4.8.0-r1:
#     - CVE-2020-10232
#     - CVE-2020-10233

prepare() {
	default_prepare
	sh bootstrap
}

build() {
	# https://github.com/sleuthkit/sleuthkit/issues/642
	export CFLAGS="$CFLAGS -DHAVE_LIBEWF_V2_API -Dlibewf_handle_read_random=libewf_handle_read_buffer_at_offset"
	export CXXFLAGS="$CXXFLAGS -Wno-error=cpp"
	./configure --prefix=/usr
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	install -d "$pkgdir"/usr/share/licenses/$pkgname
	install -Dm0644 licenses/* "$pkgdir"/usr/share/licenses/$pkgname
}

sha512sums="
9c8542c836882189a1d910e714b8a96d8f74fd61ab0d7a74bbef7e85aab88312bd01eecf655374eed60c741c23899a321e9b12f019afa04f49726ec51d174e83  sleuthkit-4.12.1.tar.gz
26b197688a2ae1b6b3224ace5cb61272f7ca61c33c672545ebfff2f54de8e39657ce13a2fed8f8e74305b41b3e9af4bb480d10cdcf267a5eba1d93771e446a7c  20_disable_failing_tests.patch
4b68367bff62c731c09ab9a95f810b11562f0942021825226ca8d5e846e54c64004f77ac587ea0377bcb5c50c9dcb33dba1caa8cffd717076cc13c9931dd2c9c  30_fix-manpages.patch
e0421b2fc4bb1d04d3bdb13805d060b386f700586d9e33728185eaff26eef14d5fdbf89979fb5d898dfeee7467f891b5d3c33441f9cb35af5f93d3d576e7cc26  40_no_static_ldflags.patch
cb0d17840f1b4570da1ee0d092f8716a7e073463658d4a7b1cddb74058c5eccf316fcbd2e7c5fba3af0f0adaaabe4e395bd5a41aa1438be615edacb8c6efd89d  50_disable_ant_clean.patch
"
