Skip to main content
Copr supports multiple build source types to accommodate different workflows and package management approaches.

URL source

Provide direct HTTP/HTTPS URLs to SRPM or spec files.

SRPM URLs

Provide URLs to .src.rpm or .nosrc.rpm files:
copr-cli build my-project https://example.com/package-1.0-1.fc40.src.rpm

Spec file URLs

Provide a URL to a .spec file. Copr will download sources specified in the spec during the build:
copr-cli build my-project https://example.com/package.spec

Multiple URLs

Submit multiple builds at once by separating URLs with spaces or newlines:
copr-cli build my-project \
  https://example.com/pkg1.src.rpm \
  https://example.com/pkg2.src.rpm
Build order is not guaranteed when submitting multiple URLs.

Upload source

Upload SRPM or spec files directly from your local machine.
copr-cli build my-project /path/to/package.src.rpm

SCM source

Build from Git, DistGit, or SVN repositories containing RPM spec files.

Basic usage

copr-cli add-package-scm my-project \
  --name mypackage \
  --clone-url https://github.com/user/mypackage.git

SCM options

Type SCM type: git or svn
--scm-type git
Clone URL Repository URL to clone:
--clone-url https://github.com/user/repo.git
Committish Specific branch, tag, or commit to checkout (default: HEAD of master branch):
--committish v1.2.3
Subdirectory Path relative to repository root where build should be executed:
--subdirectory rpm/
Spec file Path to spec file relative to subdirectory. Auto-located if not specified:
--spec mypackage.spec
You can anchor the path with / for absolute repository paths:
--spec /rpm/example.spec

SRPM build methods

Copr supports four methods for generating SRPMs from SCM repositories.
The default method using rpkg-util. Supports Git, SVN, and DistGit repositories.
copr-cli add-package-scm my-project \
  --name mypackage \
  --clone-url https://github.com/user/repo.git \
  --srpm-build-method rpkg
Starting from December 2021, Copr uses rpkg-util v3. Your spec files need to use {{{ }}} templates. See the rpkg-util documentation for details.
Uses Tito to build SRPM from the latest Git tag.
copr-cli add-package-scm my-project \
  --name mypackage \
  --clone-url https://github.com/user/repo.git \
  --srpm-build-method tito
The repository must be initialized with tito init first. The spec file field is ignored when using Tito.
Uses Tito with the --test flag to build from a specific committish instead of the latest tag.
copr-cli add-package-scm my-project \
  --name mypackage \
  --clone-url https://github.com/user/repo.git \
  --committish develop \
  --srpm-build-method tito_test
Executes a user-provided Makefile to generate the SRPM. Create a .copr/Makefile in your repository with an srpm target.Example .copr/Makefile:
srpm:
	dnf -y install tito
	tito build --test --srpm --output=$(outdir)
The Makefile is invoked as:
make -f <repodir>/.copr/Makefile srpm outdir="<outdir>" spec="<spec_path>"
Parameters:
  • outdir: Where to place the resulting SRPM
  • spec: The spec file path (can be ignored if not needed)
The script runs with root privileges in a mock chroot and has internet access.
copr-cli add-package-scm my-project \
  --name mypackage \
  --clone-url https://github.com/user/repo.git \
  --srpm-build-method make_srpm

Complete SCM example

copr-cli add-package-scm my-project \
  --name myapp \
  --clone-url https://github.com/user/myapp.git \
  --committish main \
  --subdirectory packaging/ \
  --spec myapp.spec \
  --srpm-build-method rpkg \
  --webhook-rebuild on

copr-cli build-package my-project --name myapp

DistGit source

Simplified interface for building from Fedora or CentOS DistGit repositories.

Building from Fedora DistGit

copr-cli build-distgit my-project --name python-requests
This uses the default Fedora DistGit instance and default branch (rawhide).

Building from CentOS DistGit

copr-cli build-distgit my-project \
  --name httpd \
  --distgit centos \
  --commit c8

DistGit options

Name Package name in DistGit:
--name httpd
DistGit instance Which DistGit to use (default: fedora):
--distgit centos
Committish Branch, tag, or commit to build from:
--commit f39
Namespace DistGit namespace (for forks or special paths):
--namespace forks/username
For Copr packages:
--namespace @copr/copr
The SRPM is downloaded once per build, regardless of the number of chroots. All chroots build from the same SRPM, which may cause incompatibilities if building for multiple OS versions.

Workaround for multiple OS versions

Submit separate builds for different branches:
copr-cli build-distgit my-project \
  --name mypackage \
  --chroot fedora-rawhide-x86_64 \
  --commit rawhide

copr-cli build-distgit my-project \
  --name mypackage \
  --chroot epel-8-x86_64 \
  --commit epel8

PyPI source

Build Python packages directly from PyPI.
copr-cli add-package-pypi my-project \
  --name python-flask \
  --packagename flask \
  --packageversion 2.0.1

PyPI options

Package name PyPI package name:
--packagename flask
Package version Specific version (optional, uses latest if not specified):
--packageversion 2.0.1
Spec generator Tool to generate RPM spec file:
  • pyp2rpm (legacy)
  • pyp2spec (default, recommended)
--spec-generator pyp2spec
Spec template Template for spec generation:
  • default
  • fedora
  • epel7
  • mageia
  • pld
--spec-template fedora
Python versions Which Python versions to build for:
--pythonversions 3

Example PyPI build

copr-cli add-package-pypi my-project \
  --name python-requests \
  --packagename requests \
  --spec-generator pyp2spec \
  --pythonversions 3

copr-cli build-package my-project --name python-requests
Copr uses pyp2rpm or pyp2spec to translate PyPI packages to SRPMs.

RubyGems source

Build Ruby gems from RubyGems.org.
copr-cli add-package-rubygems my-project \
  --name rubygem-rails \
  --gem rails

RubyGems options

Gem name Gem name from RubyGems.org:
--gem rails
Copr uses gem2rpm to translate RubyGems packages to SRPMs.

Example RubyGems build

copr-cli add-package-rubygems my-project \
  --name rubygem-sinatra \
  --gem sinatra

copr-cli build-package my-project --name rubygem-sinatra

Custom source (script)

Use a custom script to generate sources for building SRPMs.

Creating a custom source package

copr-cli add-package-custom my-project \
  --name mypackage \
  --script script.sh \
  --builddeps "git rpmdevtools" \
  --script-chroot fedora-latest-x86_64

Custom source options

Script The script that generates sources. Must be executable and start with a shebang:
#!/bin/bash
set -e

# Clone repository
git clone https://github.com/user/repo.git
cd repo

# Generate tarball
git archive --format=tar.gz --prefix=myapp-1.0/ HEAD > $COPR_RESULTDIR/myapp-1.0.tar.gz

# Copy spec file
cp myapp.spec $COPR_RESULTDIR/
Build dependencies Packages to install before running the script:
--builddeps "git rpmdevtools spectool"
External repositories Additional repositories for build dependencies:
--script-repos "https://example.com/repo/"
Script chroot Mock chroot where the script runs (default: fedora-latest-x86_64):
--script-chroot fedora-latest-x86_64
Result directory Where to place generated files (default: current directory):
--script-resultdir ./output

Environment variables

COPR_RESULTDIR Directory where you must place the spec file and sources. hook_data For custom webhook builds, POST data is available in the hook_data file in the current directory.

Complete custom source example

script.sh:
#!/bin/bash
set -eu

# Install additional tools
dnf install -y git rpmdevtools

# Clone and prepare sources
git clone https://github.com/myuser/myapp.git
cd myapp
git archive --format=tar.gz --prefix=myapp-1.0/ HEAD > myapp-1.0.tar.gz

# Copy to result directory
cp myapp-1.0.tar.gz "$COPR_RESULTDIR/"
cp packaging/myapp.spec "$COPR_RESULTDIR/"
Add package:
copr-cli add-package-custom my-project \
  --name myapp \
  --script script.sh \
  --builddeps "git rpmdevtools" \
  --script-chroot fedora-latest-x86_64
Build:
copr-cli build-package my-project --name myapp
The custom script runs with root privileges inside a mock chroot and has internet access.

Choosing a source type

Use URL source when:
  • You already have built SRPMs hosted somewhere
  • You want to quickly test a build without setting up package definitions
  • You’re building from a one-time URL
Use Upload source when:
  • You have SRPMs or spec files on your local machine
  • You’re doing quick tests or one-off builds
  • You want to build locally-modified packages
Use SCM source when:
  • Your package sources are in Git or SVN
  • You want to rebuild automatically via webhooks
  • You use tito or rpkg for package management
  • You need fine-grained control over the build process
Use DistGit source when:
  • You’re building from Fedora or CentOS DistGit
  • You want a simpler interface than SCM
  • You’re building Fedora packages in Copr
Use PyPI source when:
  • You’re packaging Python projects from PyPI
  • You want automatic spec file generation
  • You’re creating RPMs for Python modules
Use RubyGems source when:
  • You’re packaging Ruby gems from RubyGems.org
  • You want automatic spec file generation
  • You’re creating RPMs for Ruby gems
Use Custom source when:
  • You need a completely custom build process
  • Existing source types don’t fit your workflow
  • You need to perform complex preparation steps
  • You want to integrate with external systems

Build docs developers (and LLMs) love