FreeBSD Tip #2

| | Comments (3)

Playing with ports

If you are familiar with FreeBSD, you are already familiar with the concept of ports and the great portupgrade (sysutils/portupgrade) program. So I am not going through explainin them from ground up. Just a few tips that might come useful:

1- Quick way to find out which port needs to be upgraded:
portsdb -Ffu && portversion -L =

2- Quick way to upgrade installed ports, interactively:
portupgrade -ari

3- To deinstall a port and unneeded dependencies, interactively:
pkg_deinstall -ri portname

4- To re-install an already installed port (for any reason):
portupgrade -f portname

5- To cleanup your ports tree from stale working directories and distfiles:
portsclean -CD

6- To fix your packages database:
pkgdb -F

After installing and removing ports on your system, you will find out there are some packages are installed which has no use. Many of them were installed as dependency of other ports which you already deinstalled. The pkg_cutleaves package (sysutils/pkg_cutleaves) comes to help in these cases. To have a list of all installed packages that no other package depends on them run pkg_cutleaves -l. Taking a quick look to the output of this command you will see some packages that you have not installed directly and no other packages use them either. Like share libraries. You can safely run pkg_cutleaves -F that interactively asks you which of these packages should be deleted.

And as the last tip about ports: Be careful when upgrading major ports like Perl. Always look /usr/ports/UPDATING for vital information about these ports. When such major upgrade happens, you should upgrade all packages depending on the port, otherwise you will break a big part of installed ports. An example of such upgrade may look like:
portupgrade -Rr perl5

Play with the ports as much as you can to get more familiar with them. And keep them up to date. Do not forget using portaudit (security/portaudit) to audit for vulnerable ports.

3 Comments

Jeff Cross said:

I have never used the commands you mentioned in step 1, although I will give them a try. I use the following for determining what ports require upgrading:

portversion -v -l "<"

I then run the following to upgrade all ports (non-interactive) from packages:

portupgrade -varRPP

Then, any ports that did not have available packages, I update from the ports tree by compiling from source using:

portupgrade -varR

This works for me. Nice write up! I look forward to reading more of your FreeBSD tips in the future.

Jeff

Hamed said:

Compact and useful! Dude will you leave notes on OpenBSD too? Thank you!

Hamed said:

Dude!

One of the most frequent questions that people who are FreeBSD lovers has is how they can use all programs which related to Perl, after they have upgraded their Perl! "portupgrade -r perl" will do that!

About this Entry

This page contains a single entry by Babak Farrokhi published on March 5, 2006 6:42 PM.

FreeBSD Tip #1 was the previous entry in this blog.

10 Favorite Firefox Extensions is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.01