source: contrib/mpab/chroot-scripts/genportlist.tcl @ 38930

Last change on this file since 38930 was 38930, checked in by raimue@…, 9 years ago

Import MPAB from the wiki

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 3.2 KB
Line 
1#!/usr/bin/env tclsh
2#
3# Generates a list of ports where a port is only listed after all of its
4# dependencies (sans variants) have already been listed
5#
6# Copyright (c) 2006,2008 Bryan L Blackburn.  All rights reserved.
7#
8# Redistribution and use in source and binary forms, with or without
9# modification, are permitted provided that the following conditions
10# are met:
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
15#    the documentation and/or other materials provided with the
16#    distribution.
17# 3. Neither the name Bryan L Blackburn, nor the names of any contributors
18#    may be used to endorse or promote products derived from this software
19#    without specific prior written permission.
20#
21# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
22# AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
25# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
28# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
30# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
31# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32#
33
34catch {source \
35   [file join "/" Library Tcl macports1.0 macports_fastload.tcl]}
36package require macports
37
38
39proc ui_prefix {priority} {
40   return "OUT: "
41}
42
43
44proc ui_channels {priority} {
45   return {}
46}
47
48
49proc process_port_deps {portname portdeps_in portlist_in} {
50   upvar $portdeps_in portdeps
51   upvar $portlist_in portlist
52   if {[lsearch -exact $portlist $portname] == -1} {
53      if {[info exists portdeps($portname)]} {
54         foreach portdep $portdeps($portname) {
55            if {[lsearch -exact $portlist $portdep] == -1} {
56               process_port_deps $portdep portdeps portlist
57            }
58         }
59      }
60      lappend portlist $portname
61   }
62}
63
64
65if {[catch {mportinit "" "" ""} result]} {
66   puts "$errorInfo"
67   fatal "Failed to initialize ports sytem: $result"
68}
69
70if {[catch {set search_result [mportsearch ^.+$ no]} result]} {
71   puts "$errorInfo"
72   fatal "Failed to find any ports: $result"
73}
74
75array set portdepinfo {}
76foreach {name infoarray} $search_result {
77   array set portinfo $infoarray
78   set depstypes {depends_build depends_lib depends_run}
79   set deplist [list]
80   foreach depstype $depstypes {
81      if {[info exists portinfo($depstype)] && $portinfo($depstype) != ""} {
82         foreach onedep $portinfo($depstype) {
83            lappend deplist [lindex [split [lindex $onedep 0] :] end]
84         }
85      }
86   }
87   set portdepinfo($portinfo(name)) $deplist
88   array unset portinfo
89}
90
91set portlist [list]
92foreach portname [lsort -dictionary [array names portdepinfo]] {
93   process_port_deps $portname portdepinfo portlist
94}
95
96puts [join $portlist "\n"]
97
Note: See TracBrowser for help on using the repository browser.