That's a picture of me in Baldwin Hills, Santa Monica
Bangalore based engineer currently helping SMEs grow via SMERGERS. Interested in Programming, Design, Startups and a few other things. MS-CS @USC, Los Angeles, BE @BMSCE.
I can be reached on
krishna [at] krishnabharadwaj [dot] info
Here are some of my other online profiles
Powered by Python and Django
kb
Geek, Programmer, FOSS Enthusiast, MS CS @USC. Loves Python / Django. Co-founder @ SMERGERS, Previously at Google, BlockBeacon, NI R&D

Contributing to FOSS 11-May-2009


Introduction to FOSS

Free and open source software is software which is liberally licensed to grant the right of users to study, change, and improve its design through the availability of its source code. Did you know that Firefox is a Free and Open source software? The code we write will be used by millions of people across the world. Some other famous free softwares include GNU/Linux OS, VLC Player, Apache web server, Eclipse IDE, Sun's Java, MySql DBMS etc.

Let’s consider one of the projects here and then proceed. The project we are trying to build here is GNUSim8085. It is a 8085 simulator. The code is written in C, the front end is designed using GTK (GTK stands for GIMP Tool Kit, It is the building block of GNOME Desktop Environment on GNU/Linux).


Installing the software
One of the pre-requisites for most of the FOSS projects is a Unix/Linux machine. Almost all Open source projects have a domain where they host their project. The official page of the GNUSim8085 project is http://gnusim8085.sourceforge.net/. Here, we can download the program and start using it. The example programs that come bundled with it is sufficient to get a feel of the software. Debian and distributions based on it, like Ubuntu can install it from the command line using the command

$ sudo apt-get instal gnusim8085

Getting the source code
The Source code can be downloaded from the same link mentioned before, but this is not the latest source code. This is the code on or before the last release of the software. All the development that happens goes into a directory called the 'trunk'. This 'trunk' has the latest code at any point of time. It is maintained with the help of Revision Control system.

Many people across the world will be working on a single project. The Revision control systems are used to synchronize their work. Whenever a developer from one part of the world submits code to this ‘trunk’, the source file must be updated with this newly submitted code. We will see its functionality later on. Some of the Revision control systems widely used in FOSS are SVN (SubVersion) , CVS ( Concurrent Versions System), Git, Bazaar etc..

We can see in the GNUSim8085 website that it uses SVN for managing the project. Along with that they have also provided the URL of the SVN server where the project is hosted. Now we can download the source code from the link provided using the command:

$ svn co https://gnusim8085.svn.sourceforge.net/svnroot/gnusim8085/trunk gnusim8085

Here 'svn' is the subversion client which will fetch the source code from the link provided and save it in gnusim8085 directory. The 'co' used in the command is an instruction to the subversion client to 'check out' (download) the code from the trunk.

If svn is not installed in the system, one can install it by following the instructions from http://subversion.tigris.org/ Debian and distributions based on it, like Ubuntu etc can install it using the command

$ sudo apt-get install subversion

Building the Project

Along with this, we will need some compilers to build the GNUSim8085 project. These compilers can be installed from the repositories depending on the Linux distribution one is using. Debian and distributions based on it can install it using the command

$ sudo apt-get install build-essential

We just used the term 'build', what exactly does this mean? We might have compiled many programs which are just 40 to 50 lines. When a project grows, we cannot restrict the entire code in a single file, so we have to split them into different files in order to increase the readability. This neat organization comes at a cost; we have to specify the order in which these files must be compiled before the object file is created. It gets more complicated as the project grows. Hence to avoid this, the concept of build system was introduced. With the help of this build system, the user need not worry about the sequence of compilation etc. He/she can concentrate on the implementation aspect of it. The build system generates a 'Makefile'. This 'Makefile' is nothing but a set of rules that guides the compiler to compile files of a project in the desired manner thereby eliminating the complication.

Once the compilers are installed, we can start building the GNUSim8085 project. Now we move to the directory where the source code is present.

$ cd gnusim8085

Here, we have to configure all the pre-requisites or dependencies in order to build the software and make use of the configure program.

$ ./configure
‘Error: Cannot find libgtk2.0 >= 2.12.0'

Here, we will be informed that we do not have libgtk2.0 library. By searching on the internet, we get the exact library name. We can install this using the command:

$ sudo apt-get install libgtk2.0-dev

Once this is installed we proceed with configuring the build system.

$ ./configure
‘Error: Cannot find gtksourceview2 >= 2.2.0'

This time it asks for the gtksourceview2 package.

$ sudo apt-get install libgtksourceview2.0-dev
$ ./configure

Now we should not come across any errors. If there are any, simply Google the error message, it will provide the solution almost instantaneously. The configure process is complete now.
Now we build the project using the make command

$ make

Once this is complete, the binary file is created in the ‘src’ directory.

$ cd src

This is the directory where all the C source files and the header files are present. All the changes we wish to make must be made here. We shall leave it as it is for time being.

$ ./gnusim8085

This is the program that we have built from the source. This command launches the GNUSim8085 program.

Contribution

If you think you can make this program better, then go ahead with your idea, implement it and submit it.

If you are not sure of what to do exactly: The program we are currently running is not 100 % bug free. There are errors! The list of all the bugs is submitted in the project webpage.
https://sourceforge.net/tracker/?group_id=86462
Here we can select either bugs or feature requests, make modifications in the code to fix the bug or provide the needed feature.

Once we have made the necessary changes to the code, the source must be re compiled.

$ cd ..

Moving to the parent directory

$ make

This command carefully compiles the files that were changed since the previous build.

$ cd src
$ ./gnusim8085

The program that executes now is the one with our modifications.

The code I have written works absolutely fine. How do I submit it to the project maintainers? To do that, we need to create something called a patch. Patch is nothing but a 'diff' file (‘diff’ is a Unix command which gives us the difference between two text files). This diff file is uploaded to the sourceforge.net website where we came across the bug or the feature request.

Generating the patch

$ svn diff > Gnusim8085_bugno.patch

Attaching the bug number is a good practice since it can be used to keep track of patches.

This is how one can start contributing to the Free and Open source Software world.

PS : This article was written for the college magazine.


blog comments powered by Disqus