finding ports

I like to get to the specified port without having to recall/dig/search/cd (type type type) to which location that port may be in. For this purpose, I created a local tool that instantly assists me in this fashion:

[root@sigma ~]# port ncdu
[root@sigma /usr/ports/sysutils/ncdu]# port apache
[root@sigma /usr/ports]# port apache13
[root@sigma /usr/ports]# port apache22
[root@sigma /usr/ports/www/apache22]# ls
Makefile Makefile.options pkg-descr
Makefile.doc distinfo pkg-message
Makefile.modules files pkg-plist
[root@sigma /usr/ports/www/apache22]#


As you see here, the method is straightforward. I'm wondering if this type of function would be useful in base FreeBSD, or if it's desirable per specifications to navigate the tree for each port.
 
Would be nice to save a lot of hassle.

Could you maybe add a globbing functionality a la "port *blah*" that shows you what choices are available.
The different arbitrary namings and the inclusion of versions in the ports' names often are the worst difficulty in finding a particular port.
Because, when I need a software called "blah" for example, the port/package name could be for example "blah56_78", "blah-server" or even "devel-blah_12".

And, maybe you could upload your script so we all can use it? ;)
 
Code:
cd /usr/ports
make search name=blah
make search key=blah
... has been around for a long time. And 'blah' is automatically treated like a case-insensitive *glob*.

Use quicksearch instead of search to show a little less information.
 
There is also psearch, which is similar. Type psearch (part of port name) and it will give you said port's location or locations.
 
Just to demonstrate why I'm asking the OP question:

Where is psearch (wasn't specified)? Ah, use make search name=psearch to discover where the port is... ironically having to spend more time making the search query, waiting for the result, and cd'ing to the port directory, than getting work done. Observation, not complaint.

[root@sigma /usr/ports]# make search name=psearch
Port: psearch-2.0.2
Path: /usr/ports/ports-mgmt/psearch
Info: Utility for searching the FreeBSD Ports Collection
Maint: mail@maxlor.com
B-deps:
R-deps:
WWW: http://www.maxlor.com/freebsd-scripts.shtml

Port: www/dpsearch
Moved:
Date: 2014-11-29
Reason: Has expired: Broken for more than 6 months

[root@sigma /usr/ports]# cd ports-mgmt/psearch
[root@sigma /usr/ports/ports-mgmt/psearch]#


[root@sigma ~]# psearch wsgi4
www/mod_wsgi4 Python WSGI adapter module for Apache
[root@sigma ~]#


Some administrative functions should really be streamlined. We have a ports system, so obviously uniformity, accessibility, and OS management are important. pkg install psearch for example is another great resource, however that lacks integration and optimization (and timeliness of version updates). freebsd-update made a world of difference in OS update management, as a good example of fluid administration.

Basically, this post touches on but one example of how generic CLI operations become over-complicated, and one proposed solution to the issue. I'd like to see more modern fluidity in this respect.

Code share as requested. It's really simple but saves much time. I'm sure this can be consolidated.
Code:
File: /usr/local/scripts/port                                  
#!/bin/bash

PORT=`/usr/bin/perl /usr/local/scripts/where $1`

cd /usr/ports/$PORT
Code:
File: /usr/local/scripts/where                                
#!/usr/bin/perl

$arg = shift @ARGV;
if (! $arg) {
  cd /usr/ports;
  exit;
}

if ($arg !~ /\//) {
  $input_arg = `/usr/bin/whereis $arg`;
  ($port) = $input_arg =~ /^.*?ports\/(\S+)\s+.*?$/;
}

print "$port";
 
pkg-search man page said:
-o, --origins
List packages by origin for each package matching pattern.
Equivalent to -L origin.

Code:
$ pkg search -o psearch
ports-mgmt/psearch             Utility for searching the FreeBSD Ports Collection
 
Basically, this post touches on but one example of how generic CLI operations become over-complicated, and one proposed solution to the issue. I'd like to see more modern fluidity in this respect.

Yes, me too. But that's because I keep missing the "essential guide for the FreeBSD newbie", and would never think there would be commands like that.
But anyway, don't you think the need to install bash and perl are against the idea to keep it simple?
 
In context, yes. That's why I mentioned the scripts provided could certainly be reduced. Unfortunately I lack the /bin/sh skills to accomplish that.

Also want to add portmaster to the list of fluid management. Personally I sincerely appreciate everyone's work that goes into improving the FreeBSD experience. Thank you guys.
 
This also works: find . -maxdepth 2 | sort | grep <port>

- or -

add this to ~/.cshrc in home folder.

alias findport 'find /usr/ports/ -maxdepth 2 | sort | grep $1'
 
Back
Top