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.