Ignore:
Timestamp:
May 16, 2014, 11:49:58 PM (5 years ago)
Author:
ryandesign@…
Message:

github-1.0.tcl: support "github.tarball_from releases" (#42273); improve documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dports/_resources/port1.0/group/github-1.0.tcl

    r120143 r120144  
    3131#
    3232#
    33 # This PortGroup sets up default behaviors for projects hosted at github.
     33# This PortGroup accommodates projects hosted at github.
    3434#
    3535# Usage:
    3636#
    37 #   PortGroup               github 1.0
     37# After the PortSystem 1.0 line, put:
     38#
     39#   PortGroup           github 1.0
     40#
     41# Then, replace the name and version lines with:
     42#
    3843#   github.setup            author project version [tag_prefix]
     44#
     45# The port's name will be set to the github project name. If that's not correct,
     46# override it by setting the port name as usual, for example:
     47#
     48#   github.setup        someone someproject 1.2.3
     49#   name                myportname
     50#
     51# The tag_prefix is optional, and refers to any characters that may appear
     52# before the actual version number when you view the list of tags for this
     53# project on github. For example, if the tags are named like "v1.2.3" then
     54# tag_prefix should be specified as "v":
     55#
     56#   github.setup        someone someproject 1.2.3 v
     57#
     58# Some projects use github's "releases" service to offer distfiles:
     59#
     60# https://github.com/blog/1547-release-your-software
     61#
     62# If the project offers a "release", that's probably the best distfile to use
     63# for the port. To do this, use:
     64#
     65#   github.tarball_from releases
     66#
     67# Github imposes no naming convention for "release" distfiles, so you may need
     68# to set distname as you would for other ports.
     69#
     70# Older projects use the discontinued "downloads" service. New "downloads" can
     71# no longer be created, but old ones are still available:
     72#
     73# https://github.com/blog/1302-goodbye-uploads
     74#
     75# If the project doesn't have "releases" but does have "downloads", use them
     76# this way (and set distname if needed):
     77#
     78#   github.tarball_from downloads
     79#
     80# If neither "releases" nor "downloads" are available, github can automatically
     81# generate a distfile from a git tag or commit. This is the github portgroup's
     82# default behavior; to use this, simply don't set github.tarball_from. The
     83# distname is irrelevant when fetching from a tag or commit, so don't set it
     84# either.
     85#
     86# If the project's developers do not tag their releases, encourage them to do
     87# so. Until they do, or if you need to use a development version that's not
     88# tagged, you can use a git commit hash and set the version field. If the
     89# project does not assign version numbers (or for development versions) you can
     90# invent one, typically in the YYYYMMDD format corresponding to the date of the
     91# commit you picked. For example, if you want to use a commit with the hash
     92# 0ff25277c3842598d919cd3c73d60768 that was committed on April 1, 2014, then
     93# you would use:
     94#
     95#   github.setup        someone someproject 0ff25277c3842598d919cd3c73d60768
     96#   version             20140401
     97#
     98# Some projects' tag- or commit-based distfiles will not contain all the
     99# necessary files, if the project uses git submodules. If available, use a
     100# distfile from "releases" or "downloads" instead, as described above. If the
     101# project does not provide those, encourage the project's developers to provide
     102# releases. Until they do, fetch from git instead of from a distfile, and add a
     103# post-fetch block to fetch the submodules:
     104#
     105#   fetch.type          git
     106#
     107#   post-fetch {
     108#       system -W ${worksrcpath} "git submodule update --init"
     109#   }
    39110
    40111options github.author github.project github.version github.tag_prefix github.livecheck_type
     
    47118default master_sites {${github.master_sites}}
    48119
    49 # The ability to host downloads on github is going away
    50 # https://github.com/blog/1302-goodbye-uploads
    51120default github.tarball_from {tags}
    52121option_proc github.tarball_from handle_tarball_from
    53122proc handle_tarball_from {option action args} {
    54     global github.author github.project github.master_sites
     123    global github.author github.project github.master_sites git.branch github.homepage
    55124
    56     # keeping the default at tags like many portfiles already do
    57     # the port writer can set github.tarball_from to "downloads" and have the URI path accordingly changed
    58     if {${action} eq "set" && $args eq "downloads"} {
     125    if {${action} eq "set"} {
    59126        github.tarball_from ${args}
    60         github.master_sites https://github.com/downloads/${github.author}/${github.project}
     127        switch ${args} {
     128            downloads {
     129                github.master_sites https://github.com/downloads/${github.author}/${github.project}
     130            }
     131            releases {
     132                github.master_sites ${github.homepage}/releases/download/${git.branch}
     133            }
     134            tags {
     135                github.master_sites ${github.homepage}/tarball/${git.branch}
     136            }
     137            default {
     138                return -code error "invalid value \"${args}\" for github.tarball_from"
     139            }
     140        }
    61141    }
    62142}
     
    78158    fetch.ignore_sslcert    yes
    79159
    80     # if worksrcpath does not exist, try to guess the directory that should be and rename it
    81160    post-extract {
     161        # When fetching from a tag, the extracted directory name will contain a
     162        # truncated commit hash. So that the port author need not specify what
     163        # that hash is every time the version number changes, rename the
     164        # directory to the value of distname (not worksrcdir: ports may want to
     165        # set worksrcdir to a subdirectory of the extracted directory).
    82166        if {![file exists ${worksrcpath}] && \
    83167                ${fetch.type} eq "standard" && \
Note: See TracChangeset for help on using the changeset viewer.