source: trunk/dports/_resources/port1.0/group/github-1.0.tcl @ 125636

Last change on this file since 125636 was 125636, checked in by ryandesign@…, 3 years ago

github-1.0.tcl: remove unused github.livecheck_type variable

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.5 KB
Line 
1# -*- 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
2# $Id: github-1.0.tcl 125636 2014-09-23 13:34:35Z ryandesign@macports.org $
3#
4# Copyright (c) 2012-2014 The MacPorts Project
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions are
9# met:
10#
11# 1. Redistributions of source code must retain the above copyright
12#    notice, this list of conditions and the following disclaimer.
13# 2. Redistributions in binary form must reproduce the above copyright
14#    notice, this list of conditions and the following disclaimer in the
15#    documentation and/or other materials provided with the distribution.
16# 3. Neither the name of The MacPorts Project nor the names of its
17#    contributors may be used to endorse or promote products derived from
18#    this software without specific prior written permission.
19#
20# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31#
32#
33# This PortGroup accommodates projects hosted at github.
34#
35# Usage:
36#
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#
43#   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#   }
110
111options github.author github.project github.version github.tag_prefix
112options github.homepage github.raw github.master_sites github.tarball_from
113
114default github.homepage {https://github.com/${github.author}/${github.project}}
115default github.raw {https://raw.githubusercontent.com/${github.author}/${github.project}}
116default github.master_sites {${github.homepage}/tarball/[join ${github.tag_prefix} ""]${github.version}}
117
118default master_sites {${github.master_sites}}
119
120default github.tarball_from {tags}
121option_proc github.tarball_from handle_tarball_from
122proc handle_tarball_from {option action args} {
123    global github.author github.project github.master_sites git.branch github.homepage
124
125    if {${action} eq "set"} {
126        github.tarball_from ${args}
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        }
141    }
142}
143
144proc github.setup {gh_author gh_project gh_version {gh_tag_prefix ""}} {
145    global extract.suffix github.author github.project github.version github.tag_prefix github.homepage github.master_sites PortInfo
146
147    github.author           ${gh_author}
148    github.project          ${gh_project}
149    github.version          ${gh_version}
150    github.tag_prefix       ${gh_tag_prefix}
151
152    if {!([info exists PortInfo(name)] && (${PortInfo(name)} ne ${github.project}))} {
153        name                ${github.project}
154    }
155
156    version                 ${github.version}
157    homepage                ${github.homepage}
158    git.url                 ${github.homepage}.git
159    git.branch              [join ${github.tag_prefix}]${github.version}
160    distname                ${github.project}-${github.version}
161    fetch.ignore_sslcert    yes
162
163    post-extract {
164        # When fetching from a tag, the extracted directory name will contain a
165        # truncated commit hash. So that the port author need not specify what
166        # that hash is every time the version number changes, rename the
167        # directory to the value of distname (not worksrcdir: ports may want to
168        # set worksrcdir to a subdirectory of the extracted directory).
169        if {![file exists ${worksrcpath}] && \
170                ${fetch.type} eq "standard" && \
171                ${master_sites} eq ${github.master_sites} && \
172                [llength ${distfiles}] > 0 && \
173                [llength [glob -nocomplain ${workpath}/*]] > 0} {
174            if {[file exists [glob ${workpath}/${github.author}-${github.project}-*]] && \
175                [file isdirectory [glob ${workpath}/${github.author}-${github.project}-*]]} {
176                move [glob ${workpath}/${github.author}-${github.project}-*] ${workpath}/${distname}
177            }
178        }
179    }
180
181    # If the "version" is composed entirely of hex characters, and is at least
182    # nine characters long, and no tag_prefix is provided, then assume we are
183    # using a commit hash and livecheck commits; otherwise livecheck tags.
184    if {[join ${github.tag_prefix}] eq "" && \
185        [regexp "^\[0-9a-f\]{9,}\$" ${github.version}]} {
186        livecheck.type      regexm
187        livecheck.url       ${github.homepage}/commits/master.atom
188        livecheck.regex     <id>tag:github.com,2008:Grit::Commit/(\[0-9a-f\]{[string length ${github.version}]})\[0-9a-f\]*</id>
189    } else {
190        livecheck.type      regex
191        livecheck.url       ${github.homepage}/tags
192        livecheck.regex     archive/[join ${github.tag_prefix} ""](\[^"\]+)${extract.suffix}
193    }
194    livecheck.version       ${github.version}
195}
Note: See TracBrowser for help on using the repository browser.