From 87a7e90e58a795c40afe6acfe96859f5aff6a2c9 Mon Sep 17 00:00:00 2001 From: Michal Cmarada Date: Mon, 28 Jan 2019 11:36:44 +0100 Subject: update packaging - fix minor issues - add optional parameters to build ZIP and TGZ packages - updated list of supported OS - updated documentation Change-Id: Ie4ee73fc77232c6bd35644cdd8bb67bb4df42d93 Signed-off-by: Michal Cmarada --- CMakeLists.txt | 14 ++++++-- docs/jvpp.rst | 19 ++++++++++- java/CMakeLists.txt | 94 +++++++++++++++++++++++++++++------------------------ 3 files changed, 81 insertions(+), 46 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 427f31b..c344540 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,16 @@ if (compiler_flag_no_address_of_packed_member) add_definitions(-Wno-address-of-packed-member) endif() +find_package(Threads REQUIRED) + +# OPTIONS +option(PackZip "Create ZIP package (default: fasle)" false) +option(PackTgz "Create Tgz package (default: fasle)" false) + +message("\nOptions:") +message(" PackZip: ${PackZip}") +message(" PackTgz: ${PackTgz}") + message("\nEnvironment Variables:") # JVPP RELATED VARIABLES @@ -49,6 +59,8 @@ message(" JVPP Main Version: ${JVPP_VERSION}") message(" JVPP Version: ${JAPI_LIB_VERSION}") # OS RELATED VARIABLES +list(APPEND DebianBasedOS "Ubuntu" "LinuxMint") +list(APPEND RHBasedOS "CentOS") unset(RELEASE_ID) unset(RELEASE_CODENAME) find_program(LSB_RELEASE_EXEC lsb_release) @@ -70,8 +82,6 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build-root/lib) set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib) set(CMAKE_INSTALL_MESSAGE NEVER) -find_package(Threads REQUIRED) - unset(dirlist) macro(subdirlist dirlist dirpath) diff --git a/docs/jvpp.rst b/docs/jvpp.rst index 4fbeb39..7e07b80 100644 --- a/docs/jvpp.rst +++ b/docs/jvpp.rst @@ -52,6 +52,23 @@ from JVPP's root directory: cmake . This will configure all variables and setup the build. +If needed there are several optional parameters that can be set. You can list all configuration parameters using: + +.. code-block:: console + + cmake -LH + +as an example you can enable packaging using ZIP or TGZ. DEB or RPM packages are automatically configured based on OS. +To enable packaging using ZIP or TGZ (or both) add optional parameter to cmake like this: + +.. code-block:: console + + cmake -DPackZip=ON -DPackTgz=ON . + +.. note:: + + PackZip, PackTgz are boolean variables. You can use "1, ON, YES, TRUE, Y, or a non-zero number" to enable + or "0, OFF, NO, FALSE, N, IGNORE, NOTFOUND" to disable these options. Building the source ------------------- @@ -62,7 +79,7 @@ To build the source use make command: make -You can also install the library using (you need to use sudo or have root privileges to install libraries): +You can also install the library (Optional) using (you need to use sudo or have root privileges to install libraries): .. code-block:: console diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt index 1e823db..e7fde61 100644 --- a/java/CMakeLists.txt +++ b/java/CMakeLists.txt @@ -130,12 +130,12 @@ endfunction() unset (files) unset (corefiles) -if(${RELEASE_ID} MATCHES Ubuntu) +if(${RELEASE_ID} IN_LIST DebianBasedOS) execute_process(COMMAND dpkg-query -L vpp COMMAND grep -v memclnt COMMAND grep api.json OUTPUT_VARIABLE corefiles) STRING(REGEX REPLACE "\n" ";" corefiles "${corefiles}") -elseif(${RELEASE_ID} MATCHES CentOS) +elseif(${RELEASE_ID} IN_LIST RHBasedOS) # Exclude vpp plugin api files. VPP package should not contain vpp-plugins api files and vice-versa. Temporary fixing # by excluding them manually. execute_process(COMMAND rpm -ql vpp @@ -171,6 +171,8 @@ elseif(${RELEASE_ID} MATCHES CentOS) COMMAND grep -v vxlan_gpe_ioam_export COMMAND grep api.json OUTPUT_VARIABLE corefiles) STRING(REGEX REPLACE "\n" ";" corefiles "${corefiles}") +else() + message( FATAL_ERROR "Unsupported OS, CMake will now exit." ) endif() FILE(GLOB_RECURSE files RELATIVE @@ -193,11 +195,11 @@ unset (IOAM_TRACE_JSON_FILE) unset (IOAM_POT_JSON_FILE) unset (IOAM_EXPORT_JSON_FILE) -if(${RELEASE_ID} MATCHES Ubuntu) +if(${RELEASE_ID} IN_LIST DebianBasedOS) execute_process(COMMAND dpkg-query -L vpp-plugin-core COMMAND grep api.json OUTPUT_VARIABLE pluginfiles) STRING(REGEX REPLACE "\n" ";" pluginfiles "${pluginfiles}") -elseif(${RELEASE_ID} MATCHES CentOS) +elseif(${RELEASE_ID} IN_LIST RHBasedOS) execute_process(COMMAND rpm -ql vpp-plugins COMMAND grep api.json OUTPUT_VARIABLE pluginfiles) STRING(REGEX REPLACE "\n" ";" pluginfiles "${pluginfiles}") @@ -269,6 +271,7 @@ if(IOAM_EXPORT_JSON_FILE) endif() # Package Generator ####################################################### + unset(vpp_version) set(COLUMNS 200) execute_process( @@ -286,43 +289,48 @@ set(CPACK_PACKAGE_VENDOR "Cisco") set(CPACK_PACKAGE_CONTACT "hc2vpp@lists.fd.io") set(CPACK_OUTPUT_FILE_PREFIX build-root/packages) set(CPACK_PACKAGE_FILE_NAME "vpp-api-java_${JVPP_VERSION}") -if (${RELEASE_ID} MATCHES "Ubuntu") - set(CPACK_GENERATOR "DEB") - set(CPACK_DEBIAN_PACKAGE_NAME "${CPACK_PACKAGE_NAME}") - set(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}") - set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION}") - set(CPACK_DEBIAN_PACKAGE_SECTION "${CPACK_PACKAGE_SECTION}") - set(CPACK_DEBIAN_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME}) - set(CPACK_DEBIAN_PACKAGE_PRIORITY extra) - set(CPACK_DEBIAN_PACKAGE_DEPENDS "vpp (>= ${vpp_version}), vpp-plugin-core (>= ${vpp_version})") - - # Print Debian package summary - message("\nDebian package:") - message(" Name: ${CPACK_DEBIAN_PACKAGE_NAME}") - message(" Version: ${CPACK_DEBIAN_PACKAGE_VERSION}") - message(" Description: ${CPACK_DEBIAN_PACKAGE_DESCRIPTION}") - message(" File name: ${CPACK_DEBIAN_PACKAGE_FILE_NAME}") - message(" Depends on: ${CPACK_DEBIAN_PACKAGE_DEPENDS}\n") - include (CPack) -elseif(${RELEASE_ID} MATCHES "CentOS") - set(CPACK_GENERATOR "RPM") - # Excluding /usr/share/java top level directory due to conflict with javapackages-tools (openjdk dependency) - set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/share/java") - set(CPACK_RPM_PACKAGE_NAME "${CPACK_PACKAGE_NAME}") - set(CPACK_RPM_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}") - set(CPACK_RPM_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION}") - set(CPACK_RPM_PACKAGE_SECTION "${CPACK_PACKAGE_SECTION}") - set(CPACK_RPM_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME}) - set(CPACK_RPM_PACKAGE_PRIORITY extra) - set(CPACK_RPM_PACKAGE_DEPENDS "vpp (>= ${vpp_version}), vpp-plugins (>= ${vpp_version})") - - # Print CentOS package summary - message("\nRPM package:") - message(" Name: ${CPACK_RPM_PACKAGE_NAME}") - message(" Version: ${CPACK_RPM_PACKAGE_VERSION}") - message(" Description: ${CPACK_RPM_PACKAGE_DESCRIPTION}") - message(" File name: ${CPACK_RPM_PACKAGE_FILE_NAME}") - message(" Depends on: ${CPACK_RPM_PACKAGE_DEPENDS}\n") - include (CPack) +if (${RELEASE_ID} IN_LIST DebianBasedOS) + set(CPACK_GENERATOR DEB) + set(CPACK_DEBIAN_PACKAGE_NAME "${CPACK_PACKAGE_NAME}") + set(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}") + set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION}") + set(CPACK_DEBIAN_PACKAGE_SECTION "${CPACK_PACKAGE_SECTION}") + set(CPACK_DEBIAN_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME}) + set(CPACK_DEBIAN_PACKAGE_PRIORITY extra) + set(CPACK_DEBIAN_PACKAGE_DEPENDS "vpp (>= ${vpp_version}), vpp-plugin-core (>= ${vpp_version})") + + # Print Debian package summary + message("\nDebian package:") + message(" Name: ${CPACK_DEBIAN_PACKAGE_NAME}") + message(" Version: ${CPACK_DEBIAN_PACKAGE_VERSION}") + message(" Description: ${CPACK_DEBIAN_PACKAGE_DESCRIPTION}") + message(" File name: ${CPACK_DEBIAN_PACKAGE_FILE_NAME}") + message(" Depends on: ${CPACK_DEBIAN_PACKAGE_DEPENDS}\n") + +elseif (${RELEASE_ID} IN_LIST RHBasedOS) + set(CPACK_GENERATOR DEB) + # Excluding /usr/share/java top level directory due to conflict with javapackages-tools (openjdk dependency) + set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/share/java") + set(CPACK_RPM_PACKAGE_NAME "${CPACK_PACKAGE_NAME}") + set(CPACK_RPM_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}") + set(CPACK_RPM_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION}") + set(CPACK_RPM_PACKAGE_SECTION "${CPACK_PACKAGE_SECTION}") + set(CPACK_RPM_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME}) + set(CPACK_RPM_PACKAGE_PRIORITY extra) + set(CPACK_RPM_PACKAGE_DEPENDS "vpp (>= ${vpp_version}), vpp-plugins (>= ${vpp_version})") + + # Print CentOS package summary + message("\nRPM package:") + message(" Name: ${CPACK_RPM_PACKAGE_NAME}") + message(" Version: ${CPACK_RPM_PACKAGE_VERSION}") + message(" Description: ${CPACK_RPM_PACKAGE_DESCRIPTION}") + message(" File name: ${CPACK_RPM_PACKAGE_FILE_NAME}") + message(" Depends on: ${CPACK_RPM_PACKAGE_DEPENDS}\n") endif () - +if (PackZip) + list(APPEND CPACK_GENERATOR ZIP) +endif() +if (PackTgz) + list(APPEND CPACK_GENERATOR TGZ) +endif() +include(CPack) -- cgit 1.2.3-korg