Creating RPM's From Source

Latest response

Hello
My name is ryan and im studying for my RHCSA and RHCE id like to learn how to compile rpms from source and also how to host my own rpm repo locally for my 2 red had machines.

Reason being id like to have more control over versions and not have to use 3rd party repos for the non official apps that i use, if someone could point me in the right direction that would be great.

Kind Regards

Ryan

Responses

You're muddling questions here, so, have to ask, "are you simply looking at how to create an RPM from an SRPM" (what's sort of implied by "compile RPMs froms source") or are you looking for walkthroughs on how to create an RPM from scratch? I'm assuming you mean the latter. There's different techniques depending on what you're looking to package.

At any rate, other than the usual suspects (Fedora's HowTos, etc.), there are any number of blog articles on the topic. A good one that recently came through my Google tiles was Justing Flory's blog-entry ...though much of its values is in the link-outs rather than the direct contents (see the "Finding documentation" section).

And for the second part of the original poster's question, here's the really short guide on how to create and host your own RPM repository:

  1. Put a pile of RPMs in a directory.
  2. Run a createrepo command on that directory.
  3. Share that directory using HTTPS, HTTP, FTP, or possibly NFS or Samba if you find it convenient for you.
  4. Write a .repo file for putting into /etc/yum.repos.d on those hosts you want to use your repository. (If you used NFS or Samba to share the repository, you'll need to mount the shared directory manually and then use a file:// URL to point to it.)

Any RPMs you get from RedHat are already cryptographically signed, and thus can be verified using a GPG public key. For RPMs you create for your own private use, you might omit the signing... but if you want to publish your packages, it would be best to sign them and also document the public key that can be used to verify them.

If you're undertaking the project for work (and don't want to piss off your IA guys):

  1. Make sure you sign your RPMs 1a. Don't forget your comps.xml if you've got logical groupings of stuff 2a. Don't forget to create a signature for your repo 4a. Don't forget to make an RPM of your repo file - if you find that you're reorganizing or otherwise moving repo-content about or just want an easy way to distribute repo-configs.

Hello, this is relatively new one RPM Packaging Guide.

Hello Everyone

Sorry im new to the rpm realm so didn't realise i was mixing terms, id like to learn how to create rpms from either the source code, a tarball tar.gz, or a github repository. as an example im using the nux dextop repo for libdvdcss and vlc, id like to know how to create an rpm to install them rather than using a 3rd party repo

Mainly to learn a new skill but also to have a bit finer control of my system aswell, ive used arch based distros for the past few years on my desktop, so getting used to the whole .rpm file install method again.

Ryan,

I'd recommend the following doc: https://rpm-packaging-guide.github.io/

Adam Miller, the author of this document has been an engineer with Fedora and, more recently Ansible. However, this document is the basis for his perennial Red Hat Summit hands-on lab session "From Source to RPM in 120 Minutes." It's a two hour presentation, so you can go a lot deeper into building RPMs, the build environment, mock, etc. but I think this is a good primer.

More generally, I'm surprised you can't find your apps already maintained as part of the EPEL (Extra Packages for Enterprise Linux) repo. Almost always, if I'm looking for something in an RPM, I can find it there.

-STM

Hi Scott I like to use alot of multimedia packages so i need things like libdvdcss, mpv, kdenlive, xine, among others while there are 3rd party repos out there nux dextop has been the best one so far. im more curious than anything else id like to build the skill set to build rpms and hopefully setup my own repo and if i get good enough share it with the community :)

You really need to start simple and build up. I think the best method is to download some basic SRPMs of other (official) RPMs and pull them apart to see how they are assembled. Building SRPMs is also a good exercise for understanding the build process.

I once had a paper copy of this book and still use it as the RPM bible, even if it is getting on in years (~20)
http://rpm5.org/docs/max-rpm.pdf

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.