From bd8fea4fe5760902a2b1e4bff25fe47a2f1063b5 Mon Sep 17 00:00:00 2001 From: Brenden Blanco Date: Tue, 25 Aug 2015 23:14:25 -0700 Subject: [PATCH] Add proper debian build support The cmake based build system is nice, but not quite production ready. Move to the more painful but featureful debuild style. This is one step towards an upstreamable package. Rename libbpfprog (ugh) to libbcc. Split out python-bpf and libbcc-examples into separate packages that depend on libbcc. Signed-off-by: Brenden Blanco --- CMakeLists.txt | 14 -------------- Dockerfile.ubuntu | 11 ++++++----- FAQ.txt | 4 ++-- debian/changelog | 5 +++++ debian/compat | 1 + debian/control | 24 ++++++++++++++++++++++++ debian/copyright | 7 +++++++ debian/docs | 3 +++ debian/libbcc-examples.install | 1 + debian/libbcc.install | 3 +++ debian/python-bpf.install | 2 ++ debian/rules | 8 ++++++++ debian/source/format | 1 + scripts/README.md | 4 ++-- src/cc/CMakeLists.txt | 22 ++++++++++++++-------- src/cc/{libbpfprog.pc.in => libbcc.pc.in} | 6 +++--- src/python/CMakeLists.txt | 3 ++- src/python/bpf/__init__.py | 2 +- 18 files changed, 85 insertions(+), 36 deletions(-) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/docs create mode 100644 debian/libbcc-examples.install create mode 100644 debian/libbcc.install create mode 100644 debian/python-bpf.install create mode 100755 debian/rules create mode 100644 debian/source/format rename src/cc/{libbpfprog.pc.in => libbcc.pc.in} (75%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1dc4280..664a649 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,17 +49,3 @@ add_subdirectory(scripts) add_subdirectory(examples) add_subdirectory(src) add_subdirectory(tests) - -set(CPACK_PACKAGE_NAME "libbcc") -set(CPACK_PACKAGE_VERSION "${REVISION}") -set(CPACK_PACKAGE_CONTACT "Brenden Blanco Mon, 06 Jul 2015 18:04:28 +0000 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..b94e0d4 --- /dev/null +++ b/debian/control @@ -0,0 +1,24 @@ +Source: bcc +Maintainer: Brenden Blanco +Section: misc +Priority: optional +Standards-Version: 3.9.5 +Build-Depends: debhelper (>= 9), cmake, libllvm3.8, llvm-3.8-dev, libclang-3.8-dev +Homepage: https://github.com/iovisor/bcc + +Package: libbcc +Architecture: amd64 +Depends: libc6, libstdc++6, make, gcc +Description: Shared Library for BPF Compiler Collection (BCC) + Shared Library for BPF Compiler Collection to control BPF programs + from userspace. + +Package: libbcc-examples +Architecture: any +Depends: libbcc +Description: Shared Library for BPF Compiler Collection (BCC) + +Package: python-bpf +Architecture: all +Depends: libbcc, python +Description: Python wrappers for BPF Compiler Collection (BCC) diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..f262737 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,7 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: bcc +Source: https://github.com/iovisor/bcc + +Files: * +Copyright: 2015 PLUMgrid, Inc. +License: Apache-2.0 diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..7d88104 --- /dev/null +++ b/debian/docs @@ -0,0 +1,3 @@ +FAQ.txt +LICENSE.txt +README.md diff --git a/debian/libbcc-examples.install b/debian/libbcc-examples.install new file mode 100644 index 0000000..94c7b5a --- /dev/null +++ b/debian/libbcc-examples.install @@ -0,0 +1 @@ +usr/share/bcc/examples/* diff --git a/debian/libbcc.install b/debian/libbcc.install new file mode 100644 index 0000000..7d20e9e --- /dev/null +++ b/debian/libbcc.install @@ -0,0 +1,3 @@ +usr/include/bcc/* +usr/lib/libbcc* /usr/lib/x86_64-linux-gnu/ +usr/share/bcc/include/* diff --git a/debian/python-bpf.install b/debian/python-bpf.install new file mode 100644 index 0000000..552050d --- /dev/null +++ b/debian/python-bpf.install @@ -0,0 +1,2 @@ +usr/lib/python* +usr/bin/bpf-run diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..941a8fa --- /dev/null +++ b/debian/rules @@ -0,0 +1,8 @@ +#!/usr/bin/make -f +# -*- makefile -*- + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +%: + dh $@ --buildsystem=cmake --parallel diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/scripts/README.md b/scripts/README.md index fbcc2ce..8dd200e 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -50,8 +50,8 @@ Reconnect and run the final step, building and testing bcc. [root@bpf-demo ~]# bcc-setup Cloning into 'bcc'... ... -Linking CXX shared library libbpfprog.so -[100%] Built target bpfprog +Linking CXX shared library libcc.so +[100%] Built target bcc ... Running tests... Test project /root/bcc/build diff --git a/src/cc/CMakeLists.txt b/src/cc/CMakeLists.txt index 24ef907..4be7784 100644 --- a/src/cc/CMakeLists.txt +++ b/src/cc/CMakeLists.txt @@ -11,7 +11,7 @@ include_directories(${LLVM_INCLUDE_DIRS}) # todo: if check for kernel version include_directories(${CMAKE_CURRENT_SOURCE_DIR}/compat) add_definitions(${LLVM_DEFINITIONS}) -configure_file(libbpfprog.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libbpfprog.pc @ONLY) +configure_file(libbcc.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libbcc.pc @ONLY) # prune unused llvm static library stuff when linking into the new .so set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--exclude-libs=ALL") @@ -29,7 +29,8 @@ endif() # tell the shared library where it is being installed so it can find shared header files set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBCC_INSTALL_PREFIX='\"${CMAKE_INSTALL_PREFIX}\"'") -add_library(bpfprog SHARED bpf_common.cc bpf_module.cc libbpf.c) +add_library(bcc SHARED bpf_common.cc bpf_module.cc libbpf.c) +set_target_properties(bcc PROPERTIES VERSION ${REVISION} SOVERSION 0) # BPF is still experimental otherwise it should be available #llvm_map_components_to_libnames(llvm_libs bpf mcjit irreader passes) @@ -41,14 +42,19 @@ set(clang_libs ${libclangFrontend} ${libclangSerialization} ${libclangDriver} ${ ${libclangAST} ${libclangLex} ${libclangBasic}) # Link against LLVM libraries -target_link_libraries(bpfprog b_frontend clang_frontend ${clang_libs} ${llvm_libs} LLVMBPFCodeGen) +target_link_libraries(bcc b_frontend clang_frontend ${clang_libs} ${llvm_libs} LLVMBPFCodeGen) -install(TARGETS bpfprog LIBRARY DESTINATION lib${LIBSUFFIX}) -install(DIRECTORY export/ DESTINATION share/bcc/include/bcc +install(TARGETS bcc LIBRARY COMPONENT libbcc + DESTINATION lib${LIBSUFFIX}) +install(DIRECTORY export/ COMPONENT libbcc + DESTINATION share/bcc/include/bcc FILES_MATCHING PATTERN "*.h") -install(FILES bpf_common.h ../libbpf.h DESTINATION include/bcc) -install(DIRECTORY compat/linux/ DESTINATION include/bcc/compat/linux +install(FILES bpf_common.h ../libbpf.h COMPONENT libbcc + DESTINATION include/bcc) +install(DIRECTORY compat/linux/ COMPONENT libbcc + DESTINATION include/bcc/compat/linux FILES_MATCHING PATTERN "*.h") -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libbpfprog.pc DESTINATION lib${LIBSUFFIX}/pkgconfig) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libbcc.pc COMPONENT libbcc + DESTINATION lib${LIBSUFFIX}/pkgconfig) add_subdirectory(frontends) diff --git a/src/cc/libbpfprog.pc.in b/src/cc/libbcc.pc.in similarity index 75% rename from src/cc/libbpfprog.pc.in rename to src/cc/libbcc.pc.in index 8ccdee1..69b28c1 100644 --- a/src/cc/libbpfprog.pc.in +++ b/src/cc/libbcc.pc.in @@ -6,9 +6,9 @@ datarootdir=${prefix}/share compatdir=${includedir}/bcc/compat -Name: libbpfprog +Name: libbcc Version: @REVISION@ -Description: BPF Program library +Description: BCC Program library Requires: -Libs: -L${libdir} -lbpfprog +Libs: -L${libdir} -lbcc Cflags: -I${includedir} -I${compatdir} diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index d0ef831..0e04764 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -22,4 +22,5 @@ if(EXISTS "/etc/debian_version") set(PYTHON_FLAGS "${PYTHON_FLAGS} --install-layout deb") endif() install(CODE "execute_process(COMMAND python setup.py install -f ${PYTHON_FLAGS} - --prefix=${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})") + --prefix=${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})" + COMPONENT python) diff --git a/src/python/bpf/__init__.py b/src/python/bpf/__init__.py index 032e09c..28bd1db 100644 --- a/src/python/bpf/__init__.py +++ b/src/python/bpf/__init__.py @@ -23,7 +23,7 @@ from subprocess import Popen, PIPE import sys basestring = (unicode if sys.version_info[0] < 3 else str) -lib = ct.CDLL("libbpfprog.so") +lib = ct.CDLL("libbcc.so") # keep in sync with bpf_common.h lib.bpf_module_create_b.restype = ct.c_void_p -- 2.7.4