build packages on copr
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:
-
setup a fas account:
-
log into copr:
-
go to copr api page:
-
copy the generated auth token into
~/.config/copr
; -
install
copr-cli
command-line tool:dnf install copr-cli
-
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
-
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
-
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
-
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}
-
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;
-
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}
-
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:
-
Overview:
project info; external repo list; yum repo of built packages;
-
Packages:
list project packages; click into a package to see its builds;
-
Builds:
https://copr.fedorainfracloud.org/coprs/{user}/{project}/builds/
list project builds; click into a build to see its information; most build information are straightforward;
on a build page, one can click into the chroot of the build:
https://download.copr.fedorainfracloud.org/results/{user}/{project}/fedora-{release}-{arch}/{build}/
the chroot contains, among other files:
-
builder-live.log.gz
:the live build log, for user to monitor build progress;
-
all built rpm packages;
-
-
Modules:
for user to build modules;
-
Monitor:
for user to monitor builds;
-
Settings:
project settings: build options, external repos, etc.;
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}