# Template file for 'libmediainfo'
pkgname=libmediainfo
version=22.12
revision=1
_tests_commit=983666091bee260198d8426e2045f1aca85e5e2f
build_wrksrc=Project/GNU/Library
build_style=gnu-configure
configure_args="--enable-shared --disable-static --with-libcurl --with-libmms"
hostmakedepends="automake libtool pkg-config"
makedepends="libcurl-devel libmms-devel libzen-devel"
checkdepends="git libxml2 nodejs libxml2"
short_desc="Shared library for mediainfo"
maintainer="John <me@johnnynator.dev>"
license="BSD-2-Clause"
homepage="https://mediaarea.net/MediaInfo"
distfiles="https://mediaarea.net/download/source/libmediainfo/${version}/${pkgname}_${version}.tar.xz"
checksum=0fc6d32f06d6ce5e144074d2e57e0db8dfa4e38e752d3123ada27ccaf89634bc
skip_extraction="mediatrace.xsd
 micromediatrace.xsd
 mediainfo.xsd
 mediaarea.xsd"

if [ "$XBPS_CHECK_PKGS" ]; then
	distfiles+="
	 https://github.com/MediaArea/MediaAreaXml/raw/master/mediatrace.xsd
	 https://github.com/MediaArea/MediaAreaXml/raw/master/micromediatrace.xsd
	 https://mediaarea.net/mediainfo/mediainfo_2_0.xsd>mediainfo.xsd
	 https://github.com/MediaArea/MediaAreaXml/raw/master/mediaarea.xsd
	 https://github.com/MediaArea/MediaArea-RegressionTestingFiles/archive/${_tests_commit}.tar.gz"
        checksum+="
	 a11b37a3c421da4b876f3d9394e9b4c5893115e5431774c2f34225753c01a399
	 40ff46f5475cd20e110b92b312ec30196ffe691b84f355e6a8923a038df4ed39
	 adb4bdb1b354299b95c8484a6ffeafe06614de29a0fd070caff3d7b059f89b4b
	 14faa6e04046c49952c9405266a21bf6fb0e4ad56a13232a5bfe3c9dbdfe9a8f
	 ba4ab436ce514d99e9c7cbfc46d844c597bfec0a986d49b441d62385561c0e0d"
fi

post_extract() {
	if [ "$XBPS_CHECK_PKGS" ]; then
		mv ../MediaArea-RegressionTestingFiles-${_tests_commit} "${wrksrc}/${build_wrksrc}/test/Files"
		for f in mediatrace.xsd micromediatrace.xsd mediainfo.xsd mediaarea.xsd; do
			cp "${XBPS_SRCDISTDIR}/${pkgname}-${version}/$f" "${wrksrc}/${build_wrksrc}/test/$f"
		done
	fi
}

pre_check() {
	npm install jsonlint
	export PATH="$PATH:${wrksrc}/${build_wrksrc}/node_modules/.bin/"
}

pre_configure() {
	autoreconf -fi
}

post_install() {
	for i in MediaInfo MediaInfoDLL; do
		install -Dm644 ${wrksrc}/Source/$i/*.h -t ${DESTDIR}/usr/include/$i
	done

	sed -i -e 's|Version: |Version: '$version'|g' libmediainfo.pc
	vinstall libmediainfo.pc 644 usr/lib/pkgconfig
	vlicense ${wrksrc}/License.html
}

libmediainfo-devel_package() {
	depends="${makedepends} libmediainfo>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove "usr/lib/*.so"
	}
}
