Ticket #685: bigpatch

File bigpatch, 8.3 KB (added by jcorley1@…, 21 years ago)

patch to fix toc on Portfile upgrade, and add query-variants, query-dependencies, and query-installed

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  16 Aug 2003 04:36:59 -0000
8@@ -160,6 +160,11 @@
9     } else {
10                return -code error "Library directory '$libpath' must exist"
11     }
12+
13+    # Moved from darwinports::worker_init
14+    if {[info exists darwinports::portdbpath] && ![info exists darwinports::registry.path]} {
15+        set darwinports::registry.path [file join ${darwinports::portdbpath} receipts]
16+    }
17 }
18 
19 proc darwinports::worker_init {workername portpath options variations} {
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@@ -752,5 +754,24 @@
32        dportregistry::fileinfo_for_entry rval $dir $file
33     }
34     return $rval
35+}
36+
37+proc dportregistry::listinstalled {} {
38+    global darwinports::registry.path
39+
40+    set receiptglob [glob -nocomplain ${darwinports::registry.path}/*]
41+
42+    if {![string length $receiptglob]} {
43+        puts "No ports installed."
44+    } else {
45+        puts "The following ports are installed:"
46+        foreach receipt $receiptglob {
47+            if {"[file extension $receipt]" == ".bz2"} {
48+                puts "\t[file rootname [file tail $receipt]]"
49+            } else {
50+                puts "\t[file tail $receipt]"
51+            }
52+        }
53+    }
54 }
55 
56Index: src/port/port.1
57===================================================================
58RCS file: /Volumes/src/cvs/od/proj/darwinports/base/src/port/port.1,v
59retrieving revision 1.17
60diff -u -r1.17 port.1
61--- src/port/port.1     13 Aug 2003 08:52:11 -0000      1.17
62+++ src/port/port.1     16 Aug 2003 04:37:00 -0000
63@@ -141,6 +141,18 @@
64 .Pp
65 .Dl "port toc apr"
66 .Pp
67+To find out what dependencies a port has:
68+.Pp
69+.Dl "port query-dependencies"
70+.Pp
71+To find out what ports are installed:
72+.Pp
73+.Dl "port query-installed"
74+.Pp
75+To find out what variants a port has:
76+.Pp
77+.Dl "port query-variants"
78+.Pp
79 The following demonstrates invoking
80 .Nm
81 with the "extract" target on portdir "textproc/figlet" and extract.sufx set to ".tgz":
82Index: src/port/port.tcl
83===================================================================
84RCS file: /Volumes/src/cvs/od/proj/darwinports/base/src/port/port.tcl,v
85retrieving revision 1.43
86diff -u -r1.43 port.tcl
87--- src/port/port.tcl   14 Aug 2003 02:11:05 -0000      1.43
88+++ src/port/port.tcl   16 Aug 2003 04:37:00 -0000
89@@ -172,6 +172,121 @@
90 }
91 
92 switch -- $action {
93+    query-dependencies {
94+        set nodeps true
95+
96+        # make sure a port was given on the command line
97+        if {![info exists portname]} {
98+           return -code error "You must specify a port"
99+        }
100+
101+        # search for port
102+        if {[catch {dportsearch ^$portname$} result]} {
103+           return -code error "port search failed: $result"
104+        }
105+
106+        if {![string length $result]} {
107+            return -code error "No port $portname found."
108+        }
109+
110+        array set portinfo [lindex $result 1]
111+
112+        # find build dependencies
113+        if {![catch {set depends_build $portinfo(depends_build)} result]} {
114+            puts "$portname has build dependencies on:"
115+            foreach i $depends_build {
116+                puts "\t[lindex [split [lindex $i 0] :] 2]"
117+            }
118+            set nodeps false
119+        }
120+
121+        # find library dependencies
122+        if {![catch {set depends_lib $portinfo(depends_lib)} result]} {
123+            puts "$portname has library dependencies on:"
124+            foreach i $depends_lib {
125+                puts "\t[lindex [split [lindex $i 0] :] 2]"
126+            }
127+            set nodeps false
128+        }
129+
130+        # find runtime dependencies
131+        if {![catch {set depends_run $portinfo(depends_run)} result]} {
132+            puts "$portname has runtime dependencies on:"
133+            foreach i $depends_run {
134+                puts "\t[lindex [split [lindex $i 0] :] 2]"
135+            }
136+            set nodeps false
137+        }
138+
139+        # no dependencies found
140+        if {"$nodeps" == "true"} {
141+            puts "$portname has no dependencies"
142+        }
143+    }
144+    query-installed {
145+        if {[catch {dportregistry::listinstalled} result]} {
146+            return -code error "Port failed: $result"
147+        }
148+    }
149+    query-variants {
150+        # make sure a port was given on the command line
151+        if {![info exists portname]} {
152+           return -code error "You must specify a port"
153+        }
154+
155+        # search for port
156+        if {[catch {dportsearch ^$portname$} result]} {
157+           return -code error "port search failed: $result"
158+        }
159+
160+        if {"$result" == ""} {
161+            return -code error "No port $portname found."
162+        }
163+
164+        array set portinfo [lindex $result 1]
165+
166+        # if this fails the port doesn't have any variants
167+        if {[catch {set portvariants $portinfo(variants)} result]} {
168+            puts "$portname has no variants"
169+        } else {
170+        # print out all the variants
171+            for {set i 0} {$i < [llength $portvariants]} {incr i} {
172+                puts "[lindex $portvariants $i]"
173+            }
174+        }
175+    }
176+    toc {
177+        set rfile [dportregistry::exists $portname]
178+        if {[string length $rfile]} {
179+            if {"[file extension $rfile]" == ".bz2"} {
180+                set shortname [file rootname [file tail $rfile]]
181+                set fd [open "|bzcat -q $rfile" r]
182+            } else {
183+                set shortname [file tail $rfile]
184+                set fd [open $rfile r]
185+            }
186+            set entry [read $fd]
187+            # kind of a corner case but I ran into it testing
188+            if {[catch {close $fd} result]} {
189+                return -code error "Port failed: $rfile may be corrupted"
190+            }
191+
192+            # look for a contents list
193+            set ix [lsearch $entry contents]
194+            if {$ix >= 0} {
195+                set contents [lindex $entry [incr ix]]
196+                set uninst_err 0
197+                puts "Contents of $shortname"
198+                foreach f $contents {
199+                    puts "\t[lindex $f 0]"
200+                }
201+            } else {
202+                return -code error "No contents list for $shortname"
203+            }
204+        } else {
205+            return -code error "Contents listing failed - no registry entry"
206+        }
207+    }
208     search {
209        if {![info exists portname]} {
210            puts "You must specify a search pattern"
211Index: src/port1.0/Makefile
212===================================================================
213RCS file: /Volumes/src/cvs/od/proj/darwinports/base/src/port1.0/Makefile,v
214retrieving revision 1.34
215diff -u -r1.34 Makefile
216--- src/port1.0/Makefile        5 Aug 2003 09:28:56 -0000       1.34
217+++ src/port1.0/Makefile        16 Aug 2003 04:37:00 -0000
218@@ -4,8 +4,8 @@
219        portfetch.tcl portmain.tcl portbuild.tcl portpatch.tcl portutil.tcl \
220        portinstall.tcl portdepends.tcl portdestroot.tcl                    \
221        portinstall.tcl portuninstall.tcl                                   \
222-       portdepends.tcl portclean.tcl portpackage.tcl portcontents.tcl      \
223-       portmpkg.tcl portrpmpackage.tcl
224+       portdepends.tcl portclean.tcl portpackage.tcl portmpkg.tcl          \
225+        portrpmpackage.tcl
226 
227 SUBDIR=                resources
228 
229Index: src/port1.0/port.tcl
230===================================================================
231RCS file: /Volumes/src/cvs/od/proj/darwinports/base/src/port1.0/port.tcl,v
232retrieving revision 1.22
233diff -u -r1.22 port.tcl
234--- src/port1.0/port.tcl        5 Aug 2003 09:28:56 -0000       1.22
235+++ src/port1.0/port.tcl        16 Aug 2003 04:37:00 -0000
236@@ -45,5 +45,4 @@
237 package require portclean 1.0
238 package require portpackage 1.0
239 package require portrpmpackage 1.0
240-package require portcontents 1.0
241 package require portmpkg 1.0