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

name                    helm
categories              sysutils
license                 Apache-2
maintainers             {ogsite.net:sirn @sirn} \
                        {gmail.com:herby.gillot @herbygillot} \
                        openmaintainer

subport helm_select     {}

# *NOTE* Remember to update `latestVersion` on a version upgrade.
set latestVersion       helm-4.2

set armAvailable        no

proc helmVersion {} {
    global baseVersion
    global patchNumber
    return ${baseVersion}.${patchNumber}
}

proc helmDistBase {arch} {
    return helm-v[helmVersion]-darwin-${arch}
}

proc helmDistName {arch} {
    global extract.suffix
    return [helmDistBase ${arch}]${extract.suffix}
}

subport helm-4.2 {
    set baseVersion     4.2
    set patchNumber     2
    revision            0

    set armAvailable    yes

    checksums           [helmDistName arm64] \
                        rmd160  01fdc976950405db30b4cbe6c2050c43e6ea665f \
                        sha256  5410a0dae3d5d91f45653b161260d9301aabc4ae80ae50a6605d66884b6df8ea \
                        size    18369011 \
                        [helmDistName amd64] \
                        rmd160  6dbbdbf5e98afc071336bb1df02c5d333a44dca2 \
                        sha256  10c1e36ee8c5f2e2ee25a16599cb03ab74c0953cd889cacb980a49ba4b6574ba \
                        size    20200021

}

subport helm-4.1 {
    set baseVersion     4.1
    set patchNumber     4
    revision            0

    set armAvailable    yes

    checksums           [helmDistName arm64] \
                        rmd160  b0f2aec1c50e9c64ac75e2b37371b36a6b7e4289 \
                        sha256  7c2eca678e8001fa863cdf8cbf6ac1b3799f9404a89eb55c08260ef5732e658d \
                        size    17986898 \
                        [helmDistName amd64] \
                        rmd160  88182be59ab6476b9e62b6ac789ba93a3f1f89b3 \
                        sha256  abf09c8503ad1d8ef76d3737a058c3456a998aae5f5966fce4bb3031aeb1654e \
                        size    19705342

}

subport helm-4.0 {
    set baseVersion     4.0
    set patchNumber     5
    revision            0

    set armAvailable    yes

    checksums           [helmDistName arm64] \
                        rmd160  3769b43f909369a1cb7efc2ea726b8932a242963 \
                        sha256  b4d04ccf68004604e13878fce4a893711490914512f8759879f848136a9f5fca \
                        size    18585894 \
                        [helmDistName amd64] \
                        rmd160  fd506b46eddd95bd4661fddd537f923eb02c8fd9 \
                        sha256  270d906140eadbe95584d2cebae1fa0e46950027d82de0c4db937dc936b564a6 \
                        size    20325953
}

subport helm-3.21 {
    set baseVersion     3.21
    set patchNumber     2
    revision            0

    set armAvailable    yes

    checksums           [helmDistName arm64] \
                        rmd160  91eff026c93de5bcdd66d8973a50cfab31506d7c \
                        sha256  aea537342b4c03cf58e089cb8dc99468087bb1a0218531df40462faca3f6c5d3 \
                        size    16532537 \
                        [helmDistName amd64] \
                        rmd160  9bf06863fde8f8c73a0b6676a1e2fec4cf84b3ee \
                        sha256  82ac9105e657267cb029b5bf27ed28e35db104777328a036a84d345046f9f329 \
                        size    18171575
}

subport helm-3.20 {
    set baseVersion     3.20
    set patchNumber     2
    revision            0

    set armAvailable    yes

    checksums           [helmDistName arm64] \
                        rmd160  fcc2264c426defd8648edbf3b1d2bd9dac50ea78 \
                        sha256  139c794c22f16b579d08ddd3008c8038b9bb2814f35b5bcca91f50a1f458978d \
                        size    16242831 \
                        [helmDistName amd64] \
                        rmd160  8bc857a52f44574777e16059ab10fdb82982f446 \
                        sha256  7de04301f28b902a74f6286ed941cadc86ee5e6a9086a18f2ccf1f548e99d618 \
                        size    17792817
}

subport helm-3.19 {
    set baseVersion     3.19
    set patchNumber     5
    revision            0

    set armAvailable    yes

    checksums           [helmDistName arm64] \
                        rmd160  348f2539b2ec039a3d0c2791de2da5d0d6ae161d \
                        sha256  195e24e587f423f15a78feebab04583ceee68323598575a0e8b3b11b43fd26fe \
                        size    17061257 \
                        [helmDistName amd64] \
                        rmd160  5da3437d0fb23e0400360648fea6c4caa15f945f \
                        sha256  57f4a847c349382b7cc742a6434ef25f88f0928a113d8cf49084b464878ef0b9 \
                        size    18369542
}

subport helm-3.18 {
    set baseVersion     3.18
    set patchNumber     6
    revision            0

    set armAvailable    yes

    checksums           [helmDistName arm64] \
                        rmd160  5d69dd4a40bfc122e4e66a567f308425ec8b59b4 \
                        sha256  48e30d236a1f334c6acb78501be5a851eaa2a267fefeb1131b6484eb2f9f30d7 \
                        size    17032674 \
                        [helmDistName amd64] \
                        rmd160  babb23fc9afc7b329d6baf0540a0d0b571242317 \
                        sha256  80cad0470e38cf25731cdead7c32dfbeb887bc177bd6fa01e31b065722f8f06b \
                        size    18340044
}

subport helm-3.17 {
    set baseVersion     3.17
    set patchNumber     4
    revision            0

    set armAvailable    yes

    checksums           [helmDistName arm64] \
                        rmd160  c7941b079c9a872a7f535b16f1413a055d8c3619 \
                        sha256  f4732719827a76452035641629aa92091adc4a9f1ccbc8d53a729b53e0add869 \
                        size    16649548 \
                        [helmDistName amd64] \
                        rmd160  d9477ca45d1644562aa9e24086da020842191802 \
                        sha256  6dfce5d8b09442205393068f5c911b8f20958edd5b67cc26f7eb3330f93225f1 \
                        size    17831253
}

subport helm-3.16 {
    set baseVersion     3.16
    set patchNumber     4
    revision            0

    set armAvailable    yes

    checksums           [helmDistName arm64] \
                        rmd160  eed46682f35249c76575c0db05474559db442d77 \
                        sha256  e2442d8f05d53d84c39b869bc5fe5affad247ee2f4c706a040919c146edb1f94 \
                        size    16515853 \
                        [helmDistName amd64] \
                        rmd160  320653e2a1b987cd6aacf8812536e54e4e510d89 \
                        sha256  8dc25671120a4af197afe7ad9041fb8e1dd71bc01e5ef73dba1139cbc9e9f44b \
                        size    17683741
}

subport helm-3.15 {
    set baseVersion     3.15
    set patchNumber     4
    revision            0

    set armAvailable    yes

    checksums           [helmDistName arm64] \
                        rmd160  9baf932162a38bb5dee7a3462e49a18a08832721 \
                        sha256  88115846a1fb58f8eb8f64fec5c343d95ca394f1be811602fa54a887c98730ac \
                        size    15757510 \
                        [helmDistName amd64] \
                        rmd160  c77b871e8ae5de04e6dbdb26fe878ecc6285d301 \
                        sha256  1bc3f354f7ce4d7fd9cfa5bcc701c1f32c88d27076d96c2792d5b5226062aee5 \
                        size    16948392
}

subport helm-3.14 {
    set baseVersion     3.14
    set patchNumber     4
    revision            0

    set armAvailable    yes

    checksums           [helmDistName arm64] \
                        rmd160  29136a00dd08758850e8b102696f268a3c48e01b \
                        sha256  61e9c5455f06b2ad0a1280975bf65892e707adc19d766b0cf4e9006e3b7b4b6c \
                        size    16128955 \
                        [helmDistName amd64] \
                        rmd160  7b942c0651f706fd07880d1e6da1779b4f27d1bf \
                        sha256  73434aeac36ad068ce2e5582b8851a286dc628eae16494a26e2ad0b24a7199f9 \
                        size    16974410
}

subport helm-3.13 {
    set baseVersion     3.13
    set patchNumber     3
    revision            0

    set armAvailable    yes

    checksums           [helmDistName arm64] \
                        rmd160  63f4c6484e775617ca8cc669f754269620bfff1c \
                        sha256  61ba210cd65c53be5c0021c8fc8e0b94f4c122aff32f5ed0e4ea81728108ea20 \
                        size    16172665 \
                        [helmDistName amd64] \
                        rmd160  ddb038ca0bcbefb8c0a6a93eadf90334183dd3b3 \
                        sha256  da654c9e0fd4fcb50cc5dba051c1c9cf398e21ffa5064b47ac89a9697e139d39 \
                        size    16999788
}

subport helm-3.12 {
    set baseVersion     3.12
    set patchNumber     3
    revision            0

    set armAvailable    yes

    checksums           [helmDistName arm64] \
                        rmd160  9a5e9c6fe7cd5da6afbc6c41c6e7a1a75e23adb1 \
                        sha256  240b0a7da9cae208000eff3d3fb95e0fa1f4903d95be62c3f276f7630b12dae1 \
                        size    16019570 \
                        [helmDistName amd64] \
                        rmd160  03b0eb4e1b01ad03efc37862fb6990895159398f \
                        sha256  1bdbbeec5a12dd0c1cd4efd8948a156d33e1e2f51140e2a51e1e5e7b11b81d47 \
                        size    16828211
}

subport helm-3.11 {
    set baseVersion     3.11
    set patchNumber     3
    revision            0

    set armAvailable    yes

    checksums           [helmDistName arm64] \
                        rmd160  7d3c03bc1fce7920c5ea7410677e34e129bf5506 \
                        sha256  267e4d50b68e8854b9cc44517da9ab2f47dec39787fed9f7eba42080d61ac7f8 \
                        size    15451086 \
                        [helmDistName amd64] \
                        rmd160  2f169d9c040f71334853600d314edcbecb4ccbb4 \
                        sha256  9d029df37664b50e427442a600e4e065fa75fd74dac996c831ac68359654b2c4 \
                        size    16275303
}

subport helm-3.10 {
    set baseVersion     3.10
    set patchNumber     3
    revision            0

    set armAvailable    yes

    checksums           [helmDistName arm64] \
                        rmd160  87de6f68f36bdb107b570a6dcae9616f886df05a \
                        sha256  4f3490654349d6fee8d4055862efdaaf9422eca1ffd2a15393394fd948ae3377 \
                        size    14482164 \
                        [helmDistName amd64] \
                        rmd160  ecd09022e7e7fb05fde4144c73caabdfdec6b119 \
                        sha256  77a94ebd37eab4d14aceaf30a372348917830358430fcd7e09761eed69f08be5 \
                        size    15274709
}

subport helm-3.9 {
    set baseVersion     3.9
    set patchNumber     4
    revision            0

    set armAvailable    yes

    checksums           [helmDistName arm64] \
                        rmd160  7bad284b961bf54b772f13f8c52701ababdabab1 \
                        sha256  a73d91751153169781b3ab5b4702ba1a2631fc8242eba33828b5905870059312 \
                        size    14494646 \
                        [helmDistName amd64] \
                        rmd160  789518b58cd2b7505f2703134b1c39043da2be90 \
                        sha256  fe5930feca6fd1bd2c57df01c1f381c6444d1c3d2b857526bf6cbfbd6bf906b4 \
                        size    14728714
}

subport helm-3.8 {
    set baseVersion     3.8
    set patchNumber     2
    revision            0

    set armAvailable    yes

    checksums           [helmDistName arm64] \
                        rmd160  85c5371ce7c99218080484fbbce7bbb3a910425b \
                        sha256  dfddc0696597c010ed903e486fe112a18535ab0c92e35335aa54af2360077900 \
                        size    14086490 \
                        [helmDistName amd64] \
                        rmd160  77a4e6bf6e484a5dd8568409853081deef3d4e54 \
                        sha256  25bb4a70b0d9538a97abb3aaa57133c0779982a8091742a22026e60d8614f8a0 \
                        size    14317429
}

subport helm-3.7 {
    set baseVersion     3.7
    set patchNumber     2
    revision            3

    set armAvailable    yes

    
    checksums           [helmDistName arm64] \
                        rmd160  903cf44fa466a1901aaa21a1b40c595041d153c6 \
                        sha256  260d4b8bffcebc6562ea344dfe88efe252cf9511dd6da3cccebf783773d42aec \
                        size    13978034 \
                        [helmDistName amd64] \
                        rmd160  51cfcf1a0bffeba102afffe8333bebd875a11e94 \
                        sha256  5a0738afb1e194853aab00258453be8624e0a1d34fcc3c779989ac8dbcd59436 \
                        size    14529117
}

subport helm-3.6 {
    set baseVersion     3.6
    set patchNumber     3
    revision            3

    set armAvailable    yes

    checksums           [helmDistName arm64] \
                        rmd160  695a17118869a5aced451048907ed27cc59a3cdd \
                        sha256  a50b499dbd0bbec90761d50974bf1e67cc6d503ea20d03b4a1275884065b7e9e \
                        size    13810693 \
                        [helmDistName amd64] \
                        rmd160  8082929fd4afea08cc40d11fcb9cf1f33347f2ef \
                        sha256  84a1ff17dd03340652d96e8be5172a921c97825fd278a2113c8233a4e8db5236 \
                        size    14356954
}

subport helm-3.5 {
    set baseVersion     3.5
    set patchNumber     4
    revision            0
    checksums           rmd160  bc390477253c4bc8f3fe71e62f50e883430b2792 \
                        sha256  072c40c743d30efdb8231ca03bab55caee7935e52175e42271a0c3bc37ec0b7b \
                        size    13052607
}

subport helm-3.4 {
    set baseVersion     3.4
    set patchNumber     2
    revision            0
    checksums           rmd160  761552971c5a60307ce66c3caae40102c626f952 \
                        sha256  c33b7ee72b0006f23b33f5032b531dd609fff7b08a4324f9ba07722a4f3fec9a \
                        size    13987793
}

subport helm-3.3 {
    set baseVersion     3.3
    set patchNumber     4
    revision            0
    checksums           rmd160  7ff3dfb382044aa3f4c4f7b11ac61dd1dcbda73f \
                        sha256  9fffc847c61da0e06319788d3998ea173eb86c1cc5600ac3ada8d0d40c911793 \
                        size    13384835
}

subport helm-3.2 {
    set baseVersion     3.2
    set patchNumber     4
    revision            0
    checksums           rmd160  13a3665b175529dbc5c6ca7917b5985b305c1cb2 \
                        sha256  603bc2da184b69e6303a15baf037f55f44de7359d0ba84151459ddc7a20851a8 \
                        size    13578611
}

subport helm-3.1 {
    set baseVersion     3.1
    set patchNumber     1
    revision            0
    checksums           rmd160  7324750fb10656b9b4a686620e461a41e6f4e1d8 \
                        sha256  2ce00e6c44ba18fbcbec21c493476e919128710d480789bb35bd228ae695cd66 \
                        size    12889373
}

subport helm-3.0 {
    set baseVersion     3.0
    set patchNumber     3
    revision            0
    checksums           rmd160  85b53300b25820dc6588af92e6041d6c01261caf \
                        sha256  5e27bc6ecf838ed28a6a480ee14e6bec137b467a56f427dbc3cf995f9bdcf85c \
                        size    12716418
}

subport helm-2.17 {
    set baseVersion     2.17
    set patchNumber     0
    revision            0
    checksums           rmd160  aabf1de19972e37ac39854677987274612328b34 \
                        sha256  104dcda352985306d04d5d23aaf5252d00a85c083f3667fd013991d82f57ae83 \
                        size    26358642
}

subport helm-2.16 {
    set baseVersion     2.16
    set patchNumber     12
    revision            0
    checksums           rmd160  b15d6040bb5ee8e64f274304ea28b4598ace5eb8 \
                        sha256  cd36888b5c89e0fb7f9f336e1e286773ad15e9a8fa16e3b8ef34b10347341cf4 \
                        size    26363838
}

subport helm-2.15 {
    set baseVersion     2.15
    set patchNumber     2
    revision            0
    checksums           rmd160  2f0790dbe10ccebd724f43d5e0f3533b0c389ee1 \
                        sha256  0815dc44f9f1c5bcee1c130268bfca2ddf6425b60cf042d3b3c907c35ef11e31 \
                        size    25747450
}

subport helm-2.14 {
    set baseVersion     2.14
    set patchNumber     2
    revision            0
    checksums           rmd160  002bdedc70c51fd03ba76fbbe31c3e509ee0c11e \
                        sha256  9469da75bb357bc325c985dead224480bbacc7aa8aecff74089dff97e64655d0 \
                        size    27862805
}

subport helm-2.13 {
    set baseVersion     2.13
    set patchNumber     1
    revision            0
    checksums           rmd160  33f9f56bc0cc1ce4a47f863f8ba278bfa02431ba \
                        sha256  c9564c4133349b98a8c1dda42fdb6545f6e4bfdf0980cdfc38cf76d2f8e5e701 \
                        size    24089303
}

subport helm-2.12 {
    set baseVersion     2.12
    set patchNumber     3
    revision            0
    checksums           rmd160  8676268e53e3d21c1ca3216db8684ea3b68c4ba0 \
                        sha256  564a087915e07333d2335face555eaac63accd669fb63672ae1b66a73144ac50 \
                        size    23867687
}

if {${subport} == ${name}} {
    PortGroup           obsolete 1.0

    replaced_by         ${latestVersion}
    version             4.2.2
    revision            0

} elseif {${subport} == "helm_select"} {
    version             0.0
    revision            0
    supported_archs     noarch
    platforms           any

    description         Common files for selecting default Helm version
    long_description    This port installs files that allow 'port select' \
                        to create links to the preferred default version \
                        of Helm/Tiller.
    homepage            https://www.macports.org/

    distfiles
    use_configure       no
    build {}

    destroot {
        select::install helm ${filespath}/base
        select::install helm ${filespath}/none
    }

    livecheck.type     none

} else {
    PortGroup           github 1.0

    supported_archs     x86_64

    depends_run         port:helm_select

    set patchVersion    ${baseVersion}.${patchNumber}
    set baseName        helm${baseVersion}
    github.setup        helm helm ${patchVersion} v
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball

    description         Kubernetes package manager
    long_description    Helps you manage Kubernetes applications — Helm Charts \
                        help you define, install, and upgrade even the most \
                        complex Kubernetes application.

    master_sites        https://get.helm.sh/
    distname            [helmDistBase amd64]

    if ${armAvailable} {
        supported_archs arm64 x86_64

        if {${build_arch} eq "arm64"} {
            distname    [helmDistBase arm64]
        }
    }

    use_configure       no

    select.group        helm
    select.file         ${filespath}/${baseName}

    build {}

    destroot {
        xinstall ${worksrcpath}/helm ${destroot}${prefix}/bin/helm${baseVersion}
        # Starting with helm 3 there is no tiller anymore
        set majorVersion [string index $baseVersion 0]
        if {${majorVersion} == "2" } {
            xinstall ${worksrcpath}/tiller ${destroot}${prefix}/bin/tiller${baseVersion}
        }
    }

    # Skip -rc and other pre-release tags
    set regexVersionPart [string map {. {\.}} $baseVersion]
    github.livecheck.regex  (${regexVersionPart}\\.\\d+)

    notes "
    To make this the default Helm/Tiller (i.e., the version run by the 'helm' or\
    'tiller' commands, Tiller is only present in v2), run:
        sudo port select --set helm ${baseName}
    "
}
