source: contrib/mpab/subports.tcl @ 81233

Last change on this file since 81233 was 81233, checked in by jmr@…, 6 years ago

mpab: add script to find subports

  • Property svn:executable set to *
File size: 2.6 KB
Line 
1#!/usr/bin/tclsh
2#
3# Generates a list of the subports for the given port.
4#
5# Copyright (c) 2011 The MacPorts Project.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions
9# are met:
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
14#    the documentation and/or other materials provided with the
15#    distribution.
16# 3. Neither the name of the MacPorts project, nor the names of any contributors
17#    may be used to endorse or promote products derived from this software
18#    without specific prior written permission.
19#
20# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
21# AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
24# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
30# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32if {[info exists env(PREFIX)]} {
33    set prefix $env(PREFIX)
34} else {
35    set prefix /opt/local
36}
37
38source ${prefix}/share/macports/Tcl/macports1.0/macports_fastload.tcl
39package require macports
40
41if {[catch {mportinit "" "" ""} result]} {
42   ui_error "$errorInfo"
43   fatal "Failed to initialize ports sytem: $result"
44}
45
46if {[llength $::argv] == 0} {
47    fatal "Usage: $argv0 <portname>"
48}
49
50set portname [lindex $::argv 0]
51
52if {[catch {set one_result [mportlookup $portname]}]} {
53    fatal "lookup failed for port: $portname"
54}
55puts [lindex $one_result 0]
56array set portinfo [lindex $one_result 1]
57if {[info exists portinfo(porturl)]} {
58    if {[catch {set mport [mportopen $portinfo(porturl) "" ""]}]} {
59        ui_warn "failed to open port: $portname"
60    } else {
61        array unset portinfo
62        array set portinfo [mportinfo $mport]
63        if {[info exists portinfo(subports)]} {
64            foreach subport $portinfo(subports) {
65                puts $subport
66            }
67        }
68    }
69    catch {mportclose $mport}
70}
Note: See TracBrowser for help on using the repository browser.