Next Previous Contents

5. Modifying Packages

If you do anything more than trivial recompilations, you will occasionally need to modify packages. This can usually be managed with the assistance of CVS "vendor branches" and patch files.

5.1 Scope

We will only store the debian directory in the CVS archive. While it is possible to store the entire source tree, it is rarely necessary and requires a substantial amount of disk space.

(On the other hand, storing the entire source code for your system in CVS, then publishing it with cvsweb, can be an extremely valuable resource. But this requires many gigabytes of disk space, and takes some time to learn to use effectively.)

5.2 Initial Setup

For each package which we will modify, we need to unpack the source tree and import the debian directory into CVS. Using fileutils, specifically fileutils-4.0l-8, as a concrete example the comands are:


$ apt-get source fileutils
$ cd fileutils-4.0l/debian
$ rmdir CVS
$ cvs import -ko -m"Debian 'fileutils' package" fileutils/debian \
    DEBIAN_DIST FILEUTILS_4_0L_8

Few packages include CVS directories in the debian subdirectory, but a few do (e.g., nvi) and this directory can and should be removed.

We now need to check out the newly imported files:


$ (back at original directory)
$ ln -s fileutils-4.0l fileutils
$ rm -rf fileutils/debian
$ cvs checkout fileutils/debian

Finally, we should bump the version number slightly, e.g., by appending ".local", to distinguish this package from the original one, then rebuild the source package.

5.3 New Debian releases

When a new Debian package is released, we need to synchronize the changes. This is done by creating a "vendor branch" in the CVS tree. Using a concrete example of fileutils-4.0l-9, we would use the command:


$ apt-get source fileutils -- from upstream repository
$ cd fileutils-4.0l/debian
$ rmdir CVS  -- original CVS tree, not ours!
$ cvs import -m "new upstream version" fileutils/debian \
    DEBIAN_DIST FILEUTILS_4_0L_9

CVS is usually good at merging changes, but if it has problems you will need to fix them manually. You can do this with


$ (back at original directory)
$ ln -s fileutils-4.0l fileutils
$ rm -rf fileutils/debian
$ cvs checkout -jDEBIAN_DIST:yesterday -jDEBIAN_DIST fileutils/debian

Alternately, you could use the release tag (FILEUTILS_4_0L_8) instead of the time-based tag (DEBIAN_DIST:yesterday).

5.4 Local modifications: debian directory

When making local changes to the debian directory, we can work as usual with only a slight change:


$ apt-get source fileutils -- from local repository
$ cd fileutils-4.0l/debian
$ cvs update
$ -- edit files
$ cvs commit
$ cd ..
$ dpkg-buildpackage

If we add new files, we must tell CVS about them with cvs add.

Examples

Some examples of what you can do with debian-only changes include:

5.5 Local modifications: package source

If we need to change the package source itself, we need to work through patch files and scripts.

Simple changes can be made through patch files. If the package already contains a debian/patches directory, we can just add our patches to this directory. (Don't forget to run cvs add!)

More complex changes can be made through scripts, e.g., you could use a script to rename all instances of "foo" to "foobar" via a script.

For more information, see run-parts(8).


Next Previous Contents