Compiling and modifying a source rpm

Hi all,

If this is the wrong forum please feel free to move the post :slight_smile:

I want to install and compile a source rpm so that I can patch it with some local changes.

I’ve installed the rpm with :

zypper si gzdoom

And can change to /usr/src/pacakages and build it with :slight_smile:

rpmbuild -ba SPECS/gzdoom.spec

And this all goes as it should, and the rpm is left in RPMS/x86_64

However what I can’t find is the source tree from which the rpm has been compiled? How do I get to the stage where I have a source tree that I can modify build and then build to get what I want.

Cheers.

Phill.

@phillhs Hi it will be in the SOURCES directory, your better off grabbing the actual src rpm and rebuild that as your local user and create patches in you @HOME dir and then just install as root user when built.

I build it in my /home:

As User, create the directories:
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}

Set the config to .rpmmacros:
echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros

That are the same directories as in /usr/src/packages/
You can use the SRPMS directory to store the downloaded xxx.src.rpm, goto that directory and execute as User:
rpmbuild --rebuild xxx.src.rpm

That will unzip the xxx.src.rpm, store the xxx.spec to the SPECS directory and all Sources and Patches to the SOURCES directory.
If the rpm is build without any errors, it will be stored in the RPMS directory.
If you use this directory as an Repo, you can install the rpm:
zypper in xxx.rpm

So only for Installing you have to be the User root, all others will be done by your “normal” User.

1 Like

Hello, this is Gulshan Negi.
Well, I did a search on this, and I will say that you can use the following command to access the RPM package’s source tree:
rpm -q --queryformat ‘%{SOURCERPM}\n’ gzdoom | xargs rpm2cpio | cpio -idmv
Thanks

rpmbuild -bp will unpack sources and apply patches. You can then modify resulting source tree and continue build (rpmbuild --short-circuit ...) but you will need to repeat it every time. Better is to add you changes as patch to spec file so they are applied automatically.