# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem              1.0
PortGroup               github 1.0
PortGroup               makefile 1.0

github.setup            hashcat hashcat 7.1.2 v
github.tarball_from     archive
revision                0

categories              security
platforms               {darwin >= 19}
license                 MIT
maintainers             @gaming-hacker openmaintainer

description             World's fastest and most advanced password recovery utility.
long_description        hashcat is the world's fastest and most advanced \
                        password recovery utility, supporting five unique modes \
                        of attack for over 200 highly-optimized hashing algorithms. \
                        hashcat currently supports CPUs, GPUs, and other hardware \
                        accelerators on Linux, Windows, and macOS, and has \
                        facilities to help enable distributed password cracking

homepage                https://hashcat.net/hashcat/

build.target            {}

checksums               rmd160  0f547ff9218e81a4db88a8190d931c4bab487b00 \
                        sha256  9546a6326d747530b44fcc079babad40304a87f32d3c9080016d58b39cfc8b96 \
                        size    19125734

set python_branch       3.13
set python_version      [string map {. ""} ${python_branch}]
set perl_version        5.34

depends_lib-append      port:xxhash \
                        port:zlib \
                        port:minizip \
                        port:libiconv \
                        port:python${python_version}

depends_run-append      port:py${python_version}-python-snappy \
                        port:py${python_version}-plyvel \
                        port:py${python_version}-cryptography \
                        port:py${python_version}-pycryptodome \
                        port:py${python_version}-protobuf3 \
                        port:py${python_version}-asn1 \
                        port:perl${perl_version} \
                        port:p${perl_version}-dbd-sqlite

patchfiles-append       patch-remove-arch.patch
post-patch {
    reinplace "s|MACOSX_DEPLOYMENT_TARGET=.\*|MACOSX_DEPLOYMENT_TARGET=${macosx_deployment_target}|" ${worksrcpath}/src/Makefile
    reinplace "s|python3-config|${prefix}/bin/python${python_branch}-config|" {*}[glob ${worksrcpath}/src/bridges/bridge_python_*.mk]
    reinplace -E "s|#! */usr/bin/(env)* *python3*|#!${prefix}/bin/python${python_branch}\\\n|" {*}[glob ${worksrcpath}/tools/*hashcat.py]
    reinplace "s|#! */usr/bin/env *perl|#!${prefix}/bin/perl${perl_version}|" {*}[glob ${worksrcpath}/tools/*hashcat.pl]
}

set build_env {
                        SHARED=1
                        USE_SYSTEM_ZLIB=1
                        USE_SYSTEM_OPENCL=1
                        USE_SYSTEM_XXHASH=1
}

build.env-append        {*}$build_env
destroot.env-append     {*}$build_env

post-destroot {
    xinstall -d ${destroot}${prefix}/share/bash-completion/completions
    xinstall -m 0644 ${worksrcpath}/extra/tab_completion/${name}.sh ${destroot}${prefix}/share/bash-completion/completions/${name}
}
