# Description: Multi functional app to find duplicates, empty folders, similar images etc
# URL: https://github.com/qarmin/czkawka
# Maintainer: Tim Biermann, tbier at posteo dot de
# Depends on: rust
# Optional: gtk4

name=czkawka
version=6.0.0
release=1
source=(https://github.com/qarmin/czkawka/archive/$version/$name-$version.tar.gz)

build() {
  prt-get isinst sccache && export RUSTC_WRAPPER=/usr/bin/sccache
  mkdir "$PKGMK_SOURCE_DIR/rust" || true
  export CARGO_HOME="$PKGMK_SOURCE_DIR/rust"

  cargo build --bin czkawka_cli --release --manifest-path $name-$version/Cargo.toml
  install -Dt $PKG/usr/bin $name-$version/target/release/${name}_cli

  if prt-get isinst gtk4; then
    cargo build --bin czkawka_gui --release --locked --manifest-path $name-$version/Cargo.toml
    install -Dm644 $SRC/czkawka-$version/data/com.github.qarmin.czkawka.desktop \
      $PKG/usr/share/applications/com.github.qarmin.czkawka.desktop
    install -Dm644 $SRC/czkawka-$version/data/icons/com.github.qarmin.czkawka.svg \
      $PKG/usr/share/icons/hicolor/scalable/apps/com.github.qarmin.czkawka.svg
    install -Dm644 $SRC/czkawka-$version/data/icons/com.github.qarmin.czkawka.Devel.svg \
      $PKG/usr/share/icons/hicolor/scalable/apps/com.github.qarmin.czkawka.Devel.svg
    install -Dm644 $SRC/czkawka-$version/data/icons/com.github.qarmin.czkawka-symbolic.svg \
      $PKG/usr/share/icons/hicolor/scalable/apps/com.github.qarmin.czkawka-symbolic.svg
    install -Dm644 $SRC/czkawka-$version/data/com.github.qarmin.czkawka.metainfo.xml \
      $PKG/usr/share/metainfo/com.github.qarmin.czkawka.metainfo.xml
    install -Dt $PKG/usr/bin $name-$version/target/release/${name}_gui
  fi
}
