# -*- 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

github.setup        dbeaver dbeaver 25.3.2
github.tarball_from releases
revision            0
name                dbeaver-community

categories          databases
supported_archs     x86_64 arm64
license             Apache-2

maintainers         {judaew @judaew} {mascguy @mascguy} openmaintainer

description         Free multi-platform database tool for developers, SQL \
                    programmers, database administrators and analysts.
long_description    \
    {*}${description} Supports any database which has JDBC driver (which \
    basically means - ANY database). Has a lot of features including metadata \
    editor, SQL editor, rich data editor, ERD, data export/import/migration, \
    SQL execution plans, etc. Uses plugins architecture and provides \
    additional functionality for the following databases: MySQL/MariaDB, \
    PostgreSQL, Greenplum, Oracle, DB2 LUW, Exasol, SQL Server, Sybase/SAP \
    ASE, SQLite, Firebird, H2, HSQLDB, Derby, Teradata, Vertica, Netezza, \
    Informix, etc.
homepage            https://dbeaver.io/

use_dmg             yes

set dist_x86_64     dbeaver-ce-${version}-macos-x86_64${extract.suffix}
set dist_arm64      dbeaver-ce-${version}-macos-aarch64${extract.suffix}

variant all_arches description {Download files for all arches} {
    distfiles       ${dist_x86_64} \
                    ${dist_arm64}
}

checksums-append \
                    ${dist_x86_64} \
                        rmd160  ae34d60e5854d49ecffd76df9aa9fd9db52f9fe0 \
                        sha256  7a29914bde8ca5e8f70545393b55cf4bfa337b4986c37fb8415d83ad1432ebc5 \
                        size    122577862
checksums-append \
                    ${dist_arm64} \
                        rmd160  d29f3efc22e6388c0a169c27e8766b14cdec8bac \
                        sha256  4bbb1d5c67cbd7a4398485e690cdb675b99f65e487284bf732d86840e60eea7d \
                        size    121424873

switch ${configure.build_arch} {
    x86_64 {
        distfiles   ${dist_x86_64}
    }
    arm64 {
        distfiles   ${dist_arm64}
    }
    default {
        known_fail  yes
        pre-fetch {
            ui_error "${subport} @ ${version} only supported for architectures ${supported_archs}"
            return -code error "Unsupported architecture: ${build_arch}"
        }
    }
}

use_configure       no

build {}

destroot {
    copy ${worksrcpath}/DBeaver.app ${destroot}${applications_dir}
}
