Rhyous

February 12, 2010

How to update all your installed ports on FreeBSD using portupgrade?

Filed under: FreeBSD — J. Abram barneck @ 12:00 am
Tags: ,

Ok, this week there is a simple tool that we are going to talk about. It is called portupgrade. This is a handy software that allows you to manage your ports more efficiently.

I use portupgrade when I want to do things the easy way.

Lets give you a use case. You want to install a new piece of software that requires a library that you already have installed, for example, openssl, however the port fails because the dependency is too old of a version. Well, now you have find the updated port for openssl and uninstall and reinstall it. That might seem easy with one port. But now imaging you have a very new piece of software and you have to update a dozen or more ports. That is going to be time consuming. That is where portupgrade comes in. It does the hard work for you.

Step 1 – Make sure you have ports installed and updated
I already have a post on this. It is pretty short. Check it out here.
How to install ports on FreeBSD?

Make sure that even if you have installed ports that you update ports again so you have the latest.

Step 2 – Install portupgrade

  1. Log on as root.
    $ su
    Password:
    #
  2. Change to the ports directory and
    #
    #
    cd /usr/ports/ports-mgmt/portupgrade
    make BATCH=yes install

Step 3 – See which ports are outdated
The following command will show you which packages are up to date and which are not. Ok, you don’t really need portupgrade for this, because you can also run pkg_version which is part of base, but portupgrade seems to make a database and do this faster.

# portversion

Now, if you want to only see ports that are not up to date, do this:

# portversion |grep \<

Step 4 – Upgrade a port
Ok, now that portupgrade is installed, it is easy to upgrade a port.

# portupgrade portname

You can just copy and past the portname from the output of the portversion command.

Step 5 – Upgrade all ports
Ok, maybe you want to upgrade all your ports, and I am not saying you should, but maybe you want to. Here is a nice command that will do that for you.

# portupgrade -a -m BATCH=yes

Now that is not exactly complete, because we need to update the ports tree first. So do this:

# portsnap fetch update && portupgrade -a -m BATCH=yes

Now, on my FreeBSD box with an Xorg and KDE4 install, this has been going for over a day and isn’t done yet. I takes a long time to recompile all the Xorg, GTK, KDE4, and other miscellaneous ports.

Have fun with portupgrade.


Copyright ® Rhyous.com – Linking to this article is allowed without permission and as many as ten lines of this article can be used along with this link. Any other use of this article is allowed only by permission of Rhyous.com.

Advertisements

6 Comments »

  1. Here is a command that was recommend by Ujwa Ifa on Facebook:

    portsnap fetch update && portupgrade -apPDR --batch

    Comment by rhyous — February 15, 2010 @ 1:38 pm | Reply

  2. Once again, thanks for your clear instructions getting going with FreeBSD. I work a lot with *nix (including Linux) and Windows, but I feel like a complete nOOb just doing basic things in BSD!

    With that as an intro, is there a way to get prebuilt upgrades for FreeBSD? It seems like a real waste having every user building packages vs. having someone “in the know” do it once for everyone.

    I’ve already upgraded Firefox twice this month using portupgrade, but really, watching the thing build for an hour is a drag, when with some Linux distros you get a 1.8MB rpm and you’re up in seconds!

    Worse, I’m trying to update KDE and I keep hitting an internal compiler error during the process; I found some discussions that gnu 4.4 might fix the internal error, but once again I am stumped at how to get 4.4 on my machine: the instructions at http://www.freebsd.org/ports/index.html aren’t clear or don’t apply to 4.4, and even trusty portupgrade doesn’t seem to offer a path to 4.4!

    I would appreciate any suggestions.

    Comment by Chris — April 30, 2010 @ 12:22 am | Reply

  3. Thanks; I will definitely use the forums in the future. The compiler segfault was indeed patched in 4.4 and I can compile the KDE components OK; that could be a useful tidbit on your blog somewhere, since gcc 4.2.1 was installed with FreeBSD 8. Unfortunately, there appears to be a bug in the source (missing member ‘metaObject), which leads to two last questions:

    1. Do you consider updating using portupgrade to be leading-edge and not required unless one has a problem?

    2. Do FreeBSD users generally wait to upgrade components as part of an OS release (e.g., 8.0 -> 8.1)? If so, I am just out of sync with the flow of the BSD world…

    Regards,
    Chris

    Comment by Chris — April 30, 2010 @ 9:25 am | Reply

  4. Thank You for this great Tuto !!!

    is there any option to speed up ports compiling procedure, to make it faster ???

    Thx in advance

    Comment by Hafez — August 18, 2010 @ 9:44 am | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: