Source Of Rpm's

Hi every one...i am new to linux and have a problem with rpm's.
Do we have any facility to chk out the source code of rpm's.If yes plz specify the location so that i can explore a few...

secondly can i know where we can get the source code of standard shell commands like sleep,ls,top....etc.I am interested in chking out how they were coded.......

                             thanks in advance.....sandy

For most distributions, source RPMs (SRPM) are included on the CD-ROMs/DVD-ROM, or can be downloaded off the distribution site.

You may install the SRPM but they will always be installed in /usr/src/[whatever]. To extract it at any arbitrary location, you will need to do it via cpio.

More info:
http://www.rpm.org/max-rpm/s1-rpm-miscellania-rpm2cpio.html

An example:

This will extract the source RPM in the current directory. This package (coreutils) includes sources to all the fundamental commands. The official source package is in the coreutils-5.2.1.tar.bz2 tarball (known as "pristine sources" in the official literature), those outside are patches that will be automatically applied before the actual building process begins with rpmbuild. For more information about this process, please read the RPM book.

thanks for that,now let me tell u my actual problem.i am doing a project that includes load balancing in linux clusters.In that situation i used a shell script called "top" that gives the load of user,system and i/o.I am interested in knowing how the load is calculated on each node.for that i need the source code of top command....can u guide me by giving precise links or related material...
thank u in advance.....sandy

On my system, top is not a shell script. It is a compiled executable.

You may be interested in this:

just a note, I know this thread is old but I'm posting it for posterity, the "pristine" source tarball for all RPM's is in the RPM header, as are any patches to the pristine source, the purpose of which is exactly what this user's problem is.

just an FYI incase you're running into the same problem