# New port searching tool



## artificer (Dec 5, 2008)

I was looking for a command-line tool that searches within the ports tree and presents the results in a colorful and informative way.
I wasn't satisfied with the current programs in the ports tree, so, I made this little script in python which does exactly that:

eXquisite Port Seeker
tarball

I won't try to bloat it with features, as there are already sophisticated tools for playing with ports and packages such as portupgrade. It is only meant for searching ports.

The code is not of the best quality, but it works for me. Maybe someone will find it useful.
Any comments are welcome.


----------



## SirDice (Dec 5, 2008)

I mainly use http://www.freshports.org 

Or in the ports dir:
*make search name=portname*
Or if I don't know the port's name:
*make search key=somesearchkey*


----------



## anomie (Dec 5, 2008)

Nice work.


----------



## artificer (Dec 5, 2008)

SirDice said:
			
		

> I mainly use http://www.freshports.org
> 
> Or in the ports dir:
> *make search name=portname*
> ...



Of course, both ways are handy. It's just that I usually use the command line, and make search seems a bit limited to me.


----------



## anomie (Dec 5, 2008)

FYI, it doesn't seem to be in the ports tree yet. Perhaps after the freeze is over. I'm looking forward to trying it out. (I see you've made the tarball available for download too.)


----------



## artificer (Dec 5, 2008)

anomie said:
			
		

> FYI, it doesn't seem to be in the ports tree yet. Perhaps after the freeze is over. I'm looking forward to trying it out. (I see you've made the tarball available for download too.)



Yes, it will probably take a while until it gets in the tree.
It's just a single executable however (and a man page), so it doesn't need any installation at all. Just unpack and run.


----------



## tingo (Dec 6, 2008)

Even with all the options available now, I still use my old script hacked together many years ago:

```
root@kg-vm# ls -l /usr/local/bin/port
-rwxr-xr-x  1 root  wheel  474 Oct 14  2006 /usr/local/bin/port
root@kg-vm# cat /usr/local/bin/port
#!/bin/sh
# @(#)port	1.0	10-nov-2001	T. Ingolfsen / KG4, Norway
#
# Just a quick hack to get any easier way to search for ports
#
NAME=`basename ${0}`
PORTNAME="${1}"
PORTSDIR="/usr/ports"

if [ "$1" = "" ]; then
	echo " ${NAME} - find a given port in /usr/ports"
	echo "	Use with '${NAME} xxx', where xxx is the name of the port."
else
	if [ ! -d ${PORTSDIR} ]; then
		echo " ERROR: ${PORTSDIR} doesn't exist!"
		exit 0
	fi
	cd ${PORTSDIR}
	make search name=${PORTNAME}
fi
```
As you can see, I haven't even bothered to correct my spelling error in the comment


----------



## Citsakots (Dec 7, 2008)

An other way to search for ports when you have a browser with working internet is to use the page below.
http://www.freebsd.org/ports/


----------



## DutchDaemon (Dec 7, 2008)

I just use psearch ...


----------



## kamikaze (Dec 8, 2008)

Actually make search is quite powerful. You can specify explicitly by which criteria you want to search.


----------



## bsddaemon (Dec 8, 2008)

I just use my script, based on whereis and locate. It is able to list all matching ports & categories, let you choose which one to install and remind you to update portsnap as well:

http://asternix.org/data/img/pinstall.png

The script wasnt well written, though, since it was long time ago when I was still new to scripting, but I will post the script if anyone interested.


----------



## lme@ (Dec 8, 2008)

I usually use 
	
	



```
make quicksearch
```
 when I am looking for a port and I have a portstree installed with an INDEX file.
When I want to know to which port/package a specific file belongs to, I query porgle which is very fast and useful.
With tcsh, the INDEX and /var/db/pkg file you can have some fun with the ports management tools:

```
complete portupgrade	'c/--/(help all afterinstall= backup-packages beforebuild= clean cleanup \
				distclean force fetch-only ignore-moved interactive keep-going results-file= \
				log-file= make-args= make-env= noexecute new origin= omit-check package \
				use-packages use-packages-only noconfig recursive upward-recursive sudo \
				sudo-command= uninstall-shlibs verbose noclean nocleanup exclude= yes)/' \
			'c/-/(h a A b B c C D f F i k l L m M n N o O p P q r R s S u v w W x y)/' \
			'n@*@`\ls -1 /var/db/pkg | sed "s%/var/db/pkg/%%;s%^\(.*\)-[0-9].*%\1%"`@'

complete portversion	'n@*@`\ls -1 /var/db/pkg | sed "s%/var/db/pkg/%%;s%^\(.*\)-[0-9].*%\1%"`@'
complete pkg_deinstall	'n@*@`\ls -1 /var/db/pkg | sed "s%/var/db/pkg/%%;s%^\(.*\)-[0-9].*%\1%"`@'
complete pkg_info	'c/-/(a b v p q Q c d D f g i I j k K r R m L s o G W O x X e E l t V P)/' \
			'n@*@`\ls -1 /var/db/pkg | sed "s%/var/db/pkg/%%;s%^\(.*\)-[0-9].*%\1%"`@'
complete pkg_delete	'n@*@`\ls -1 /var/db/pkg | sed "s%/var/db/pkg/%%"`@'

complete portmaster	'n@*@`\ls -1 /var/db/pkg | sed "s%/var/db/pkg/%%;s%^\(.*\)-[0-9].*%\1%"`@'

complete portsnap	'c/-/(I d f k p s)/' \
			'n/-d/d/' \
			'n/-p/d/' \
			'n/*/(fetch extract update)/'

complete pkg_add 'n@-r@`awk -F\| \{sub\(/-\[0-9\]\.\*\/\,\"\"\,\$1\)\;print\ \$1\} /usr/ports/INDEX | sort -u`@'
```
When you insert the lines to your .tcshrc, you have a completion from /var/db/pkg for portupgrade, portversion, pkg_deinstall, pkg_info, pkg_delete and portmaster as well as a completion from INDEX for 'pkg_add -r'.

But I am getting off-topic here. To the OT: Nice new tool which will for sure find its way to the ports tree! Don't forget to send a PR for it.


----------



## nORKy (Dec 8, 2008)

lme@ said:
			
		

> I usually use
> 
> 
> 
> ...



Do you have this fun for zsh ??


----------



## lme@ (Dec 8, 2008)

nORKy said:
			
		

> Do you have this fun for zsh ??



Nay, but it should be possible to port this to zsh.


----------



## artificer (Dec 8, 2008)

lme@ said:
			
		

> Nice new tool which will for sure find its way to the ports tree! Don't forget to send a PR for it.


I'm glad it's useful to others as well 
It's already in the tree, thanks to miwi@'s fast response.


----------



## lme@ (Dec 8, 2008)

Yeah, miwi@ is a ports machine.


----------

