diff --git a/sdk/cpp/core/CMakeLists.txt b/sdk/cpp/core/CMakeLists.txt index c8a804c2e..b993a6050 100644 --- a/sdk/cpp/core/CMakeLists.txt +++ b/sdk/cpp/core/CMakeLists.txt @@ -2,9 +2,101 @@ cmake_minimum_required(VERSION 2.8.9) cmake_policy(SET CMP0048 NEW) project(ydk VERSION 0.5.4 LANGUAGES C CXX) - set(YDK_DESCRIPTION "YANG Development Kit Library. The library for YDK API.") +# CPack Dynamic Settings +set (CPACK_PACKAGE_NAME "libydk") +set (CPACK_PACKAGE_VERSION "${PROJECT_VERSION}") +set (CPACK_PACKAGE_RELEASE "1") +set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "YDK Core Library") +# set (CPACK_PACKAGE_DESCRIPTION_SUMMARY ${YDK_DESCRIPTION}) + +# CPack Static Settings +set (CPACK_PACKAGE_DESCRIPTION "An SDK that provides API's that are modeled in YANG. +The main goal of YDK is to reduce the learning curve of YANG data +models by expressing the model semantics in an API and abstracting +protocol/encoding details. YDK is composed of a core package that +defines services and providers, plus one or more module bundles that +are based on YANG models. Each module bundle is generated using a +bundle profile and the ydk-gen tool.") + +set (CPACK_PACKAGE_CONTACT "ydk-admin@cisco.com") +set (CPACK_PACKAGE_VENDOR "Cisco") +set (CPACK_PACKAGE_INSTALL_DIRECTORY "/usr/local") + +# MAC OS -- not working +if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + message("CMake System: MacOS") + # set(CPACK_GENERATOR "productbuild") + # set(CPACK_COMMAND_PKGBUILD "/usr/bin/pkgbuild") + +elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") + find_program(LSB_RELEASE lsb_release) + execute_process(COMMAND ${LSB_RELEASE} -is + OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + set (CMAKE_C_COMPILER "/usr/bin/clang") + set (CMAKE_CXX_COMPILER "/usr/bin/clang++") + + # Linux Debian + if (${LSB_RELEASE_ID_SHORT} MATCHES "Ubuntu") + message("CMake System: 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_ARCHITECTURE "amd64") + set (CPACK_DEBIAN_PACKAGE_DEPENDS + "libcurl4-openssl-dev, + libpcre3-dev, + libssh-dev, + libxml2-dev, + libxslt1-dev, + libtool-bin, + cmake (>=3), + git, + pkg-config") + set (CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT}) + set (CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) + set (CPACK_DEBIAN_PACKAGE_SECTION "devel") + set (CPACK_DEBIAN_PACKAGE_PRIORITY "optional") + set (CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/CiscoDevNet/ydk-cpp") + + # _-_.deb + # libydk_0.6.0-0.1.alpha_amd64.deb // Debian + set (CPACK_PACKAGE_FILE_NAME + "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}") + + # Linux Fedora + elseif(${LSB_RELEASE_ID_SHORT} MATCHES "CentOS") + message("CMake System: CentOS") + + set (CPACK_GENERATOR "RPM") + + set (CPACK_RPM_PACKAGE_NAME ${CPACK_PACKAGE_NAME}) + set (CPACK_RPM_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) + set (CPACK_RPM_PACKAGE_RELEASE ${CPACK_PACKAGE_RELEASE}) + set (CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") + set (CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) + set (CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION}) + + set (CPACK_RPM_PACKAGE_LICENSE "Apache 2.0") + set (CPACK_RPM_PACKAGE_GROUP "Development/Libraries") + set (CPACK_RPM_PACKAGE_VENDOR ${CPACK_PACKAGE_VENDOR}) + set (CPACK_RPM_PACKAGE_URL "https://github.com/CiscoDevNet/ydk-cpp") + set (CPACK_RPM_PACKAGE_REQUIRES "epel-release, python-pip, python-devel, libxml2-devel, libxslt-devel, libssh-devel, libcurl-devel, libtool, clang, cmake3, pcre-devel") + + # --..(src).rpm + # libydk-0.6.0-0.1.alpha.x86_64.rpm // RPM + set (CPACK_PACKAGE_FILE_NAME + "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CPACK_RPM_PACKAGE_ARCHITECTURE}") + endif() +endif() + +include(CPack) + # include custom Modules set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/") diff --git a/sdk/cpp/install/README.md b/sdk/cpp/install/README.md new file mode 100644 index 000000000..cb6de8913 --- /dev/null +++ b/sdk/cpp/install/README.md @@ -0,0 +1,32 @@ +# How to Package a YDK Library for RPM/Debian/MacOS +We can use the CPack module in CMake to produce packages based off os. +``` +$ cd project_dir/ydk-gen/sdk/cpp/core +$ mkdir build && cd build +$ cmake -DCMAKE_BUILD_TYPE=Release .. +$ make project +``` +That's all for RPM/Debian packages. Please see the following section for creating packages for Mac OS. + +## Mac OS +The CPack generators for producing a .pkg file for mac os are unreliable. Instead, we can use the pkgbuild tool included on Mac OS. + +Unzip the tarball produced by the previous steps and then execute the build command: +``` +$ tar -xvf tarball_name.tar.gz +$ pkgbuild --root tarball_name --identifier com.cisco.project_name --version project_version --install-location install_location package_name.pkg +``` + +For example, the following was how libydk was packaged for 0.5.4 release: +``` +$ tar -xvf libydk-0.5.4-Darwin.tar.gz +$ pkgbuild --root libydk-0.5.4-Darwin --identifier com.cisco.libydk --version 0.5.4 --install-location /usr/local libydk_0.5.4_Darwin.pkg +``` + +# Note +The following variables are hardcoded in the CMakeLists.txt file and may need to be modified depending on the desired package/bundle: +* CPACK_PACKAGE_NAME +* CPACK_PACKAGE_VERSION +* CPACK_PACKAGE_RELEASE +* CPACK_PACKAGE_DESCRIPTION_SUMMARY +* CPACK_PACKAGE_FILE_NAME diff --git a/sdk/cpp/install/centos/README.md b/sdk/cpp/install/centos/README.md index d7bdabb03..a60a601ca 100644 --- a/sdk/cpp/install/centos/README.md +++ b/sdk/cpp/install/centos/README.md @@ -30,23 +30,23 @@ $ wget https://github.com/CiscoDevNet/ydk-cpp/archive/0.5.4.tar.gz RPM package names follow a strict format: name-version-release.architecture.rpm Since the tarball will be unzipped and placed into the BUILD directory, we must sanitize the tarball such that its name and contents are consistent with the format name-version: ``` -$ tar -xvf 0.5.4.tar.gz -$ mv ydk-cpp-0.5.4 ydk.0.5.4 // note: 0.5.4.tar.gz unzips to ydk-cpp-0.5.4 -$ tar -cvf ydk.0.5.4.tar.gz ydk.0.5.4 -$ rm 0.5.4.tar.gz -$ rm -rf ydk.0.5.4 +$ tar -xvf 0.5.4.tar.gz // note: 0.5.4.tar.gz unzips to ydk-cpp-0.5.4 +$ mv ydk-cpp-0.5.4 ydk-0.5.4 // correct naming format to ydk-0.5.4 +$ tar -cvf ydk.0.5.4.tar.gz ydk-0.5.4 // repackage +$ rm 0.5.4.tar.gz // clean up +$ rm -rf ydk-0.5.4 ``` ## The Spec File The spec file is included. Simply move it to the SPEC directory: ``` -$ mv /path/to/ydk.spec ~/rpmbuild/SPEC/ydk.spec +$ mv /path/to/ydk.spec ~/rpmbuild/SPECS/ydk.spec ``` For more information on spec files, see [Fedora Project Docs: Spec Files](https://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch-specfiles.html) ## Build the RPM To build the binary, run: ``` -$ rpmbuild -bb ~/rpmbuild/SPEC/ydk.spec +$ rpmbuild -bb ~/rpmbuild/SPECS/ydk.spec ``` See more build options at [Fedora Project Docs: rpmbuild Command](https://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch08s02s04.html) diff --git a/sdk/cpp/install/ubuntu/README.md b/sdk/cpp/install/ubuntu/README.md index f673f4dc7..46e138858 100644 --- a/sdk/cpp/install/ubuntu/README.md +++ b/sdk/cpp/install/ubuntu/README.md @@ -1,4 +1,4 @@ -#Getting Set Up +# Getting Set Up http://packaging.ubuntu.com/html/getting-set-up.html Install basic packaging software @@ -76,7 +76,7 @@ export DEBFULLNAME="Bob Bacon (BB)" export DEBEMAIL="BBacon@cisco.com" ``` -#Packaging +# Packaging http://packaging.ubuntu.com/html/packaging-new-software.html Install build tools @@ -96,7 +96,7 @@ $ bzr dh-make ydk 0.5.2 ydk-0.5.2.tar.gz ``` Package type is l for library. Verify information is correct. This will create a directory `ydk`. In this, a few files under `ydk/debian` need to be customized. -##Customize Debian Files +## Customize Debian Files Remove the optional example files ``` @@ -149,7 +149,7 @@ Commit the code to your packaging branch $ bzr add debian/source/format $ bzr commit -m "Initial commit of Debian packaging." ``` -##Build Package +## Build Package Build Package ``` $ bzr builddeb -- -us -uc @@ -168,7 +168,7 @@ $ debuild -S -rfakeroot -k ``` Packages and source.changes are output to one directory above and thus outside the project. -##Confirm source (optional) +## Confirm source (optional) View Contents ``` @@ -205,7 +205,7 @@ Set up a PPA in Launchpad https://launchpad.net/~ ``` -##Upload Package +## Upload Package Upload PPA with dput ``` diff --git a/sdk/cpp/packages/CMakeLists.txt b/sdk/cpp/packages/CMakeLists.txt index ecd635f9a..16d497693 100644 --- a/sdk/cpp/packages/CMakeLists.txt +++ b/sdk/cpp/packages/CMakeLists.txt @@ -2,6 +2,100 @@ cmake_minimum_required(VERSION 2.8.9) cmake_policy(SET CMP0048 NEW) project(ydk_@BRIEF_NAME@ VERSION @VERSION@ LANGUAGES C CXX) +# CPack Dynamic Settings +set (CPACK_PACKAGE_NAME "libydk") +set (CPACK_PACKAGE_VERSION "${PROJECT_VERSION}") +set (CPACK_PACKAGE_RELEASE "1") +set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "YDK Core Library") +# set (CPACK_PACKAGE_DESCRIPTION_SUMMARY ${YDK_DESCRIPTION}) + +# CPack Static Settings +set (CPACK_PACKAGE_DESCRIPTION "An SDK that provides API's that are modeled in YANG. +The main goal of YDK is to reduce the learning curve of YANG data +models by expressing the model semantics in an API and abstracting +protocol/encoding details. YDK is composed of a core package that +defines services and providers, plus one or more module bundles that +are based on YANG models. Each module bundle is generated using a +bundle profile and the ydk-gen tool.") + +set (CPACK_PACKAGE_CONTACT "ydk-admin@cisco.com") +set (CPACK_PACKAGE_VENDOR "Cisco") +set (CPACK_PACKAGE_INSTALL_DIRECTORY "/usr/local") + +# MAC OS -- not working +if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + message("CMake System: MacOS") + # set(CPACK_GENERATOR "productbuild") + # set(CPACK_COMMAND_PKGBUILD "/usr/bin/pkgbuild") + +elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") + find_program(LSB_RELEASE lsb_release) + execute_process(COMMAND ${LSB_RELEASE} -is + OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + set (CMAKE_BUILD_TYPE "Release") + set (CMAKE_C_COMPILER "/usr/bin/clang") + set (CMAKE_CXX_COMPILER "/usr/bin/clang++") + + # Linux Debian + if (${LSB_RELEASE_ID_SHORT} MATCHES "Ubuntu") + message("CMake System: 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_ARCHITECTURE "amd64") + set (CPACK_DEBIAN_PACKAGE_DEPENDS + "libcurl4-openssl-dev, + libpcre3-dev, + libssh-dev, + libxml2-dev, + libxslt1-dev, + libtool-bin, + cmake (>=3), + git, + pkg-config") + set (CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT}) + set (CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) + set (CPACK_DEBIAN_PACKAGE_SECTION "devel") + set (CPACK_DEBIAN_PACKAGE_PRIORITY "optional") + set (CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/CiscoDevNet/ydk-cpp") + + # _-_.deb + # libydk_0.6.0-0.1.alpha_amd64.deb // Debian + set (CPACK_PACKAGE_FILE_NAME + "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}") + + # Linux Fedora + elseif(${LSB_RELEASE_ID_SHORT} MATCHES "CentOS") + message("CMake System: CentOS") + + set (CPACK_GENERATOR "RPM") + + set (CPACK_RPM_PACKAGE_NAME ${CPACK_PACKAGE_NAME}) + set (CPACK_RPM_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) + set (CPACK_RPM_PACKAGE_RELEASE ${CPACK_PACKAGE_RELEASE}) + set (CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") + set (CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) + set (CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION}) + + set (CPACK_RPM_PACKAGE_LICENSE "Apache 2.0") + set (CPACK_RPM_PACKAGE_GROUP "Development/Libraries") + set (CPACK_RPM_PACKAGE_VENDOR ${CPACK_PACKAGE_VENDOR}) + set (CPACK_RPM_PACKAGE_URL "https://github.com/CiscoDevNet/ydk-cpp") + set (CPACK_RPM_PACKAGE_REQUIRES "epel-release, python-pip, python-devel, libxml2-devel, libxslt-devel, libssh-devel, libcurl-devel, libtool, clang, cmake3, pcre-devel") + + # --..(src).rpm + # libydk-0.6.0-0.1.alpha.x86_64.rpm // RPM + set (CPACK_PACKAGE_FILE_NAME + "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CPACK_RPM_PACKAGE_ARCHITECTURE}") + endif() +endif() + +include(CPack) + # include custom Modules set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/")