From 9533e4b92a925a4c392a65a4a60c87d10acb3e24 Mon Sep 17 00:00:00 2001 From: Sergey Yakubov <sergey.yakubov@desy.de> Date: Tue, 8 Dec 2020 14:30:47 +0100 Subject: [PATCH] build python rpm packages --- CMakeLists.txt | 1 - consumer/api/cpp/CMakeLists.txt | 15 +++++++- consumer/api/cpp/CPackConfig.cmake | 0 consumer/api/cpp/consumer.spec.in | 38 +++++++++++++++++++ .../python/source_dist_linux/CMakeLists.txt | 8 ++++ .../api/python/source_dist_linux/setup.py.in | 3 +- deploy/build_env/Centos7.7/Dockerfile | 31 --------------- deploy/build_env/Centos7.7/build.sh | 13 ------- deploy/build_env/Centos7.7/build_image.sh | 3 -- deploy/build_env/centos/Dockerfile.7.9.2009 | 21 ++++++++++ deploy/build_env/centos/build.sh | 11 ++++++ deploy/build_env/centos/build_image.sh | 2 + .../{Centos7.7 => centos}/install_cmake.sh | 0 .../{Centos7.7 => centos}/install_curl.sh | 0 deploy/build_env/centos/install_libfabric.sh | 12 ++++++ 15 files changed, 108 insertions(+), 50 deletions(-) create mode 100644 consumer/api/cpp/CPackConfig.cmake create mode 100644 consumer/api/cpp/consumer.spec.in delete mode 100644 deploy/build_env/Centos7.7/Dockerfile delete mode 100755 deploy/build_env/Centos7.7/build.sh delete mode 100755 deploy/build_env/Centos7.7/build_image.sh create mode 100644 deploy/build_env/centos/Dockerfile.7.9.2009 create mode 100755 deploy/build_env/centos/build.sh create mode 100755 deploy/build_env/centos/build_image.sh rename deploy/build_env/{Centos7.7 => centos}/install_cmake.sh (100%) rename deploy/build_env/{Centos7.7 => centos}/install_curl.sh (100%) create mode 100755 deploy/build_env/centos/install_libfabric.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 0277a0231..b0491fe45 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,6 @@ ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "GNU") SET(BUILD_SHARED_LIBS OFF) ENDIF(WIN32) - #TODO: Better way then GLOBAL PROPERTY IF(WIN32) find_package(Threads REQUIRED) diff --git a/consumer/api/cpp/CMakeLists.txt b/consumer/api/cpp/CMakeLists.txt index ae5ce7be2..49b92eeb6 100644 --- a/consumer/api/cpp/CMakeLists.txt +++ b/consumer/api/cpp/CMakeLists.txt @@ -42,6 +42,19 @@ set(TEST_LIBRARIES "${TARGET_NAME}") gtest(${TARGET_NAME} "${TEST_SOURCE_FILES}" "${TEST_LIBRARIES}") -install(TARGETS ${TARGET_NAME} DESTINATION lib) +set(CPACK_PACKAGE_VERSION ${ASAPO_VERSION}) +set(CPACK_GENERATOR "RPM") +set(CPACK_PACKAGE_NAME "asapo_consumer") +set(CPACK_PACKAGE_RELEASE 1) +set(CPACK_PACKAGE_CONTACT "IT") +set(CPACK_PACKAGE_VENDOR "DESY") +set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) +set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}") +include(CPack) + +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/consumer.spec.in" "${CMAKE_CURRENT_BINARY_DIR}/consumer.spec" @ONLY IMMEDIATE) +set(CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_CURRENT_BINARY_DIR}/my_project.spec") + +install(TARGETS ${TARGET_NAME} DESTINATION lib) install(DIRECTORY include/ DESTINATION include) diff --git a/consumer/api/cpp/CPackConfig.cmake b/consumer/api/cpp/CPackConfig.cmake new file mode 100644 index 000000000..e69de29bb diff --git a/consumer/api/cpp/consumer.spec.in b/consumer/api/cpp/consumer.spec.in new file mode 100644 index 000000000..7f0cd6d10 --- /dev/null +++ b/consumer/api/cpp/consumer.spec.in @@ -0,0 +1,38 @@ +Buildroot: @CMAKE_CURRENT_BINARY_DIR@/_CPack_Packages/Linux/RPM/@CPACK_PACKAGE_FILE_NAME@ +Summary: Asapo Consumer +Name: @CPACK_PACKAGE_NAME@ +Version: @CPACK_PACKAGE_VERSION@ +Release: @CPACK_PACKAGE_RELEASE@ +License: MIT +Group: Development/Tools/Other +Vendor: @CPACK_PACKAGE_VENDOR@ +Prefix: @CPACK_PACKAGING_INSTALL_PREFIX@ +#Requires: opencv >= 2.4 + +%define _rpmdir @CMAKE_CURRENT_BINARY_DIR@/_CPack_Packages/Linux/RPM +%define _rpmfilename @CPACK_PACKAGE_FILE_NAME@.rpm +%define _unpackaged_files_terminate_build 0 +%define _topdir @CMAKE_CURRENT_BINARY_DIR@/_CPack_Packages/Linux/RPM + +%description +Cool project solving the problems of many colleagues. + +# This is a shortcutted spec file generated by CMake RPM generator +# we skip _install step because CPack does that for us. +# We do only save CPack installed tree in _prepr +# and then restore it in build. +%prep +mv $RPM_BUILD_ROOT @CMAKE_CURRENT_BINARY_DIR@/_CPack_Packages/Linux/RPM/tmpBBroot + +%install +if [ -e $RPM_BUILD_ROOT ]; +then + rm -Rf $RPM_BUILD_ROOT +fi +mv "@CMAKE_CURRENT_BINARY_DIR@/_CPack_Packages/Linux/RPM/tmpBBroot" $RPM_BUILD_ROOT + +%files +%defattr(-,root,root,-) +@CPACK_PACKAGING_INSTALL_PREFIX@/@LIB_INSTALL_DIR@/* +@CPACK_PACKAGING_INSTALL_PREFIX@/bin/my_project + diff --git a/consumer/api/python/source_dist_linux/CMakeLists.txt b/consumer/api/python/source_dist_linux/CMakeLists.txt index cc3b1dc5e..ba4a4fd83 100644 --- a/consumer/api/python/source_dist_linux/CMakeLists.txt +++ b/consumer/api/python/source_dist_linux/CMakeLists.txt @@ -6,6 +6,14 @@ ADD_CUSTOM_TARGET(python-dist ALL COMMAND ${Python_EXECUTABLE} setup.py sdist ) +ADD_CUSTOM_TARGET(python-rpm + COMMAND PACKAGE_PREFIX=python- python setup.py bdist_rpm + ) + +ADD_CUSTOM_TARGET(python3-rpm + COMMAND PACKAGE_PREFIX=python3- python3 setup.py bdist_rpm + ) + #get_property(ASAPO_CONSUMER_LIB TARGET asapo-consumer PROPERTY LOCATION) ADD_CUSTOM_TARGET(copy_python_dist ALL diff --git a/consumer/api/python/source_dist_linux/setup.py.in b/consumer/api/python/source_dist_linux/setup.py.in index 2fcefc2e0..7e0ac6048 100644 --- a/consumer/api/python/source_dist_linux/setup.py.in +++ b/consumer/api/python/source_dist_linux/setup.py.in @@ -1,6 +1,7 @@ from distutils.core import setup from distutils.core import Extension import numpy +import os # TODO 'lib/libcurl.a' seems to have no effect, because there is a libcurl.so file ext_modules = [ @@ -13,7 +14,7 @@ ext_modules = [ ] setup( - name ="asapo_consumer", + name = os.environ.get('PACKAGE_PREFIX', '') + "asapo_consumer", ext_modules = ext_modules, version = "@PYTHON_ASAPO_VERSION@", setup_requires=["numpy>=@NUMPY_VERSION@", "cython>=0.28"], diff --git a/deploy/build_env/Centos7.7/Dockerfile b/deploy/build_env/Centos7.7/Dockerfile deleted file mode 100644 index fee61a4d1..000000000 --- a/deploy/build_env/Centos7.7/Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -from centos:7 - -ENV GOPATH /tmp - -RUN yum update -y && yum install -y cmake g++ golang zlib1g-dev python cython python-numpy python3 cython3 python3-numpy git wget - -RUN yum -y install gcc - -RUN yum -y install epel-release make - -ADD install_curl.sh install_curl.sh -RUN ./install_curl.sh /curl - -RUN yum install -y python-pip python3-pip && pip install --upgrade cython && pip3 install --upgrade cython -RUN pip3 install sphinx - -ADD build.sh /bin/build.sh - -RUN yum -y install gcc-c++ - -ADD install_cmake.sh install_cmake.sh -RUN ./install_cmake.sh - -RUN yum -y install zlib-devel - -RUN yum -y install python3-numpy python-numpy - -RUN yum -y install numpy - -RUN yum -y install python-devel python36-devel -RUN yum -y install glibc-static libstdc++-static \ No newline at end of file diff --git a/deploy/build_env/Centos7.7/build.sh b/deploy/build_env/Centos7.7/build.sh deleted file mode 100755 index b902e0e67..000000000 --- a/deploy/build_env/Centos7.7/build.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -cd /asapo/build -cmake \ - -DCMAKE_BUILD_TYPE="Release" \ - -DLIBCURL_DIR=/curl \ - -DBUILD_PYTHON_DOCS=ON \ - -DBUILD_EVENT_MONITOR_PRODUCER=ON \ - .. -cd consumer && make -cd ../producer && make -cd ../sphinx && make - diff --git a/deploy/build_env/Centos7.7/build_image.sh b/deploy/build_env/Centos7.7/build_image.sh deleted file mode 100755 index f158b9098..000000000 --- a/deploy/build_env/Centos7.7/build_image.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -docker build -t yakser/asapo-env:centos7.7 . -#docker push yakser/asapo-env:ubuntu16.04 diff --git a/deploy/build_env/centos/Dockerfile.7.9.2009 b/deploy/build_env/centos/Dockerfile.7.9.2009 new file mode 100644 index 000000000..2903c19a5 --- /dev/null +++ b/deploy/build_env/centos/Dockerfile.7.9.2009 @@ -0,0 +1,21 @@ +from centos:7.9.2009 + +RUN yum update -y && yum install -y epel-release make g++ python python3 git wget rpm-build +RUN yum -y install gcc gcc-c++ glibc-static libstdc++-static zlib-devel libcurl-devel python-pip python3-pip python-devel python3-devel numpy python3-numpy +RUN pip install --upgrade pip +RUN pip install cython +RUN pip3 install cython + +ADD install_cmake.sh install_cmake.sh +RUN ./install_cmake.sh + +ADD install_curl.sh install_curl.sh +RUN ./install_curl.sh /curl + +RUN yum -y install autoconf libtool libibverbs librdmacm librdmacm-devel + +ADD install_libfabric.sh install_libfabric.sh +RUN ./install_libfabric.sh + +ENV GOPATH /tmp +ADD build.sh /bin/build.sh \ No newline at end of file diff --git a/deploy/build_env/centos/build.sh b/deploy/build_env/centos/build.sh new file mode 100755 index 000000000..662e4888d --- /dev/null +++ b/deploy/build_env/centos/build.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +cd /asapo/build +cmake \ + -DCMAKE_BUILD_TYPE="Release" \ + -DLIBCURL_DIR=/curl \ + .. +cd consumer && make && make python-rpm && make python3-rpm +cd ../producer && make && make python-rpm && make python3-rpm + + diff --git a/deploy/build_env/centos/build_image.sh b/deploy/build_env/centos/build_image.sh new file mode 100755 index 000000000..407078a61 --- /dev/null +++ b/deploy/build_env/centos/build_image.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +docker build -t yakser/asapo-env:centos7.9.2009 -f Dockerfile.7.9.2009 . diff --git a/deploy/build_env/Centos7.7/install_cmake.sh b/deploy/build_env/centos/install_cmake.sh similarity index 100% rename from deploy/build_env/Centos7.7/install_cmake.sh rename to deploy/build_env/centos/install_cmake.sh diff --git a/deploy/build_env/Centos7.7/install_curl.sh b/deploy/build_env/centos/install_curl.sh similarity index 100% rename from deploy/build_env/Centos7.7/install_curl.sh rename to deploy/build_env/centos/install_curl.sh diff --git a/deploy/build_env/centos/install_libfabric.sh b/deploy/build_env/centos/install_libfabric.sh new file mode 100755 index 000000000..e6970a094 --- /dev/null +++ b/deploy/build_env/centos/install_libfabric.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +wget https://github.com/ofiwg/libfabric/archive/v1.11.0.tar.gz +tar xzf v1.11.0.tar.gz +cd libfabric-1.11.0 +./autogen.sh +./configure +make +make install +cd - +rm -rf libfabric-1.11.0 +rm v1.11.0.tar.gz -- GitLab