source: trunk/dports/_resources/port1.0/group/bitbucket-1.0.tcl @ 102585

Last change on this file since 102585 was 102585, checked in by sean@…, 7 years ago

bitbucket-1.0: fix missing prefix in distname

File size: 4.7 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$
3#
4# Copyright (c) 2012 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 sets up default behaviors for projects hosted at bitbucket.
34#
35# Usage:
36#
37#   PortGroup               bitbucket 1.0
38#   bitbucket.setup         author project version [tag_prefix]
39
40options bitbucket.author bitbucket.project bitbucket.version bitbucket.tag_prefix bitbucket.livecheck_type
41options bitbucket.homepage bitbucket.master_sites bitbucket.tarball_from
42
43default bitbucket.homepage {https://bitbucket.org/${bitbucket.author}/${bitbucket.project}}
44default bitbucket.master_sites {${bitbucket.homepage}/get}
45default bitbucket.tarball_from {tags}
46default bitbucket.livecheck_type ""
47
48default master_sites {${bitbucket.master_sites}}
49
50option_proc bitbucket.tarball_from handle_tarball_from
51
52proc handle_tarball_from {option action args} {
53    global bitbucket.author bitbucket.project bitbucket.master_sites
54
55    # keeping the default at tags like many portfiles already do
56    # the port writer can set bitbucket.tarball_from to "downloads" and have the URI path accordingly changed
57    if {[string equal ${action} "set"] && $args == "downloads"} {
58        bitbucket.tarball_from ${args}
59        bitbucket.master_sites https://bitbucket.org/${bitbucket.author}/${bitbucket.project}/downloads
60    }
61}
62
63proc bitbucket.setup {bb_author bb_project bb_version {bb_tag_prefix ""}} {
64    global bitbucket.author bitbucket.project bitbucket.version bitbucket.tag_prefix bitbucket.homepage bitbucket.master_sites extract.suffix bitbucket.livecheck_type
65
66    bitbucket.author        ${bb_author}
67    bitbucket.project       ${bb_project}
68    bitbucket.version       ${bb_version}
69    bitbucket.tag_prefix    ${bb_tag_prefix}
70
71    name                    ${bitbucket.project}
72    version                 ${bitbucket.version}
73    homepage                ${bitbucket.homepage}
74    hg.url                  ${bitbucket.homepage}
75    hg.tag                  [join ${bitbucket.tag_prefix}]${bitbucket.version}
76    distname                [join ${bitbucket.tag_prefix}]${bitbucket.version}
77    fetch.ignore_sslcert    yes
78
79    post-extract {
80        if {![file exists ${worksrcpath}] && "standard" == ${fetch.type} && \
81            ${master_sites} == ${bitbucket.master_sites} && [llength ${distfiles}] > 0 && \
82            [llength [glob -nocomplain ${workpath}/*]] > 0} {
83            move [glob ${workpath}/*] ${worksrcpath}
84        }
85    }
86
87    if {[join ${bitbucket.tag_prefix}] == "" && [regexp "^\[0-9a-f\]{9,}\$" ${bitbucket.version}]} {
88        bitbucket.livecheck_type "commits"
89    } else {
90        bitbucket.livecheck_type "tags"
91    }
92
93    if {[string equal ${bitbucket.livecheck_type} "commits"]} {
94        livecheck.type      regexm
95        livecheck.url       ${bitbucket.homepage}/atom
96        livecheck.version   ${bitbucket.version}
97        livecheck.regex     <id>changeset:(\[0-9a-f\]{[string length ${bitbucket.version}]})\[0-9a-f\]*</id>
98    } else {
99        livecheck.type      regex
100        livecheck.version   ${bitbucket.version}
101        livecheck.url       ${bitbucket.homepage}/downloads
102        livecheck.regex     get/[join ${bitbucket.tag_prefix}](\[0-9\.\]+)${extract.suffix}
103    }
104}
105
Note: See TracBrowser for help on using the repository browser.