Ticket #48937: Portfile.2

File Portfile.2, 3.4 KB (added by raimue (Rainer Müller), 7 years ago)

extract.mkdir, no distpath deletion

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
3# Global Keywords
4PortSystem                1.0
5PortGroup                 github 1.0
6
7github.setup              bazelbuild bazel 0.4.5
8github.tarball_from       releases
9categories                devel
10maintainers               tfmnet.com:mohamed.issa \
11                          openmaintainer
12description               A tool for automating builds and tests.
13long_description          ${description}
14platforms                 darwin
15license                   Apache-2
16
17# Pre-Fetch Phase
18pre-fetch {
19    # Make sure the Java compiler exists
20    set cmdnm "javac"
21    set param [auto_execok $cmdnm]
22    if {$param == ""} {
23        error "The Java compiler was not detected on this machine. \
24               Please ensure JDK 8 or newer is properly installed."
25    }
26
27    # Get the Java compiler version and then extract the major + minor parts
28    set ver [exec -ignorestderr -- $cmdnm -version 2>@1]
29    set count [scan $ver "%s %d.%d." cmdnm mjver mnver]
30    if {$count != 3} {
31        error "The Java compiler version data could not be parsed."
32    }
33
34    # Check for major version incompatbility
35    if {$mjver < 1} {
36        error "The installed JDK is too old, please upgrade to JDK 8 or newer."
37    }
38
39    # Check for minor version incompatbility
40    if {$mjver == 1} {
41        if {$mnver < 8} {
42            error "The installed JDK is too old, please upgrade to JDK 8 or newer."
43        }
44    }
45}
46
47# Fetch Phase
48distname                  ${distname}-dist
49dist_subdir               ${name}
50
51# Checksum Phase
52checksums                 rmd160  1ab01266e8d1448936bf1f4e2fefcb847c1f44a2 \
53                          sha256  2b737be42678900470ae9e48c975ac5b2296d9ae23c007bf118350dbe7c0552b
54
55# Extract Phase
56use_zip                   yes
57extract.mkdir             yes
58
59# Patch Phase
60patch {}
61
62# Configure Phase
63use_configure             no
64
65# Build Phase
66build {
67    # The Bazel compilation script erroneously writes to the standard
68    # error stream, so we'll just ignore it. If the build fails, then there
69    # won't be a binary to copy and the destroot phase will fail.
70    exec -ignorestderr -- sudo sh ${worksrcpath}/compile.sh
71}
72
73# Test Phase
74test {}
75
76# Destroot Phase
77destroot {
78    # Copy compiled binary
79    set bindir ${prefix}/bin
80    xinstall -d ${destroot}${bindir}
81    xinstall -m 755 -W ${worksrcpath}/output ${name} ${destroot}${bindir}
82}
83
84# Post-Destroot Phase
85post-destroot {
86    # Mark documentation, source, and example directories
87    set docdir ${prefix}/share/doc/${name}
88    set srcdir ${prefix}/src/${name}
89    set expdir ${prefix}/share/examples/${name}
90
91    # Copy documentation files
92    xinstall -d ${destroot}${docdir}
93    xinstall -m 644 -W ${worksrcpath} AUTHORS \
94                                      CHANGELOG.md \
95                                      CONTRIBUTING.md \
96                                      CONTRIBUTORS \
97                                      ISSUE_TEMPLATE.md \
98                                      LICENSE \
99                                      LICENSE.txt \
100                                      README.md \
101                       ${destroot}${docdir}
102
103    # Copy source files
104    xinstall -d ${destroot}${srcdir}
105    file copy -force {*}[glob ${worksrcpath}/src/*] ${destroot}${srcdir}
106
107    # Copy example files
108    xinstall -d ${destroot}${expdir}
109    file copy -force {*}[glob ${worksrcpath}/examples/*] ${destroot}${expdir}
110}