Ticket #58638: ytdl.diff

File ytdl.diff, 7.1 KB (added by RJVB (René Bertin), 5 years ago)
  • net/youtube-dl/Portfile

    diff --git a/net/youtube-dl/Portfile b/net/youtube-dl/Portfile
    index d5521a64dde..a7bfcf4f0cb 100644
    a b  
    33PortSystem          1.0
    44
    55name                youtube-dl
    6 version             2019.06.08
    7 revision            0
    8 checksums           rmd160  bccdfbfeccbd820dbc6af9157dd3558a0c4faa38 \
    9                     sha256  275a8506ecd6c72589bfc66b749cd80847e7393df1d6e1becd1d11ba90980837 \
    10                     size    3169571
     6version             2019.06.21
     7checksums           rmd160  2034f79f88cebc47db00e66e34c831d862f873a0 \
     8                    sha256  85872e23add44409711bd0eb5620c663d67c578a3df663578ff07f944212470d \
     9                    size    3169975
    1110
    1211categories          net
    1312platforms           darwin
    1413maintainers         {ryandesign @ryandesign} openmaintainer
    1514supported_archs     noarch
     15installs_libs       no
    1616license             public-domain
    1717
    1818description         command-line program to download videos from YouTube.com and other sites
    worksrcdir ${name} 
    2929post-extract {
    3030    # Force the script to be regenerated by `make`.
    3131    delete ${worksrcpath}/${name}
     32    system -W ${worksrcpath} "chmod +x devscripts/make_contributing.py devscripts/make_supportedsites.py"
    3233}
    3334
    34 patchfiles          patch-config-location.diff \
    35                     patch-youtube_dl-update.py.diff
    3635patch.args          --backup
    3736
    3837post-patch {
    post-patch { 
    4342
    4443    # Restore original mtimes of files changed by the patch so that `make` doesn't try to regenerate the documentation with `pandoc`.
    4544    foreach f {youtube_dl/update.py youtube_dl/options.py README.md youtube-dl.1} {
    46         file mtime ${worksrcpath}/${f} [file mtime ${worksrcpath}/${f}.orig]
     45        if {[file exists ${worksrcpath}/${f}.orig]} {
     46            file mtime ${worksrcpath}/${f} [file mtime ${worksrcpath}/${f}.orig]
     47            file delete ${worksrcpath}/${f}.orig
     48        }
    4749    }
    4850}
    4951
    5052use_configure       no
    5153
    52 pre-build {
    53     build.args-append   PYTHON=${configure.python}
    54 }
    55 
    5654destroot.args       PREFIX=${prefix} \
    5755                    MANDIR=${prefix}/share/man \
    5856                    SYSCONFDIR=${prefix}/etc
    variant ffmpeg description {Add ffmpeg dependency, used to extract audio} { 
    6866                            path:bin/ffmpeg:ffmpeg
    6967}
    7068
    71 default_variants    +ffmpeg
     69default_variants            +ffmpeg
     70
     71variant stock conflicts python27 python35 python36 python37 description {pure stock version} {}
    7272
    73 variant python27 conflicts python35 python36 python37 description {Use Python 2.7} {
     73variant python27 conflicts python35 python36 python37 stock description {Use Python 2.7 from MacPorts} {
    7474    depends_run-append      port:python27
    7575    depends_build-append    port:python27
    7676    configure.python        ${prefix}/bin/python2.7
    7777}
    7878
    79 variant python35 conflicts python27 python36 python37 description {Use Python 3.5} {
     79variant python35 conflicts python27 python36 python37 stock description {Use Python 3.5 from MacPorts} {
    8080    depends_run-append      port:python35
    8181    depends_build-append    port:python35
    8282    configure.python        ${prefix}/bin/python3.5
    8383}
    8484
    85 variant python36 conflicts python27 python35 python37 description {Use Python 3.6} {
     85variant python36 conflicts python27 python35 python37 stock description {Use Python 3.6 from MacPorts} {
    8686    depends_run-append      port:python36
    8787    depends_build-append    port:python36
    8888    configure.python        ${prefix}/bin/python3.6
    8989}
    9090
    91 variant python37 conflicts python27 python35 python36 description {Use Python 3.7} {
     91variant python37 conflicts python27 python35 python36 stock description {Use Python 3.7 from MacPorts} {
    9292    depends_run-append      port:python37
    9393    depends_build-append    port:python37
    9494    configure.python        ${prefix}/bin/python3.7
    9595}
    9696
     97if {![variant_isset stock]} {
     98    default_variants        +python37
     99}
     100
    97101if {![variant_isset python27] && ![variant_isset python35] && ![variant_isset python36] && ![variant_isset python37]} {
    98     default_variants +python37
     102    # There isn't actually a need to use a MacPorts Python interpreter; the system one will do just fine.
     103    # When using the system interpreter (or whichever python is on the path) there is also no hard reason to
     104    # ban in-app upgrading; this will only replace ${prefix}/bin/youtube-dl with a new version (= not introduce
     105    # new files).
     106    # NB: python 2.7 runs this significantly faster.
     107    if {[variant_isset stock]} {
     108        configure.python    python
     109    } else {
     110        ui_error "You need to select either one of the +python variants or the +stock variant"
     111        return -code error "A variant must be selected"
     112    }
     113} else {
     114    patchfiles              patch-config-location.diff \
     115                            patch-youtube_dl-update.py.diff
     116    pre-build {
     117        build.args-append   PYTHON=${configure.python}
     118    }
     119}
     120
     121variant unpacked description {improve startup performance by installing as a bundle of uncompressed scripts} {}
     122
     123if {[variant_isset unpacked]} {
     124    # unpack the compressed script that was just created. This ensures that we get the exact
     125    # same behaviour. In-app upgrading is not supported when installing this way.
     126    post-destroot {
     127        set catchval [catch {system -W ${destroot} "unzip ${destroot}${prefix}/bin/youtube-dl"} rval optval]
     128        # we will probably get an exit code 1 from unzip because of the
     129        if {(${catchval} == 0 || [lindex ${::errorCode} 2] == 1)
     130            && [file exists ${destroot}/__main__.py]
     131        } {
     132            file delete ${destroot}${prefix}/bin/youtube-dl
     133            file rename ${destroot}/__main__.py ${destroot}${prefix}/bin/youtube-dl
     134            system "chmod 755 ${destroot}${prefix}/bin/youtube-dl"
     135            file rename ${destroot}/youtube_dl ${destroot}${prefix}/libexec/youtube_dl
     136            # force a compilation by invoking the script once
     137            system -W ${destroot} "env PYTHONPATH=${destroot}${prefix}/libexec \
     138                ${configure.python} -v ${destroot}${prefix}/bin/youtube-dl --version"
     139            # make certain the wrapper script will load the correct programme
     140            reinplace "s|__file__|'${prefix}/libexec/youtube_dl/version.py'|g" ${destroot}${prefix}/bin/youtube-dl
     141            if {${configure.python} ne "python"} {
     142                reinplace "s|#!/usr/bin/env python|#!${configure.python}|g" ${destroot}${prefix}/bin/youtube-dl
     143            }
     144        } else {
     145            ui_error "Unpacking youtube-dl failed (${rval})"
     146            return -code error "Unpacking failed"
     147        }
     148    }
     149    pre-activate {
     150        # remove the bytecode cache directory
     151        if {[file exists ${prefix}/libexec/youtube_dl]} {
     152            ui_warn "Purging any existing youtube_dl bytecode cache files"
     153            file delete -force {*}[glob -nocomplain -directory ${prefix}/libexec/youtube_dl *.pyc *.pyo]
     154        }
     155        if {[file exists ${prefix}/libexec/youtube_dl/__pycache__]} {
     156            ui_warn "Purging the youtube_dl bytecode cache directory"
     157            file delete -force ${prefix}/libexec/youtube_dl/__pycache__
     158        }
     159    }
    99160}
    100161
    101162livecheck.type      regex