Ken,

I pushed to GitHub a skeleton of the idea:

    https://github.com/emcrisostomo/macports-utils

I've moved what I'm using to a new script to see what the end result looked 
like. If you want to try it, just grab the release tarball here (if you don't 
have the Autotools installed):

    ./configure && make install

otherwise just clone the repo, bootstrap it and use it:

    ./autogen.sh && ./configure && make install

An example:

    $ port-gen --url 
https://github.com/emcrisostomo/semver-utils/releases/download/1.1.3/semver-utils-1.1.3.tar.gz

outputs:

    # -*- 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        emcrisostomo semver-utils 1.1.3
    github.tarball_from releases

    categories          changeme
    platforms           darwin
    license             GPL-3

    maintainers         obfuscated-maintainer-mail \
                        openmaintainer
    description         Add a short port description here.
    long_description    Add a long port description here.

    homepage            https://github.com/emcrisostomo/semver-utils

    checksums           md5    e65be62dc9e25af8aa467aa99cde1e00 \
                        rmd160 71cf46420315edd8019d6974062033480b5c79a0 \
                        sha256 
888a688feabc82ce59abc754c63fd2babff5747f0463fb1a3f8fffaf50d5d982 \
                        size   514429

    livecheck.url       ${github.homepage}/releases/latest


The template is intuitive:

    $ cat /usr/local/share/macports-utils/templates/github.in
    # -*- 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        ${GITHUB_AUTHOR} ${PORT_NAME} ${PORT_VERSION}
    github.tarball_from releases
   
    categories          changeme
    platforms           darwin
    license             GPL-3

    maintainers         obfuscated-maintainer-mail \\\\
                        openmaintainer
    description         Add a short port description here.
    long_description    Add a long port description here.

    homepage            ${GITHUB_REPO_URL}

    checksums           md5    ${CHECKSUM_MD5} \\\\
                        rmd160 ${CHECKSUM_RMD160} \\\\
                        sha256 ${CHECKSUM_SHA256} \\\\
                        size   ${CHECKSUM_SIZE}

    livecheck.url       \${github.homepage}/releases/latest

> On 7 Mar 2018, at 10:23, Enrico Maria Crisostomo 
> <enrico.m.crisost...@gmail.com> wrote:
> 
> Hi Ken,
> 
> I think it's a great idea. I'm maintaining a lot of software both on my 
> personal machines and at work using MacPorts and I've setup some local 
> Makefile targets to do some of this work. Perhaps I could contribute some 
> work on this area, but first I'd like to know what is it that we'd like to 
> have.
> 
> What is currently working for me is a very simple, template-based approach. 
> Since 90% of the time I'm dealing with ports using the github portgroup, I'm 
> basically calculating the relevant variables (port name, version, checksums, 
> etc.) and fill in a template. The template is a file where shell expansion is 
> performed (i.e.: variables in the form ${VAR}) are expanded.) I think this 
> approach could be both very useful and simple to maintain if we had a list of 
> pre-defined templates. It doesn't scale well with the number of different 
> templates to support and their complexity. If we needed templates to have 
> logic in it (flow control, expressions, etc.),then my guts say we should move 
> to a suitable templating engine (or a different kind of solution altogether).
> 
> I've had a look at portfile-gen and it's a nice source of inspiration. Yet, 
> I'm not convinced that outputting text directly from the program flow is 
> either easy to read or easily maintainable, especially if complexity goes up.
> 
> portfile-gen, if I understand correctly, supports the following groups:
> 
>  * perl5
>  * php 
>  * python 
>  * ruby
>  * github
> 
> If we extracted a template for each one of those groups (or more templates in 
> case a group may have multiple templates), then the effort required to come 
> up with a working prototype would be implementing the functions required to 
> populate the environment (i.e.: downloading a file if needed, calculating 
> checksums, examining it). Perhaps we would have to split a Portfile in 
> multiple segments, and generate each segment from a specific template (e.g.: 
> if a port requires GNU Autotools).
> 
> What are your gut feelings about a template-based solution? Do you think it 
> would be able to manage the level of Portfile complexity we desire for this 
> tool?
> 
> Cheers,
> -- 
> Enrico
> 
> 
>> On 7 Mar 2018, at 01:27, Ken Cunningham <ken.cunningham.web...@gmail.com> 
>> wrote:
>> 
>> 
>> On 2018-03-06, at 7:19 AM, Joshua Root wrote:
>> 
>>> 
>>> There's a fairly basic tool called portfile-gen in contrib. Improvements
>>> are certainly welcome.
>> 
>> That is indeed a step towards what I was thinking of.
>> 
>> I'll look at this. 
>> 
>> Ken
>> 
> 

Reply via email to