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

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

bitbucket-1.0.tcl: use eq for string comparisons

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
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: bitbucket-1.0.tcl 125633 2014-09-23 12:35:22Z ryandesign@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 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    # 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    }
60}
61
62proc bitbucket.setup {bb_author bb_project bb_version {bb_tag_prefix ""}} {
63    global bitbucket.author bitbucket.project bitbucket.version bitbucket.tag_prefix bitbucket.homepage bitbucket.master_sites extract.suffix bitbucket.livecheck_type
64
65    bitbucket.author        ${bb_author}
66    bitbucket.project       ${bb_project}
67    bitbucket.version       ${bb_version}
68    bitbucket.tag_prefix    ${bb_tag_prefix}
69
70    name                    ${bitbucket.project}
71    version                 ${bitbucket.version}
72    homepage                ${bitbucket.homepage}
73    hg.url                  ${bitbucket.homepage}
74    hg.tag                  [join ${bitbucket.tag_prefix}]${bitbucket.version}
75    distname                [join ${bitbucket.tag_prefix}]${bitbucket.version}
76    fetch.ignore_sslcert    yes
77
78    post-extract {
79        if {![file exists ${worksrcpath}] && \
80            ${fetch.type} eq "standard" && \
81            ${master_sites} eq ${bitbucket.master_sites} && \
82            [llength ${distfiles}] > 0 && \
83            [llength [glob -nocomplain ${workpath}/*]] > 0} {
84            move [glob ${workpath}/*] ${worksrcpath}
85        }
86    }
87
88    if {[join ${bitbucket.tag_prefix}] eq "" && \
89        [regexp "^\[0-9a-f\]{9,}\$" ${bitbucket.version}]} {
90        bitbucket.livecheck_type commits
91    } else {
92        bitbucket.livecheck_type tags
93    }
94
95    if {[string equal ${bitbucket.livecheck_type} "commits"]} {
96        livecheck.type      regexm
97        livecheck.url       ${bitbucket.homepage}/atom
98        livecheck.version   ${bitbucket.version}
99        livecheck.regex     <id>changeset:(\[0-9a-f\]{[string length ${bitbucket.version}]})\[0-9a-f\]*</id>
100    } else {
101        livecheck.type      regex
102        livecheck.version   ${bitbucket.version}
103        livecheck.url       ${bitbucket.homepage}/downloads
104        livecheck.regex     get/[join ${bitbucket.tag_prefix}](\[0-9\.\]+)${extract.suffix}
105    }
106}
107
Note: See TracBrowser for help on using the repository browser.