pavement

Ports Tree, Updating

From FreeBSDwiki
Revision as of 13:44, 20 December 2014 by Sidetone (Talk | contribs)
Jump to: navigation, search

When updating your FreeBSD system, you'll first want to sync your sources to the live sources offered. If you hail from a Windows environment, you may think of keeping your sources updated as about the first half of the FreeBSD procedure which corresponds to Windows Update.

Contents

Portsnap

In newer (5.5-RELEASE and up) systems, you should use portsnap to maintain your ports tree. If you are using such a system, stop reading right now and head over to the portsnap article to learn how! It is still possible to use the CVS system with newer installations - at least for now - but it's much less efficient, especially for folks who keep their trees up-to-date on a regular and consistent basis.

Cvsup

Systems older than 5.5-RELEASE will need to use the cvs system instead of portsnap. There is a port cvsup that you can use to update your ports tree and source trees. Port updates through cvs are no longer supported, as they were replaced with subversion.

Installing cvsup

You'll need to have superuser access, so su to root and then go to your /usr/ports/net/ directory. There are two versions of cvsup available to you: cvsup and cvsup-without-gui (for systems that don't have or need the cvsup GUI). Pick the one that's most appropriate for you and go into that directory and "make install clean":

   dave@samizdata:~% su -
   Password:
   samizdata# cd /usr/ports/net/
   samizdata# ls | grep cvsup
   cvsup
   cvsup-mirror
   cvsup-without-gui

so, let's say this is a headless server and I don't want X11 on it (which it is, and I don't) so:

   samizdata# cd cvsup-without-gui/
   samizdata# make install clean

and you'll get a lot of lines scrolling by; this is the program compiling.

So it's installed already, how do I update the ports tree?

Not so fast, speed racer. First you need to configure your supfile. Go to /usr/share/examples/cvsup and look through the example files. The easiest way to make a supfile for your own personal use is to copy the one that want out of the examples and edit it. So from the command line, do a

   cp /usr/share/examples/cvsup/ports-supfile /root/ports-supfile

and you have just copied the ports-supfile over to the /root/ directory (root's home directory). Now you'll need to edit that file: use your favorite text file editor such as vi, ee (commonly aliased under FreeBSD as "edit"), joe, nano, pico, vim or emacs to edit the ports-supfile.

In that file, you'll want to search for a string that says "CHANGE_THIS.freebsd.org" and change that "CHANGE_THIS" to the name of a real CVSup server. You can get a list of the servers at the list of CVSup mirrors on freebsd.org but they all have the general form of cvsup(number).(country).freebsd.org such as cvsup1000000.qw.freebsd.org. It will almost always make the process much faster if you choose a mirror nearest you (or the country that you're in, rather.) Save your change to the file and exit your editor. An easy way to do this is to use sed:

samizdata# sed s/CHANGE_THIS.FreeBSD.org/cvsup#.FreeBSD.org/g /root/ports-supfile > /root/ports-supfile_complete

substitute a real number instead of # and et voila, you've got a useful ports-supfile, named /root/ports-supfile_complete.

Once that's done, we're ready to actually update the ports. As root, issue this command:

samizdata# cvsup -g -L2 /root/ports-supfile_complete

In a perfect world, that will always work. The only times when it wont are when you don't have connectivity or the server that you're cvsup-ing against is not allowing connections. Strictly speaking, the -g command isn't necessary from a command line, since I installed cvsup-without-gui and the -g switch just makes sure that the GUI stuff in the regular CVSup program doesn't run. Since it isn't installed, I could have not given the switch and the command would have run just the same. The -L switch will give you error information, as well as a sort of progress-output -- the number next to the L (2 in this case) increases or decreases the verbosity of the output (0 is totally silent and 3 will give you everything you never wanted to read and more.) The last argument of the command is the actual ports-supfile that we made.

How do I know which cvsup server to use?

The port fastest_cvsup takes (most of) the guess work out of finding the server that will be the fastest source for your location. Once you've installed it, you can use it on the command-line something like this:

samizdata# /usr/local/bin/fastest_cvsup -Q -c us
cvsup11.freebsd.org
samizdata# /usr/local/bin/cvsup -h cvsup11.freebsd.org /root/ports-supfile-complete

What we did here was ask fastest_cvsup to look for the fastest connection to an official cvsup server, but to limit the search to those cvsup servers which are in the USA. (There isn't normally any point in querying servers that aren't even on the same continent that you are.) Then we called cvsup, but used the -h argument to force it to use cvsup11.freebsd.org instead of whatever cvsup server was specified in the supfile.

We can also get fancy and do both things in a single step:

samizdata# /usr/local/bin/cvsup -h `/usr/local/bin/fastest_cvsup -Q -c us` /root/ports-supfile-complete

Note that doing this does add a noticeable (10-15 seconds) delay while we locate the fastest server, and that that's really not something you generally need to do every time you update: it's generally better to go ahead and find the fastest server, then update your ports-supfile with it and leave it alone unless and until it starts to seem a lot slower than it used to / doesn't respond / etc. Also note that we used backticks (`), not single quotes ('). That tells the shell to execute whatever is inside the backticks and use the results in the command that we gave it.

It's updated. Now what?

Well, go into /usr/ports and find stuff you want to install!

You may also want to install the very useful port management tool portupgrade, which also installs a program called portversion. You can use portversion to check your existing installed programs against what is available in the ports tree, and then use portupgrade to upgrade your existing, old, installed software to the new versions found in the ports tree. Together, cvsup, portversion, and portupgrade allow you to make sure you have the latest version of ANY port in the ports tree, including packages installed with the base FreeBSD install that have been updated since your particular version was released.

See also:

Personal tools