New port searching tool

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.
 
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.)
 
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.
 
Even with all the options available now, I still use my old script hacked together many years ago:
Code:
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 :)
 
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.
 
I usually use
Code:
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:
Code:
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. :)
 
lme@ said:
I usually use
Code:
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:
Code:
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. :)

Do you have this fun for zsh ??
 
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.
 
Back
Top