On Sun, 29 Oct 2017 14:40:56 +0100 vychytraly . wrote:
Frank please could you explain how to create rpms for el7 from fedora src.rpms?
The complexity of doing this will vary a lot with what you're trying to compile, but for userland programs like email clients, text editors, games and the like it can be very easy to do in a lot of cases.
As Johnny says, you don't really want to do this with core operating system functions since you can end up with a Frankenstein system that might not work properly any more.
In many cases (more than a few but by no means all) you can compile a Fedora rpm for Centos using the following procedure.
You need to have rpmdevtools installed:
yum install rpmdevtools
Now set up the build directory structure in your home directory:
rpmdev-setuptree
After that, download the Fedora srpm, then run a rpmbuild command against the rpm you downloaded:
rpmbuild -ba nameofsourcerpm.src.rpm
Now you see what happens. Sometimes the process will run and you'll end up with a rpm file in ~/rpmbuild/RPMS/. If so, then you're done. You've got the Centos rpm that you wanted.
If the process errors out then your next step depends on the nature of the error. If it's a missing dependency then you might be able to simply install that dependency:
yum install nameofdependency
Then run the rpmbuild command again and see if it works.
If you can't find a pre-built rpm of the missing dependency then you might be able to build it yourself using the above process. Or not. It depends on the circumstances and what's missing. If the program requires a newer version of a dependency that you already have installed, you might want to re-consier your plan at that point. See above about creating a Frankenstein system.
If the process errors out due to something other than a missing dependency, things become a bit more complex at that point. If you look in ~/rpmbuild/SPECS you will find a .spec file for your rpm. Crank up your text editor and inspect that and see what it's doing and where things go wrong. Sometimes it's useful to simply compile the original source file directly and see if that works. (You can find that in ~/rpmbuild/SOURCES. )
If the original source file compiles but the rpm doesn't, then there's likely a fix that you need to do to the spec file to make it work. Sometimes it's useful to compare the spec file for an older version that does work on Centos with the spec file for a newer version that doesn't, and see what changed.
If the source file doesn't compile then you have bigger problems to solve -- perhaps you need to patch the sources or perhaps it just plain won't work on Centos. That's the place where I'll usually give up unless it's really important to me to get it to work.
If it is really important (that doesn't happen very often) then I keep a sacrificial Centos 7 Virtual Box image that I can use to experiment with changing some of the stuff that's under the hood without worrying about blowing up my main desktop. But again, that doesn't happen very often.
Note that some Fedora stuff won't work on Centos. Period.
But some stuff will work just fine.