Building Personal Fedora Repos with Copr: No More Manual ‘make install’!

Fedora tutorial - IT technology blog
Fedora tutorial - IT technology blog

The Pain of Installing Software from Source Code

After using Fedora as my primary workstation for two years, I really appreciate the package update speed of this distro. However, life isn’t always a dream. Sometimes you find a great tool on GitHub like lazygit or lsd, but Fedora’s official repositories haven’t updated to the latest version yet, or they might not even be available.

Usually, we download the code and run make install. This is quick but leaves a messy aftermath: you can’t uninstall it cleanly, there are no automatic updates via dnf update, and you have to do it all over again when switching machines. Instead of manual labor, Copr helps you standardize everything in a much more professional and effortless way.

What is Copr? Why is it a Developer’s “Secret Weapon”?

Copr (Community Projects) is an automated package build system for the Fedora community. If you’ve used Ubuntu before, think of Copr as a cooler version of “PPA.” This system allows you to create your own repository, push source code, and wait for it to automatically package into .rpm files for various architectures from x86_64 to aarch64.

Instead of risky “random” installations, you put your software into Copr. Installing on any Fedora machine is now simplified into just two commands:

sudo dnf copr enable user/project
sudo dnf install package-name

Everything stays clean with no system clutter. Notably, Copr supports GitHub webhooks. Just git push your new code, and the system immediately triggers a new build.

Preparation Before You Start

To start “building your warehouse,” you need to complete these two basic preparation steps:

  1. Create a Fedora Account (FAS): Register at accounts.fedoraproject.org. This is the master key to all Fedora services.
  2. Set up API Token: Log in to Copr and find the API Token section. Copy this content into the ~/.config/copr file so your terminal has permission to “command” the Copr server.

Don’t forget to install the command-line tool for faster operations:

sudo dnf install copr-cli

Hands-on: Shipping Your First Package

Suppose I need to package a small tool named my-fast-tool from GitHub. The process goes as follows:

Step 1: Initialize Project on Web UI

In the Copr interface, click New Project. You need to fill in some important information:

  • Project Name: Repo name (e.g., dev-utilities).
  • Description: A brief description so you remember what it is later.
  • Chroots: Select target Fedora versions (it’s recommended to choose fedora-40-x86_64 and fedora-rawhide to stay ahead).

Step 2: Connect via Terminal

After saving the API configuration file in the preparation step, check your connection by trying to create the config file if it doesn’t exist:

mkdir -p ~/.config
nano ~/.config/copr

Now, your computer is officially authorized to submit packaging requests to the Fedora server.

Step 3: Send Source Code for “Processing”

There are two common ways. If you are a beginner, use SRPM (Source RPM). If you want to build directly from GitHub, set it up in the Settings > Webhooks tab.

To build manually from your personal machine using a .spec file, run the command:

# Generate local SRPM file (requires rpm-build)
rpmbuild -bs your-app.spec

# Push file to Copr for server processing
copr-cli build dev-utilities /path/to/your-app.src.rpm

It usually takes only 3 to 5 minutes for Copr to complete a basic package. You can sit back, enjoy a coffee, and monitor the build logs via your browser. If it fails, the logs will clearly indicate which BuildRequires library you are missing.

Enjoy the Results

When the status shows a lush green Succeeded, your repo is ready. To install it on your machine, simply run:

sudo dnf copr enable username/dev-utilities
sudo dnf install your-app-name

The best part is that from now on, whenever there’s an update on Copr, your regular dnf update command will automatically pull the new version. No more manual file copying and pasting like before!

“Hard-earned” Lessons to Avoid Build Errors

Packaging can sometimes be a headache. Here are three tips to save you from “pulling your hair out”:

  • Don’t forget BuildRequires: Copr builds code in a completely clean environment (chroot). Libraries you’ve already installed on your local machine won’t be there. Make sure to list them all in your .spec file.
  • Test with Mock: Before pushing to the server, run mock on your local machine. If mock succeeds, it will likely work on Copr 99% of the time.
  • Copyright Rules: Don’t even think about uploading pirated software or anything that violates Fedora’s policies. Admins will delete your repo without prior notice.

Conclusion

Mastering Copr not only keeps your Fedora machine tidy but is also a huge skill booster. Instead of telling colleagues to run risky curl | bash commands, confidently send them your Copr Repo link. Happy packaging on Fedora!

Share: