# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=czkawka
pkgver=6.1.0
pkgrel=0
pkgdesc="Multi functional app to find duplicates, empty folders, similar images etc. (CLI)"
url="https://github.com/qarmin/czkawka"
arch="x86_64 armv7 armhf aarch64 x86 ppc64le"  # limited by rust/cargo
license="MIT"
makedepends="
	alsa-lib-dev
	bzip2-dev
	cargo
	cargo-auditable
	gtk4.0-dev
	"
checkdepends="cmd:xvfb-run"
subpackages="$pkgname-gui $pkgname-doc"
source="https://github.com/qarmin/czkawka/archive/$pkgver/czkawka-$pkgver.tar.gz"
options="net" # fetch dependencies


prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --frozen --release
}

check() {
	# Tests must be run inside an X11 or Wayland session.
	xvfb-run cargo test --frozen
}

package() {
	install -D -m 755 target/release/czkawka_cli "$pkgdir"/usr/bin/czkawka
	ln -s czkawka "$pkgdir"/usr/bin/czkawka_cli

	install -D -m 644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}

gui() {
	pkgdesc="${pkgdesc/CLI/GUI}"
	license="$license AND CC-BY-4.0"

	cd "$builddir"

	install -D -m 755 ./target/release/czkawka_gui -t "$subpkgdir"/usr/bin/

	install -D -m 644 ./data/icons/com.github.qarmin.czkawka.svg \
		-t "$subpkgdir"/usr/share/icons/hicolor/scalable/apps/

	install -D -m 644 ./data/com.github.qarmin.czkawka.desktop \
		-t "$subpkgdir"/usr/share/applications/

	install -D -m 644 ./data/com.github.qarmin.czkawka.metainfo.xml \
		-t "$subpkgdir"/usr/share/metainfo/
}

sha512sums="
42c0017988c308afc8187f3b375af2990f508cce7b847955ac6e4f2cb928cb306cd42267f85bba11bf31cb71ff9d23b9333634af4df89a62abcaf80fddf1a8c8  czkawka-6.1.0.tar.gz
"
