Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPack Update #466

Merged
merged 2 commits into from
Jun 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 93 additions & 1 deletion sdk/cpp/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 "[email protected]")
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")

# <foo>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.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")

# <name>-<version>-<release>.<architecture>.(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/")

Expand Down
32 changes: 32 additions & 0 deletions sdk/cpp/install/README.md
Original file line number Diff line number Diff line change
@@ -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
14 changes: 7 additions & 7 deletions sdk/cpp/install/centos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
12 changes: 6 additions & 6 deletions sdk/cpp/install/ubuntu/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Getting Set Up
# Getting Set Up
<a href="http://packaging.ubuntu.com/html/getting-set-up.html">http://packaging.ubuntu.com/html/getting-set-up.html</a>

Install basic packaging software
Expand Down Expand Up @@ -76,7 +76,7 @@ export DEBFULLNAME="Bob Bacon (BB)"
export DEBEMAIL="[email protected]"
```

#Packaging
# Packaging
<a href="http://packaging.ubuntu.com/html/packaging-new-software.html">http://packaging.ubuntu.com/html/packaging-new-software.html</a>

Install build tools
Expand All @@ -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
```
Expand Down Expand Up @@ -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
Expand All @@ -168,7 +168,7 @@ $ debuild -S -rfakeroot -k<key-id>
```
Packages and source.changes are output to one directory above and thus outside the project.

##Confirm source (optional)
## Confirm source (optional)

View Contents
```
Expand Down Expand Up @@ -205,7 +205,7 @@ Set up a PPA in Launchpad
https://launchpad.net/~<LP USERNAME>
```

##Upload Package
## Upload Package

Upload PPA with dput
```
Expand Down
94 changes: 94 additions & 0 deletions sdk/cpp/packages/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 "[email protected]")
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")

# <foo>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.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")

# <name>-<version>-<release>.<architecture>.(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/")

Expand Down