From 3af67cc66340644d04726d810f14a2476867749d Mon Sep 17 00:00:00 2001 From: Alex Zhang Date: Mon, 2 Sep 2019 17:18:11 -0700 Subject: [PATCH 1/2] Add preliminary support to build Debian packages with Cmake infrastructure. --- CMakeLists.txt | 14 ++++++++++++++ extra/install_dep.sh | 11 ++++++++++- extra/make_runnerdeb.sh | 22 ++++++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100755 extra/make_runnerdeb.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 21a4fe7a..37ebaf20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,17 @@ pkg_check_modules(KMOD REQUIRED libkmod) find_library(PTHREAD pthread) find_library(DL dl) +# Stuff for building the Debian package +set(CPACK_GENERATOR "DEB") +set(CPACK_DEB_COMPONENT_INSTALL ON) +set(CPACK_DEBIAN_PACKAGE_DEPENDS "libnl-3-200, libnl-genl-3-200") +set(CPACK_DEBIAN_PACKAGE_SECTION "net") +set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") +set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "A daemon that handles the userspace side of the LIO TCM-User backstore") +set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Target Devel ") +set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/open-iscsi/tcmu-runner") +include(CPack) + # Stuff for building the shared library add_library(tcmu SHARED @@ -202,6 +213,7 @@ endif (with-zbc) if (with-rbd) find_library(LIBRBD rbd) + set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, librados2, librbd1") # Stuff for building the rbd handler add_library(handler_rbd @@ -231,6 +243,7 @@ if (with-glfs) set(GFAPI_VERSION760 1) endif (GFAPI760_FOUND) + set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, glusterfs-common") # Stuff for building the glfs handler add_library(handler_glfs SHARED @@ -251,6 +264,7 @@ endif (with-glfs) if (with-qcow) find_package(ZLIB REQUIRED) + set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, zlib1g") # Stuff for building the qcow handler add_library(handler_qcow diff --git a/extra/install_dep.sh b/extra/install_dep.sh index e5326972..33e55e11 100755 --- a/extra/install_dep.sh +++ b/extra/install_dep.sh @@ -23,8 +23,17 @@ if [ y`uname`y = yLinuxy ]; then yum search librbd-devel | grep -q "N/S matched" && LIBRBD=librbd || LIBRBD=librbd1 $SUDO yum install -y $LIBRBD-devel ;; + ubuntu|debian) + # for generic + $SUDO apt-get install cmake make gcc libnl-3-dev libnl-genl-3-dev libglib2.0-dev zlib1g-dev libkmod-dev + + # for glusterfs + $SUDO apt-get install glusterfs-common + # for ceph + $SUDO apt-get install librados2 librados-dev + $SUDO apt-get install librbd1 librbd-dev *) - echo "TODO: only fedora/rhel/centos are supported for now!" + echo "TODO: only fedora/rhel/centos/ubuntu/debian are supported for now!" ;; esac else diff --git a/extra/make_runnerdeb.sh b/extra/make_runnerdeb.sh new file mode 100755 index 00000000..77f30815 --- /dev/null +++ b/extra/make_runnerdeb.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +if [ "$1" == "--help" -o "$1" == "help" ]; then + echo "" + echo " USAGE:" + echo "" + echo " # cd tcmu-runner/extra/" + echo " # ./make_runnerdeb.sh [-Dwith-=false]" + echo "" + echo " Will build the Debian package in top dir by using the HEAD commit ID as default." + echo "" + exit +fi + +TOPDIR=`pwd`/../ + +VERSION=`git describe --tags --match "v[0-9]*"` +VERSION=`echo $VERSION | sed "s/-/./g"` +VERSION=`echo $VERSION | sed "s/v//"` + +cmake $TOPDIR -DSUPPORT_SYSTEMD=ON -DCMAKE_INSTALL_PREFIX=/usr -DCPACK_DEBIAN_PACKAGE_VERSION=$VERSION "$@" +(cd $TOPDIR ; make package) From f6ede7ecf26369e49ed9e4682c41673a391e121e Mon Sep 17 00:00:00 2001 From: Alex Zhang Date: Mon, 2 Sep 2019 17:37:52 -0700 Subject: [PATCH 2/2] Use tab instead of spaces for indention. --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b0a22fc7..8431576d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -225,7 +225,7 @@ endif (with-zbc) if (with-rbd) find_library(LIBRBD rbd) - set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, librados2, librbd1") + set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, librados2, librbd1") # Stuff for building the rbd handler add_library(handler_rbd @@ -256,8 +256,8 @@ if (with-glfs) set(GFAPI_VERSION760 1) endif (GFAPI760_FOUND) - set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, glusterfs-common") - set(GFAPI_VERSION766 0) + set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, glusterfs-common") + set(GFAPI_VERSION766 0) pkg_check_modules(GFAPI766 glusterfs-api>=7.6.6 QUIET) if (GFAPI766_FOUND) @@ -285,7 +285,7 @@ endif (with-glfs) if (with-qcow) find_package(ZLIB REQUIRED) - set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, zlib1g") + set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, zlib1g") # Stuff for building the qcow handler add_library(handler_qcow