Creating a x86_64 rpm from the src.rpm

I recently had a need to rebuild a x86_64 rpm from the source rpm on RHEL 6. I needed the Darwin Streaming Server from Apple, but it seems to be neglected. So no rpm at all.

A prerequisite for this is a key to sign the rpm with. If you don’t have one, creating one won’t be covered ¬†here.
Download the source rpm into an appropriately rpm src directory and then extract the .spec file with

rpm -Uvh DarwinStreamingServer-6.0.3-2.src.rpm

Here you can edit it if needed. Then to build:

rpmbuild -ba –sign –target x86_64 SPECS/DarwinStreamingServer.spec

This would also build, bypassing the need to extract the spec file, if you don’t need to edit the spec file.

rpmbuild -v –sign –rebuild DarwinStreamingServer-6.0.3-2.src.rpm

I was able to verify the key was used:
rpm -i DarwinStreamingServer-6.0.3-2.src.rpm
rpm –checksig RPMS/x86_64/DarwinStreamingServer-6.0.3-2.x86_64.rpm
and compare the output of:

gpg –list-keys

Be sure to read the man page of rpmbuild for the meanings of the -ba, -bb, etc switches.