Upgrading FreeBSD Ports with portsnap

I used to upgrade FreeBSD ports tree with CVSup. I run it through cron everyday.

Today found a much better way to upgrade FreeBSD ports tree – portsnap

portsnap is more efficient and secure way to upgrade ports tree. Here is how to install portsnap

First find location of portsnap in your ports tree.

# cd /usr/ports
freebsd# make search name=portsnap
Port: portsnap-0.9.4
Path: /usr/ports/sysutils/portsnap
Info: Provides secure snapshots of the ports directory
Maint: cperciva@daemonology.net
B-deps:
R-deps: bsdiff-4.2
WWW: http://www.daemonology.net/portsnap/

So we find the portsnap is available in ports tree at /usr/ports/sysutils/portsnap. To install

# cd /usr/ports/sysutils/portsnap
# make install

Before you can use portsnap, you will have to create an update configuration
file specifying the server from which to fetch snapshots and the sha256 hash
of the openssl public key which is trusted to sign the snapshots.

A sample configuration file has been installed in

/usr/local/etc/portsnap.conf.sample

which will fetch snapshots built and signed by the author. If you want to
use these updates, copy that file to

/usr/local/etc/portsnap.conf

otherwise, create that file as appropriate.

NOTE TO USERS UPGRADING FROM PORTSNAP 0.3.1 OR EARLIER: The structure
of the portsnap configuration file has changed; you will have to replace
your existing portsnap.conf with a new version.

Now portsnap is installed and ready to use. Before you can use any newly installed program, you should run rehash.

# rehash

Creating configuration file for portsnap

# cd /usr/local/etc/
# cp portsnap.conf.sample portsnap.conf

portsnap command with out any parameter will display help

# portsnap
usage: portsnap [options] command [URL | path]

Options:
-d workdir — Store working files in workdir
(default: /usr/local/portsnap/)
-f conffile — Read configuration options from conffile
(default: /usr/local/etc/portsnap.conf)
-I — Update INDEX only. (update command only)
-k KEY — Trust an RSA key with SHA1 hash of KEY
-p portsdir — Location of uncompressed ports tree
(default: /usr/ports/)
URL — Fetch updates from given URL. (fetch / cron commands only)
path — Extract only parts of the tree starting with the given
string. (extract command only)
Commands:
fetch — Fetch a compressed snapshot of the ports tree,
or update an existing snapshot.
cron — Sleep rand(3600) seconds, and then fetch updates.
extract — Extract snapshot of ports tree, replacing existing
files and directories.
update — Update ports tree to match current snapshot, replacing
files and directories which have changed.

Running portsnap fetch

# portsnap fetch
Fetching public key… done.
Fetching snapshot tag… done.
Fetching snapshot metadata… done.
Fetching snapshot generated at Tue Nov 15 06:58:14 IST 2005:
Receiving e505da4cc61d5dcd62af26aa7ec4f119f5ba1a4 (38309460 bytes): 0% (ETA 48:25:07)

This take some time, it is downloading a 38309460 bytes (38 MB) file. It seems CVSUP is better on my local pc as it won’t download 38 MB when i upgrade ports tree.

May be this is because it is running for first time. Lets wait and see.


Posted in FreeBSD. Bookmark the permalink.