home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book HomeMac OS X for Unix GeeksSearch this book

7.2. Getting the Source Code

To get the Darwin source code, you'll need to register with the Apple Open Source web site and check the source code out of the CVS archive. (The kernel source code weighs in at about 35 MB; after you compile the kernel, it will occupy about 150 MB.) To register for CVS access, visit http://developer.apple.com/darwin/tools/cvs/. That page should lead to a getting-started page, where you can register as a user.

The first step in registering is to agree to the Apple Public Source License (http://www.opensource.apple.com/apsl/). When you agree to that license, you can create a username and password that lets you check files out of CVS and view the web-based CVS archive.

7.2.1. Using CVS

When you register with Apple, you choose a username and password. You'll need to use that username and password when you log into CVS. The first step is setting your CVSROOT environment variable. Under tcsh, issue this command:

setenv CVSROOT :pserver:username@anoncvs.opensource.apple.com:/cvs/Darwin

Under bash or zsh, use this command:

export CVSROOT=:pserver:username@anoncvs.opensource.apple.com:/cvs/Darwin

Replace username with your username. After you set this environment variable, you can log into CVS with cvs login:

% cvs login
(Logging in to username@anoncvs.opensource.apple.com)
CVS password: ********

7.2.1.1. Checking out sources

To check out the source code for a module, use the checkout command:

cvs -z3 checkout [-r VERSION] modulename

The -z3 option tells CVS to use compression when transferring files.

7.2.2. Getting the Right Version

The only version of Darwin that should work with your copy of Mac OS X is the same one that Apple used. Your mileage may vary if you try to use an older or newer version. So, before you try anything like that, get the correct version and use that as a dry run to verify that you can build and install a working kernel.

First, find your Darwin version with the uname -v command. The output you're looking for is the xnu (Darwin kernel) version, shown in italic type:

% uname -v
Darwin Kernel Version 6.0: Sat Jul 27 13:18:52 PDT 2002;
root:xnu/xnu-344.obj~1/RELEASE_PPC 

You need to translate that number into an Apple CVS tag, by replacing the period (.) with a dash (-) and prefixing the version with Apple-. So, the Apple CVS tag for the xnu version previously shown would be Apple-344. This is the version you must supply with the -r flag. Now that you know the CVS tag, you can check it out:

cvs -z3 checkout -r APPLE_CVS_TAG modulename

Where APPLE_CVS_TAG is the CVS tag you computed, and modulename is xnu. For example:

% cvs -z3 checkout -r Apple-344
cvs server: Updating xnu
U xnu/APPLE_LICENSE
U xnu/Makefile
U xnu/PB.project
U xnu/README
.
.
.
TIP: The CVS tags are symbolic names associated with a snapshot of the source code in time. An easy way to browse the available tags is through the Darwin CVSWeb archive, available at http://www.opensource.apple.com/tools/cvs/. You will need to provide your registered username and password to access the archive. You can also use CVSWeb to peruse the archive and view the source code.



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.