Building packages in COPR with own settings

Let’s start from some story behind. Let’s look at createrepo_c, it supports building with/without DRPM library. In RPM spec file we have:

%if 0%{?rhel} && 0%{?rhel} <= 7
%bcond_with drpm
%else
%bcond_without drpm
%endif

%if %{with drpm}
BuildRequires:  drpm-devel
%endif

Which means on RHEL8+ and other distros it will require at the build-time drpm-devel which is correct, and will not require it on RHEL7-. We don’t have drpm package in RHEL7- so it’s correct.

Now I want to build createrepo_c with drpm support for RHEL7 on COPR. I already built drpm there, but createrepo_c will not use drpm because %bcond_with disables option by default and allows you to enable it. Unfortunately (or fortunately) there is no way to pass parameters like --with drpm to COPR like to rpmbuild.. So we need to create package with RPM macros which will enable this option for us. Let’s create it!

Name:           drpm-rpm-macros
Version:        1
Release:        1%{?dist}
Summary:        RPM macros to enable DRPM

License:        Public Domain
URL:            https://github.com/ignatenkobrain/drpm-rpm-macros

BuildArch:      noarch
Provides:       drpm-macros = %{version}-%{release}

%description
%{summary}.

We have on EL7 and below %bcond_with drpm, but we want to enable DRPM.

%prep
%autosetup -c -D -T

%build
# Nothing to build

%install
mkdir -p %{buildroot}/%{_rpmconfigdir}/macros.d/
echo '%_with_drpm 1' > %{buildroot}/%{_rpmconfigdir}/macros.d/macros.drpm

%files
%{_rpmconfigdir}/macros.d/macros.drpm

%changelog
* Tue Apr 12 2016 Igor Gnatenko <ignatenko@redhat.com> - 1-1
- Initial package

Now we need to create src.rpm for this package and submit for building to the COPR. Once it’s done we need to modify buildroot options to always install this package. Just open settings of the project, click edit button on interesting chroot (in my case it’s epel-7-x86_64), add drpm-rpm-macros to the packages line and save. In all next builds in this chroot you will have drpm-rpm-macros installed automatically.

Now we can submit building of createrepo_c without any changes and it will be built with enabled drpm feature.

CI for mesa in Fedora Project

Today I played with jenkins for my primary work. I wanted to check sources periodically and if it has been changed – build new RPM package from new git version. I have started playing with mesa, because I maintain it in Fedora and has git version in Rawhide which I’m building from time to time from git.

Q: What it’s doing right now?
A: Checking if there new upstream commits, updating .spec file, commiting to fedorapeople git repository, copying .src.rpm to fedorapeople http site and submitting to build in COPR repo.

Q: How I can use this CI and what version of Fedora I need?
A: You can use this CI only on Fedora Rawhide. You can enable repo via # dnf copr enable ignatenkobrain/mesa and update packages.

How I built this in jenkins?
Continue reading →

css.php