Skip to content

Commit f667d91

Browse files
committed
make-srpm.sh: make both python2 and python3 optional
1 parent 142ee3f commit f667d91

File tree

1 file changed

+38
-7
lines changed

1 file changed

+38
-7
lines changed

Diff for: make-srpm.sh

+38-7
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,20 @@ xz -c "$SRC_TAR" > "$SRC" || die "failed to compress sources"
7474

7575
SPEC="./$PKG.spec"
7676
cat > "$SPEC" << EOF
77+
# python3 is not available on RHEL <= 7
78+
%if 0%{?fedora} || 0%{?rhel} > 7
79+
%bcond_without python3
80+
%else
81+
%bcond_with python3
82+
%endif
83+
84+
# python2 is not available on RHEL > 7 and not needed on Fedora > 29
85+
%if 0%{?rhel} > 7 || 0%{?fedora} > 29
86+
%bcond_with python2
87+
%else
88+
%bcond_without python2
89+
%endif
90+
7791
Name: $PKG
7892
Version: $VER
7993
Release: 1%{?dist}
@@ -94,9 +108,13 @@ This package contains the csdiff tool for comparing code scan defect lists in
94108
order to find out added or fixed defects, and the csgrep utility for filtering
95109
defect lists using various filtering predicates.
96110
111+
%if %{with python2}
97112
%package -n python2-%{name}
98113
Summary: Python interface to csdiff for Python 2
99114
Conflicts: %{name} <= 1.2.3
115+
%if 0%{?fedora} > 28
116+
BuildRequires: boost-python2-devel
117+
%endif
100118
BuildRequires: python2-devel
101119
%{?python_provide:%python_provide python2-%{name}}
102120
@@ -108,10 +126,9 @@ code scan defect lists to find out added or fixed defects.
108126
%{!?__python2: %global __python2 /usr/bin/python2}
109127
%{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
110128
%endif
129+
%endif
111130
112-
# build the python3-csdiff package on Fedora 23+
113-
%global py3_support ((7 < 0%{?rhel}) || (22 < 0%{?fedora}))
114-
%if %{py3_support}
131+
%if %{with python3}
115132
%package -n python3-%{name}
116133
Summary: Python interface to csdiff for Python 3
117134
BuildRequires: boost-python3-devel
@@ -130,22 +147,34 @@ code scan defect lists to find out added or fixed defects.
130147
make version.cc
131148
mkdir csdiff_build
132149
cd csdiff_build
150+
%cmake .. -DBUILD_PYCSDIFF=OFF
151+
make %{?_smp_mflags} VERBOSE=yes
152+
153+
%if %{with python2}
154+
mkdir ../csdiff_build_py2
155+
cd ../csdiff_build_py2
133156
%cmake .. -DPYTHON_EXECUTABLE=%{__python2}
134157
make %{?_smp_mflags} VERBOSE=yes
158+
%endif
135159
136-
# build the python3-csdiff package on Fedora 23+
137-
%if %{py3_support}
160+
%if %{with python3}
138161
mkdir ../csdiff_build_py3
139162
cd ../csdiff_build_py3
140163
%cmake .. -DPYTHON_EXECUTABLE=%{__python3} -DBOOST_PYTHON_LIB_NAME=boost_python3
141164
make %{?_smp_mflags} VERBOSE=yes pycsdiff
142165
%endif
143166
144167
%install
145-
%if %{py3_support}
168+
%if %{with python2}
169+
mkdir -vp %{buildroot}%{python2_sitearch}
170+
install -vm0644 csdiff_build_py2/pycsdiff.so %{buildroot}%{python2_sitearch}
171+
%endif
172+
173+
%if %{with python3}
146174
mkdir -vp %{buildroot}%{python3_sitearch}
147175
install -vm0644 csdiff_build_py3/pycsdiff.so %{buildroot}%{python3_sitearch}
148176
%endif
177+
149178
cd csdiff_build
150179
make install DESTDIR="\$RPM_BUILD_ROOT"
151180
@@ -166,11 +195,13 @@ ctest %{?_smp_mflags} --output-on-failure
166195
%{_mandir}/man1/cssort.1*
167196
%doc COPYING README
168197
198+
%if %{with python2}
169199
%files -n python2-%{name}
170200
%{python2_sitearch}/pycsdiff.so
171201
%doc COPYING
202+
%endif
172203
173-
%if %{py3_support}
204+
%if %{with python3}
174205
%files -n python3-%{name}
175206
%{python3_sitearch}/pycsdiff.so
176207
%doc COPYING

0 commit comments

Comments
 (0)