pkgname=fastfetch
pkgver=2.56.1
pkgdesc="A feature-rich and performance oriented neofetch like system information tool"
homepage="https://github.com/fastfetch-cli/fastfetch"
arch=('x86_64')
license=('MIT')
sources=("${pkgname}-${pkgver}.tar.gz"
  "fastfetch-2.56.1-leaf.patch"
)
urls=("https://github.com/fastfetch-cli/fastfetch/archive/refs/tags/${pkgver}.tar.gz"
  "fastfetch-2.56.1-leaf.patch"
)
md5sums=("352542c153e59434dcedd0aa23d63ebf"
  "12924e7da723d89453d0c53ae4287a99"
)

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
  patch -p1 -i ${distdir}/${sources[1]}
}

src_build() {
  cmake -B build \
    -DCMAKE_BUILD_TYPE='RelWithDebInfo' \
    -DCMAKE_INSTALL_PREFIX='/usr' \
    -DBUILD_FLASHFETCH='OFF' \
    -DBUILD_TESTS='ON' \
    -DENABLE_IMAGEMAGICK6='OFF' \
    -DENABLE_SYSTEM_YYJSON='ON' \
    -DPACKAGES_DISABLE_APK='ON' \
    -DPACKAGES_DISABLE_DPKG='ON' \
    -DPACKAGES_DISABLE_EMERGE='ON' \
    -DPACKAGES_DISABLE_EOPKG='ON' \
    -DPACKAGES_DISABLE_GUIX='ON' \
    -DPACKAGES_DISABLE_LINGLONG='ON' \
    -DPACKAGES_DISABLE_LPKG='ON' \
    -DPACKAGES_DISABLE_LPKGBUILD='ON' \
    -DPACKAGES_DISABLE_OPKG='ON' \
    -DPACKAGES_DISABLE_PACSTALL='ON' \
    -DPACKAGES_DISABLE_PALUDIS='ON' \
    -DPACKAGES_DISABLE_PKG='ON' \
    -DPACKAGES_DISABLE_PKGTOOL='ON' \
    -DPACKAGES_DISABLE_RPM='ON' \
    -DPACKAGES_DISABLE_SORCERY='ON' \
    -DPACKAGES_DISABLE_XBPS='ON' \
    -Wno-dev
  cmake --build build
}

src_check() {
  ctest --test-dir build --output-on-failure
}

src_install() {
  DESTDIR="${pkgdir}" cmake --install build
}
