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

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

bitbucket: add proc to only livecheck a certain branch

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.4 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: bitbucket-1.0.tcl 126059 2014-10-03 02:16:44Z sean@macports.org $
3#
4# Copyright (c) 2013-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 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
41options bitbucket.homepage bitbucket.master_sites bitbucket.tarball_from
42options bitbucket.livecheck_branch
43
44default bitbucket.homepage {https://bitbucket.org/${bitbucket.author}/${bitbucket.project}}
45default bitbucket.master_sites {${bitbucket.homepage}/get}
46default bitbucket.tarball_from {tags}
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 bitbucket.version
54
55    # the port writer can set bitbucket.tarball_from to "downloads" and have the URI path accordingly changed
56    if {[string equal ${action} "set"] && ${args} eq "downloads"} {
57        bitbucket.tarball_from ${args}
58        bitbucket.master_sites https://bitbucket.org/${bitbucket.author}/${bitbucket.project}/downloads
59        default distname {${bitbucket.project}-${bitbucket.version}}
60    }
61}
62
63proc bitbucket.livecheck_regex {} {
64    global bitbucket.tag_prefix bitbucket.tarball_from distname extract.suffix version
65    switch ${bitbucket.tarball_from} {
66        tags {
67            set dir get
68        }
69        default {
70            set dir ${bitbucket.tarball_from}
71        }
72    }
73    return ${dir}/[regsub -- [quotemeta ${version}] ${distname} {([0-9.]+)}][quotemeta [quotemeta ${extract.suffix}]]
74}
75
76proc bitbucket.setup {bb_author bb_project bb_version {bb_tag_prefix ""}} {
77    global bitbucket.author bitbucket.homepage bitbucket.master_sites bitbucket.project bitbucket.tag_prefix bitbucket.version extract.suffix
78
79    bitbucket.author        ${bb_author}
80    bitbucket.project       ${bb_project}
81    bitbucket.version       ${bb_version}
82    bitbucket.tag_prefix    ${bb_tag_prefix}
83
84    name                    ${bitbucket.project}
85    version                 ${bitbucket.version}
86    homepage                ${bitbucket.homepage}
87    hg.url                  ${bitbucket.homepage}
88    hg.tag                  [join ${bitbucket.tag_prefix}]${bitbucket.version}
89    default distname        {${hg.tag}}
90    fetch.ignore_sslcert    yes
91
92    post-extract {
93        if {![file exists ${worksrcpath}] && \
94            ${fetch.type} eq "standard" && \
95            ${master_sites} eq ${bitbucket.master_sites} && \
96            [llength ${distfiles}] > 0 && \
97            [llength [glob -nocomplain ${workpath}/*]] > 0} {
98            move [glob ${workpath}/*] ${worksrcpath}
99        }
100    }
101
102    if {[join ${bitbucket.tag_prefix}] eq "" && \
103        [regexp "^\[0-9a-f\]{9,}\$" ${bitbucket.version}]} {
104        default livecheck.type      regexm
105        default livecheck.url       {${bitbucket.homepage}/atom}
106        default livecheck.regex     {<id>changeset:(\[0-9a-f\]{[string length ${bitbucket.version}]})\[0-9a-f\]*</id>}
107    } else {
108        default livecheck.type      regex
109        default livecheck.url       {${bitbucket.homepage}/downloads}
110        default livecheck.regex     {[bitbucket.livecheck_regex]}
111    }
112
113    default livecheck.version   {${bitbucket.version}}
114}
115
116# proc that sets the livecheck to only check a branch instead of the newest
117# commits (meant to be used when the version is a hash); to be called *after*
118# bitbucket.setup
119proc bitbucket.livecheck {bb_branch} {
120    global bitbucket.homepage bitbucket.author bitbucket.project bitbucket.version
121
122    livecheck.url       ${bitbucket.homepage}/commits/branch/${bb_branch}
123    livecheck.type      regexm
124    livecheck.regex     <a  class="hash execute" href="/${bitbucket.author}/${bitbucket.project}/commits/(\[0-9a-f\]{[string length ${bitbucket.version}]}).*"
125}
Note: See TracBrowser for help on using the repository browser.