BSD Tricks: CVS
Pages: 1, 2
Some modules contain other modules. For example, FreeBSD's
module includes the modules for everything in
/usr/sbin. You can grab the whole
usr.sbin tree, or just one part, with proper selection of module names.
CVS also allows you to access arbitrary chunks of a project's source
tree. All you need is the path to the portion of the source tree you
want. For example, various developers are working on integrating
portions of the BSD
make system. If one of these folks wants to
download the latest version of OpenBSD's
make to see how they handle
something, he can log into an OpenBSD CVS server and do:
cvs checkout src/usr.bin/make
FreeBSD's multiplicity of module names is convenient, but not necessary.
When reading a BSD mailing list, one common solution is "grab this revision of this file and see if your problem goes away." You can specify revisions with the
Also in Big Scary Daemons:
cvs checkout -r1.15 sys/netinet/ip_log.c
You can also specify branches. Most people don't want the latest
version of a file; by definition, that's
-current. To get the latest
version of FreeBSD's 4.0-STABLE kernel source, use the RELENG_4
cvs checkout -rRELENG_4 sys
There are many other uses for downloading pieces of source code. If you
think you've fried something in your
/etc directory, you can grab the
latest version. If you think a particular file in your system might
be breaking something, use CVS to check out the previous revision.
Or, if you want to try backporting a feature from
-current or from
another BSD, CVS allows you to easily fetch the relevant sources.
cvs command takes a variety of useful options. Options to
cvs must appear between
checkout. A good one is
-z3, which compresses the source code before sending it across the network. This can vastly reduce bandwidth. The
-q option makes CVS run almost silently, checking out the code without listing every file. Finally, the
-d option lets you set an alternate
CVSROOT without changing your environment. For example, to quietly download the latest version of the core nessus utility without changing my environment, I could use:
cvs -q -z3 -d:pserver:firstname.lastname@example.org:/usr/local/cvs checkout nessus-core
What's more, the
checkout command takes a variety of flags. The
-l flag tells CVS to not recurse down the source tree. If you just wanted the files under
/etc, not in its subdirectories, you would use:
cvs checkout -l etc
One of the more interesting features is the ability to check out code as of a particular date. Suppose your system ran fine a month ago, but "ls" started failing when you upgraded a few days ago. You can narrow down the problem by getting the last source code you know is good. The
-D flag allows you to specify a date in a variety of formats.
cvs checkout -D "1 month ago" ls
You can confirm that the code worked then, and successively bring the code closer to the current date.
cvs checkout -D "1 fortnight ago" ls
(Somehow, I never thought the word "fortnight" would be useful to a sysadmin.)
By building successive versions of
ls, you can learn when the problem started. You can even fall back to older versions of kernel and world this way.
When you're finished, tell CVS you're done:
Combined with RCS, CVS gives you the ability to grab arbitrary versions of almost any file -- both those you maintain, and those supported by a BSD project. This gives you unlimited control over your system, and greatly enhances your abilities.
Read more Big Scary Daemons columns.
Return to the BSD DevCenter.