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

name                iana-enterprise-numbers
version             20260617
categories          net
license             public-domain
maintainers         {dports @drkp} openmaintainer
platforms           any
supported_archs     noarch
installs_libs       no

description         IANA Private Enterprise Number (PEN) registry

long_description    The IANA Private Enterprise Numbers (PEN) registry maps \
                    numeric organizational identifiers, assigned under the \
                    iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) \
                    OID arc, to organization names. Tools such as ipmitool, \
                    net-snmp, and wireshark consume this database to \
                    translate enterprise OIDs to human-readable names. \
                    This port installs the registry as \
                    ${prefix}/share/misc/enterprise-numbers.

homepage            https://www.iana.org/assignments/enterprise-numbers/

set pen_file        enterprise-numbers
set pen_distfile    ${pen_file}-${version}

# The registry is fetched from Lars Eggert's actively-maintained git mirror of
# the IANA assignments, pinned to a specific commit so the downloaded bytes are
# reproducible. The file in the repository is unversioned, so synthesize a
# versioned distfile name by appending a dummy GET parameter.
set pen_commit      62976620bb29267c62c34d9953129048d217ace7
master_sites        macports_distfiles \
                    https://raw.githubusercontent.com/larseggert/iana-assignments/${pen_commit}/${pen_file}/${pen_file}?dummy=

distfiles           ${pen_distfile}

checksums           rmd160  d522caa84d2fb1569d50f3b3b63c43168328c7cf \
                    sha256  25f4161a2e9af76d09c9d97bec71205cf55dfbec6429f25a0189fbe5e743c663 \
                    size    5059654

use_configure       no
build               {}

extract {
    xinstall -d ${worksrcpath}
    file copy ${distpath}/${pen_distfile} ${worksrcpath}/${pen_file}
}

destroot {
    xinstall -d ${destroot}${prefix}/share/misc
    xinstall -m 0644 ${worksrcpath}/${pen_file} \
        ${destroot}${prefix}/share/misc/${pen_file}
}

pre-activate {
    # ipmitool releases prior to 1.8.19_1 installed the same file themselves
    # (https://trac.macports.org/ticket/67161). Deactivate any such version
    # that is currently active so that this port can claim the file.
    if {![catch {set vers [lindex [registry_active ipmitool] 0]}]} {
        set v [lindex $vers 1]
        set r [lindex $vers 2]
        if {[vercmp $v 1.8.19] < 0
            || ([vercmp $v 1.8.19] == 0 && [vercmp $r 1] < 0)} {
            registry_deactivate_composite ipmitool "" \
                [list ports_nodepcheck 1]
        }
    }
}

livecheck.type      regex
livecheck.url       https://www.iana.org/assignments/enterprise-numbers.txt
livecheck.version   [regsub {(....)(..)(..)} ${version} {\1-\2-\3}]
livecheck.regex     {\(last updated (\d{4}-\d{2}-\d{2})\)}
