Skip to content

Instantly share code, notes, and snippets.

@jclay
Created February 8, 2019 19:24
Show Gist options
  • Save jclay/a91af161d542d509b8fe16bb1e7abafa to your computer and use it in GitHub Desktop.
Save jclay/a91af161d542d509b8fe16bb1e7abafa to your computer and use it in GitHub Desktop.
RPM Build From Source

Modify and rebuild a source RPM on Fedora

In several cases, there has been an RPM in the Fedora repo's which I would like to use, but is out of date.

I'm using the following in order to pull the source rpm, bump the version and reinstall.

I'm using the cloc tool here as an example. You may find it helpfult reference this guide from Fedora

Setup

Ensure you follow the first steps in the Fedora guide in order to setup the tooling needed.

Download the source rpm

$> sudo dnf download --source cloc

Extract the rpm to the rpmbuild directory for working

$> rpmbuild --rp cloc-1.72-6.fc29.src.rpm

This will extract the RPM and move the spec to ~/rpmbuild/SPEC

Install necessary build dependencies

$> sudo dnf builddep ~/rpmbuild/SPEC/cloc.spec

This will install all the necessary build dependencies.

Edit the package

vim ~/rpmbuild/SPEC/cloc.spec

Here, I edited the version to bump it from 1.72 to 1.80.

Next, we need to use the spectool to download the updated sources:

$> spectool -g -R ~/rpmbuild/SPEC/cloc.spec

Build the updated spec

$> rpmbuild -bb ~/rpmbuild//SPECS/cloc.spec

From here, you should have a new rpm located in ~/rpmbuild/RPMs which you can install.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment