| 1136 | | set status 0 |
| 1137 | | require_portlist portlist |
| 1138 | | foreachport $portlist { |
| 1139 | | # Get information about the named port |
| 1140 | | if {[catch {dportsearch $portname no exact} result]} { |
| 1141 | | global errorInfo |
| 1142 | | ui_debug "$errorInfo" |
| 1143 | | break_softcontinue "search for portname $portname failed: $result" 1 status |
| 1144 | | } |
| 1145 | | |
| 1146 | | if {$result == ""} { |
| 1147 | | puts "No port $portname found." |
| 1148 | | } else { |
| 1149 | | set found [expr [llength $result] / 2] |
| 1150 | | if {$found > 1} { |
| 1151 | | ui_warn "Found $found port $portname definitions, displaying first one." |
| 1152 | | } |
| 1153 | | array unset portinfo |
| 1154 | | array set portinfo [lindex $result 1] |
| 1155 | | |
| 1156 | | |
| 1157 | | # Map from friendly to less-friendly but real names |
| 1158 | | array set name_map " |
| 1159 | | category categories |
| 1160 | | maintainer maintainers |
| 1161 | | platform platforms |
| 1162 | | variant variants |
| 1163 | | " |
| 1164 | | |
| 1165 | | # Understand which info items are actually lists |
| 1166 | | # (this could be overloaded to provide a generic formatting code to |
| 1167 | | # allow us to, say, split off the prefix on libs) |
| 1168 | | array set list_map " |
| 1169 | | categories 1 |
| 1170 | | depends_build 1 |
| 1171 | | depends_lib 1 |
| 1172 | | maintainers 1 |
| 1173 | | platforms 1 |
| 1174 | | variants 1 |
| 1175 | | " |
| 1176 | | |
| 1177 | | # Set up our field separators |
| 1178 | | set show_label 1 |
| 1179 | | set field_sep "\n" |
| 1180 | | set subfield_sep ", " |
| 1181 | | |
| 1182 | | # Tune for sort(1) |
| 1183 | | if {[info exists options(ports_info_line)]} { |
| 1184 | | array unset options ports_info_line |
| 1185 | | set show_label 0 |
| 1186 | | set field_sep "\t" |
| 1187 | | set subfield_sep "," |
| 1188 | | } |
| 1189 | | |
| 1190 | | # Figure out whether to show field name |
| 1191 | | set quiet [ui_isset ports_quiet] |
| 1192 | | if {$quiet} { |
| 1193 | | set show_label 0 |
| 1194 | | } |
| 1195 | | |
| 1196 | | # Spin through action options, emitting information for any found |
| 1197 | | set fields {} |
| 1198 | | foreach { option } [array names options ports_info_*] { |
| 1199 | | set opt [string range $option 11 end] |
| 1200 | | |
| 1201 | | # Map from friendly name |
| 1202 | | set ropt $opt |
| 1203 | | if {[info exists name_map($opt)]} { |
| 1204 | | set ropt $name_map($opt) |
| 1205 | | } |
| 1206 | | |
| 1207 | | # If there's no such info, move on |
| 1208 | | if {![info exists portinfo($ropt)]} { |
| 1209 | | if {!$quiet} { |
| 1210 | | puts "no info for '$opt'" |
| 1211 | | } |
| 1212 | | continue |
| 1213 | | } |
| 1214 | | |
| 1215 | | # Calculate field label |
| 1216 | | set label "" |
| 1217 | | if {$show_label} { |
| 1218 | | set label "$opt: " |
| 1219 | | } |
| 1220 | | |
| 1221 | | # Format the data |
| 1222 | | set inf $portinfo($ropt) |
| 1223 | | if [info exists list_map($ropt)] { |
| 1224 | | set field [join $inf $subfield_sep] |
| 1225 | | } else { |
| 1226 | | set field $inf |
| 1227 | | } |
| 1228 | | |
| 1229 | | lappend fields "$label$field" |
| 1230 | | } |
| 1231 | | |
| 1232 | | if {[llength $fields]} { |
| 1233 | | # Show specific fields |
| 1234 | | puts [join $fields $field_sep] |
| 1235 | | } else { |
| 1236 | | |
| 1237 | | # If we weren't asked to show any specific fields, then show general information |
| 1238 | | puts -nonewline "$portinfo(name) $portinfo(version)" |
| 1239 | | if {[info exists portinfo(revision)] && $portinfo(revision) > 0} { |
| 1240 | | puts -nonewline ", Revision $portinfo(revision)" |
| 1241 | | } |
| 1242 | | puts -nonewline ", $portinfo(portdir)" |
| 1243 | | if {[info exists portinfo(variants)]} { |
| 1244 | | puts -nonewline " (Variants: [join $portinfo(variants) ", "])" |
| 1245 | | } |
| 1246 | | puts "" |
| 1247 | | if {[info exists portinfo(homepage)]} { |
| 1248 | | puts "$portinfo(homepage)" |
| 1249 | | } |
| 1250 | | |
| 1251 | | if {[info exists portinfo(long_description)]} { |
| 1252 | | puts "\n[join $portinfo(long_description)]\n" |
| 1253 | | } |
| 1254 | | |
| 1255 | | # Emit build, library, and runtime dependencies |
| 1256 | | foreach {key title} { |
| 1257 | | depends_build "Build Dependencies" |
| 1258 | | depends_lib "Library Dependencies" |
| 1259 | | depends_run "Runtime Dependencies" |
| 1260 | | } { |
| 1261 | | if {[info exists portinfo($key)]} { |
| 1262 | | puts -nonewline "$title:" |
| 1263 | | set joiner "" |
| 1264 | | foreach d $portinfo($key) { |
| 1265 | | puts -nonewline "$joiner [lindex [split $d :] end]" |
| 1266 | | set joiner "," |
| 1267 | | } |
| 1268 | | set nodeps false |
| 1269 | | puts "" |
| 1270 | | } |
| 1271 | | } |
| 1272 | | |
| 1273 | | if {[info exists portinfo(platforms)]} { puts "Platforms: $portinfo(platforms)"} |
| 1274 | | if {[info exists portinfo(maintainers)]} { puts "Maintainers: $portinfo(maintainers)"} |
| 1275 | | } |
| 1276 | | } |
| 1277 | | } |
| 1278 | | |
| 1279 | | return $status |
| | 1136 | set status 0 |
| | 1137 | require_portlist portlist |
| | 1138 | foreachport $portlist { |
| | 1139 | # If we have a url, use that, since it's most specific |
| | 1140 | # otherwise try to map the portname to a url |
| | 1141 | if {$porturl eq ""} { |
| | 1142 | # Verify the portname, getting portinfo to map to a porturl |
| | 1143 | if {[catch {dportsearch $portname no exact} result]} { |
| | 1144 | ui_debug "$::errorInfo" |
| | 1145 | break_softcontinue "search for portname $portname failed: $result" 1 status |
| | 1146 | } |
| | 1147 | if {[llength $result] < 2} { |
| | 1148 | break_softcontinue "Port $portname not found" 1 status |
| | 1149 | } |
| | 1150 | set found [expr [llength $result] / 2] |
| | 1151 | if {$found > 1} { |
| | 1152 | ui_warn "Found $found port $portname definitions, displaying first one." |
| | 1153 | } |
| | 1154 | array unset portinfo |
| | 1155 | array set portinfo [lindex $result 1] |
| | 1156 | set porturl $portinfo(porturl) |
| | 1157 | set portdir $portinfo(portdir) |
| | 1158 | } |
| | 1159 | |
| | 1160 | set dport [dportopen $porturl [array get options] [array get variations]] |
| | 1161 | array unset portinfo |
| | 1162 | array set portinfo [dportinfo $dport] |
| | 1163 | dportclose $dport |
| | 1164 | if {[info exists portdir]} { |
| | 1165 | set portinfo(portdir) $portdir |
| | 1166 | } |
| | 1167 | |
| | 1168 | # Map from friendly to less-friendly but real names |
| | 1169 | array set name_map " |
| | 1170 | category categories |
| | 1171 | maintainer maintainers |
| | 1172 | platform platforms |
| | 1173 | variant variants |
| | 1174 | " |
| | 1175 | |
| | 1176 | # Understand which info items are actually lists |
| | 1177 | # (this could be overloaded to provide a generic formatting code to |
| | 1178 | # allow us to, say, split off the prefix on libs) |
| | 1179 | array set list_map " |
| | 1180 | categories 1 |
| | 1181 | depends_build 1 |
| | 1182 | depends_lib 1 |
| | 1183 | maintainers 1 |
| | 1184 | platforms 1 |
| | 1185 | variants 1 |
| | 1186 | " |
| | 1187 | |
| | 1188 | # Set up our field separators |
| | 1189 | set show_label 1 |
| | 1190 | set field_sep "\n" |
| | 1191 | set subfield_sep ", " |
| | 1192 | |
| | 1193 | # Tune for sort(1) |
| | 1194 | if {[info exists options(ports_info_line)]} { |
| | 1195 | array unset options ports_info_line |
| | 1196 | set show_label 0 |
| | 1197 | set field_sep "\t" |
| | 1198 | set subfield_sep "," |
| | 1199 | } |
| | 1200 | |
| | 1201 | # Figure out whether to show field name |
| | 1202 | set quiet [ui_isset ports_quiet] |
| | 1203 | if {$quiet} { |
| | 1204 | set show_label 0 |
| | 1205 | } |
| | 1206 | |
| | 1207 | # Spin through action options, emitting information for any found |
| | 1208 | set fields {} |
| | 1209 | foreach { option } [array names options ports_info_*] { |
| | 1210 | set opt [string range $option 11 end] |
| | 1211 | |
| | 1212 | # Map from friendly name |
| | 1213 | set ropt $opt |
| | 1214 | if {[info exists name_map($opt)]} { |
| | 1215 | set ropt $name_map($opt) |
| | 1216 | } |
| | 1217 | |
| | 1218 | # If there's no such info, move on |
| | 1219 | if {![info exists portinfo($ropt)]} { |
| | 1220 | if {!$quiet} { |
| | 1221 | puts "no info for '$opt'" |
| | 1222 | } |
| | 1223 | continue |
| | 1224 | } |
| | 1225 | |
| | 1226 | # Calculate field label |
| | 1227 | set label "" |
| | 1228 | if {$show_label} { |
| | 1229 | set label "$opt: " |
| | 1230 | } |
| | 1231 | |
| | 1232 | # Format the data |
| | 1233 | set inf $portinfo($ropt) |
| | 1234 | if [info exists list_map($ropt)] { |
| | 1235 | set field [join $inf $subfield_sep] |
| | 1236 | } else { |
| | 1237 | set field $inf |
| | 1238 | } |
| | 1239 | |
| | 1240 | lappend fields "$label$field" |
| | 1241 | } |
| | 1242 | |
| | 1243 | if {[llength $fields]} { |
| | 1244 | # Show specific fields |
| | 1245 | puts [join $fields $field_sep] |
| | 1246 | } else { |
| | 1247 | |
| | 1248 | # If we weren't asked to show any specific fields, then show general information |
| | 1249 | puts -nonewline "$portinfo(name) $portinfo(version)" |
| | 1250 | if {[info exists portinfo(revision)] && $portinfo(revision) > 0} { |
| | 1251 | puts -nonewline ", Revision $portinfo(revision)" |
| | 1252 | } |
| | 1253 | if {[info exists portinfo(portdir)]} { |
| | 1254 | puts -nonewline ", $portinfo(portdir)" |
| | 1255 | } |
| | 1256 | if {[info exists portinfo(variants)]} { |
| | 1257 | puts -nonewline " (Variants: [join $portinfo(variants) ", "])" |
| | 1258 | } |
| | 1259 | puts "" |
| | 1260 | if {[info exists portinfo(homepage)]} { |
| | 1261 | puts "$portinfo(homepage)" |
| | 1262 | } |
| | 1263 | |
| | 1264 | if {[info exists portinfo(long_description)]} { |
| | 1265 | puts "\n[join $portinfo(long_description)]\n" |
| | 1266 | } |
| | 1267 | |
| | 1268 | # Emit build, library, and runtime dependencies |
| | 1269 | foreach {key title} { |
| | 1270 | depends_build "Build Dependencies" |
| | 1271 | depends_lib "Library Dependencies" |
| | 1272 | depends_run "Runtime Dependencies" |
| | 1273 | } { |
| | 1274 | if {[info exists portinfo($key)]} { |
| | 1275 | puts -nonewline "$title:" |
| | 1276 | set joiner "" |
| | 1277 | foreach d $portinfo($key) { |
| | 1278 | puts -nonewline "$joiner [lindex [split $d :] end]" |
| | 1279 | set joiner "," |
| | 1280 | } |
| | 1281 | set nodeps false |
| | 1282 | puts "" |
| | 1283 | } |
| | 1284 | } |
| | 1285 | |
| | 1286 | if {[info exists portinfo(platforms)]} { puts "Platforms: $portinfo(platforms)"} |
| | 1287 | if {[info exists portinfo(maintainers)]} { puts "Maintainers: $portinfo(maintainers)"} |
| | 1288 | } |
| | 1289 | } |
| | 1290 | |
| | 1291 | return $status |