Skip to content

Commit

Permalink
[libpcap] Update to 1.10.5, cleanup (#41453)
Browse files Browse the repository at this point in the history
  • Loading branch information
dg0yt authored Oct 11, 2024
1 parent 748125e commit 99685fa
Show file tree
Hide file tree
Showing 12 changed files with 131 additions and 117 deletions.
29 changes: 0 additions & 29 deletions ports/libpcap/add-disable-packet-option.patch

This file was deleted.

37 changes: 0 additions & 37 deletions ports/libpcap/install-pc-on-msvc.patch

This file was deleted.

53 changes: 53 additions & 0 deletions ports/libpcap/install.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9012ef4..88179b0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -798,6 +798,7 @@ if(WIN32)
cmake_pop_check_state()
if(LIBWS2_32_HAS_GETADDRINFO)
set(PCAP_LINK_LIBRARIES ws2_32 ${PCAP_LINK_LIBRARIES})
+ set(LIBS "-lws2_32 ${LIBS}")
else(LIBWS2_32_HAS_GETADDRINFO)
message(FATAL_ERROR "getaddrinfo is required, but wasn't found")
endif(LIBWS2_32_HAS_GETADDRINFO)
@@ -3405,7 +3406,8 @@ set(MANMISC_EXPAND
)

if(BUILD_SHARED_LIBS)
- set(LIBRARIES_TO_INSTALL "${LIBRARY_NAME}" "${LIBRARY_NAME_STATIC}")
+ set(LIBRARIES_TO_INSTALL "${LIBRARY_NAME}")
+ set_target_properties(${LIBRARY_NAME_STATIC} PROPERTIES EXCLUDE_FROM_ALL 1)
else(BUILD_SHARED_LIBS)
set(LIBRARIES_TO_INSTALL "${LIBRARY_NAME_STATIC}")
endif(BUILD_SHARED_LIBS)
@@ -3416,7 +3418,7 @@ if(WIN32 OR CYGWIN OR MSYS)
# the target is Windows; would there ever be a case where
# CYGWIN or MSYS are set but WIN32 *isn't* set?
#
- if(MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8)
+ if(0)
#
# Install 64-bit code built with MSVC in the x64 subdirectories,
# as that's where it expects it to be.
@@ -3463,7 +3465,10 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pcap-namedb.h DESTINATION ${CMAKE_INST

# On UN*X, and on Windows when not using MSVC, generate libpcap.pc and
# pcap-config and process man pages and arrange that they be installed.
-if(NOT MSVC)
+if(1)
+ if(MSVC AND NOT BUILD_SHARED_LIBS)
+ string(APPEND PACKAGE_NAME "_static")
+ endif()
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix "\${prefix}")
set(includedir "\${prefix}/include")
@@ -3533,8 +3538,8 @@ if(NOT MSVC)
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pcap-config.in ${CMAKE_CURRENT_BINARY_DIR}/pcap-config @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpcap.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libpcap.pc @ONLY)
- install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/pcap-config DESTINATION bin)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpcap.pc DESTINATION lib/pkgconfig)
+elseif(0)

#
# Man pages.
15 changes: 15 additions & 0 deletions ports/libpcap/mingw-dynamic-libname.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 88179b0..51a2732 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3222,10 +3222,6 @@ if(WIN32)
# For compatibility, build the shared library without the "lib" prefix on
# MinGW as well.
#
- set_target_properties(${LIBRARY_NAME} PROPERTIES
- PREFIX ""
- OUTPUT_NAME "${LIBRARY_NAME}"
- )
set_target_properties(${LIBRARY_NAME}_static PROPERTIES
OUTPUT_NAME "${LIBRARY_NAME}"
)
75 changes: 30 additions & 45 deletions ports/libpcap/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,80 +2,65 @@ if(EXISTS "${CURRENT_INSTALLED_DIR}/share/winpcap")
message(FATAL_ERROR "FATAL ERROR: winpcap and libpcap are incompatible.")
endif()

if(VCPKG_TARGET_IS_LINUX)
message(
"libpcap currently requires the following libraries from the system package manager:
flex
libbison-dev
These can be installed on Ubuntu systems via sudo apt install flex libbison-dev"
)
endif()

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO the-tcpdump-group/libpcap
REF "libpcap-${VERSION}"
SHA512 7352ff4d5bded916c0802e4a846fcb6b26e3ea8025dbbf58543abd9d9f6e8f7f5d60e03bcadb222d20434b7e052f663a560d7487af4b81fba74cf5aea040d733
SHA512 bb8ba3a589425d71531312285a3c7ded4abdff5ea157b88195e06a2b4f8c93b4db0bca122e9ac853cff14cd16e9519dca30b6bdf0311e7749038fdce57325726
HEAD_REF master
PATCHES
install-pc-on-msvc.patch
add-disable-packet-option.patch
PATCHES
install.diff
mingw-dynamic-libname.diff
)

vcpkg_find_acquire_program(BISON)
get_filename_component(BISON_PATH ${BISON} DIRECTORY)
vcpkg_add_to_path(${BISON_PATH})
vcpkg_find_acquire_program(FLEX)
get_filename_component(FLEX_PATH ${FLEX} DIRECTORY)
vcpkg_add_to_path(${FLEX_PATH})

string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" USE_STATIC_RT)

SET(options "")
if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_CMAKE_CONFIGURE_OPTIONS MATCHES "Packet_ROOT")
list(APPEND options "-DPCAP_TYPE=null")
message(STATUS [[Attention:

This build does not include packet capture capabilities.
In order to enable such capabilities, install the Npcap SDK or the WinPcap SDK,
and pass '-DPacket_ROOT=<path of SDK>' via VCPKG_CMAKE_CONFIGURE_OPTIONS
in a custom triplet file.
]])
endif()

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
DISABLE_PARALLEL_CONFIGURE
OPTIONS
-DDISABLE_NETMAP=ON
${options}
-DBUILD_WITH_LIBNL=OFF
-DDISABLE_AIRPCAP=ON
-DDISABLE_BLUETOOTH=ON
-DDISABLE_DAG=ON
-DDISABLE_DBUS=ON
-DDISABLE_DPDK=ON
-DDISABLE_NETMAP=ON
-DDISABLE_RDMA=ON
-DDISABLE_DAG=ON
-DDISABLE_SEPTEL=ON
-DDISABLE_SNF=ON
-DDISABLE_TC=ON
-DDISABLE_PACKET=ON
-DENABLE_REMOTE=OFF
"-DLEX_EXECUTABLE=${FLEX}"
"-DYACC_EXECUTABLE=${BISON}"
-DUSE_STATIC_RT=${USE_STATIC_RT}
MAYBE_UNUSED_VARIABLES
BUILD_WITH_LIBNL # linux only
CMAKE_DISABLE_FIND_PACKAGE_Packet # windows only
)

vcpkg_cmake_install()
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")

# On Windows 64-bit, libpcap 1.10.1 installs the libraries in a x64 subdirectory of the usual directories
if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
set(libsubdir "x64")
file(GLOB_RECURSE FILES_TO_MOVE "${CURRENT_PACKAGES_DIR}/lib/${libsubdir}/*")
file(COPY ${FILES_TO_MOVE} DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
file(GLOB_RECURSE FILES_TO_MOVE "${CURRENT_PACKAGES_DIR}/debug/lib/${libsubdir}/*")
file(COPY ${FILES_TO_MOVE} DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib")
file(GLOB_RECURSE FILES_TO_MOVE "${CURRENT_PACKAGES_DIR}/bin/${libsubdir}/*")
file(COPY ${FILES_TO_MOVE} DESTINATION "${CURRENT_PACKAGES_DIR}/bin")
file(GLOB_RECURSE FILES_TO_MOVE "${CURRENT_PACKAGES_DIR}/debug/bin/${libsubdir}/*")
file(COPY ${FILES_TO_MOVE} DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib/${libsubdir}"
"${CURRENT_PACKAGES_DIR}/debug/lib/${libsubdir}"
"${CURRENT_PACKAGES_DIR}/bin/${libsubdir}"
"${CURRENT_PACKAGES_DIR}/debug/bin/${libsubdir}")
endif()

# Even if compiled with BUILD_SHARED_LIBS=ON, pcap also install a pcap_static library
if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/pcap_static.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/pcap_static.lib")
endif()

vcpkg_fixup_pkgconfig()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share")
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
endif()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share" "${CURRENT_PACKAGES_DIR}/share/man")

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
3 changes: 1 addition & 2 deletions ports/libpcap/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "libpcap",
"version-semver": "1.10.4",
"port-version": 1,
"version-semver": "1.10.5",
"description": "A portable C/C++ library for network traffic capture",
"homepage": "https://www.tcpdump.org/",
"license": "BSD-3-Clause",
Expand Down
14 changes: 14 additions & 0 deletions ports/nmap/pcap_socket.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/nse_nsock.cc b/nse_nsock.cc
index 7cbfcd2..cf9d5db 100644
--- a/nse_nsock.cc
+++ b/nse_nsock.cc
@@ -29,6 +29,9 @@

#define DEFAULT_TIMEOUT 30000

+#ifdef PCAP_SOCKET
+# undef PCAP_SOCKET
+#endif
/* Upvalues for library variables */
enum {
NSOCK_POOL = lua_upvalueindex(1),
4 changes: 4 additions & 0 deletions ports/nmap/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ else()
vcpkg_extract_source_archive(source_path_release
ARCHIVE "${ARCHIVE}"
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel"
PATCHES
pcap_socket.diff
)

vcpkg_execute_required_process(
Expand All @@ -84,6 +86,8 @@ else()
vcpkg_extract_source_archive(source_path_debug
ARCHIVE "${ARCHIVE}"
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel"
PATCHES
pcap_socket.diff
)

vcpkg_execute_required_process(
Expand Down
2 changes: 1 addition & 1 deletion ports/nmap/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nmap",
"version": "7.70",
"port-version": 11,
"port-version": 12,
"description": "A library for scanning network ports.",
"dependencies": [
{
Expand Down
6 changes: 3 additions & 3 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -4909,8 +4909,8 @@
"port-version": 5
},
"libpcap": {
"baseline": "1.10.4",
"port-version": 1
"baseline": "1.10.5",
"port-version": 0
},
"libpff": {
"baseline": "2021-11-14",
Expand Down Expand Up @@ -6322,7 +6322,7 @@
},
"nmap": {
"baseline": "7.70",
"port-version": 11
"port-version": 12
},
"nmslib": {
"baseline": "2.1.1",
Expand Down
5 changes: 5 additions & 0 deletions versions/l-/libpcap.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "bb54ee6890b51e54614371d548053020585027ea",
"version-semver": "1.10.5",
"port-version": 0
},
{
"git-tree": "7bfda50e586151e14fb6704ed154e8747bc64ea9",
"version-semver": "1.10.4",
Expand Down
5 changes: 5 additions & 0 deletions versions/n-/nmap.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "b4b897cddcd9c1849f9181b400599aa7b93be5bd",
"version": "7.70",
"port-version": 12
},
{
"git-tree": "d96fe27573cd4c06549f6a711e54f0f26a1c4485",
"version": "7.70",
Expand Down

0 comments on commit 99685fa

Please sign in to comment.