diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2021-06-07 16:22:49 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2021-06-07 16:22:49 +0200 |
commit | 5954e46340c4851d40aecece4622f5082398ad66 (patch) | |
tree | 50f70792526ab0b3836c7358aafbcc26e660ac52 | |
parent | 54e0601fec5330aa93810c7212dde233c4354379 (diff) |
Build system cleanup / cosmetics.1.4
* libnDPI submodule update
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | .travis.yml | 4 | ||||
-rw-r--r-- | CMakeLists.txt | 26 | ||||
m--------- | libnDPI | 0 | ||||
-rw-r--r-- | nDPIsrvd.c | 4 | ||||
-rwxr-xr-x | scripts/daemon.sh (renamed from daemon.sh) | 4 | ||||
-rwxr-xr-x | scripts/get-and-build-libndpi.sh | 23 |
7 files changed, 40 insertions, 24 deletions
diff --git a/.gitignore b/.gitignore index 83d073eb9..42c18c116 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ __pycache__ # go related *.sum + +# lockfiles generated by some shell scripts +*.lock diff --git a/.travis.yml b/.travis.yml index fd43b0a91..824c2ddf0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,5 +14,5 @@ script: - ./build/nDPId-test || test $? -eq 1 - ./build/nDPId -h || test $? -eq 1 # dameon start/stop test -- ./daemon.sh ./build/nDPId ./build/nDPIsrvd -- ./daemon.sh ./build/nDPId ./build/nDPIsrvd +- ./scripts/daemon.sh ./build/nDPId ./build/nDPIsrvd +- ./scripts/daemon.sh ./build/nDPId ./build/nDPIsrvd diff --git a/CMakeLists.txt b/CMakeLists.txt index 955ea017a..6753b2277 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,21 +3,6 @@ project(nDPId C) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) find_package(PkgConfig REQUIRED) -function(initialize_submodule DIRECTORY) - if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${DIRECTORY}/.git) - find_package(Git QUIET REQUIRED) - message(STATUS "${CMAKE_CURRENT_SOURCE_DIR}/${DIRECTORY}/.git does not exist. " - "Initializing ${DIRECTORY} submodule ...") - execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init ${DIRECTORY} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - RESULT_VARIABLE GIT_EXIT_CODE) - if(NOT GIT_EXIT_CODE EQUAL "0") - message(FATAL_ERROR "${GIT_EXECUTABLE} submodule update --init ${DIRECTORY} " - "failed with exit code ${GIT_EXIT_CODE}, please checkout submodules") - endif() - endif() -endfunction(initialize_submodule) - option(ENABLE_SANITIZER "Enable ASAN/LSAN/UBSAN." OFF) option(ENABLE_SANITIZER_THREAD "Enable TSAN (does not work together with ASAN)." OFF) option(ENABLE_MEMORY_PROFILING "Enable dynamic memory tracking." OFF) @@ -73,17 +58,20 @@ if(ENABLE_SANITIZER_THREAD) endif() if(STATIC_LIBNDPI_INSTALLDIR STREQUAL "" AND BUILD_NDPI) - initialize_submodule(libnDPI) include(ExternalProject) ExternalProject_Add( libnDPI SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libnDPI - CONFIGURE_COMMAND env CC=${CMAKE_C_COMPILER} CFLAGS=${CMAKE_C_FLAGS} LDFLAGS=${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/libnDPI/autogen.sh - --prefix=${CMAKE_CURRENT_BINARY_DIR}/libnDPI - --with-only-libndpi + CONFIGURE_COMMAND env CC=${CMAKE_C_COMPILER} CFLAGS=${CMAKE_C_FLAGS} LDFLAGS=${CMAKE_EXE_LINKER_FLAGS} + MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} DEST_INSTALL=${CMAKE_BINARY_DIR}/libnDPI + ${CMAKE_CURRENT_SOURCE_DIR}/scripts/get-and-build-libndpi.sh BUILD_COMMAND make BUILD_IN_SOURCE 1) + add_custom_target(clean-libnDPI + COMMAND rm -rf ${CMAKE_BINARY_DIR}/libnDPI ${CMAKE_BINARY_DIR}/libnDPI-prefix + ) + set(STATIC_LIBNDPI_INSTALLDIR "${CMAKE_BINARY_DIR}/libnDPI") add_dependencies(nDPId libnDPI) add_dependencies(nDPId-test libnDPI) diff --git a/libnDPI b/libnDPI -Subproject c4084ca3c7b3657659aff624158a9c4f5710f57 +Subproject 2af7b33de07fac404b2efb6d6b3189664a21d50 diff --git a/nDPIsrvd.c b/nDPIsrvd.c index 7e5f80a9e..d16768ed9 100644 --- a/nDPIsrvd.c +++ b/nDPIsrvd.c @@ -905,6 +905,10 @@ int main(int argc, char ** argv) signal(SIGPIPE, SIG_IGN); + signal(SIGINT, SIG_IGN); + signal(SIGTERM, SIG_IGN); + signal(SIGQUIT, SIG_IGN); + epollfd = setup_event_queue(); if (epollfd < 0) { diff --git a/daemon.sh b/scripts/daemon.sh index af062a702..86e4d5aea 100755 --- a/daemon.sh +++ b/scripts/daemon.sh @@ -29,8 +29,6 @@ if [ -r "/tmp/nDPId-${NSUFFIX}.pid" -o -r "/tmp/nDPIsrvd-${NSUFFIX}.pid" ]; then printf '%s\n' "${2} not started .." >&2 fi - sudo rm -f "/tmp/nDPId-${NSUFFIX}.pid" - rm -f "/tmp/nDPIsrvd-${NSUFFIX}.pid" printf '%s\n' "daemons stopped" >&2 else set -x @@ -40,5 +38,5 @@ else sudo ${1} -p "/tmp/nDPId-${NSUFFIX}.pid" -c "/tmp/nDPIsrvd-${NSUFFIX}-collector.sock" -d -u "${NUSER}" set +x printf '%s\n' "daemons started" >&2 - printf '%s\n' "You may now run examples e.g.: ./examples/py-flow-info/flow-info.py --unix /tmp/nDPIsrvd-${NSUFFIX}-distributor.sock" + printf '%s\n' "You may now run examples e.g.: $(realpath --relative-to="$(pwd)" $(dirname "${0}")/../examples/py-flow-info/flow-info.py) --unix /tmp/nDPIsrvd-${NSUFFIX}-distributor.sock" fi diff --git a/scripts/get-and-build-libndpi.sh b/scripts/get-and-build-libndpi.sh new file mode 100755 index 000000000..df0ab2b2c --- /dev/null +++ b/scripts/get-and-build-libndpi.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -e +set -x + +LOCKFILE="$(realpath "${0}").lock" +touch "${LOCKFILE}" +exec 42< "${LOCKFILE}" +flock -x -n 42 || { + printf '%s\n' "Could not aquire file lock for ${0}. Already running instance?" >&2; + exit 1; +} + +cd "$(dirname "${0}")/.." +git submodule update --init ./libnDPI + +cd ./libnDPI +DEST_INSTALL="${DEST_INSTALL:-$(realpath ./install)}" +MAKE_PROGRAM="${MAKE_PROGRAM:-make -j4}" +./autogen.sh --prefix="${DEST_INSTALL}" --with-only-libndpi +${MAKE_PROGRAM} install + +rm -f "${LOCKFILE}" |