Including third party code in CVS
Let's say we want to start a project, and include the excellent database abstraction layer ADOdb into our CVS repository.
First, let's import our new project, and name the CVS module _myproject:
$ cd original_code
$ cvs import -m 'Initial import' _myproject INTERNAL R0_01
$ cd ..
The leading underscore is not required. It's just a convention I use to indicate a module that is included within another module.
Next, we'll import ADOdb and name the CVS module _adodb:
$ wget http://phplens.com/lens/dl/adodb372.tgz
$ tar xvzf adodb372.tgz
$ cd adodb
$ cvs import -m 'Imported ADOdb 3.72' _adodb PHPLENS_COM R3_72
$ cd ..
Now, we want to associate these two modules, such that when we check out the _myproject module, we get the _adodb module as well. We do that thru the CVSROOT/modules file, which we'll now check out:
$ cvs commit CVSROOT
$ cd CVSROOT
We'll add the following lines to the modules file:
adodb -d adodb _adodb
myproject &_myproject &adodb
Next, we'll commit these changes:
$ cvs commit -m 'Added myproject and adodb to modules file'
$ cd ..
The first line tells CVS that adodb is an alias for the _adodb module. But when we check out adodb, the _adodb module's files will be created in a directory named adodb.
The second line tells CVS that myproject is an alias for both the _myproject module and the adodb alias. When we check out myproject, the _myproject module's files will be created in a directory named myproject, and the _adodb module's files will be created in a directory named adodb, within the myproject directory.
Here's an example:
$ cvs checkout myproject
$ cd myproject
$ ls -l
-rw-rw-r-x 13 ross cvsusers 4096 Jul 29 23:11 myproject.php
drwxrwxr-x 7 ross cvsusers 4096 Aug 9 11:14 adodb
Why not just include the ADOdb code directly in the myproject module? There are two reasons:
1. You want to share the _adodb module between two or more modules, yet have only one instance of the ADOdb code in CVS. We can easily add a second project by adding the following to our CVSROOT/modules file:
project2 &_project2 &adodb
If we want to store ADODb in project2's lib/adodb directory, we would instead add:
libadodb -d lib/adodb _adodb
project2 &_project2 &libadodb
2. You can easily upgrade the ADOdb code when a new version is released. See Upgrading third party code in CVS for details.
3. You cleanly define what is internal code, and what is external code. While this may not matter on smaller projects, it's importance will increase as projects get bigger.