Hack 83 Keep Ports Up-to-Date with CTM

figs/beginner.gif figs/hack83.gif

Keep your ports up-to-date without using cvsup.

If you have a slow Internet connection, it can take a while to download the ports tree; the current tarball is over 21 MB in size. Once you have the ports collection, keeping up-to-date with cvsup might not be such an attractive option if it involves tying up your phone line.

Perhaps bandwidth isn't the problem. Perhaps you're just looking for an alternative way to stay current, without having to install and configure cvsup. After all, why install additional software if you can achieve the same results using commands that come with the base system?

Regardless of which category you fall into, CTM may be what you're looking for.

CTM was originally CVS Through Email, meaning you could receive the changes you usually receive through cvsup via email. (In the case of numerous changes, you'd receive several, smaller mails instead of one monolithic message.) This can be a cheaper alternative to cvsup if you're charged for the amount of time you are connected to the Internet.

However, it's even easier to retrieve these changes with ftp. FreeBSD maintains several CTM servers that contain the changes, or deltas, to the FreeBSD source and the ports collection. This hack will concentrate on keeping your ports up-to-date using ftp and the CTM servers.

8.8.1 Using ftp and ctm to Stay Current

Let's start with a system that doesn't have the ports collection installed. First, I'll create an empty ports directory for ctm to work with:

# mkdir /usr/ports/ # cd /usr/ports

Then, instead of downloading and untarring the ports tree tarball, I'll ftp into a CTM server and download the latest ports tree delta. The Handbook's section on CTM includes the addresses of the CTM mirrors.

# ftp ftp.freebsd.org <snip banner and login> ftp> cd pub/FreeBSD/development/CTM/ports-cur ftp> ls <snip most of long listing> -rw-r--r--  1 110    root    22332066 Jan 23 08:46 ports-cur.5100xEmpty.gz -rw-r--r--  1 110    root       67953 Jan 24 00:43 ports-cur.5101.gz -rw-r--r--  1 110    root       14256 Jan 24 16:51 ports-cur.5102.gz

Look toward the end of the listing for the large file closest to the present date. It will have the word xEmpty in its name. That file is your starting delta. Download that and any subsequent deltas.

ftp> get ports-cur.5100xEmpty.gz ftp> get ports-cur.5101.gz ftp> get ports-cur.5102.gz ftp> quit

Your first ftp transfer will be the largest and longest, as you are downloading the elements necessary to build the ports tree structure. Subsequent sessions will be very quick.

Note the .gz extension; leave the files compressed. CTM will still work, and you'll save disk space.

Save your deltas to /usr/ports, and remain in this directory when you use the ctm command.

Now that you have your starting deltas, apply them with ctm:

# ctm ports-cur.5100xEmpty.gz ctm: warning: .ctm_status not found <snip long output>

The first time you use ctm, it will complain about a missing .ctm_status file. Don't worry; it will create it for you. After a few seconds, it will send a lot of output to stdout. Once the command has finished, you'll have a fully installed version of the ports tree.

That .ctm-status file will tell you the delta number of that ports tree:

# more .ctm-status ports-cur 5100

Then, simply apply any subsequent deltas in ascending order. This will correctly incorporate all of the changes to the ports tree.

# ctm ports-cur.5101.gz # ctm ports-cur.5102.gz # more .ctm-status ports-cur 5102

That's it. Whenever you want to update your ports tree, ftp into your CTM mirror, download the deltas containing a higher number than your current version, and apply them in order.

It's up to you whether to keep the compressed versions of the files you download. Once you've successfully applied a delta as indicated by .ctm-status you no longer need to store that delta file. However, if download speed or time is an issue, consider keeping a copy of that large starting delta, just in case you ever want to recreate your ports tree from scratch.

8.8.2 Hacking the Hack

If you're too lazy or forgetful to ftp for changes periodically, consider receiving them automatically via email. Changes occur once or twice a day. Subscribe to the ctm-ports-cur mailing list to receive them (http://lists.freebsd.org/mailman/listinfo/ctm-ports-cur/).

Complete the online subscription form, and reply to the email that asks you to confirm your subscription.

However, do not subscribe to that mailing list until you've configured your system to handle those emails. Basically, you want the system to intercept those CTM updates instead of sending them directly to your mailbox. There are two ways to do this: either create a sendmail alias or create a procmail recipe. See man ctm_rmail for detailed instructions.

It's also a good idea to verify the PGP signatures before applying those updates. You can find detailed instructions for this, as well as for using ctm_rmail to handle incoming deltas, in this message from the ctm-users mailing list: http://lists.freebsd.org/pipermail/ctm-users/2003-October/000039.html.

8.8.3 See Also

  • man ctm_rmail

  • The CTM section of the FreeBSD Handbook (http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ctm.html)

BSD Hacks
BSD Hacks
ISBN: 0596006799
EAN: 2147483647
Year: 2006
Pages: 160
Authors: Lavigne

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net