Changeset 14506 for trunk/base


Ignore:
Timestamp:
Oct 9, 2005, 3:31:28 PM (19 years ago)
Author:
jberry
Message:

Add new actions to port(1):

  • path (emits the path to the port's directory)
  • portfile (emits the path to the portfile)
  • cat (copies the portfile to standard output)
  • ed (invokes any editor specified in EDITOR or VISUAL on the portfile)

Based on a feature request by Juan.

Location:
trunk/base
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/ChangeLog

    r14502 r14506  
    11#
    2 #       $Id: ChangeLog,v 1.6 2005/10/09 13:54:26 jberry Exp $
     2#       $Id: ChangeLog,v 1.7 2005/10/09 15:31:27 jberry Exp $
    33#
    44#       This is a log of major user-visible changes in each release
     
    8585
    8686        - Snazzy new ChangeLog file
     87       
     88        - Add new actions for port(1): help, echo, cat, ed, path, portfile (jberry)
    8789
    8890
  • trunk/base/src/port/port.tcl

    r14487 r14506  
    33exec @TCLSH@ "$0" "$@"
    44# port.tcl
    5 # $Id: port.tcl,v 1.113 2005/10/08 22:24:14 jberry Exp $
     5# $Id: port.tcl,v 1.114 2005/10/09 15:31:28 jberry Exp $
    66#
    77# Copyright (c) 2004 Robert Shaw <rshaw@opendarwin.org>
     
    5050array set global_variations     {}
    5151
     52# Save off a copy of the environment before dportinit monkeys with it
     53global env
     54array set boot_env [array get env]
     55
    5256# UI Instantiations
    5357# ui_options(ports_debug) - If set, output debugging messages.
     
    127131    }
    128132}
     133
    129134
    130135# Standard procedures
     
    16941699        }
    16951700       
    1696         sync {
    1697                 if {[catch {dportsync} result]} {
    1698                         global errorInfo
    1699                         ui_debug "$errorInfo"
    1700                         fatal "port sync failed: $result"
    1701                 }
    1702         }
    1703        
    1704         default {
     1701        ed      -
     1702        cat -
     1703        path -
     1704        portfile {
     1705                # Operations on the PortFiles of the port
    17051706                require_portlist
    17061707                foreachport $portlist {
    1707                         set target $action
    1708 
    17091708                        # If we have a url, use that, since it's most specific
    17101709                        # otherwise try to map the portname to a url
     
    17231722                        }
    17241723                       
     1724                        set portdir [darwinports::getportdir $porturl $portdir]
     1725                        set portfile "${portdir}/PortFile"
     1726                       
     1727                        if {[file readable $portfile]} {
     1728                                switch -- $action {
     1729                                        cat     {
     1730                                                # Copy the portfile to standard output
     1731                                                set f [open $portfile RDONLY]
     1732                                                while { ![eof $f] } {
     1733                                                        puts [read $f 4096]
     1734                                                }
     1735                                                close $f
     1736                                        }
     1737                                       
     1738                                        ed {
     1739                                                # Find an editor to edit the portfile
     1740                                                set editor ""
     1741                                                foreach ed { VISUAL EDITOR } {
     1742                                                        if {[info exists boot_env($ed)]} {
     1743                                                                set editor $boot_env($ed)
     1744                                                        }
     1745                                                }
     1746                                               
     1747                                                if { $editor == "" } {
     1748                                                        fatal "No EDITOR is specified in your environment"
     1749                                                } else {
     1750                                                        eval exec $editor $portfile
     1751                                                }                                               
     1752                                        }
     1753                                       
     1754                                        path {
     1755                                                # output the path to the port
     1756                                                puts $portdir
     1757                                        }
     1758
     1759                                        portfile {
     1760                                                # output the path to the portfile
     1761                                                puts $portfile
     1762                                        }
     1763                                }
     1764                        } else {
     1765                                fatal_softcontinue "Could not read $portfile"
     1766                        }
     1767                }
     1768        }
     1769       
     1770        sync {
     1771                if {[catch {dportsync} result]} {
     1772                        global errorInfo
     1773                        ui_debug "$errorInfo"
     1774                        fatal "port sync failed: $result"
     1775                }
     1776        }
     1777       
     1778        default {
     1779                require_portlist
     1780                foreachport $portlist {
     1781                        set target $action
     1782
     1783                        # If we have a url, use that, since it's most specific
     1784                        # otherwise try to map the portname to a url
     1785                        if {$porturl == ""} {
     1786                                # Verify the portname, getting portinfo to map to a porturl
     1787                                if {[catch {set res [dportsearch $portname no exact]} result]} {
     1788                                        global errorInfo
     1789                                        ui_debug "$errorInfo"
     1790                                        fatal_softcontinue "search for portname $portname failed: $result"
     1791                                }
     1792                                if {[llength $res] < 2} {
     1793                                        fatal_softcontinue "Port $portname not found"
     1794                                }
     1795                                array set portinfo [lindex $res 1]
     1796                                set porturl $portinfo(porturl)
     1797                        }
     1798                       
    17251799                        # If this is the install target, add any global_variations to the variations
    17261800                        # specified for the port
Note: See TracChangeset for help on using the changeset viewer.