Skip to content

Build templates

Panu Matilainen edited this page Sep 26, 2018 · 2 revisions

Rough ideas for templating common build types

Name:           foo
Version:        1.2
Release:        1%{?dist}
Summary:        Example of build type template
License:
URL:
Source0:        http://some.where/%{name}-%{version}.tar.gz
BuildType:      autotools
BuildRequires:  bar-devel

%description
%{summary}

%files
%doc README
%license COPYING
%{_bindir}/%{name}
%{_libdir}/libfoo*.so.*

Simplified example of course, -devel is not there etc. What happens behind the scenes is that "BuildType: autotools" populates the following:

%prep
%autosetup

%build
%autotools_setup
%autotools_build

%install
%autotools_install

...which in turn internally expands to what we see in specs today:

%prep
%autosetup

%build
%configure
%make_build

%install
%make_install

...which is all just tedious boilerplate present in every damn spec. One obvious problem here is how to tweak the necessary sections, like %configure for which you almost always want to pass some arguments. Probably add a new section to the spec between %prep and %build which consists of nothing but the step to configure the software, and when you need to change that you only add that section to the spec.

Similar steps can be created for cmake, python2 / python3 with setup.py, ruby, rust, golang etc etc.

Clone this wiki locally