aboutsummaryrefslogtreecommitdiffstats
path: root/src/cmake
diff options
context:
space:
mode:
authorYohanPipereau <ypiperea@cisco.com>2019-07-19 17:53:18 +0200
committerAndrew Yourtchenko <ayourtch@gmail.com>2019-07-31 16:02:50 +0000
commit093dd7fe5a7b840a1de3457ac7faa069ed7cab11 (patch)
tree78dcf1f81f3374ceb73bf42f85e3aa2f15af9ff0 /src/cmake
parente3cb1f94bad8bb778cebf90aa09ceb8ddbc4b61f (diff)
build: Append build number for cpack packages
add_vpp_packaging maccro was circumventing scripts/version causing: 1. build number not being appended to the package 2. invalid package name format (due to cmake cpack module) Change-Id: I2b9a985357a3f3bd501be6db6ca638d4430f4bbb Type: make Fixes: def35a2352c9a54f748d301ffa47a446d25a83e0 Signed-off-by: YohanPipereau <ypiperea@cisco.com>
Diffstat (limited to 'src/cmake')
-rw-r--r--src/cmake/pack.cmake63
1 files changed, 32 insertions, 31 deletions
diff --git a/src/cmake/pack.cmake b/src/cmake/pack.cmake
index 0da3093b1a0..a89a90c452c 100644
--- a/src/cmake/pack.cmake
+++ b/src/cmake/pack.cmake
@@ -11,14 +11,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-##############################################################################
-# DEB Packaging
-##############################################################################
-
-macro(add_vpp_packaging name)
+# name, vendor, description are macros, arguments are in ${ARGN}
+macro(add_vpp_packaging)
cmake_parse_arguments(ARG
""
- "NAME;DESCRIPION;VENDOR"
+ "NAME;DESCRIPTION;VENDOR"
""
${ARGN}
)
@@ -42,7 +39,6 @@ macro(add_vpp_packaging name)
)
string(REGEX REPLACE "v(.*)-([0-9]+)-(g[0-9a-f]+)" "\\1;\\2;\\3" VER ${VER})
list(GET VER 0 tag)
- string(REPLACE "-" "~" tag ${tag})
list(GET VER 1 commit_num)
list(GET VER 2 commit_name)
@@ -51,45 +47,50 @@ macro(add_vpp_packaging name)
set(deb_ver "${tag}")
set(rpm_ver "${tag}")
else()
- set(deb_ver "${tag}~${commit_num}~${commit_name}")
- set(rpm_ver "${tag}~${commit_num}_${commit_name}")
+ if (DEFINED ENV{BUILD_NUMBER})
+ set(deb_ver "${tag}~${commit_num}-${commit_name}~b$ENV{BUILD_NUMBER}")
+ set(rpm_ver "${tag}~${commit_num}_${commit_name}~b$ENV{BUILD_NUMBER}")
+ else()
+ set(deb_ver "${tag}~${commit_num}-${commit_name}")
+ set(rpm_ver "${tag}~${commit_num}_${commit_name}")
+ endif()
endif()
- get_cmake_property(components COMPONENTS)
+ set(CPACK_PACKAGE_NAME ${ARG_NAME})
+ set(CPACK_STRIP_FILES OFF)
+ set(CPACK_PACKAGE_VENDOR "${ARG_VENDOR}")
+ set(CPACK_COMPONENTS_IGNORE_GROUPS 1)
+ set(CPACK_${CPACK_GENERATOR}_COMPONENT_INSTALL ON)
+ set(CPACK_${type}_PACKAGE_DESCRIPTION "${ARG_DESCRIPTION}")
+ set(CPACK_${type}_PACKAGE_RELEASE 1)
if(OS_ID_LIKE MATCHES "debian")
set(CPACK_GENERATOR "DEB")
set(type "DEBIAN")
set(CPACK_PACKAGE_VERSION "${deb_ver}")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "VPP Team")
- set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
- foreach(lc ${components})
- string(TOUPPER ${lc} uc)
- set(CPACK_DEBIAN_${uc}_PACKAGE_NAME "${lc}")
- endforeach()
+ execute_process(
+ COMMAND dpkg --print-architecture
+ OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE})
elseif(OS_ID_LIKE MATCHES "rhel")
set(CPACK_GENERATOR "RPM")
set(type "RPM")
set(CPACK_PACKAGE_VERSION "${rpm_ver}")
- set(CPACK_RPM_FILE_NAME RPM-DEFAULT)
- foreach(lc ${components})
- string(TOUPPER ${lc} uc)
- if(${lc} MATCHES ".*-dev")
- set(CPACK_RPM_${uc}_DEBUGINFO_PACKAGE ON)
- set(lc ${lc}el)
- endif()
- set(CPACK_RPM_${uc}_PACKAGE_NAME "${lc}")
- endforeach()
+ execute_process(
+ COMMAND uname -m
+ OUTPUT_VARIABLE CPACK_RPM_PACKAGE_ARCHITECTURE
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.${CPACK_RPM_PACKAGE_ARCHITECTURE})
endif()
if(CPACK_GENERATOR)
- set(CPACK_PACKAGE_NAME ${ARG_NAME})
- set(CPACK_STRIP_FILES OFF)
- set(CPACK_PACKAGE_VENDOR "${ARG_VENDOR}")
- set(CPACK_COMPONENTS_IGNORE_GROUPS 1)
- set(CPACK_${CPACK_GENERATOR}_COMPONENT_INSTALL ON)
- set(CPACK_${type}_PACKAGE_DESCRIPTION "${ARG_DESCRIPTION}")
- set(CPACK_${type}_PACKAGE_RELEASE 1)
include(CPack)
+ else()
+ message(ERROR "CPACK_GENERATOR must be set")
endif()
+
endmacro()