# -*- 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        Poikilos uncrx 94b08ab38ee6634dd6c3a1991e076d42dfc1f6d9
github.tarball_from archive
version             20230113
revision            0
supported_archs     noarch
categories          archivers python
maintainers         {i0ntempest @i0ntempest} openmaintainer
license             Unknown

description         Chromium extension extractor
long_description    Extract Chrome extension 2 or 3 crx packages, downloading if store URL is specified.

checksums           rmd160  57a8f8502052a6df2d2c61550b8d10716eec9e3a \
                    sha256  ae23aa384da80a343204f095e063ae9148551dc92065292586ae3dfe7683f508 \
                    size    3258

pre-configure {
    if {![variant_isset python313] && ![variant_isset python314]} {
        ui_error "${name} requires Python, please use a Python variant."
        return -code error
    }
}

use_configure       no
build {}

destroot {
    xinstall -m 755 ${worksrcpath}/${name}.py ${destroot}${prefix}/bin/${name}
}

proc python-depends {python_branch} {
    set python_version [string map {. ""} ${python_branch}]
    depends_run-append  port:python${python_version}
    post-patch {
        reinplace "s|#!/usr/bin/env python|#!${prefix}/bin/python${python_branch}|" ${worksrcpath}/${name}.py
    }
}

variant python314 conflicts python310 python311 python312 python313 description {Use Python 3.14 as interpreter} {
    set ::python_branch 3.14
    python-depends ${::python_branch}
}

variant python313 conflicts python310 python311 python312 python314 description {Use Python 3.13 as interpreter} {
    set ::python_branch 3.13
    python-depends ${::python_branch}
}

if {![variant_isset python313]} {
    default_variants +python314
}
