copr is a cloud build system for everybody to build rpm packages; it takes as input an srpm package (.src.rpm) or a spec file (.spec), and then gives as output an rpm package (.rpm) and a yum repo (.repo);

to be precise, one can build multiple rpm packages from a single srpm package;

building rpm packages on copr has a few advantages:

  • consistent build environment;

  • multi-version and multi-arch support;

  • yum repo for easy package install;

quickstart

follow these steps if you are new to copr:

  1. setup a fas account:

    https://admin.fedoraproject.org/accounts/user/new

  2. log into copr:

    https://copr.fedorainfracloud.org/

  3. go to copr api page:

    https://copr.fedorainfracloud.org/api/

  4. copy the generated auth token into ~/.config/copr;

  5. install copr-cli command-line tool:

    dnf install copr-cli
    
  6. to create a project, run:

    copr-cli create {project} --chroot fedora-{release}-{arch} --enable-net on
    

    for example:

    copr-cli create test-project --chroot fedora-29-x86_64 --enable-net on
    
  7. to build the project from the url of an srpm package:

    copr-cli build {project} {url}
    

    for example:

    copr-cli build test-project http://www.example.com/package-1.6-1.fc29.src.rpm
    
  8. to build the project by uploading a local srpm package:

    copr-cli build {project} {.src.rpm}
    

    for example:

    copr-cli build test-project ~/package-1.6-1.fc29.src.rpm
    
  9. user can build multiple srpm packages in one project:

    copr-cli build {project} {0.src.rpm}
    copr-cli build {project} {1.src.rpm}
    copr-cli build {project} {2.src.rpm}
    
  10. the command-line tool will monitor the build and update any changes and results; after the build has started, the command-line tool will give a notice about it is safe to interrupt the command-line tool now; the build will continue running in the cloud, with live build logs available online;

  11. when the build is finished, a yum repo is made up of built packages; to use this repo, user needs to install dnf-plugins-core:

    dnf install dnf-plugins-core
    

    then enable the repo:

    dnf copr enable {user}/{project}
    

    now built packages can be installed via dnf as usual;

    the repo can be disabled with:

    dnf copr disable {user}/{project}
    
  12. user can also directly download built packages from the build chroot:

    https://download.copr.fedorainfracloud.org/results/{user}/{project}/fedora-{release}-{arch}/{build}/

    user can find the build chroot on the build page;

project management

there are several tabs on a project page:

external repos

some packages have dependencies outside of official fedora repos; we can add such build dependencies using external repos;

click into project settings, and fill the blank in External Repositories; each line is a yum repo baseurl; the repo may or may not be a copr repo;

the baseurl may contain some variables (shown with example values):

  • $chroot (fedora-21-x86_64)
  • $releasever (21)
  • $basearch (x86_64)
  • $distname (fedora)

there are 2 ways to reference a copr repo:

  • use its baseurl, which looks like this:

    https://download.copr.fedorainfracloud.org/results/{user}/{project}/fedora-{releasever}-{arch}/
    
  • use copr:// protocol:

    copr://{user}/{project}
    

continuous testing

when writing a new spec file or working with a broken spec file, we often need to repeatedly build with the spec file to test it;

assume the spec file is in ~/rpmbuild/SPECS/, we can cd into ~/rpmbuild and loop this until everything works:

  • modify spec file;

  • build srpm package on local:

    rpmbuild -bs SPECS/{.spec}
    

    this outputs an srpm package in SRPMS/;

  • build rpm package on copr:

    copr-cli build {project} SRPMS/{.src.rpm}