Creating RPM's From Source
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:
- Put a pile of RPMs in a directory.
- Run a
createrepocommand on that directory. - Share that directory using HTTPS, HTTP, FTP, or possibly NFS or Samba if you find it convenient for you.
- Write a .repo file for putting into
/etc/yum.repos.don 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):
- 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.
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
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
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
