Linux Tutorial
Linux File/Directory Management
Linux Packaging And Compression
Vim Text Editor
Linux Text Processing
Linux Software Installation
Linux User/User Group Management
Linux Permission Management
Linux Filesystem Management
Linux Advanced Filesystem Management
Linux System Management
Linux Backup and Recovery
Linux System Service Management
Linux System Log Management
Linux Boot Management
LAMP/LNMP Environment
SELinux Management
In this tutorial, we will demonstrate how to install an SRPM (Source RPM) package on a Linux system. SRPM packages contain the source code and a .spec
file, which has instructions to build the software into an RPM package for installation.
We'll use the wget
package as an example in this tutorial. The installation process involves three primary steps:
Step 1: Install Required Tools
You will need the following tools to build and install an SRPM package:
For CentOS/RHEL-based systems:
sudo yum groupinstall "Development Tools" sudo yum install rpm-build
For Fedora-based systems:
sudo dnf groupinstall "Development Tools" sudo dnf install rpm-build
Step 2: Download the SRPM Package
First, search for the SRPM package on the distribution's repository or package database. In this example, we'll use the Fedora package database (https://koji.fedoraproject.org/koji/) to download the wget
SRPM package.
You can also use the dnf
or yum
tool to download the SRPM package if you have the appropriate repository enabled.
For Fedora-based systems:
sudo dnf install dnf-plugins-core sudo dnf download --source wget
For CentOS/RHEL-based systems:
sudo yum install yum-utils sudo yumdownloader --source wget
Step 3: Install the SRPM Package and Build the RPM
Now, install the SRPM package:
rpm -i wget-VERSION.src.rpm
Replace wget-VERSION.src.rpm
with the downloaded SRPM package name.
The SRPM package will be installed into the ~/rpmbuild
directory. Change to the ~/rpmbuild/SPECS
directory:
cd ~/rpmbuild/SPECS
Install any additional dependencies required to build the package:
For Fedora/CentOS/RHEL-based systems:
sudo dnf builddep wget.spec
Next, build the RPM package using the .spec
file:
rpmbuild -ba wget.spec
The built RPM package will be located in the ~/rpmbuild/RPMS
directory.
Step 4: Install the Built RPM Package
Now, install the built RPM package:
For Fedora/CentOS/RHEL-based systems:
sudo dnf install ~/rpmbuild/RPMS/path/to/wget.rpm
Replace path/to/wget.rpm
with the appropriate path to the built RPM package.
That's it! You have successfully installed an SRPM package on your Linux system.
By following this tutorial, you have learned how to install an SRPM package, which contains the source code and the build instructions for a Linux application. This process can be helpful when you need to modify or recompile the source code with specific options or when the pre-built binary package is not available.
Using RPM for source package installation in Linux:
# Example: Installing an RPM package sudo rpm -ivh package.rpm
Building and installing SRPMs in Red Hat-based systems:
# Example: Building and installing SRPM rpmbuild --rebuild package.src.rpm sudo rpm -ivh /path/to/built/package.rpm
SRPM installation on CentOS and Fedora:
rpm
and rpmbuild
commands. Ensure the necessary build tools and dependencies are installed.# Example: Installing SRPM on CentOS/Fedora sudo rpm -ivh package.src.rpm
Spec file and SRPM customization in Linux:
# Example: Editing spec file vi /path/to/package.spec rpmbuild -ba /path/to/package.spec
Dependencies and resolving issues during SRPM installation:
dnf
or yum
. Ensure all required dependencies are installed before building and installing an SRPM.# Example: Resolving dependencies sudo dnf builddep package.src.rpm
Automating SRPM installations in Linux:
# Example: Automated SRPM installation script ./install_script.sh
Troubleshooting SRPM installation errors in Linux:
# Example: Checking logs for errors journalctl -xe | grep rpm