# -*- 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                    rar
version                 7.20
categories              archivers
license                 Restrictive
installs_libs           no
homepage                https://www.rarlab.com
master_sites            ${homepage}/rar/
maintainers             {i0ntempest @i0ntempest} openmaintainer

supported_archs         x86_64 arm64

description             the official RAR archiver utility
long_description        ${name} is ${description}, providing complete support for RAR and ZIP archives and is able to unpack\
                        CAB, ARJ, LZH, TAR, GZ, UUE, BZ2, JAR, ISO, 7Z, XZ, Z archives.

if {${build_arch} eq "x86_64"} {
    # file name is "x64" for x86_64
    set arch_filename   x64
    checksums           rmd160  e09c3390d17d54a30b6a0b515a5cdcd618449c7f \
                        sha256  2e12d8f64b93b30702e38ddae4bfb063b9c73888599fa0aac8a5aa99f8d766de \
                        size    745282
} else {
    # file name is "arm" for arm64
    set arch_filename   arm
    checksums           rmd160  ab326b19157aee6de8b75ef79c6849daf6e0c2f2 \
                        sha256  e0e363c8f7b48f0dad54deabd1dc462a300ab740226e9eb2c091edbd2e05bd4a \
                        size    669373
}

distname                ${name}macos-${arch_filename}-[string map {. ""} ${version}]
extract.rename          yes

use_configure           no
build                   {}

destroot {
    xinstall -m 0755 ${worksrcpath}/${name} ${destroot}${prefix}/bin
    xinstall -d ${destroot}${prefix}/share/${name}
    xinstall -m 0644 -W ${worksrcpath} \
        {*}[glob -tails -directory ${worksrcpath} *.txt] default.sfx rarfiles.lst \
        ${destroot}${prefix}/share/${name}
}

livecheck.url       ${homepage}/download.htm
livecheck.regex     "RAR for macOS ARM (\\d+(?:\\.\\d+)*)"
