misc: fix ubuntu 20.04 python deps
Type: fix
Change-Id: I9cdfbffd6333d090f970422bf047aaa90c1e4c65
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/pkg/CMakeLists.txt b/src/pkg/CMakeLists.txt
index 357d966..a5a0ffe 100644
--- a/src/pkg/CMakeLists.txt
+++ b/src/pkg/CMakeLists.txt
@@ -20,14 +20,34 @@
OUTPUT_STRIP_TRAILING_WHITESPACE
)
-foreach(f rules changelog)
+# parse /etc/os-release
+file(READ "/etc/os-release" os_release)
+string(REPLACE "\n" ";" os_release ${os_release})
+foreach(l ${os_release})
+ string(REPLACE "=" ";" l ${l})
+ list(GET l 0 _name)
+ list(GET l 1 _value)
+ string(REPLACE "\"" "" _value ${_value})
+ set(OS_${_name} ${_value})
+endforeach()
+
+if (OS_ID STREQUAL "ubuntu" AND OS_VERSION_ID VERSION_LESS 20.04)
+ set(VPP_DEB_BUILD_DEPENDS "python-all, python3-all, python3-setuptools")
+ set(VPP_DEB_WITH_PYTHON2 "yes")
+else()
+ set(VPP_DEB_BUILD_DEPENDS "python3-all, python3-setuptools")
+ set(VPP_DEB_WITH_PYTHON2 "no")
+endif()
+
+foreach(f rules changelog control)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/debian/${f}.in
${CMAKE_BINARY_DIR}/debian/${f}
+ @ONLY
)
endforeach()
-foreach(f control copyright vpp.preinst vpp.postrm vpp.postinst vpp.service)
+foreach(f copyright vpp.preinst vpp.postrm vpp.postinst vpp.service)
file(COPY
${CMAKE_CURRENT_SOURCE_DIR}/debian/${f}
DESTINATION ${CMAKE_BINARY_DIR}/debian
diff --git a/src/pkg/debian/control b/src/pkg/debian/control.in
similarity index 96%
rename from src/pkg/debian/control
rename to src/pkg/debian/control.in
index 48de48a..0b0c621 100644
--- a/src/pkg/debian/control
+++ b/src/pkg/debian/control.in
@@ -5,9 +5,7 @@
Build-Depends: debhelper (>= 9),
dh-systemd,
dh-python,
- python-all,
- python3-all,
- python3-setuptools
+ @VPP_DEB_BUILD_DEPENDS@
Standards-Version: 3.9.4
Package: vpp
diff --git a/src/pkg/debian/rules.in b/src/pkg/debian/rules.in
index ceef46a..f09db38 100755
--- a/src/pkg/debian/rules.in
+++ b/src/pkg/debian/rules.in
@@ -9,18 +9,23 @@
export PYBUILD_NAME = vpp-api
export PYBUILD_DIR = @CMAKE_SOURCE_DIR@/vpp-api/python
-export PYBUILD_DESTDIR_python2=debian/vpp-api-python/
-export PYBUILD_DISABLE_python2=test
export PYBUILD_DESTDIR_python3=debian/python3-vpp-api/
export PYBUILD_DISABLE_python3=test
export PYBUILD_SYSTEM=distutils
-
+ifeq (@VPP_DEB_WITH_PYTHON2@,yes)
+export PYBUILD_DESTDIR_python2=debian/vpp-api-python/
+export PYBUILD_DISABLE_python2=test
buildvers := $(shell pyversions -sv)
+DH_WITH = systemd,python2,python3
+else
+DH_WITH = systemd,python3
+endif
+
build3vers := $(shell py3versions -sv)
# main packaging script based on dh7 syntax
%:
- dh $@ --with systemd,python2,python3 --buildsystem=pybuild
+ dh $@ --with $(DH_WITH) --buildsystem=pybuild
override_dh_strip:
dh_strip --dbg-package=vpp-dbg
diff --git a/src/vpp-api/python/CMakeLists.txt b/src/vpp-api/python/CMakeLists.txt
index 910df6b..6450fd9 100644
--- a/src/vpp-api/python/CMakeLists.txt
+++ b/src/vpp-api/python/CMakeLists.txt
@@ -11,7 +11,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-find_package(Python3 COMPONENTS Interpreter)
+if (CMAKE_VERSION VERSION_LESS 3.12)
+ find_package(PythonInterp 2.7)
+else()
+ find_package(Python3 COMPONENTS Interpreter)
+endif()
if(PYTHONINTERP_FOUND)
install(