#!/usr/bin/tclsh
# Traverse through all ports running the supplied target.  If target is
# "index" then just print some useful information about each port.

package require darwinports
dportinit
package require Pextlib

global target

proc port_traverse {func {dir .}} {
    set pwd [pwd]
    if [catch {cd $dir} err] {
	ui_error $err
	return
    }
    foreach name [readdir .] {
	if {[string match $name .] || [string match $name ..]} {
	    continue
	}
	if [file isdirectory $name] {
	    port_traverse $func $name
	} else {
	    if [string match $name Portfile] {
		catch {eval $func {[file join $pwd $dir]}}
	    }
	}
    }
    cd $pwd
}

proc pindex {portdir} {
    global target
    set interp [dportopen file://$portdir]
    array set portinfo [dportinfo $interp]
    puts "Doing $target for port: $portinfo(portname)"
    dportexec $interp $target
    dportclose $interp
}

if { $argc < 1 } {
    set target build
} else {
    set target [lindex $argv 0]
}

port_traverse pindex software

#!/usr/bin/tclsh
# Traverse through all ports running the supplied target.  If target is
# "index" then just print some useful information about each port.

package require darwinports
dportinit
package require Pextlib

global target

proc port_traverse {func {dir .}} {
    set pwd [pwd]
    if [catch {cd $dir} err] {
	ui_error $err
	return
    }
    foreach name [readdir .] {
	if {[string match $name .] || [string match $name ..]} {
	    continue
	}
	if [file isdirectory $name] {
	    port_traverse $func $name
	} else {
	    if [string match $name Portfile] {
		catch {eval $func {[file join $pwd $dir]}}
	    }
	}
    }
    cd $pwd
}

proc pindex {portdir} {
    global target
    set interp [dportopen file://$portdir]
    array set portinfo [dportinfo $interp]
    puts "Doing $target for port: $portinfo(portname)"
    dportexec $interp $target
    dportclose $interp
}

if { $argc < 1 } {
    set target build
} else {
    set target [lindex $argv 0]
}

port_traverse pindex dports

Use the right base directory now that things have moved around.
Use the right base directory now that things have moved around.

git-svn-id: 620571fa9b4bd0cbce9a0cf901e91ef896adbf27@735 d073be05-634f-4543-b044-5fe20cf6d1d6
