Skip to content

Commit e25d700

Browse files
committed
make-srpm.sh: modernize spec file
This commit makes csdiff.spec look closer to what we have in Fedora but preserves compatibility with EPEL-7 buildroot. It also enables python3 support for EPEL-7. Closes: https://github.com/kdudka/csdiff/pull/15
1 parent 56e824f commit e25d700

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

make-srpm.sh

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#/bin/bash
22

3-
# Copyright (C) 2014 Red Hat, Inc.
3+
# Copyright (C) 2014 - 2020 Red Hat, Inc.
44
#
55
# This file is part of csdiff.
66
#
@@ -71,20 +71,16 @@ xz -c "$SRC_TAR" > "$SRC" || die "failed to compress sources"
7171

7272
SPEC="./$PKG.spec"
7373
cat > "$SPEC" << EOF
74-
# python3 is not available on RHEL <= 7
75-
%if 0%{?fedora} || 0%{?rhel} > 7
76-
%bcond_without python3
77-
%else
78-
%bcond_with python3
79-
%endif
80-
81-
# python2 is not available on RHEL > 7 and not needed on Fedora > 29
82-
%if 0%{?rhel} > 7 || 0%{?fedora} > 29
74+
# python2 is not available on RHEL > 7 and Fedora
75+
%if 0%{?rhel} > 7 || 0%{?fedora}
8376
%bcond_with python2
8477
%else
8578
%bcond_without python2
8679
%endif
8780
81+
# python3 support is optional
82+
%bcond_without python3
83+
8884
Name: $PKG
8985
Version: $VER
9086
Release: 1%{?dist}
@@ -111,7 +107,7 @@ defect lists using various filtering predicates.
111107
%if %{with python2}
112108
%package -n python2-%{name}
113109
Summary: Python interface to csdiff for Python 2
114-
%if 0%{?fedora} > 28
110+
%if 0%{?fedora}
115111
BuildRequires: boost-python2-devel
116112
%endif
117113
BuildRequires: python2-devel
@@ -125,7 +121,13 @@ code scan defect lists to find out added or fixed defects.
125121
%if %{with python3}
126122
%package -n python3-%{name}
127123
Summary: Python interface to csdiff for Python 3
128-
BuildRequires: boost-python3-devel
124+
125+
# this packages redefines %%{python3_pkgversion} to 36 because there is
126+
# no boost-python3-devel in epel-7 buildroot, only boost-python36-devel
127+
%if 0%{?rhel} == 7
128+
BuildRequires: epel-rpm-macros
129+
%endif
130+
BuildRequires: boost-python%{python3_pkgversion}-devel
129131
BuildRequires: python3-devel
130132
%{?python_provide:%python_provide python3-%{name}}
131133
@@ -139,41 +141,40 @@ code scan defect lists to find out added or fixed defects.
139141
140142
%build
141143
make version.cc
142-
mkdir csdiff_build
143-
cd csdiff_build
144+
mkdir -p %{_target_platform}
145+
cd %{_target_platform}
144146
%cmake .. -B. -DBUILD_PYCSDIFF=OFF
145-
make %{?_smp_mflags} VERBOSE=yes
147+
%make_build
146148
147149
%if %{with python2}
148-
mkdir ../csdiff_build_py2
149-
cd ../csdiff_build_py2
150+
mkdir -p ../%{_target_platform}-py2
151+
cd ../%{_target_platform}-py2
150152
%cmake .. -B. -DPYTHON_EXECUTABLE=%{__python2}
151-
make %{?_smp_mflags} VERBOSE=yes pycsdiff
153+
%make_build pycsdiff
152154
%endif
153155
154156
%if %{with python3}
155-
mkdir ../csdiff_build_py3
156-
cd ../csdiff_build_py3
157+
mkdir -p ../%{_target_platform}-py3
158+
cd ../%{_target_platform}-py3
157159
%cmake .. -B. \\
158160
-DPYTHON_EXECUTABLE=%{__python3} \\
159161
-DBOOST_PYTHON_LIB_NAME=boost_python%{python3_version_nodots}
160-
make %{?_smp_mflags} VERBOSE=yes pycsdiff
162+
%make_build pycsdiff
161163
%endif
162164
163165
%install
164166
%if %{with python2}
165-
make install-pycsdiff -C csdiff_build_py2 DESTDIR=%{buildroot}
167+
make install-pycsdiff -C %{_target_platform}-py2 DESTDIR=%{buildroot}
166168
%endif
167169
168170
%if %{with python3}
169-
make install-pycsdiff -C csdiff_build_py3 DESTDIR=%{buildroot}
171+
make install-pycsdiff -C %{_target_platform}-py3 DESTDIR=%{buildroot}
170172
%endif
171173
172-
cd csdiff_build
173-
%make_install
174+
%make_install -C %{_target_platform}
174175
175176
%check
176-
cd csdiff_build
177+
cd %{_target_platform}
177178
ctest %{?_smp_mflags} --output-on-failure
178179
179180
%files

0 commit comments

Comments
 (0)