AddThis Social Bookmark Button


FreeBSD Basics Interesting New Ports

by Dru Lavigne, author of BSD Hacks

For those faithful readers who were starting to wonder when the next article in this column would appear, I'm back. BSD Hacks is finally finished.

In today's article, I'd like to demonstrate some useful utilities that recently arrived in the ports collection. I usually discover these from FreshPorts, which keeps statistics on which ports have been added in the last 24 hours, 48 hours, week, fortnight, and month.

Pruning Installed Ports

However, I first learned about sysutils/pkg_cutleaves from Richard Bejtlich's weblog. Richard has the uncanny ability of keeping abreast of my three favorite subjects: FreeBSD, the ports collection, and security.

If you use portupgrade to keep your ports up-to-date, consider adding pkg_cutleaves to your repertoire. This interactive Perl script searches your ports database for "leaves," or software that isn't a dependency of any other installed program. This gives you the opportunity to clean your drive of those orphaned programs you no longer use or were dependencies of software you've since uninstalled.

Once you've built the port from /usr/ports/sysutils/pkg_cutleaves, take a minute to read man pkg_cutleaves. Then, as the superuser:

# pkg_cutleaves
Package 1 of 73:
AbiWord2-2.0.5 - An open-source, cross-platform WYSIWYG word processor
AbiWord2-2.0.5 - [keep]/(d)elete/(f)lush marked pkgs/(a)bort? k
** Keeping AbiWord2-2.0.5.

On this particular system, I have 250 installed ports, of which 73 are entirely independent. pkg_cutleaves will show each of these and will pause while I decide to keep or remove the port. I've chosen to keep AbiWord2, as well as the next 6 XFree86 related ports.

Package 8 of 73:
apache-ant-1.6.1 - Java- and XML-based build tool, conceptually similar to make
apache-ant-1.6.1 - [keep]/(d)elete/(f)lush marked pkgs/(a)bort? d
** Marking apache-ant-1.6.1 for removal.

However, I've chosen to delete apache-ant since I have a vague memory of it being a dependency of some application I've long ago uninstalled. I'll carry on until I've made a decision on each of the 73 ports. Once I'm finished, pkg_delete will carry out the requested deletions. In this example, I've chosen to delete 25 ports:

Package 73 of 73:
zip-2.3_1 - Create/update ZIP files compatible with pkzip
zip-2.3_1 - [keep]/(d)elete/(f)lush marked pkgs/(a)bort? k
** Keeping zip-2.3_1.

Deleting apache-ant-1.6.1 (package 1 of 25).
--->  Deinstalling 'apache-ant-1.6.1'
[Updating the pkgdb <format:bdb1_btree> in /var/db/pkg ... - 250 
packages found (-1 +0) (...) done]

When these deletions complete, pkg_cutleaves reprocesses the ports database to see if any of those deletions resulted in new leaf packages:

Go on with new leaf packages ((y)es/[no])? y

This process will continue until I've dealt with all leaves. At that point it will provide a summary of the uninstalled packages:

Didn't find any new leaves, exiting.
** Deinstalled packages:
** Number of deinstalled packages: 53

The next time you run pkg_cutleaves, it will ask you again about the ports you chose to keep. In my example, that would be AbiWord2 and those XFree86 ports. If you know you want to keep these and find it irritating to confirm this every time, create a file called /usr/local/etc/pkg_leaves.exclude containing the names of those ports you wish to keep:


Remember to include the x (exclude) switch:

# pkg_cutleaves -x

This tells pkg_cutleaves to read your exclude file. For those occasions when you don't want it to read your exclude file, don't include that switch.

BSD Hacks

Related Reading

BSD Hacks
100 Industrial Tip & Tools
By Dru Lavigne

Improving Your Fortunes

The next new port is for those of you who enjoy BOFH humor. If that strikes your funny bone, you can add BOFH-style fortunes to your system by installing /usr/ports/misc/fortune-mod-bofh.

Once installed, try a random fortune:

% fortune /usr/local/share/games/fortune/bofh
BOFH excuse #419:

overflow error in /dev/null

If you'd like these fortunes to appear randomly with the rest of your fortunes, copy them into the system fortune directory as the superuser:

# cp /usr/local/share/games/fortune/bofh* /usr/share/games/fortune/

Once you've copied over the BOFH files, you can specify you'd like a BOFH fortune by typing:

% fortune bofh

This is many keystrokes shorter than the previous incantation.

Finally, if you're a Futurama fan, repeat the above for the /usr/ports/misc/fortune-mod-futurama port:

# cd /usr/ports/misc/fortune-mod-futurama
# make install clean
# cp /usr/local/share/games/fortune/futurama* /usr/share/games/fortune/
# exit
% fortune futurama
Fry: I want to see the edge of the universe.
Amy: Ooh, that sounds cool.
Zoidberg: It's funny. You live in the universe but you
  never do these things 'til someone comes to visit.

It's funny that this fortune made me wistful for a Douglas Adams fortune. A quick Google search located that there is indeed a fortune-hitchhiker project. Download fortune-hitchhiker.tgz, then:

# tar xzvf fortune-hitchhiker.tgz
# cp fortune-hitchhiker/hitchhiker* /usr/share/games/fortune
# exit
% fortune hitchhiker
"'You know,' said Arthur, 'it's at times like this, when
I'm trapped in a Vogon airlock with a man from Betelgeuse,
and about to die from asphyxiation in deep space that I
really wish I'd listened to what my mother told me when I
was young.'
'Why, what did she tell you?'
'I don't know, I didn't listen.'"

  -- Arthur coping with certain death as best as he could.

Perhaps another Hitchhiker fan will add this to the ports collection so it will show up in the new section at FreshPorts.

Making Subjects and Verbs Agree

The next port intrigued me as it's named after one of my favorite childhood literary characters:

# cd /usr/ports/textproc/queequeg
# make install clean

This will install the qq Python script, which can run against any text, LaTeX, or HTML file, like so:

% qq filename

The Queequeg project is still in its beta stages. Its goal is to help the non-native English writer match a singular or plural noun to the correct verb conjugation. At this point, the project developers are still working on filtering out false positives so the resulting output may still be too frustrating for those who lack a solid command of English grammar. However, if English grammar is your forté and you have some time to donate, this project is looking for beta testers. If it matures, it will be an excellent tool for non-English developers to easily create manpages in natural English.

Pages: 1, 2

Next Pagearrow