Damjan Marion | 4d2f86a | 2019-01-18 13:28:22 +0100 | [diff] [blame] | 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 | |
Damjan Marion | 5857daf | 2020-06-16 16:05:12 +0200 | [diff] [blame] | 14 | if(CMAKE_CROSSCOMPILING) |
| 15 | return() |
| 16 | endif() |
| 17 | |
Damjan Marion | 4d2f86a | 2019-01-18 13:28:22 +0100 | [diff] [blame] | 18 | get_cmake_property(VPP_COMPONENTS COMPONENTS) |
| 19 | string(REPLACE ";" " " VPP_COMPONENTS "${VPP_COMPONENTS}") |
| 20 | |
| 21 | execute_process( |
| 22 | COMMAND date -R |
| 23 | OUTPUT_VARIABLE TIMESTAMP |
| 24 | OUTPUT_STRIP_TRAILING_WHITESPACE |
| 25 | ) |
| 26 | |
Damjan Marion | a416493 | 2020-05-12 12:22:18 +0200 | [diff] [blame] | 27 | # parse /etc/os-release |
| 28 | file(READ "/etc/os-release" os_release) |
| 29 | string(REPLACE "\n" ";" os_release ${os_release}) |
| 30 | foreach(l ${os_release}) |
| 31 | string(REPLACE "=" ";" l ${l}) |
| 32 | list(GET l 0 _name) |
| 33 | list(GET l 1 _value) |
| 34 | string(REPLACE "\"" "" _value ${_value}) |
| 35 | set(OS_${_name} ${_value}) |
| 36 | endforeach() |
| 37 | |
| 38 | if (OS_ID STREQUAL "ubuntu" AND OS_VERSION_ID VERSION_LESS 20.04) |
| 39 | set(VPP_DEB_BUILD_DEPENDS "python-all, python3-all, python3-setuptools") |
| 40 | set(VPP_DEB_WITH_PYTHON2 "yes") |
| 41 | else() |
| 42 | set(VPP_DEB_BUILD_DEPENDS "python3-all, python3-setuptools") |
| 43 | set(VPP_DEB_WITH_PYTHON2 "no") |
| 44 | endif() |
| 45 | |
| 46 | foreach(f rules changelog control) |
Damjan Marion | 4d2f86a | 2019-01-18 13:28:22 +0100 | [diff] [blame] | 47 | configure_file( |
| 48 | ${CMAKE_CURRENT_SOURCE_DIR}/debian/${f}.in |
| 49 | ${CMAKE_BINARY_DIR}/debian/${f} |
Damjan Marion | a416493 | 2020-05-12 12:22:18 +0200 | [diff] [blame] | 50 | @ONLY |
Damjan Marion | 4d2f86a | 2019-01-18 13:28:22 +0100 | [diff] [blame] | 51 | ) |
| 52 | endforeach() |
| 53 | |
Damjan Marion | a416493 | 2020-05-12 12:22:18 +0200 | [diff] [blame] | 54 | foreach(f copyright vpp.preinst vpp.postrm vpp.postinst vpp.service) |
Damjan Marion | 4d2f86a | 2019-01-18 13:28:22 +0100 | [diff] [blame] | 55 | file(COPY |
| 56 | ${CMAKE_CURRENT_SOURCE_DIR}/debian/${f} |
| 57 | DESTINATION ${CMAKE_BINARY_DIR}/debian |
| 58 | ) |
| 59 | endforeach() |
| 60 | |
Damjan Marion | c1b94c8 | 2020-10-16 11:23:48 +0200 | [diff] [blame] | 61 | file(WRITE ${CMAKE_BINARY_DIR}/debian/compat "10\n") |
Damjan Marion | 4d2f86a | 2019-01-18 13:28:22 +0100 | [diff] [blame] | 62 | |
| 63 | add_custom_target(package-deb |
| 64 | COMMENT "Building .deb packages..." |
| 65 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} |
| 66 | COMMAND "dpkg-buildpackage" "-us" "-uc" "-b" |
Damjan Marion | 7ec2fe2 | 2019-01-22 09:10:16 +0100 | [diff] [blame] | 67 | USES_TERMINAL |
Damjan Marion | 4d2f86a | 2019-01-18 13:28:22 +0100 | [diff] [blame] | 68 | ) |