Installing Linux Packages from Source Code in RPM based Linux Distros
How to Install in Linux: Installing from Source Code in an Rpm-based Distribution
One of the mistakes that a Linux system administrator (which is all of us) can easily make is not installing Linux packages, but compiling software from its source code. The downside of installing a program from source code (installing Linux packages other than the distribution’s package format, such as the Red Hat Package or rpm for short) is that your distribution’s package management system has no clue of the program you have installed. So, if the program’s new version appears in the repositories then your system cannot compare the installed program with the one in the repository, resulting in duplicate installs and sometimes the program not working as intended.
I know that sometimes you search for software that you want to install on your computer, but it turns out that there is no rpm or source rpm available. Even more annoying, there are times when you can find an rpm file for another distribution that’s not yours (e.g. you’re using openSuSE but you can only find an rpm for Fedora). There are also times when you can find the latest source code and the rpm, but the rpm is for your distribution’s previous release.
Are we out of chances? This is something very improbable in the Linux world. So how to install in Linux? There are a couple of easy steps to build an rpm from source code:
1. Download the source code, e.g. some_software_1.0.tar.gz
2. Look at the contents tar -tvf some_software_1.0.tar.gz and see if there is a .spec file
3. Fire up your favorite terminal [Xterm, Konsole, Gnome Terminal whatever] and issue the command
rpmbuild -tb some_software_1.0.tar.gz
(either change to root or issue the command with sudo). If you encounter any errors, check out the problem, continue accordingly until you correct them all. At the end, you will have some_software_1.0.rpm
4. In your terminal session install the software by issuing this command
rpm -ivh some_software_1.0.rpm
(you have to be root for this command to work, so either switch to the root account or issue the command with sudo)
5. If you are using openSuSE, issue the command SuSEconfig after the installation.
That’s all! Now you have successfully installed your software and made your system aware of it. The good part is, this method works for all Red Hat packages: all you need is the .spec file in the .tar file you have downloaded!
Reference: Author’s own knowledge