Skip to content

Commit

Permalink
Add CI dependencies and fix build issues
Browse files Browse the repository at this point in the history
Signed-off-by: Tin Švagelj <[email protected]>
  • Loading branch information
Caellian committed May 1, 2024
1 parent bffecae commit 1ae4580
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 67 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-and-test-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ jobs:
libimlib2-dev \
libircclient-dev \
libiw-dev \
libnl-3-dev\
libnl-route-3-dev\
liblua5.3-dev \
libmicrohttpd-dev \
libmysqlclient-dev \
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ jobs:
libimlib2-dev \
libircclient-dev \
libiw-dev \
libnl-3-dev\
libnl-route-3-dev\
liblua5.3-dev \
libmicrohttpd-dev \
libmysqlclient-dev \
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publish-appimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ jobs:
libimlib2-dev \
libircclient-dev \
libiw-dev \
libnl-3-dev\
libnl-route-3-dev\
liblua5.3-dev \
libmicrohttpd-dev \
libmysqlclient-dev \
Expand Down
5 changes: 4 additions & 1 deletion cmake/ConkyPlatformChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,10 @@ if(BUILD_WLAN AND OS_LINUX)

if(NOT NL_FOUND)
message(FATAL_ERROR "Unable to find netlink library")
endif(NOT NL_FOUND)
endif()
if(NOT HAVE_LIBNL_ROUTE)
message(FATAL_ERROR "Unable to find netlink route library")
endif()

set(conky_includes ${conky_includes} ${NL_INCLUDE_DIRS})
set(conky_libs ${conky_libs} ${NL_LIBRARIES})
Expand Down
101 changes: 40 additions & 61 deletions cmake/FindNL.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Source: https://github.com/wireshark/wireshark/blob/master/cmake/modules/FindNL.cmake
#
# Find the native netlink includes and library
#
# If they exist, differentiate between versions 1, 2 and 3.
Expand All @@ -12,6 +10,11 @@
# NL_LIBRARIES - List of libraries when using libnl.
# NL_FOUND - True if libnl found.

# Based on wireshark FindNL:
# https://github.com/wireshark/wireshark/blob/master/cmake/modules/FindNL.cmake
# Modified so it doesn't make any hard requirements for libraries used by the
# project.

if(NL_LIBRARIES AND NL_INCLUDE_DIRS)
# in cache already
SET(NL_FOUND TRUE)
Expand All @@ -27,6 +30,9 @@ else()
pkg_check_modules(NL3 libnl-3.0 libnl-genl-3.0 libnl-route-3.0)
if(NOT NL3_FOUND)
pkg_search_module(NL2 libnl-2.0)
if (NL2_FOUND)
mark_as_advanced(NL2_INCLUDE_DIR NL2_LIBRARY)
endif()
endif()

# Try to find NL 2.0, 3.0 or 3.1 (/usr/include/netlink/version.h) or
Expand All @@ -38,11 +44,12 @@ else()
NAMES
netlink/version.h
HINTS
"${NL3_libnl-3.0_INCLUDEDIR}"
"${NL2_INCLUDEDIR}"
"${NL3_libnl-3.0_includeDIR}"
"${NL2_includeDIR}"
PATHS
$(SEARCHPATHS)
)

# NL version >= 2
if(NL3_INCLUDE_DIR)
find_library(NL3_LIBRARY
Expand All @@ -56,6 +63,16 @@ else()
PATHS
$(SEARCHPATHS)
)

if(NL3_LIBRARY)
set(NL_LIBRARIES ${NL_LIBRARIES} ${NL3_LIBRARY})
set(NL_INCLUDE_DIRS ${NL_INCLUDE_DIRS} ${NL3_INCLUDE_DIR})
set(HAVE_LIBNL 1)
mark_as_advanced(NL3_LIBRARY HAVE_LIBNL)
else()

endif()

find_library(NLGENL_LIBRARY
NAMES
nl-genl-3 nl-genl
Expand All @@ -67,6 +84,13 @@ else()
PATHS
$(SEARCHPATHS)
)

if(NLGENL_LIBRARY)
mark_as_advanced(NLGENL_LIBRARY)
set(NL_LIBRARIES ${NL_LIBRARIES} ${NLGENL_LIBRARY})
set(HAVE_LIBNL_GENL 1)
endif()

find_library(NLROUTE_LIBRARY
NAMES
nl-route-3 nl-route
Expand All @@ -78,67 +102,22 @@ else()
PATHS
$(SEARCHPATHS)
)
#
# If we don't have all of those libraries, we can't use libnl.
#
if(NL3_LIBRARY AND NLGENL_LIBRARY AND NLROUTE_LIBRARY)
set(NL_LIBRARY ${NL3_LIBRARY})
if(NL3_INCLUDE_DIR)
# NL2 and NL3 are similar and just affect how the version is reported in
# the --version output. In cast of doubt, assume NL3 since a library
# without version number could be any of 2.0, 3.0 or 3.1.
if(NOT NL3_FOUND AND NL2_FOUND)
set(HAVE_LIBNL2 1)
else()
set(HAVE_LIBNL3 1)
endif()
endif()

if(NLROUTE_LIBRARY)
mark_as_advanced(NLROUTE_LIBRARY)
set(NL_LIBRARIES ${NL_LIBRARIES} ${NLROUTE_LIBRARY})
set(HAVE_LIBNL_ROUTE 1)
endif()
set(NL_INCLUDE_DIR ${NL3_INCLUDE_DIR})
endif()

# libnl-2 and libnl-3 not found, try NL version 1
if(NOT (NL_LIBRARY AND NL_INCLUDE_DIR))
pkg_search_module(NL1 libnl-1)
find_path(NL1_INCLUDE_DIR
NAMES
netlink/netlink.h
HINTS
"${NL1_INCLUDEDIR}"
PATHS
$(SEARCHPATHS)
)
find_library(NL1_LIBRARY
NAMES
nl
PATH_SUFFIXES
lib64 lib
HINTS
"${NL1_LIBDIR}"
PATHS
$(SEARCHPATHS)
)
set(NL_LIBRARY ${NL1_LIBRARY})
set(NL_INCLUDE_DIR ${NL1_INCLUDE_DIR})
if(NL1_LIBRARY AND NL1_INCLUDE_DIR)
set(HAVE_LIBNL1 1)
if(NOT NL3_FOUND AND NL2_FOUND)
set(HAVE_LIBNL2 1)
else()
set(HAVE_LIBNL3 1)
endif()
endif()
endif()
# MESSAGE(STATUS "LIB Found: ${NL_LIBRARY}, Suffix: ${NLSUFFIX}\n 1:${HAVE_LIBNL1}, 2:${HAVE_LIBNL2}, 3:${HAVE_LIBNL3}.")

# handle the QUIETLY and REQUIRED arguments and set NL_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(NL DEFAULT_MSG NL_LIBRARY NL_INCLUDE_DIR)

IF(NL_FOUND)
set(NL_LIBRARIES ${NLGENL_LIBRARY} ${NLROUTE_LIBRARY} ${NL_LIBRARY})
set(NL_INCLUDE_DIRS ${NL_INCLUDE_DIR})
set(HAVE_LIBNL 1)
else()
set(NL_LIBRARIES )
set(NL_INCLUDE_DIRS)
endif()
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(NL DEFAULT_MSG NL_LIBRARIES NL_INCLUDE_DIRS)
mark_as_advanced(NL_LIBRARIES NL_INCLUDE_DIRS)

MARK_AS_ADVANCED( NL_LIBRARIES NL_INCLUDE_DIRS )
10 changes: 5 additions & 5 deletions src/linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@
#endif

#ifdef BUILD_WLAN
#include <libnl3/netlink/attr.h>
#include <libnl3/netlink/cache.h>
#include <libnl3/netlink/route/link.h>
#include <netlink/attr.h>
#include <netlink/cache.h>
#include <netlink/route/link.h>
#include <uapi/linux/nl80211.h>
#endif

Expand Down Expand Up @@ -644,7 +644,7 @@ void update_net_interfaces(FILE *net_dev_fp, bool is_first_update,
}
nl_link = nullptr;
}
if (nl_link == nullptr) { nl_index == -1; }
if (nl_link == nullptr) { nl_index = -1; }
}
if (nl_link != nullptr) {
// See: http://www.infradead.org/~tgr/libnl/doc/route.html#link_object
Expand Down Expand Up @@ -680,7 +680,7 @@ void update_net_interfaces(FILE *net_dev_fp, bool is_first_update,
ns->freq[0]
*/

auto modes = rtnl_link_get_flags(struct rtnl_link * link);
auto modes = rtnl_link_get_flags(nl_link);
rtnl_link_flags2str(modes, ns->mode, 64);
}

Expand Down

0 comments on commit 1ae4580

Please sign in to comment.