blob: 5fa2826ad9ade982844bfc29a5bdd0c3303d157f [file] [log] [blame]
Damjan Marion4d2f86a2019-01-18 13:28:22 +01001# 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 Marion5857daf2020-06-16 16:05:12 +020014if(CMAKE_CROSSCOMPILING)
15 return()
16endif()
17
Damjan Marion4d2f86a2019-01-18 13:28:22 +010018get_cmake_property(VPP_COMPONENTS COMPONENTS)
19string(REPLACE ";" " " VPP_COMPONENTS "${VPP_COMPONENTS}")
20
Andrew Yourtchenko5ca8bfc2023-10-18 21:18:32 +000021##############################################################################
22# pinned timestamp for reproducible builds
23##############################################################################
24set(VPP_SOURCE_DATE_EPOCH
25 ""
26 CACHE
27 STRING "Artifact build timestamp for reproducible builds"
28)
29
30if(VPP_SOURCE_DATE_EPOCH STREQUAL "")
31 set(VPP_TIMESTAMP_ARG "")
32else()
33 set(VPP_TIMESTAMP_ARG "--date=@${VPP_SOURCE_DATE_EPOCH}")
34endif()
35
Damjan Marion4d2f86a2019-01-18 13:28:22 +010036execute_process(
Andrew Yourtchenko5ca8bfc2023-10-18 21:18:32 +000037 COMMAND date -R ${VPP_TIMESTAMP_ARG}
Damjan Marion4d2f86a2019-01-18 13:28:22 +010038 OUTPUT_VARIABLE TIMESTAMP
39 OUTPUT_STRIP_TRAILING_WHITESPACE
40)
41
Damjan Mariona4164932020-05-12 12:22:18 +020042# parse /etc/os-release
43file(READ "/etc/os-release" os_release)
44string(REPLACE "\n" ";" os_release ${os_release})
45foreach(l ${os_release})
46 string(REPLACE "=" ";" l ${l})
47 list(GET l 0 _name)
48 list(GET l 1 _value)
49 string(REPLACE "\"" "" _value ${_value})
50 set(OS_${_name} ${_value})
51endforeach()
52
Paul Vinciguerra3ca4b142020-12-30 00:41:15 +000053set(VPP_DEB_BUILD_DEPENDS "python3-all, python3-setuptools")
54set(VPP_DEB_WITH_PYTHON2 "no")
Damjan Mariona4164932020-05-12 12:22:18 +020055
56foreach(f rules changelog control)
Damjan Marion4d2f86a2019-01-18 13:28:22 +010057 configure_file(
58 ${CMAKE_CURRENT_SOURCE_DIR}/debian/${f}.in
Damjan Marion88b2e362021-04-29 18:47:25 +020059 ${VPP_BINARY_DIR}/debian/${f}
Damjan Mariona4164932020-05-12 12:22:18 +020060 @ONLY
Damjan Marion4d2f86a2019-01-18 13:28:22 +010061 )
62endforeach()
63
Damjan Mariona4164932020-05-12 12:22:18 +020064foreach(f copyright vpp.preinst vpp.postrm vpp.postinst vpp.service)
Damjan Marion4d2f86a2019-01-18 13:28:22 +010065 file(COPY
66 ${CMAKE_CURRENT_SOURCE_DIR}/debian/${f}
Damjan Marion88b2e362021-04-29 18:47:25 +020067 DESTINATION ${VPP_BINARY_DIR}/debian
Damjan Marion4d2f86a2019-01-18 13:28:22 +010068 )
69endforeach()
70
Damjan Marion88b2e362021-04-29 18:47:25 +020071add_custom_target(pkg-deb
Damjan Marion4d2f86a2019-01-18 13:28:22 +010072 COMMENT "Building .deb packages..."
Damjan Marion88b2e362021-04-29 18:47:25 +020073 WORKING_DIRECTORY ${VPP_BINARY_DIR}
Damjan Marion4d2f86a2019-01-18 13:28:22 +010074 COMMAND "dpkg-buildpackage" "-us" "-uc" "-b"
Damjan Marion7ec2fe22019-01-22 09:10:16 +010075 USES_TERMINAL
Damjan Marion4d2f86a2019-01-18 13:28:22 +010076)