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

Linux SRPM Source Package Installation

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:

  1. Install required tools
  2. Download the SRPM package
  3. Install the SRPM package and build the RPM

Step 1: Install Required Tools

You will need the following tools to build and install an SRPM package:

  • Development tools
  • RPM build tools

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.

  1. Using RPM for source package installation in Linux:

    • Description: RPM (Red Hat Package Manager) can be used to install source packages in Linux. It simplifies the process of managing software installations and dependencies.
    • Code:
      # Example: Installing an RPM package
      sudo rpm -ivh package.rpm
      
  2. Building and installing SRPMs in Red Hat-based systems:

    • Description: SRPMs (Source RPMs) provide source code and build instructions. To build and install an SRPM:
    • Code:
      # Example: Building and installing SRPM
      rpmbuild --rebuild package.src.rpm
      sudo rpm -ivh /path/to/built/package.rpm
      
  3. SRPM installation on CentOS and Fedora:

    • Description: On CentOS and Fedora, SRPM installation involves using the rpm and rpmbuild commands. Ensure the necessary build tools and dependencies are installed.
    • Code:
      # Example: Installing SRPM on CentOS/Fedora
      sudo rpm -ivh package.src.rpm
      
  4. Spec file and SRPM customization in Linux:

    • Description: The spec file in an SRPM contains build instructions. Customizing the spec file allows you to tailor the build process, configure options, and manage dependencies.
    • Code:
      # Example: Editing spec file
      vi /path/to/package.spec
      rpmbuild -ba /path/to/package.spec
      
  5. Dependencies and resolving issues during SRPM installation:

    • Description: Dependencies can be resolved using package managers like dnf or yum. Ensure all required dependencies are installed before building and installing an SRPM.
    • Code:
      # Example: Resolving dependencies
      sudo dnf builddep package.src.rpm
      
  6. Automating SRPM installations in Linux:

    • Description: Automating SRPM installations involves using scripts or configuration management tools to handle the build and installation process.
    • Code:
      # Example: Automated SRPM installation script
      ./install_script.sh
      
  7. Troubleshooting SRPM installation errors in Linux:

    • Description: Troubleshooting SRPM installation errors involves checking logs, resolving dependency issues, and verifying that the spec file is correctly configured.
    • Code:
      # Example: Checking logs for errors
      journalctl -xe | grep rpm