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.

GNOME Builder snippets improvement

Did you know that GNOME Builder support snippets? I didn’t.

I made 4 snippets for RPM Spec files to get spec skeleton: minimal, library, python-arch, python-noarch. You can start typing one of this, press ENTER and see how this magic works. It’s very useful when you packaging something to avoid calling rpmdev-newspec with parameters, opening editor, manual walking by lines and etc.

Also I added some basic snippets for Python files: class/function definition, interpreter line, main function and import. This helps me to more faster write code.

P.S. there some cool C snippets like gobject and main

P.P.S. for switch to next field you want to press Tab

css.php