Ticket #52713: devport-1.0.tcl

File devport-1.0.tcl, 5.3 KB (added by RJVB (René Bertin), 8 years ago)
Line 
1# -*- coding: utf-8; mode: tcl; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; truncate-lines: t -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
2
3# Copyright (c) 2015 The MacPorts Project
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met:
9#
10# 1. Redistributions of source code must retain the above copyright
11#    notice, this list of conditions and the following disclaimer.
12# 2. Redistributions in binary form must reproduce the above copyright
13#    notice, this list of conditions and the following disclaimer in the
14#    documentation and/or other materials provided with the distribution.
15# 3. Neither the name of Apple Computer, Inc. nor the names of its
16#    contributors may be used to endorse or promote products derived from
17#    this software without specific prior written permission.
18#
19# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30#
31#
32# Usage:
33# PortGroup     devport 1.0
34
35namespace eval dev {
36    # it shouldn't be necessary to record variants in the archive name
37    set archname ${name}@${version}-dev.tar.bz2
38    # this could go into the software images directory
39    set archdir ${prefix}/var/devcontent
40}
41
42options devport_content
43default devport_content ""
44
45# create the online devport content archive
46proc create_devport_content_archive {} {
47    global destroot prefix
48    set rawargs [option devport_content]
49    set args ""
50    # convert the arguments to local-relative:
51    foreach a ${rawargs} {
52        set args "${args} .${a}"
53    }
54    xinstall -m 755 -d ${destroot}${dev::archdir}
55    if {[catch {system -W ${destroot} "bsdtar -cjvf ${destroot}${dev::archdir}/${dev::archname} ${args}"} err]} {
56        ui_error "Failure creating ${destroot}${dev::archdir}/${dev::archname} for ${args}: ${err}"
57        file delete -force ${destroot}${dev::archdir}/${dev::archname}
58    } else {
59        foreach a ${args} {
60            file delete -force ${destroot}/${a}
61        }
62    }
63}
64
65# registers content that standard devports will contain
66proc register_devport_standard_content {} {
67    global subport destroot prefix name
68    if {${subport} eq "${name}"} {
69        foreach h [glob -nocomplain ${destroot}${prefix}/include/*] {
70            devport_content-append [string map [list ${destroot} ""] ${h}]
71        }
72        foreach h [glob -nocomplain ${destroot}${prefix}/lib/lib*.a] {
73            devport_content-append [string map [list ${destroot} ""] ${h}]
74        }
75        foreach h [glob -nocomplain ${destroot}${prefix}/lib/lib*.la] {
76            devport_content-append [string map [list ${destroot} ""] ${h}]
77        }
78        foreach h [glob -nocomplain ${destroot}${prefix}/lib/lib*\[a-zA-Z\].so] {
79            devport_content-append [string map [list ${destroot} ""] ${h}]
80        }
81        foreach h [glob -nocomplain ${destroot}${prefix}/lib/pkgconfig/*] {
82            devport_content-append [string map [list ${destroot} ""] ${h}]
83        }
84    }
85}
86
87proc unpack_devport_content {} {
88    global destroot prefix name
89    if {[file exists ${dev::archdir}/${dev::archname}]} {
90        if {[catch {system -W ${destroot} "bsdtar -xvf ${dev::archdir}/${dev::archname}"} err]} {
91            ui_error "Failure unpacking ${dev::archdir}/${dev::archname}: ${err}"
92        }
93    } else {
94        ui_error "The port's content archive doesn't exists (${dev::archdir}/${dev::archname})!"
95        return -code error "Missing content archive; try re-activating or reinstalling port:${name}"
96    }
97}
98
99proc create_devport {dependency} {
100    global name long_description
101    subport ${name}-dev {
102        description     "Development headers and libraries for ${name}"
103        depends_lib-append \
104                        ${dependency}
105        long_description ${long_description}\nThis installs the development headers and libraries.
106        installs_libs   yes
107        supported_archs noarch
108        distfiles
109        fetch {}
110        checksum {}
111        extract {}
112        use_configure   no
113        patchfiles
114        build {}
115        destroot {
116            unpack_devport_content
117        }
118        pre-activate {
119            if {[file exists ${dev::archdir}/${dev::archname}]} {
120                ui_info "${subport} is now installed, removing installed content archive ${dev::archdir}/${dev::archname}"
121                file delete -force ${dev::archdir}/${dev::archname}
122                # make sure the file exists to keep rev-upgrade happy
123                # NB: this c/should be a symlink to the port's image tarball!
124                system "touch ${dev::archdir}/${dev::archname}"
125            }
126        }
127    }
128}
129