Accessing the Source Code


A source code repository, or source control system, is exactly what its name indicates, a repository where source code is maintained . It is invaluable to prevent developers from tripping on each other s changes, especially if the development team is large, as is the case with Fedora Core, GNOME, and other high-profile open source projects. In a typical source control system, each developer connects to the repository and checks out a copy of the current version of the code to a local destination, where he or she can work on that code independently from others. Once the developer makes changes to the code, he or she can commit them back into the repository, where the new versions can be picked up by other developers at a later time. In cases where multiple developers commit different changes to the same set of files around the same time frame, the repository server tries to merge the changes together automatically. This merging is not always successful, in which case the developers are notified and are responsible for performing the merge manually.

This section looks at the Concurrent Versions System (CVS), which is a powerful source control system that comes with nearly all Linux distributions. The Fedora Project intends to provide a public CVS source code repository from where you can check out the operating system code. However, at the time of this writing, the repository has not been set up and there is no timeline for such an implementation. Therefore, we will look at the GNOME project and its CVS repository. More specifically , we will connect to the repository, check out code for the gnome-common and gnome-pkgview modules, build and install them, and then work on creating a simple patch.

Connecting to the Repository

You must install the cvs client application before you can connect to any CVS repository. However, if you followed the procedure and built the gFTP application in Chapter 11, you already have the necessary application installed. Otherwise, follow the instructions specified in the Installing Development Tools and Libraries section in that chapter to install the necessary development applications and tools. After you have finished the installation, issue the following commands from the command line:

   # export CVSROOT=':pserver:anonymous@anoncvs.gnome.org:/cvs/gnome'     # cvs login   Logging in to :pserver:anonymous@anoncvs.gnome.org:2401/cvs/gnome CVS password: (leave it blank) 

The CVSROOT environment variable is very important, as you need to set it to the host name and the directory path of the CVS repository that you intend to connect to. Then, you issue the cvs login command to force the cvs client application to connect to the anoncvs.gnome.org repository. If the client connects successfully, it asks you for a password. Because you are connecting to the repository in anonymous read-only mode, you don t need a password, so leave it blank. That s all there is to it.

Checking Out Source Code

Before you check out any source code, you should make it a habit to store that code in a separate location, away from all of your other personal files. That way, you can be assured of not accidentally mixing your personal files with the source code, especially if you have the access to commit files to the repository.

In this section, we will retrieve the gnome-common and gnome-pkgview GNOME packages. The gnome-pkgview application is simple in that displays the list of installed GNOME applications and their version numbers . You might be wondering why we are checking out the gnome-common package. It is needed to properly build gnome-pkgview .

Now, it s time to get some source code:

   # cd /usr/local/src     # mkdir gnome     # cd gnome     # cvs -z9 co gnome-common gnome-pkgview   cvs checkout: Updating gnome-common U gnome-common/.cvsignore U gnome-common/AUTHORS ... U gnome-common/support/vasprintf.c U gnome-common/support/vsnprintf.c cvs checkout: Updating gnome-pkgview U gnome-pkgview/.cvsignore U gnome-pkgview/AUTHORS ... U gnome-pkgview/src/pkgview-cursor-utils.h U gnome-pkgview/src/pkgview.h 

The cvs co command, where co is short for checkout, is used to check out certain modules, as defined by the remote CVS repository. In this case, we ask the repository for the gnome-common and gnome-pkgview modules. Use the -z9 switch to ask the server to compress the files before transmission; the client decompresses them on our side. This reduces the amount of data that is transmitted and is especially suited for low-bandwidth connections.

Building Modules

Now that you have the source code, you can build the gnome-pkgview application. But before doing so, you need to install the GNOME Development Libraries. Again, see the Installing Development Tools and Libraries section in Chapter 11 for more information. First, let s install the gnome-common package:

   # cd gnome-common     # ./autogen.sh --prefix=/usr/local   checking for autoconf >= 2.53...   testing autoconf2.50... not found.   testing autoconf... found 2.59 ... config.status: creating doc-build/gnome-doc-common Now type 'make' to compile Gnome Skeleton   # make     # make install   

Now let s install our main gnome-pkgview application:

   # cd ../gnome-pkgview     # ./autogen.sh --prefix=/usr/local     # make     # make install   

We were able to successfully build a GNOME application based on the latest, bleeding-edge code, directly from the source code repository. Figure 14-1 illustrates this application in action.

click to expand
Figure 14-1

Once the Fedora Project opens up the public repository, you will be able to build the latest versions of the kernel, as well as other applications whenever you feel the need to do so.

Creating a Patch

Now that you have the source code at your disposal, you can modify it, whether to implement a new feature or to fix a bug. Because it is beyond the scope of this chapter to dwell on application development, let s make a small and inconsequential change to the gnome-pkgview application. That way, you can learn how to make a patch.

First, let s add a simple line to about-box.c :

   /* This is it, this is the change. Nothing but a comment */   

Then, use the cvs diff command to make a patch:

   # cvs diff -u about-box.c > about-box.patch   

The patch file looks like this:

 Index: about-box.c =================================================================== RCS file: /cvs/gnome/gnome-pkgview/src/about-box.c,v retrieving revision 1.6 diff -u -r1.6 about-box.c --- about-box.c 6 Jan 2004 19:43:00 -0000       1.6 +++ about-box.c 6 Apr 2004 10:43:29 -0000 @@ -2,6 +2,8 @@  #include <config.h>  #include "about-box.h" +/* This is it, this is the change. Nothing but a comment */ +  void create_about_box ( void ) {          GdkPixbuf *pixbuf; 

You can send this patch to the GNOME development team, either as an attachment via the bug tracker, or as an e-mail message. Because you don t have commit access, you cannot make the change to the actual source code in the repository.




Beginning Fedora 2
Beginning Fedora 2
ISBN: 0764569961
EAN: 2147483647
Year: 2006
Pages: 170

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