From 7fb042d172465b4aa5885ac1b2caeb90bf88fc82 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Tue, 21 Apr 2015 16:08:11 -0700 Subject: [PATCH] kinetic-cpp-client: Add derivation --- .../kinetic-cpp-client/build-fix.patch | 224 ++++++++++++++++++ .../libraries/kinetic-cpp-client/default.nix | 59 +++++ pkgs/top-level/all-packages.nix | 2 + 3 files changed, 285 insertions(+) create mode 100644 pkgs/development/libraries/kinetic-cpp-client/build-fix.patch create mode 100644 pkgs/development/libraries/kinetic-cpp-client/default.nix diff --git a/pkgs/development/libraries/kinetic-cpp-client/build-fix.patch b/pkgs/development/libraries/kinetic-cpp-client/build-fix.patch new file mode 100644 index 000000000000..49edbf63a546 --- /dev/null +++ b/pkgs/development/libraries/kinetic-cpp-client/build-fix.patch @@ -0,0 +1,224 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 8217cba..a6c1d70 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -32,7 +32,7 @@ else(APPLE) + endif(${BUILD_FOR_ARM}) + endif(APPLE) + +-set(CMAKE_CXX_FLAGS "--std=c++0x -Wall -Wextra -Werror -Wno-unknown-warning-option -Wno-unused-parameter -Wno-null-dereference -Wno-unused-local-typedefs -DGTEST_USE_OWN_TR1_TUPLE=1 ${BUILD_PIC_COMPILER_FLAGS}") ++set(CMAKE_CXX_FLAGS "--std=c++11 -DGTEST_USE_OWN_TR1_TUPLE=1 ${BUILD_PIC_COMPILER_FLAGS}") + + set(TEST_BINARY "kinetic_client_test") + set(TEST_BINARY_PATH ${kinetic_cpp_client_BINARY_DIR}/${TEST_BINARY}) +@@ -50,103 +50,16 @@ set(GENERATED_SOURCES_PATH ${kinetic_cpp_client_SOURCE_DIR}/src/main/generated) + set(PREFIX "${CMAKE_BINARY_DIR}/vendor") + set(EXTERNAL_PREFIX "${kinetic_cpp_client_BINARY_DIR}/vendor") + +-include(ExternalProject) +- +-set(KINETIC_PROTO_VERSION "3.0.0") +-set(KINETIC_PROTO_MD5 "85ca027b870811a297c1f6d792498934") +- +-ExternalProject_add( +- kinetic-proto +- PREFIX ${PREFIX} +- DOWNLOAD_COMMAND curl -L https://github.com/Seagate/kinetic-protocol/archive/${KINETIC_PROTO_VERSION}.tar.gz -o kinetic-proto.tar.gz && openssl md5 kinetic-proto.tar.gz | grep -q ${KINETIC_PROTO_MD5} && rm -rf kinetic-proto && mkdir -p kinetic-proto && tar -xz --strip-components 1 -C kinetic-proto -f kinetic-proto.tar.gz +- BUILD_IN_SOURCE 1 +- CONFIGURE_COMMAND "" +- BUILD_COMMAND "" +- INSTALL_COMMAND "" +-) +- +-ExternalProject_add( +- gflags +- PREFIX ${EXTERNAL_PREFIX} +- URL "${kinetic_cpp_client_SOURCE_DIR}/tarballs/gflags-2.0-no-svn-files.tar.gz" +- URL_MD5 "9084829124e02a7e6be0f0f824523423" +- CONFIGURE_COMMAND ../gflags/configure --prefix=${EXTERNAL_PREFIX} --enable-static ${CONFIG_HOST_FLAG} ${CHILD_MAKE_FLAGS} ${PIC_MAKE_FLAGS} +-) +- +-ExternalProject_add( +- glog +- PREFIX ${EXTERNAL_PREFIX} +- URL "${kinetic_cpp_client_SOURCE_DIR}/tarballs/glog-0.3.3.tar.gz" +- URL_MD5 "a6fd2c22f8996846e34c763422717c18" +- PATCH_COMMAND sh ${kinetic_cpp_client_SOURCE_DIR}/patches/apply-glog-patches.sh ${kinetic_cpp_client_SOURCE_DIR} +- CONFIGURE_COMMAND ../glog/configure --prefix=${EXTERNAL_PREFIX} --with-gflags=${EXTERNAL_PREFIX} --enable-static ${CONFIG_HOST_FLAG} ${CHILD_MAKE_FLAGS} ${PIC_MAKE_FLAGS} +- DEPENDS gflags +-) +- +-ExternalProject_add( +- gtest +- PREFIX ${EXTERNAL_PREFIX} +- URL "${kinetic_cpp_client_SOURCE_DIR}/tarballs/gtest-1.6.0.zip" +- URL_MD5 "4577b49f2973c90bf9ba69aa8166b786" +- BUILD_IN_SOURCE 1 +- CONFIGURE_COMMAND "" +- BUILD_COMMAND ${CMAKE_CXX_COMPILER} -DGTEST_USE_OWN_TR1_TUPLE=1 -I../gtest -I../gtest/include -c ../gtest/src/gtest-all.cc && ar -rv libgtest.a gtest-all.o && ranlib libgtest.a +- INSTALL_COMMAND "" +-) +- +-ExternalProject_add( +- gmock +- PREFIX ${EXTERNAL_PREFIX} +- URL "${kinetic_cpp_client_SOURCE_DIR}/tarballs/gmock-1.6.0.zip" +- URL_MD5 "f547f47321ca88d3965ca2efdcc2a3c1" +- BUILD_IN_SOURCE 1 +- CONFIGURE_COMMAND "" +- BUILD_COMMAND ${CMAKE_CXX_COMPILER} -DGTEST_USE_OWN_TR1_TUPLE=1 -I../gmock -I../gmock/include -I../gtest -I../gtest/include -c ../gmock/src/gmock-all.cc && ar -rv libgmock.a gmock-all.o && ranlib libgmock.a +- INSTALL_COMMAND "" +- DEPENDS gtest +-) +- +-ExternalProject_add( +- openssl +- PREFIX ${EXTERNAL_PREFIX} +- URL "${kinetic_cpp_client_SOURCE_DIR}/tarballs/openssl-1.0.1g.tar.gz" +- URL_MD5 "de62b43dfcd858e66a74bee1c834e959" +- BUILD_IN_SOURCE 1 +- CONFIGURE_COMMAND ${OPENSSL_CONFIGURE_COMMAND} --prefix=${EXTERNAL_PREFIX} ${BUILD_PIC_COMPILER_FLAG} +- BUILD_COMMAND touch apps/openssl && touch openssl.pc && make ${CHILD_MAKE_FLAGS} build_libs libssl.pc libcrypto.pc +- INSTALL_COMMAND make install_sw +-) +- +-# The protobuf build requires the existence of a protoc binary that can be +-# executed on the host machine. To handle cross compilation, we always build +-# protobuf once for the host so that we have a suitable copy of protoc. +-ExternalProject_add( +- protoc +- PREFIX ${EXTERNAL_PREFIX}/host +- URL "${kinetic_cpp_client_SOURCE_DIR}/tarballs/protobuf-2.5.0.tar.bz2" +- URL_MD5 "a72001a9067a4c2c4e0e836d0f92ece4" +- CONFIGURE_COMMAND ../protoc/configure --prefix=${EXTERNAL_PREFIX}/host --enable-static +-) +- + # Protobuf code generation rules +-set(PROTOC_PATH "${PREFIX}/host/bin/protoc") +-set(PROTO_DIR "${CMAKE_BINARY_DIR}/vendor/src/kinetic-proto") ++set(PROTOC_PATH "protoc") ++set(PROTO_DIR "${CMAKE_BINARY_DIR}/kinetic-proto") + set(PROTO_ORIG_PATH "${PROTO_DIR}/kinetic.proto") + set(PROTO_MODIFIED_PATH "${PROTO_DIR}/kinetic_client.proto") +-ExternalProject_add( +- protobuf +- PREFIX ${EXTERNAL_PREFIX} +- URL "${kinetic_cpp_client_SOURCE_DIR}/tarballs/protobuf-2.5.0.tar.bz2" +- URL_MD5 "a72001a9067a4c2c4e0e836d0f92ece4" +- CONFIGURE_COMMAND ../protobuf/configure --prefix=${EXTERNAL_PREFIX} --enable-static --with-protoc=${PROTOC_PATH} ${CONFIG_HOST_FLAG} ${CHILD_MAKE_FLAGS} ${PIC_MAKE_FLAGS} +- DEPENDS protoc +-) + + add_custom_command( + COMMENT "Compiling protobuf" + OUTPUT ${GENERATED_SOURCES_PATH}/kinetic_client.pb.h ${GENERATED_SOURCES_PATH}/kinetic_client.pb.cc + COMMAND mkdir -p ${GENERATED_SOURCES_PATH} && sed 's/com\\.seagate\\.kinetic\\.proto/com.seagate.kinetic.client.proto/' ${PROTO_ORIG_PATH} > ${PROTO_MODIFIED_PATH} && ${PROTOC_PATH} -I=${PROTO_DIR} --cpp_out=${GENERATED_SOURCES_PATH} ${PROTO_MODIFIED_PATH} +- DEPENDS kinetic-proto protoc protobuf + ) + set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${GENERATED_SOURCES_PATH}) + +@@ -157,21 +70,10 @@ include_directories( + + src/test/mock + src/test +- +- ${EXTERNAL_PREFIX}/include +- ${EXTERNAL_PREFIX}/src/gmock/include +- ${EXTERNAL_PREFIX}/src/gtest/include + ) + + set(LIBRARY_DEPENDENCIES + kinetic_client +- ${CMAKE_BINARY_DIR}/vendor/lib/libglog.a +- ${CMAKE_BINARY_DIR}/vendor/lib/libgflags.a +- ${CMAKE_BINARY_DIR}/vendor/lib/libssl.a +- ${CMAKE_BINARY_DIR}/vendor/lib/libcrypto.a +- ${CMAKE_BINARY_DIR}/vendor/lib/libprotobuf.a +- ${CMAKE_BINARY_DIR}/vendor/src/gtest/libgtest.a +- ${CMAKE_BINARY_DIR}/vendor/src/gmock/libgmock.a + ${CMAKE_THREAD_LIBS_INIT} + dl + ) +@@ -180,12 +82,68 @@ set(LIBRARY_DEPENDENCIES + # Otherwise glog uses the standard glibc unwinder and there is no dependency. + find_library(LIBUNWIND "unwind") + if(LIBUNWIND) +- set(LIBRARY_DEPENDENCIES +- ${LIBRARY_DEPENDENCIES} ++ set(LIBRARY_DEPENDENCIES ++ ${LIBRARY_DEPENDENCIES} + ${LIBUNWIND} + ) + endif() + ++find_library(LIBSSL "ssl") ++if(LIBSSL) ++ set(LIBRARY_DEPENDENCIES ++ ${LIBRARY_DEPENDENCIES} ++ ${LIBSSL} ++ ) ++endif() ++ ++find_library(LIBCRYPTO "crypto") ++if(LIBCRYPTO) ++ set(LIBRARY_DEPENDENCIES ++ ${LIBRARY_DEPENDENCIES} ++ ${LIBCRYPTO} ++ ) ++endif() ++ ++find_library(LIBPROTOBUF "protobuf") ++if(LIBPROTOBUF) ++ set(LIBRARY_DEPENDENCIES ++ ${LIBRARY_DEPENDENCIES} ++ ${LIBPROTOBUF} ++ ) ++endif() ++ ++find_library(LIBGLOG "glog") ++if(LIBGLOG) ++ set(LIBRARY_DEPENDENCIES ++ ${LIBRARY_DEPENDENCIES} ++ ${LIBGLOG} ++ ) ++endif() ++ ++find_library(LIBGFLAGS "gflags") ++if(LIBGFLAGS) ++ set(LIBRARY_DEPENDENCIES ++ ${LIBRARY_DEPENDENCIES} ++ ${LIBGFLAGS} ++ ) ++endif() ++ ++find_library(LIBGMOCK "gmock") ++if(LIBGMOCK) ++ set(LIBRARY_DEPENDENCIES ++ ${LIBRARY_DEPENDENCIES} ++ ${LIBGMOCK} ++ ) ++endif() ++ ++find_library(LIBGTEST "gtest") ++if(LIBGTEST) ++ set(LIBRARY_DEPENDENCIES ++ ${LIBRARY_DEPENDENCIES} ++ ${LIBGTEST} ++ ) ++endif() ++ + add_library(kinetic_client + src/main/generated/kinetic_client.pb.cc + src/main/hmac_provider.cc +diff --git a/src/test/kinetic_cpp_client_test.cc b/src/test/kinetic_cpp_client_test.cc +index 2079fab..c5004a2 100644 +--- a/src/test/kinetic_cpp_client_test.cc ++++ b/src/test/kinetic_cpp_client_test.cc +@@ -22,6 +22,7 @@ + + #include + ++#include "gflags/gflags.h" + #include "gtest/gtest.h" + #include "glog/logging.h" + diff --git a/pkgs/development/libraries/kinetic-cpp-client/default.nix b/pkgs/development/libraries/kinetic-cpp-client/default.nix new file mode 100644 index 000000000000..9a11c85bd763 --- /dev/null +++ b/pkgs/development/libraries/kinetic-cpp-client/default.nix @@ -0,0 +1,59 @@ +{ stdenv, fetchgit, fetchurl, cmake, protobuf, libunwind, openssl, glog +, google-gflags, gmock, gtest +}: + +let + protoTar = fetchurl { + url = "http://github.com/Seagate/kinetic-protocol/archive/3.0.0.tar.gz"; + sha256 = "0406pp0sdf0rg6s5g18r2d8si2rin7p6qbzp7c6pma5hyzsygz48"; + }; +in +stdenv.mkDerivation rec { + name = "kinetic-cpp-client-2015-04-14"; + + src = fetchgit { + url = "git://github.com/Seagate/kinetic-cpp-client.git"; + rev = "015085a5c89db0398f80923053f36b9e0611e107"; + sha256 = "15iwlfjwnyswiwssdjg6qiflhddh66nv07xji4yhz1s4vqhk3nrx"; + }; + + patches = [ ./build-fix.patch ]; + + postPatch = '' + mkdir -p build/kinetic-proto + tar -x --strip-components 1 -C build/kinetic-proto -f ${protoTar} + ''; + + nativeBuildInputs = [ cmake protobuf ]; + buildInputs = [ libunwind glog google-gflags gmock gtest ]; + + # The headers and library include from these and there is no provided pc file + propagatedBuildInputs = [ protobuf openssl ]; + + cmakeFlags = [ + "-DBUILD_SHARED_LIBS=true" + ]; + + preCheck = '' + # The checks cannot find libkinetic_client.so otherwise + export LD_LIBRARY_PATH="$(pwd)" + ''; + + installPhase = '' + # There is no included install script so do our best + mkdir -p $out/lib + cp libkinetic_client.so $out/lib + cp -r ../include $out + cp ../src/main/generated/kinetic_client.pb.h $out/include + ''; + + doCheck = true; + + meta = with stdenv.lib; { + homepage = https://github.com/Seagate/kinetic-cpp-client; + description = "code for producing C and C++ kinetic clients"; + license = licenses.lgpl21; + platforms = platforms.unix; + maintainers = with maintainers; [ wkennington ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1c4cf997968d..bdbc5e64f9c2 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6200,6 +6200,8 @@ let kf5_latest = kf57; kf5_stable = kf57; + kinetic-cpp-client = callPackage ../development/libraries/kinetic-cpp-client { }; + krb5 = callPackage ../development/libraries/kerberos/krb5.nix { openldap = openldap.override { cyrus_sasl = cyrus_sasl.override { kerberos = null; };