[net-snmp] Add new port#52688
Conversation
|
@microsoft-github-policy-service agree |
| "version": "5.9.5.2", | ||
| "description": "A SNMP application library, tools and daemon", | ||
| "homepage": "https://www.net-snmp.org/", | ||
| "license": "BSD-4-Clause", |
There was a problem hiding this comment.
BSD-4-Clause doesn't look right here: none of the 14 parts in upstream's COPYING carry the BSD advertising clause. They break down as HPND (Part 1, CMU/UCD), MIT (Part 10, Lennart Poettering) and BSD-3-Clause (all the others), so something like BSD-3-Clause AND HPND AND MIT would be accurate. (SPDX used to have a dedicated Net-SNMP identifier for this stack, but it is deprecated since license list 3.25.0 in favor of an expression of the constituent licenses.)
| "supports": "windows & !mingw & !uwp", | ||
| "dependencies": [ | ||
| { | ||
| "name": "vcpkg-cmake", |
There was a problem hiding this comment.
This dependency is unused: the portfile only uses vcpkg_build_nmake and never calls vcpkg_cmake_configure/vcpkg_cmake_install, so vcpkg-cmake can be removed.
| vcpkg_replace_string( | ||
| "${TARGET_DIR}/include/net-snmp/net-snmp-config.h" | ||
| "#define INSTALL_BASE \"${TARGET_DIR}\"" | ||
| "#define INSTALL_BASE \"/../../\"" |
There was a problem hiding this comment.
"/../../" is not a resolvable path, so anything reading INSTALL_BASE at runtime gets a bogus value. If the intent is just to silence the absolute-path post-build check, a short comment explaining that would help future maintainers.
| file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" | ||
| DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") | ||
|
|
||
| vcpkg_fixup_pkgconfig() No newline at end of file |
There was a problem hiding this comment.
The win32 nmake build doesn't install any .pc files, so vcpkg_fixup_pkgconfig() is a no-op here and can be dropped. Also missing a trailing newline at EOF.
| @@ -0,0 +1,21 @@ | |||
| net-snmp provides the SNMP client/manager library and tools, and (with the | |||
There was a problem hiding this comment.
Usage files are conventionally just a short "how to consume" snippet (see e.g. ports/libuv/usage for a port without a CMake config). The installed-layout listing and the advice about system packages on other platforms (apt/Homebrew) could be dropped.
Updated usage instructions for integrating net-snmp with CMake, specifying how to link the library and include directories.
ricardoofnl
left a comment
There was a problem hiding this comment.
Thanks for addressing the earlier comments, the license expression, the removed vcpkg-cmake dependency, the trimmed usage file and the INSTALL_BASE comment all look good now. One new blocker inline: the two patch files referenced by the portfile are not part of the PR, which is why every Windows job in the latest CI run fails immediately.
|
|
||
| vcpkg_find_acquire_program(PERL) | ||
| get_filename_component(PERL_PATH "${PERL}" DIRECTORY) | ||
| vcpkg_add_to_path("${PERL_PATH}") |
There was a problem hiding this comment.
msvc-openssl-autolink.patch and no-system32-install.patch are referenced here but neither file is in the PR, so the build fails at patch time on every triplet (that is what the current CI failures are). Looks like they were not git add-ed. Remember that after adding them you also need to rerun ./vcpkg x-add-version --all since the git-tree changes.
The portfile references msvc-openssl-autolink.patch and no-system32-install.patch, but the files were never committed, so every build failed at source extraction with 'Could not find patch'. With them in place the port directory tree matches the git-tree already recorded in versions/n-/net-snmp.json. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014n2bVhar9Ab4mv1KcQdEYK
ricardoofnl
left a comment
There was a problem hiding this comment.
All points from my earlier reviews are resolved now, and CI is green across all 15 checks including the three static triplets that failed originally.
Worth highlighting for triage: msvc-openssl-autolink.patch fixes the actual root cause of those static failures. Upstream's win32/net-snmp/net-snmp-config.h.in auto-links OpenSSL via #pragma comment(lib, ...) and picks libcrypto_static.lib/libssl_static.lib when the CRT is static; those names come from the official OpenSSL Windows installers and never exist in vcpkg, which always ships libcrypto.lib/libssl.lib (that was the LNK1104 on x64-windows-static). The patch also adds crypt32.lib, which static OpenSSL needs for its CAPI/winstore code (that was the LNK2019 __imp_CertOpenStore on x64-windows-static-md). And no-system32-install.patch removing the upstream copy of DLLs/PDBs into %SYSTEMROOT%\System32 is something no vcpkg build should ever do anyway.
LGTM as a non-maintainer review.
| set(NET_SNMP_FEATURE_LIST "") | ||
| list(APPEND NET_SNMP_FEATURE_LIST "--with-sdk") | ||
| if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") | ||
| list(APPEND NET_SNMP_FEATURE_LIST "--linktype=static") | ||
| else() | ||
| list(APPEND NET_SNMP_FEATURE_LIST "--linktype=dynamic") | ||
| endif() | ||
|
|
||
| set(TARGET_DIR "${CURRENT_PACKAGES_DIR}") | ||
| set(TARGET_DIR_DEBUG "${CURRENT_PACKAGES_DIR}/debug") | ||
|
|
||
| set(NET_SNMP_SSL "") | ||
| set(NET_SNMP_SSL_DEBUG "") | ||
|
|
||
| if("ssl" IN_LIST FEATURES) | ||
| list(APPEND NET_SNMP_SSL | ||
| "--with-ssl" | ||
| "--with-sslincdir=${CURRENT_INSTALLED_DIR}/include" | ||
| "--with-ssllibdir=${CURRENT_INSTALLED_DIR}/lib") | ||
| list(APPEND NET_SNMP_SSL_DEBUG | ||
| "--with-ssl" | ||
| "--with-sslincdir=${CURRENT_INSTALLED_DIR}/include" | ||
| "--with-ssllibdir=${CURRENT_INSTALLED_DIR}/debug/lib") | ||
| endif() | ||
|
|
There was a problem hiding this comment.
| set(NET_SNMP_FEATURE_LIST "") | |
| list(APPEND NET_SNMP_FEATURE_LIST "--with-sdk") | |
| if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") | |
| list(APPEND NET_SNMP_FEATURE_LIST "--linktype=static") | |
| else() | |
| list(APPEND NET_SNMP_FEATURE_LIST "--linktype=dynamic") | |
| endif() | |
| set(TARGET_DIR "${CURRENT_PACKAGES_DIR}") | |
| set(TARGET_DIR_DEBUG "${CURRENT_PACKAGES_DIR}/debug") | |
| set(NET_SNMP_SSL "") | |
| set(NET_SNMP_SSL_DEBUG "") | |
| if("ssl" IN_LIST FEATURES) | |
| list(APPEND NET_SNMP_SSL | |
| "--with-ssl" | |
| "--with-sslincdir=${CURRENT_INSTALLED_DIR}/include" | |
| "--with-ssllibdir=${CURRENT_INSTALLED_DIR}/lib") | |
| list(APPEND NET_SNMP_SSL_DEBUG | |
| "--with-ssl" | |
| "--with-sslincdir=${CURRENT_INSTALLED_DIR}/include" | |
| "--with-ssllibdir=${CURRENT_INSTALLED_DIR}/debug/lib") | |
| endif() | |
| set(FEATURE_OPTIONS_RELEASE "") | |
| set(FEATURE_OPTIONS_DEBUG "") | |
| if("ssl" IN_LIST FEATURES) | |
| list(APPEND FEATURE_OPTIONS_RELEASE | |
| "--with-ssl" | |
| "--with-sslincdir=${CURRENT_INSTALLED_DIR}/include" | |
| "--with-ssllibdir=${CURRENT_INSTALLED_DIR}/lib" | |
| ) | |
| list(APPEND FEATURE_OPTIONS_DEBUG | |
| "--with-ssl" | |
| "--with-sslincdir=${CURRENT_INSTALLED_DIR}/include" | |
| "--with-ssllibdir=${CURRENT_INSTALLED_DIR}/debug/lib" | |
| ) | |
| endif() | |
and just use literal ${CURRENT_PACKAGES_DIR}[/debug].
| vcpkg_build_nmake( | ||
| SOURCE_PATH "${SOURCE_PATH}" | ||
| PROJECT_SUBPATH win32 | ||
| PRERUN_SHELL_RELEASE "${PERL}" Configure | ||
| ${NET_SNMP_FEATURE_LIST} | ||
| ${NET_SNMP_SSL} | ||
| --config=release | ||
| "--prefix=${TARGET_DIR}" | ||
| PRERUN_SHELL_DEBUG "${PERL}" Configure | ||
| ${NET_SNMP_FEATURE_LIST} | ||
| ${NET_SNMP_SSL_DEBUG} | ||
| --config=debug | ||
| "--prefix=${TARGET_DIR_DEBUG}" | ||
| PROJECT_NAME "Makefile" | ||
| TARGET ${TARGETS} install install_devel | ||
| LOGFILE_ROOT build-net-snmp | ||
| ) |
There was a problem hiding this comment.
| vcpkg_build_nmake( | |
| SOURCE_PATH "${SOURCE_PATH}" | |
| PROJECT_SUBPATH win32 | |
| PRERUN_SHELL_RELEASE "${PERL}" Configure | |
| ${NET_SNMP_FEATURE_LIST} | |
| ${NET_SNMP_SSL} | |
| --config=release | |
| "--prefix=${TARGET_DIR}" | |
| PRERUN_SHELL_DEBUG "${PERL}" Configure | |
| ${NET_SNMP_FEATURE_LIST} | |
| ${NET_SNMP_SSL_DEBUG} | |
| --config=debug | |
| "--prefix=${TARGET_DIR_DEBUG}" | |
| PROJECT_NAME "Makefile" | |
| TARGET ${TARGETS} install install_devel | |
| LOGFILE_ROOT build-net-snmp | |
| ) | |
| vcpkg_build_nmake( | |
| SOURCE_PATH "${SOURCE_PATH}" | |
| PROJECT_SUBPATH win32 | |
| PRERUN_SHELL_RELEASE "${PERL}" Configure | |
| --config=release | |
| --linktype=${VCPKG_LIBRARY_LINKAGE} | |
| "--prefix=${CURRENT_PACKAGES_DIR}" | |
| --with-sdk | |
| ${FEATURE_OPTIONS_RELEASE} | |
| PRERUN_SHELL_DEBUG "${PERL}" Configure | |
| --config=debug | |
| --linktype=${VCPKG_LIBRARY_LINKAGE} | |
| "--prefix=${CURRENT_PACKAGES_DIR}/debug" | |
| --with-sdk | |
| ${FEATURE_OPTIONS_DEBUG} | |
| PROJECT_NAME "Makefile" | |
| TARGET ${TARGETS} install install_devel | |
| ) |
| if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") | ||
| if(TARGETS STREQUAL "libs" AND EXISTS "${TARGET_DIR}/bin") | ||
| file(REMOVE_RECURSE "${TARGET_DIR}/bin") | ||
| file(REMOVE_RECURSE "${TARGET_DIR_DEBUG}/bin") | ||
| endif() | ||
| endif() |
There was a problem hiding this comment.
Dealing with bin in a static-only way before dealing with scripts and tools is usually a path to inconsistent build results.
| net-snmp provides no CMake targets. It can be used from CMake via: | ||
|
|
||
| find_path(NETSNMP_INCLUDE_DIR net-snmp/net-snmp-config.h) | ||
| find_library(NETSNMP_LIBRARY NAMES netsnmp) | ||
| target_include_directories(main PRIVATE ${NETSNMP_INCLUDE_DIR}) | ||
| target_link_libraries(main PRIVATE ${NETSNMP_LIBRARY} ws2_32) |
There was a problem hiding this comment.
Aligning with tool output:
| net-snmp provides no CMake targets. It can be used from CMake via: | |
| find_path(NETSNMP_INCLUDE_DIR net-snmp/net-snmp-config.h) | |
| find_library(NETSNMP_LIBRARY NAMES netsnmp) | |
| target_include_directories(main PRIVATE ${NETSNMP_INCLUDE_DIR}) | |
| target_link_libraries(main PRIVATE ${NETSNMP_LIBRARY} ws2_32) | |
| net-snmp can be used from CMake via: | |
| find_path(NETSNMP_INCLUDE_DIR net-snmp/net-snmp-config.h) | |
| find_library(NETSNMP_LIBRARY NAMES netsnmp) | |
| target_include_directories(main PRIVATE "${NETSNMP_INCLUDE_DIR}") | |
| target_link_libraries(main PRIVATE "${NETSNMP_LIBRARY}" ws2_32) |
| "description": "A SNMP application library, tools and daemon", | ||
| "homepage": "https://www.net-snmp.org/", | ||
| "license": "BSD-3-Clause AND HPND AND MIT", | ||
| "supports": "windows & !mingw & !uwp & !xbox", |
There was a problem hiding this comment.
IIUC net-snmp supports !windows, but the port is limited.
BillyONeal
left a comment
There was a problem hiding this comment.
GPT-5.5 observes:
-
The installed binaries are not relocatable.
ports/net-snmp/portfile.cmakerewritesINSTALL_BASEonly in the installed header, but installed binaries/libraries still contain absolute build/package paths for locations such asshare/snmp/mibsandlib/dlmod. Running an installed tool without operands attempted to create directories under the build package path, and binary scanning found those paths in installednetsnmp.dll, debugnetsnmp.dll, andnetsnmpmibs.lib. Ports must not embed package-build paths into installed artifacts. -
ports/net-snmp/portfile.cmakehas CRLF line endings, causinggit diff --check origin/master...HEADto report every line as trailing whitespace. vcpkg port files should use LF line endings.
============================
It also found this, but this is probably not a blocking issue to merge this.
ports/net-snmp/usageis not sufficient for consumers. The installed headers add MSVC autolink pragmas forlibcrypto.libandlibssl.libviaports/net-snmp/msvc-openssl-autolink.patch, but the usage snippet only linksnetsnmpandws2_32. A validation CMake consumer using the snippet fails for bothx64-windowsandx64-windows-staticwithLINK : fatal error LNK1104: cannot open file 'libcrypto.lib'.
…end usage - Add relocatable-install-base.patch: stop win32/Configure from substituting the --prefix path into net-snmp-config.h. The header's INSTALL_BASE feeds compile-time default runtime paths (MIBDIRS, SNMPCONFPATH, SNMPDLMODPATH, persistent storage), so the buildtree path ended up as string constants inside netsnmp.dll and the static libraries. With the patch the header keeps upstream's default c:/usr everywhere while --prefix still controls the install destination; the post-install header rewrite is no longer needed and is removed. - Convert portfile.cmake from CRLF to LF line endings. - Extend usage: consumers of the default ssl feature must link OpenSSL because net-snmp's installed headers auto-link libcrypto.lib/libssl.lib via MSVC pragmas. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014n2bVhar9Ab4mv1KcQdEYK
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014n2bVhar9Ab4mv1KcQdEYK
net-snmp: Make INSTALL_BASE relocatable and improve usage docs
Description
Adds a new Windows port for net-snmp (https://www.net-snmp.org/), the SNMP client/manager library and command-line tools.
Features
ssl(default): OpenSSL support, enabling SNMPv3 (USM authentication/privacy). Depends onopenssl.tools: net-snmp command-line utilities (e.g.snmpget,snmpwalk,snmpset), installed totools/net-snmp.Implementation
The port builds net-snmp with the upstream
win32nmake build system viavcpkg_build_nmake, using Perl (acquired throughvcpkg_find_acquire_program) to run the upstreamConfigurescript. Thesslfeature passes the OpenSSL include/lib directories of the vcpkg-installedopenssltoConfigurefor both the release and debug configurations.Two patches are applied to the upstream sources:
msvc-openssl-autolink.patch— the generatednet-snmp-config.hauto-links OpenSSL via#pragma comment(lib, ...), but the static-CRT branch referenceslibcrypto_static.lib/libssl_static.lib, which don't exist in vcpkg's OpenSSL. The patch always useslibcrypto.lib/libssl.liband addscrypt32.lib, which the static OpenSSL needs at link time. This fixesnet-snmp[ssl,tools]on the static-linkage triplets.no-system32-install.patch— removes upstream install steps that copynetsnmp.dlland PDB files into%SYSTEMROOT%\System32; a vcpkg install must not write outside the packages directory.Other implementation notes:
INSTALL_BASE(the compile-time default root for MIB/config/persistence paths) is reset in the installed header from the absolute buildtree path to upstream's defaultc:/usr, since the baked-in path is not relocatable; these paths are meant to be overridden at runtime via environment variables or the registry.BSD-3-Clause AND HPND AND MIT, matching the 14 parts of upstream's COPYING (SPDX deprecated the dedicatedNet-SNMPidentifier in license list 3.25.0 in favor of an expression of the constituent licenses).usagefile is installed; consumers linknetsnmpplusws2_32(OpenSSL andcrypt32are auto-linked through the header pragmas).Supports
windows & !mingw & !uwp & !xboxThe port targets the upstream Windows (MSVC) build system. Xbox is excluded because the perl-driven nmake build is untested there.
Testing
Verified successfully on:
x64-windowsx64-windows-staticx64-windows-static-mdx86-windowsBoth Debug and Release configurations build successfully, and CI feature testing covers all feature combinations (
core,ssl,tools,ssl+tools). The installed library and command-line tools were verified in a downstream MSVC/CMake project.New port checklist
Changes comply with the maintainer guide.
The packaged project is mature and ready for broad sharing with vcpkg users.
The packaged project shows strong association with the chosen port name.
Owner-Projectform.Optional dependencies of the build are all controlled by the port.
The versioning scheme in
vcpkg.jsonmatches what upstream says.The license declaration in
vcpkg.jsonmatches what upstream says.The installed
copyrightfile matches what upstream says.The source code comes from an authoritative source.
The generated
usagetext is brief and accurate.The version database was updated by rerunning
./vcpkg x-add-version --all.Exactly one version was added in each modified versions file.