From: Noa Osherovich <noaos@xxxxxxxxxxxx> Update packaging files and cbuild dependencies to allow pyverbs to be included in Debian-based distributions. Signed-off-by: Noa Osherovich <noaos@xxxxxxxxxxxx> Signed-off-by: Alaa Hleihel <alaa@xxxxxxxxxxxx> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> --- README.md | 2 +- buildlib/cbuild | 20 +++++++++++---- debian/control | 10 +++++++- debian/python3-pyverbs.install | 1 + debian/rules | 45 ++++++++++++++++++++++++---------- 5 files changed, 58 insertions(+), 20 deletions(-) create mode 100644 debian/python3-pyverbs.install diff --git a/README.md b/README.md index f7ea6030..9b78c78a 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ only load from the system path. ### Debian Derived ```sh -$ apt-get install build-essential cmake gcc libudev-dev libnl-3-dev libnl-route-3-dev ninja-build pkg-config valgrind +$ apt-get install build-essential cmake gcc libudev-dev libnl-3-dev libnl-route-3-dev ninja-build pkg-config valgrind python3-dev cython3 ``` ### Fedora diff --git a/buildlib/cbuild b/buildlib/cbuild index 43450332..9f06a39f 100755 --- a/buildlib/cbuild +++ b/buildlib/cbuild @@ -74,11 +74,12 @@ class DockerFile(object): class Environment(object): pandoc = True; - python_cmd = "python"; + python_cmd = "python3"; aliases = set(); use_make = False; proxy = True; build_pyverbs = False; + cmake_args = []; def image_name(self): return "build-%s/%s"%(project,self.name); @@ -178,7 +179,6 @@ class trusty(APTEnvironment): 'ninja-build', 'pandoc', 'pkg-config', - 'python', 'valgrind', }; pkgs = common_pkgs | { @@ -186,12 +186,14 @@ class trusty(APTEnvironment): 'libsystemd-id128-dev', 'libsystemd-journal-dev', }; + cmake_args = ["-DNO_PYVERBS=1"]; + python_cmd = "python"; name = "ubuntu-14.04"; aliases = {"trusty"}; class xenial(APTEnvironment): docker_parent = "ubuntu:16.04" - pkgs = trusty.common_pkgs | {"libsystemd-dev"}; + pkgs = trusty.common_pkgs | {"libsystemd-dev", "python3-dev", "cython3"}; name = "ubuntu-16.04"; aliases = {"xenial"}; @@ -205,6 +207,8 @@ class jessie(APTEnvironment): docker_parent = "debian:8" pkgs = xenial.pkgs; name = "debian-8"; + cmake_args = ["-DNO_PYVERBS=1"]; + python_cmd = "python" aliases = {"jessie"}; class stretch(APTEnvironment): @@ -623,6 +627,10 @@ def run_deb_build(args,env): "-e","DEB_BUILD_OPTIONS=parallel=%u"%(multiprocessing.cpu_count()), ]; + if env.cmake_args: + opts.append("-e"); + opts.append("EXTRA_CMAKE_FLAGS=%s"%(' '.join(env.cmake_args))); + # Create a go.py that will let us run the compilation as the user and # then switch to root only for the packaging step. with open(os.path.join(tmpdir,"go.py"),"w") as F: @@ -644,7 +652,7 @@ subprocess.check_call(["debian/rules","debian/rules","binary"]); if args.run_shell: opts.append("/bin/bash"); else: - opts.extend(["python",os.path.join(home,"go.py")]); + opts.extend(["python3",os.path.join(home,"go.py")]); docker_cmd(args,*opts); @@ -789,6 +797,9 @@ def cmd_make(args): dirs.append(BUILD_r); cmake_args = [] + if env.cmake_args: + cmake_args.extend(env.cmake_args); + cmake_envs = [] ninja_args = [] for I in args.ARGS: @@ -798,7 +809,6 @@ def cmd_make(args): cmake_envs.append(I); else: ninja_args.append(I); - if env.use_make: need_cmake = not os.path.exists(os.path.join(BUILD_r,"Makefile")); else: diff --git a/debian/control b/debian/control index 92888f9a..6b8e466b 100644 --- a/debian/control +++ b/debian/control @@ -15,7 +15,8 @@ Build-Depends: cmake (>= 2.8.11), ninja-build, pandoc, pkg-config, - python, + python3-dev, + cython3, valgrind [amd64 arm64 armhf i386 mips mips64el mipsel powerpc ppc64 ppc64el s390x] Standards-Version: 4.2.1 Vcs-Git: https://github.com/linux-rdma/rdma-core.git @@ -324,3 +325,10 @@ Description: Tools for Infiniband attached storage (SRP) In conjunction with the kernel ib_srp driver, srptools allows you to discover and use Infiniband attached storage devices which use the SCSI RDMA Protocol (SRP). + +Package: python3-pyverbs +Architecture: linux-any +Depends: rdma-core (>= 21), + ${python3:Depends} +Description: Pyverbs is a python bindings for rdma-core. + It allows an easy development in python language of RDMA applications. diff --git a/debian/python3-pyverbs.install b/debian/python3-pyverbs.install new file mode 100644 index 00000000..20130d8a --- /dev/null +++ b/debian/python3-pyverbs.install @@ -0,0 +1 @@ +usr/lib/python3/dist-packages/pyverbs diff --git a/debian/rules b/debian/rules index 5ca94e88..62cc569a 100755 --- a/debian/rules +++ b/debian/rules @@ -7,7 +7,7 @@ export DEB_BUILD_MAINT_OPTIONS=hardening=+all COHERENT_DMA_ARCHS = amd64 arm64 i386 ia64 powerpc powerpcspe ppc64 ppc64el s390x sparc64 x32 %: - dh $@ --with systemd --builddirectory=build-deb + dh $@ --with python3,systemd --builddirectory=build-deb override_dh_auto_clean: dh_auto_clean @@ -22,19 +22,28 @@ override_dh_auto_clean: # # Upstream encourages the use of Ninja to build the source, convince dh to use # it until someone writes native support for dh+cmake+ninja. +DH_AUTO_CONFIGURE := "--" \ + "-GNinja" \ + "-DDISTRO_FLAVOUR=Debian" \ + "-DCMAKE_BUILD_TYPE=Release" \ + "-DCMAKE_INSTALL_SYSCONFDIR:PATH=/etc" \ + "-DCMAKE_INSTALL_SYSTEMD_SERVICEDIR:PATH=/lib/systemd/system" \ + "-DCMAKE_INSTALL_INITDDIR:PATH=/etc/init.d" \ + "-DCMAKE_INSTALL_LIBEXECDIR:PATH=/usr/lib" \ + "-DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=/var/lib" \ + "-DCMAKE_INSTALL_RUNDIR:PATH=/run" \ + "-DCMAKE_INSTALL_UDEV_RULESDIR:PATH=/lib/udev/rules.d" \ + "-DENABLE_STATIC=1" \ + $(EXTRA_CMAKE_FLAGS) + override_dh_auto_configure: - dh_auto_configure -- -GNinja \ - -DDISTRO_FLAVOUR=Debian \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_SYSCONFDIR:PATH=/etc \ - -DCMAKE_INSTALL_SYSTEMD_SERVICEDIR:PATH=/lib/systemd/system \ - -DCMAKE_INSTALL_INITDDIR:PATH=/etc/init.d \ - -DCMAKE_INSTALL_LIBEXECDIR:PATH=/usr/lib \ - -DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=/var/lib \ - -DCMAKE_INSTALL_RUNDIR:PATH=/run \ - -DCMAKE_INSTALL_UDEV_RULESDIR:PATH=/lib/udev/rules.d \ - -DENABLE_STATIC=1 \ - $(EXTRA_CMAKE_FLAGS) +ifeq ($(EXTRA_CMAKE_FLAGS), -DNO_PYVERBS=1) + dh_auto_configure $(DH_AUTO_CONFIGURE) +else + dh_auto_configure $(DH_AUTO_CONFIGURE) \ + -DPYTHON_EXECUTABLE:PATH=/usr/bin/python3 \ + -DCMAKE_INSTALL_PYTHON_ARCH_LIB:PATH=/usr/lib/python3/dist-packages +endif override_dh_auto_build: ninja -C build-deb -v @@ -57,6 +66,9 @@ INST_EXCLUDE := "etc/init.d/srpd" \ "etc/init.d/ibacm" \ "usr/sbin/run_srp_daemon" \ "usr/sbin/srp_daemon.sh" +ifeq ($(EXTRA_CMAKE_FLAGS), -DNO_PYVERBS=1) + INST_EXCLUDE := $(INST_EXCLUDE) "usr/lib/python3/dist-packages/pyverbs" +endif INST_EXCLUDE := $(addprefix -X,$(INST_EXCLUDE)) override_dh_install: dh_install --fail-missing $(INST_EXCLUDE) @@ -86,6 +98,13 @@ override_dh_strip: dh_strip -plibrdmacm1 --dbg-package=librdmacm1-dbg dh_strip --remaining-packages +override_dh_builddeb: +ifeq ($(EXTRA_CMAKE_FLAGS), -DNO_PYVERBS=1) + dh_builddeb -Npython3-pyverbs --remaining-packages +else + dh_builddeb --remaining-package +endif + # Upstream encourages the use of 'build' as the developer build output # directory, allow that directory to be present and still allow dh to work. .PHONY: build -- 2.19.1