misc: fix ubuntu 20.04 python deps
[vpp.git] / src / pkg / CMakeLists.txt
1 # Copyright (c) 2019 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 get_cmake_property(VPP_COMPONENTS COMPONENTS)
15 string(REPLACE ";" " " VPP_COMPONENTS "${VPP_COMPONENTS}")
16
17 execute_process(
18   COMMAND date -R
19   OUTPUT_VARIABLE TIMESTAMP
20   OUTPUT_STRIP_TRAILING_WHITESPACE
21 )
22
23 # parse /etc/os-release
24 file(READ "/etc/os-release" os_release)
25 string(REPLACE "\n" ";" os_release ${os_release})
26 foreach(l ${os_release})
27   string(REPLACE "=" ";" l ${l})
28   list(GET l 0 _name)
29   list(GET l 1 _value)
30   string(REPLACE "\"" "" _value ${_value})
31   set(OS_${_name} ${_value})
32 endforeach()
33
34 if (OS_ID STREQUAL "ubuntu" AND OS_VERSION_ID VERSION_LESS 20.04)
35   set(VPP_DEB_BUILD_DEPENDS "python-all, python3-all, python3-setuptools")
36   set(VPP_DEB_WITH_PYTHON2 "yes")
37 else()
38   set(VPP_DEB_BUILD_DEPENDS "python3-all, python3-setuptools")
39   set(VPP_DEB_WITH_PYTHON2 "no")
40 endif()
41
42 foreach(f rules changelog control)
43   configure_file(
44     ${CMAKE_CURRENT_SOURCE_DIR}/debian/${f}.in
45     ${CMAKE_BINARY_DIR}/debian/${f}
46     @ONLY
47   )
48 endforeach()
49
50 foreach(f copyright vpp.preinst vpp.postrm vpp.postinst vpp.service)
51   file(COPY
52     ${CMAKE_CURRENT_SOURCE_DIR}/debian/${f}
53     DESTINATION ${CMAKE_BINARY_DIR}/debian
54   )
55 endforeach()
56
57 file(WRITE ${CMAKE_BINARY_DIR}/debian/compat "9\n")
58
59 add_custom_target(package-deb
60   COMMENT "Building .deb packages..."
61   WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
62   COMMAND "dpkg-buildpackage" "-us" "-uc" "-b"
63   USES_TERMINAL
64 )