1) Take the strace command for example, first, getwhere the command is in:
[liqingxu@localhoststrace-4.5.19]$ which strace
/usr/bin/strace
2) Then, get which package this command is in.
[liqingxu@localhoststrace-4.5.19]$ rpm -qf /usr/bin/strace
strace-4.5.19-1.17.el6.x86_64
3) Go to http://vault.centos.org/6.5/os/Source/SPackages/,get the strace-4.5.19-1.17.el6.src.rpm file.
[liqingxu@localhostDownloads]$ wgethttp://vault.centos.org/6.5/os/Source/SPackages/strace-4.5.19-1.17.el6.src.rpm
--2014-07-2401:50:55-- http://vault.centos.org/6.5/os/Source/SPackages/strace-4.5.19-1.17.el6.src.rpm
Resolvingvault.centos.org... 216.151.172.58
Connecting tovault.centos.org|216.151.172.58|:80... connected.
HTTP requestsent, awaiting response... 200 OK
Length: 533582(521K) [application/x-rpm]
Saving to:“strace-4.5.19-1.17.el6.src.rpm”
100%[===============================================================================>]533,582 56.7K/s in 11s
2014-07-2401:51:12 (48.1 KB/s) - “strace-4.5.19-1.17.el6.src.rpm” saved [533582/533582]
4) To compile this package, you need to install therpmbuild package file.
Switch to root,
yum installrpm-build
5) Then, switch back to a normal user,
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
6) Then, compile but don’t remove source filesafter buiding.
rpmbuild --recompilestrace-4.5.19-1.17.el6.src.rpm
7) Then, in ~/ rpmbuild/BUILD/strace-4.5.19, youcan find all source files and the built strace executable.