Packaging locally in Fedora, and using Fedora infrastructure (copr)

I wanted to build an SRPM locally to inspect a possible packaging bug, but I have been unable to find any documentation on how to do that. I also want to build a different package for copr, so would be good to know how to adapt my local workflow to use fedora infrastructure. Can anyone point me to some resources?

This is what I would like to do:

  • I found an issue in one of the scripts packaged with kitty. I would like to investigate where the bug is introduced, and submit a patch. I need to be able to see build logs and inspect the build root. I downloaded the srpm with dnf download --source kitty, but can’t figure out the next steps.
  • I would like to package a few other open source projects for copr. I have done this in the past, but that was quite some years ago. I already looked at fedpkg, but that seems to need a repo, not building from SRPM.

Any guidance would be really appreciated.

1 Like
  • Install the required tools: sudo dnf install fedora-packager
  • Create RPM build tree on your home directory with the rpmdev-setuptree command
  • Create your spec file
  • Have your source files ready in the ~/rpmbuild/SOURCES directory with the spectool -gR PATH-TO-YOUR-SPEC-FILE command
  • Run rpmbuild -bs PATH-TO-YOUR-SPEC-FILE command to create the source RPM. It will be located in the ~/rpmbuild/SRPMS directory
  • Run mock PATH-TO-YOUR-SRPM to create the binary RPM from your SRPM. It will be located under the /var/lib/mock directory.

To build on Copr, you can upload the locally build SRPM file or have your spec file uploaded to somewhere on the internet and point Copr to clone it from there.

2 Likes

I’ve also done this by:
cloning the repo from src.fedoraproject.org
select the branch I want to build from
fedpkg prep
fedpkg mockbuild

3 Likes

Thanks both of you. Both work for me. However I chose the fedpkg approach as the solution as it easily translates into building a package for copr.

1 Like