# -*- 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.2.3
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  9463cd082751197fac5328be4a8fbadd7f4e4318 \
                        sha256  b48900901727177eec655d991d282a7b73e702a4a853b89846ef2d359f1f85f1 \
                        size    124354325
checksums-append \
                    ${dist_arm64} \
                        rmd160  2731472b51cb68c69a9bc2fd3c046ca3465cd2d2 \
                        sha256  8a6916e03cfca968c828b4fa0af7638488d6a4499f2a4d4c595879f8d1ae8dbe \
                        size    123140610

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}
}
