# -*- 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
PortGroup           openssl 1.0

github.setup        libimobiledevice idevicerestore 1.0.0
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            2

categories          devel

license             LGPL-3
maintainers         {i0ntempest @i0ntempest} openmaintainer

description         A command-line application to restore firmware files to iOS devices.

long_description    The idevicerestore application is a full reimplementation of all granular steps which \
                    are performed during the restore of a firmware to a device. In general, upgrades and \
                    downgrades are possible, however subject to availability of SHSH blobs from Apple for \
                    signing the firmare files. Some key features are:\
                    \n* Restore: Update firmware on iOS devices\
                    \n* Firmware: Use official IPSW firmware archive file or a directory as source\
                    \n* Update: Allows updating the device by default or erasing all data\
                    \n* Download: On demand download of latest available firmware for a device\
                    \n* Cache: Downloaded firmware files are cached locally\
                    \n* Custom Firmware: Restore custom firmware files (requires bootrom exploit)\
                    \n* Baseband: Allows you to skip NOR/Baseband upgrade\
                    \n* SHSH: Fetch TSS records and save them as ".shsh" files\
                    \n* DFU: Put devices in pwned DFU mode (limera1n devices only)\
                    \n* AP Ticket: Use custom AP ticket from a file\
                    \n* Cross-Platform: Tested on Linux, macOS, Windows and Android platforms\
                    \n* History: Developed since 2010

homepage            https://www.libimobiledevice.org/

checksums           rmd160  f774ac598099e965bf4e9dcad53078e6dab66479 \
                    sha256  76ee2570745f9e876f89acf82ad91edf6e9083e08ceea429985a480cae1ddd67 \
                    size    106889

if {${subport} eq ${name}} {
    patchfiles          patch-postrelease-fixes.diff
}

depends_build-append \
                    port:autoconf \
                    port:automake \
                    port:libtool \
                    port:pkgconfig

depends_lib-append  path:lib/pkgconfig/libusb-1.0.pc:libusb \
                    port:curl \
                    port:libimobiledevice \
                    port:libirecovery \
                    port:libplist \
                    port:libzip \
                    port:readline \
                    port:zlib

configure.cmd       ./autogen.sh

subport idevicerestore-devel {
    github.setup    libimobiledevice idevicerestore 8a5abb99170b324b0fc5a00928ba2ac78a7afc98
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    version         20231126
    revision        0

    checksums       rmd160  64a472b9a29358e5f0b80eff6c53bc2709589d1c \
                    sha256  ea2732b521c368cb1b6a3d83680cfacfd964ad67a53cb1ea43039aad64534550 \
                    size    119655

    depends_lib-replace port:libimobiledevice \
                        port:libimobiledevice-devel
    depends_lib-replace port:libplist port:libplist-devel
    depends_lib-replace port:libirecovery port:libirecovery-devel

    conflicts       idevicerestore

    post-extract {
        system -W ${worksrcpath} "echo ${version} > .tarball-version"
    }

    livecheck.url   ${github.homepage}/commits/${github.livecheck.branch}.atom
}

if {${subport} eq ${name}} {
    conflicts       idevicerestore-devel
}
