Search code examples
githubtclmacports

Creating Portfile from git repo using HEAD and/or origin/master? How to?


There is very little documentation about how to create a Portfile using a github repo HEAD and pulling from origin/master or tag.

are checksums needed? if so, how to calculate?

how to pull a PR from a different repo/fork?

for example

PortSystem          1.0

name                zimg
version             1.0
categories          multimedia

maintainers         nomaintainer

description         Colorspaces: SMPTE-C (NTSC)
homepage            https://github.com/sekrit-twc/zimg
distname            ${name}

fetch.type          git
git.url             https://github.com/sekrit-twc/zimg.git
git.branch          origin/master

Solution

  • how to pull a PR from a different repo/fork?

    If you have the ID of the PR, as mentioned in "Checking out pull requests locally", the fetch URL would be

    git fetch origin pull/ID/head:BRANCHNAME
    

    Applied to a porfile, with fetch.type set to git, you can try as a branch name

    git.branch          origin/pull/ID/head
    

    As neverpanic adds in the comments:

    Note that while you can set fetch.type git and git.branch origin/master, this is not supported by MacPorts.
    It's fine for development, but when trying to get a Portfile included in MacPorts, we expect that a certain version of the Portfile will always produce the same result, regardless of when you install it.

    For git submodules, add post-fetch { system -W ${worksrcpath} "${git.cmd} submodule update --init" } together with fetch.type git.