@@ -74,6 +74,20 @@ xz -c "$SRC_TAR" > "$SRC" || die "failed to compress sources"
74
74
75
75
SPEC=" ./$PKG .spec"
76
76
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
+
77
91
Name: $PKG
78
92
Version: $VER
79
93
Release: 1%{?dist}
@@ -94,9 +108,13 @@ This package contains the csdiff tool for comparing code scan defect lists in
94
108
order to find out added or fixed defects, and the csgrep utility for filtering
95
109
defect lists using various filtering predicates.
96
110
111
+ %if %{with python2}
97
112
%package -n python2-%{name}
98
113
Summary: Python interface to csdiff for Python 2
99
114
Conflicts: %{name} <= 1.2.3
115
+ %if 0%{?fedora} > 28
116
+ BuildRequires: boost-python2-devel
117
+ %endif
100
118
BuildRequires: python2-devel
101
119
%{?python_provide:%python_provide python2-%{name}}
102
120
@@ -108,10 +126,9 @@ code scan defect lists to find out added or fixed defects.
108
126
%{!?__python2: %global __python2 /usr/bin/python2}
109
127
%{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
110
128
%endif
129
+ %endif
111
130
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}
115
132
%package -n python3-%{name}
116
133
Summary: Python interface to csdiff for Python 3
117
134
BuildRequires: boost-python3-devel
@@ -130,22 +147,34 @@ code scan defect lists to find out added or fixed defects.
130
147
make version.cc
131
148
mkdir csdiff_build
132
149
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
133
156
%cmake .. -DPYTHON_EXECUTABLE=%{__python2}
134
157
make %{?_smp_mflags} VERBOSE=yes
158
+ %endif
135
159
136
- # build the python3-csdiff package on Fedora 23+
137
- %if %{py3_support}
160
+ %if %{with python3}
138
161
mkdir ../csdiff_build_py3
139
162
cd ../csdiff_build_py3
140
163
%cmake .. -DPYTHON_EXECUTABLE=%{__python3} -DBOOST_PYTHON_LIB_NAME=boost_python3
141
164
make %{?_smp_mflags} VERBOSE=yes pycsdiff
142
165
%endif
143
166
144
167
%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}
146
174
mkdir -vp %{buildroot}%{python3_sitearch}
147
175
install -vm0644 csdiff_build_py3/pycsdiff.so %{buildroot}%{python3_sitearch}
148
176
%endif
177
+
149
178
cd csdiff_build
150
179
make install DESTDIR="\$ RPM_BUILD_ROOT"
151
180
@@ -166,11 +195,13 @@ ctest %{?_smp_mflags} --output-on-failure
166
195
%{_mandir}/man1/cssort.1*
167
196
%doc COPYING README
168
197
198
+ %if %{with python2}
169
199
%files -n python2-%{name}
170
200
%{python2_sitearch}/pycsdiff.so
171
201
%doc COPYING
202
+ %endif
172
203
173
- %if %{py3_support }
204
+ %if %{with python3 }
174
205
%files -n python3-%{name}
175
206
%{python3_sitearch}/pycsdiff.so
176
207
%doc COPYING
0 commit comments