[44056] users/perry/base-select/src/macports1.0/macports.tcl

perry at macports.org perry at macports.org
Fri Dec 19 23:17:07 PST 2008


Revision: 44056
          http://trac.macports.org/changeset/44056
Author:   perry at macports.org
Date:     2008-12-19 23:17:07 -0800 (Fri, 19 Dec 2008)
Log Message:
-----------
macports1.0/macports.tcl - Implemented --show for the sake of completeness.
Without a doubt, it *needs* to be *rewritten* ASAP.

Modified Paths:
--------------
    users/perry/base-select/src/macports1.0/macports.tcl

Modified: users/perry/base-select/src/macports1.0/macports.tcl
===================================================================
--- users/perry/base-select/src/macports1.0/macports.tcl	2008-12-20 07:10:57 UTC (rev 44055)
+++ users/perry/base-select/src/macports1.0/macports.tcl	2008-12-20 07:17:07 UTC (rev 44056)
@@ -2347,7 +2347,65 @@
             return "Success"
         }
         show {
-            ui_debug "The 'show' command has not been implemented yet."
+            if {[set versions [mportselect list $group]] eq ""} {
+                return ""
+            }
+
+            foreach version $versions {
+                # Use $confpath/$version to read in sources.
+                    if {[catch {set src_file [open "$confpath/$version"]}]} {
+                    ui_debug [concat "The file '$confpath/$version' could " \
+                                    "not be opened.  This likely means " \
+                                    "that the specified version is invalid."]
+                    return ""
+                }
+                set srcs [split [read -nonewline $src_file] "\n"]
+                close $src_file
+
+                # Use $confpath/base to read in targets.
+                if {[catch {set tgt_file [open "$confpath/base"]}]} {
+                    ui_debug "The file '$confpath/base' could not be opened."
+                    return ""
+                }
+                set tgts [split [read -nonewline $tgt_file] "\n"]
+                close $tgt_file
+
+                set i 0
+                foreach tgt $tgts {
+                    set src [lindex $srcs $i]
+
+                    switch -glob -- $src {
+                        - {
+                            set tgt [file join $macports::prefix $tgt]
+                            if {[file exists $tgt]} {
+                                break
+                            }
+                        }
+                        /* {
+                            set tgt [file join $macports::prefix $tgt]
+                            if {![file exists $tgt]} {
+                                break
+                            }
+                            set link [file link $tgt]
+                            if {$link eq $src} {
+                                return $version
+                            }
+                        }
+                        default {
+                            set src [file join $macports::prefix $src]
+                            set tgt [file join $macports::prefix $tgt]
+                            if {![file exists $tgt]} {
+                                break
+                            }
+                            set link [file link $tgt]
+                            if {$link eq $src} {
+                                return $version
+                            }
+                        }
+                    }
+                    set i [expr $i+1]
+                }
+            }
             return ""
         }
     }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20081219/e78b6a71/attachment-0001.html>


More information about the macports-changes mailing list