Print View

Managing the Ports Tree with Portsnap
Updated: 08/09/2006


General Information

The FreeBSD ports tree is the most common method of installing software.  With the latest 6.x releases of FreeBSD, the old method of keeping your ports tree updated is now considered obsolete.  This guide will teach you how to install and maintain your ports tree using the built-in portsnap utility.

Requirements

  1. Local root access on the box or be able to su to root.
  2. A SSH client such as puTTy or SecureCRT (if you aren't on the box).

Installation

Note:  If you are running a previous version of FreeBSD, you will have to install portsnap:
# pkg_add -r portsnap

The first step to using portsnap is to download and extract the latest tree.  Even if you already have the ports tree installed (/usr/ports), you will have to download and install the tree again using portsnap.
# portsnap fetch extract
Once this process is complete, you now have the latest version of the ports tree installed.

Usage

It's a good idea to keep your ports tree up-to-date and this should be done at least once a week.  To update the tree, just issue the following command:
# portsnap fetch update
Now your ports tree is up-to-date.

Author: Jon LaBass
jon at bsdguides dot org

Find this guide useful?
Support the author:


10 Comments

Posted by neomaximus2k on August 09, 2006 at 11:12:27 am EEST

nice guide, you say you should update the ports once a week, what way would you do this cronjob?


Posted by Jon on August 09, 2006 at 4:16:57 pm EEST

You can use cron to update the ports tree automatically, but be warned:  If you are in the middle of installing anything while the ports tree gets updated, you will have undesired results.


Posted by neomaximus2k on August 09, 2006 at 5:29:37 pm EEST

thanks jon i have emailed u through your site btw


Posted by loop on August 24, 2006 at 5:30:44 am EEST

This is only true if you are installing and theportsnap update command is run.  The manpage recommends using the portsnap cron command and running portsnap update just prior to installing or updating an installed port.


Posted by donanak on October 13, 2006 at 4:32:18 pm EEST

i followed the steps and get these sort of error as can't fetch the link. anyone can help as it's looks easier for port udpating.
can i change the ftp to a different one as i believe its the ftp which is down. and also which file contains this that i can edit.
Cheers!


Posted by Jon on October 13, 2006 at 8:12:55 pm EEST

donanak:  After I read your comment, I ran a portsnap fetch update on my server and it ran successfully.  You can edit /etc/portsnap.conf to change the server.  I use the following:

SERVERNAME=portsnap.FreeBSD.org

And that will actually check the mirrors for a better one.  If this doesn't help, please post the error message you receive.


Posted by donanak on October 13, 2006 at 11:31:08 pm EEST


Thanks for your help, i edited the portsnap.conf and it's just working fantastic.

I'm all up to date you all.

Thanks Jon.


Posted by fbnb70 on February 06, 2007 at 12:37:36 pm EET

Anyone that knows what might be causing this error?

(regarding freeBSD 4.11-stable)

I have installed portsnap OK (step 1), then on step 2, running '/bin/portsnap fetch extract' fails on metadata file, see below:

Looking up portsnap.FreeBSD.org mirrors... 2 mirrors found.
Fetching public key from portsnap2.FreeBSD.org... done.
Fetching snapshot tag from portsnap2.FreeBSD.org... done.
Fetching snapshot metadata... done.
Fetching snapshot generated at Tue Feb  6 00:26:52 GMT 2007:
87ea182fbb04a302e166689ff48d105f0c71cfc1920582100% of   46 MB  255 kBps 00m00s
Extracting snapshot... done.
Verifying snapshot integrity... done.
Fetching snapshot tag from portsnap2.FreeBSD.org... done.
Fetching snapshot metadata... done.
Updating from Tue Feb  6 00:26:52 GMT 2007 to Tue Feb  6 08:19:16 GMT 2007.
Fetching 3 metadata patches.lam: not found
done.
Applying metadata patches... done.
Fetching 3 metadata files... lam: not found
/bin/portsnap: cannot open eb765585ee552687dd3946169d6664f5ab6d2c26af938d6ba82411f19ae81f59.gz: no such file
metadata is corrupt.


Posted by Jon on February 07, 2007 at 4:52:55 am EET

This is usually due to a connection problem.  Try it again and if it still fails, try changing the following in your portsnap.conf:

SERVERNAME=portsnap2.FreeBSD.org


Posted by darkaxi0m on August 20, 2007 at 6:47:29 am EEST

ive got a small lan with a fue FreeBSD Servers, is it possible to download the snapshot  once then use it to update all the servers?


Copyright 2003 - 2008 BSD Guides.  All rights reserved.

About | Terms of Use | Privacy | Contact