Ticket #685: bigpatch-landonf

File bigpatch-landonf, 8.9 KB (added by jcorley1@…, 21 years ago)

patch with landon, et. al. suggestions incorporated

Line 
1Index: src/darwinports1.0/darwinports.tcl
2===================================================================
3RCS file: /Volumes/src/cvs/od/proj/darwinports/base/src/darwinports1.0/darwinports.tcl,v
4retrieving revision 1.96
5diff -u -r1.96 darwinports.tcl
6--- src/darwinports1.0/darwinports.tcl  14 Aug 2003 02:11:04 -0000      1.96
7+++ src/darwinports1.0/darwinports.tcl  19 Aug 2003 00:24:13 -0000
8@@ -140,6 +140,11 @@
9        return -code error "$portdbpath is not a directory. Please create the directory $portdbpath and try again"
10     }
11 
12+    set darwinports::registry.path [file join $portdbpath receipts]
13+    if {![file isdirectory ${darwinports::registry.path}]} {
14+       return -code error "${darwinports::registry.path} is not a directory."
15+    }
16+
17     set portsharepath ${prefix}/share/darwinports
18     if {![file isdirectory $portsharepath]} {
19        return -code error "Data files directory '$portsharepath' must exist"
20@@ -177,10 +182,6 @@
21     $workername alias ui_event darwinports::ui_event $workername
22 
23        # xxx: find a better home for this registry cruft--like six feet under.
24-       global darwinports::portdbpath darwinports::registry.path
25-       if {[info exists darwinports::portdbpath] && ![info exists darwinports::registry.path]} {
26-               set darwinports::registry.path [file join ${darwinports::portdbpath} receipts]
27-       }
28        $workername alias registry_new dportregistry::new $workername
29        $workername alias registry_store dportregistry::store
30        $workername alias registry_delete dportregistry::delete
31@@ -246,7 +247,7 @@
32 proc darwinports::getportdir {url} {
33     if {[regexp {(?x)([^:]+)://(.+)} $url match protocol string] == 1} {
34         switch -regexp -- ${protocol} {
35-            {^file$} { return $string}
36+            {^file$} { return $string }
37            {http|ftp} { return [darwinports::fetch_port $url] }
38             default { return -code error "Unsupported protocol $protocol" }
39         }
40@@ -752,5 +753,24 @@
41        dportregistry::fileinfo_for_entry rval $dir $file
42     }
43     return $rval
44+}
45+
46+proc dportregistry::listinstalled {} {
47+    global darwinports::registry.path
48+
49+    set receiptglob [glob -nocomplain ${darwinports::registry.path}/*]
50+
51+    if {$receiptglob == ""} {
52+        puts "No ports installed."
53+    } else {
54+        puts "The following ports are installed:"
55+        foreach receipt $receiptglob {
56+            if {[file extension $receipt] == ".bz2"} {
57+                puts "\t[file rootname [file tail $receipt]]"
58+            } else {
59+                puts "\t[file tail $receipt]"
60+            }
61+        }
62+    }
63 }
64 
65Index: src/port/port.1
66===================================================================
67RCS file: /Volumes/src/cvs/od/proj/darwinports/base/src/port/port.1,v
68retrieving revision 1.17
69diff -u -r1.17 port.1
70--- src/port/port.1     13 Aug 2003 08:52:11 -0000      1.17
71+++ src/port/port.1     19 Aug 2003 00:24:14 -0000
72@@ -139,7 +139,19 @@
73 .Pp
74 To list the files (table of contents) installed by a given port (in this case apr):
75 .Pp
76-.Dl "port toc apr"
77+.Dl "port contents apr"
78+.Pp
79+To find out what dependencies a port has:
80+.Pp
81+.Dl "port deps exim"
82+.Pp
83+To find out what ports are installed:
84+.Pp
85+.Dl "port installed"
86+.Pp
87+To find out what variants a port has:
88+.Pp
89+.Dl "port variants php"
90 .Pp
91 The following demonstrates invoking
92 .Nm
93Index: src/port/port.tcl
94===================================================================
95RCS file: /Volumes/src/cvs/od/proj/darwinports/base/src/port/port.tcl,v
96retrieving revision 1.44
97diff -u -r1.44 port.tcl
98--- src/port/port.tcl   18 Aug 2003 02:34:37 -0000      1.44
99+++ src/port/port.tcl   19 Aug 2003 00:24:14 -0000
100@@ -172,6 +172,121 @@
101 }
102 
103 switch -- $action {
104+    deps {
105+        set nodeps true
106+
107+        # make sure a port was given on the command line
108+        if {![info exists portname]} {
109+           return -code error "You must specify a port"
110+        }
111+
112+        # search for port
113+        if {[catch {dportsearch ^$portname$} result]} {
114+           return -code error "port search failed: $result"
115+        }
116+
117+        if {$result == ""} {
118+            return -code error "No port $portname found."
119+        }
120+
121+        array set portinfo [lindex $result 1]
122+
123+        # find build dependencies
124+        if {[info exists portinfo(depends_build)]} {
125+            puts "$portname has build dependencies on:"
126+            foreach i $portinfo(depends_build) {
127+                puts "\t[lindex [split [lindex $i 0] :] 2]"
128+            }
129+            set nodeps false
130+        }
131+
132+        # find library dependencies
133+        if {[info exists portinfo(depends_lib)]} {
134+            puts "$portname has library dependencies on:"
135+            foreach i $portinfo(depends_lib) {
136+                puts "\t[lindex [split [lindex $i 0] :] 2]"
137+            }
138+            set nodeps false
139+        }
140+
141+        # find runtime dependencies
142+        if {[info exists portinfo(depends_run)]} {
143+            puts "$portname has runtime dependencies on:"
144+            foreach i $portinfo(depends_run) {
145+                puts "\t[lindex [split [lindex $i 0] :] 2]"
146+            }
147+            set nodeps false
148+        }
149+
150+        # no dependencies found
151+        if {$nodeps == "true"} {
152+            puts "$portname has no dependencies"
153+        }
154+    }
155+    installed {
156+        if {[catch {dportregistry::listinstalled} result]} {
157+            return -code error "Port failed: $result"
158+        }
159+    }
160+    variants {
161+        # make sure a port was given on the command line
162+        if {![info exists portname]} {
163+           return -code error "You must specify a port"
164+        }
165+
166+        # search for port
167+        if {[catch {dportsearch ^$portname$} result]} {
168+           return -code error "port search failed: $result"
169+        }
170+
171+        if {$result == ""} {
172+            return -code error "No port $portname found."
173+        }
174+
175+        array set portinfo [lindex $result 1]
176+
177+        # if this fails the port doesn't have any variants
178+        if {![info exists portinfo(variants)]} {
179+            puts "$portname has no variants"
180+        } else {
181+        # print out all the variants
182+            for {set i 0} {$i < [llength $portinfo(variants)]} {incr i} {
183+                puts "[lindex $portinfo(variants) $i]"
184+            }
185+        }
186+    }
187+    contents {
188+        set rfile [dportregistry::exists $portname]
189+        if {$rfile != ""} {
190+            if {[file extension $rfile] == ".bz2"} {
191+                set shortname [file rootname [file tail $rfile]]
192+                set fd [open "|bzcat -q $rfile" r]
193+            } else {
194+                set shortname [file tail $rfile]
195+                set fd [open $rfile r]
196+            }
197+            set entry [read $fd]
198+            # kind of a corner case but I ran into it testing
199+            if {[catch {close $fd} result]} {
200+                return -code error "Port failed: $rfile may be corrupted"
201+            }
202+
203+            # look for a contents list
204+            set ix [lsearch $entry contents]
205+            if {$ix >= 0} {
206+                set contents [lindex $entry [incr ix]]
207+                set uninst_err 0
208+                puts "Contents of $shortname"
209+                foreach f $contents {
210+                    puts "\t[lindex $f 0]"
211+                }
212+            } else {
213+                return -code error "No contents list for $shortname"
214+            }
215+        } else {
216+            return -code error "Contents listing failed - no registry entry"
217+        }
218+    }
219     search {
220        if {![info exists portname]} {
221            puts "You must specify a search pattern"
222Index: src/port1.0/Makefile
223===================================================================
224RCS file: /Volumes/src/cvs/od/proj/darwinports/base/src/port1.0/Makefile,v
225retrieving revision 1.35
226diff -u -r1.35 Makefile
227--- src/port1.0/Makefile        17 Aug 2003 02:20:55 -0000      1.35
228+++ src/port1.0/Makefile        19 Aug 2003 00:24:14 -0000
229@@ -2,10 +2,9 @@
230 
231 SRCS= port.tcl portchecksum.tcl portconfigure.tcl portextract.tcl          \
232        portfetch.tcl portmain.tcl portbuild.tcl portpatch.tcl portutil.tcl \
233-       portinstall.tcl portdepends.tcl portdestroot.tcl                    \
234-       portinstall.tcl portuninstall.tcl                                   \
235-       portdepends.tcl portclean.tcl portpackage.tcl portcontents.tcl      \
236-       porttest.tcl portmpkg.tcl portrpmpackage.tcl
237+       portinstall.tcl portdepends.tcl portdestroot.tcl portuninstall.tcl  \
238+        portclean.tcl portpackage.tcl porttest.tcl portmpkg.tcl             \
239+        portrpmpackage.tcl
240 
241 SUBDIR=                resources
242 
243Index: src/port1.0/port.tcl
244===================================================================
245RCS file: /Volumes/src/cvs/od/proj/darwinports/base/src/port1.0/port.tcl,v
246retrieving revision 1.23
247diff -u -r1.23 port.tcl
248--- src/port1.0/port.tcl        17 Aug 2003 02:20:55 -0000      1.23
249+++ src/port1.0/port.tcl        19 Aug 2003 00:24:15 -0000
250@@ -45,6 +45,5 @@
251 package require portclean 1.0
252 package require portpackage 1.0
253 package require portrpmpackage 1.0
254-package require portcontents 1.0
255 package require portmpkg 1.0
256 package require porttest 1.0