Subject: [PATCH 2/2] gnu: sysdig: Update to 0.40.0-alpha2.

From: Maxim Cournoyer <[email-masked]>
Date: Thu, 23 Jan 2025 16:33:19 +0900

(Also add the missing 2024 copyright year).

* gnu/packages/admin.scm (sysdig): Update to 0.40.0-alpha2.
* gnu/packages/patches/sysdig-shared-falcosecurity-libs.patch: Rebase patch.
* gnu/packages/patches/sysdig-falcosecurity-libs-0.20.patch: New patch.
* gnu/local.mk (dist_patch_DATA): Register it.

Change-Id: I2fc91baf52aebf283615a8989e841687c6033602
---
 gnu/local.mk                                  |  1 +
 gnu/packages/admin.scm                        | 77 +++++++++----------
 .../sysdig-falcosecurity-libs-0.20.patch      | 54 +++++++++++++
 .../sysdig-shared-falcosecurity-libs.patch    | 34 ++++----
 4 files changed, 106 insertions(+), 60 deletions(-)
 create mode 100644 gnu/packages/patches/sysdig-falcosecurity-libs-0.20.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index de2e42cd79..f93b61a346 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2238,6 +2238,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/slim-display.patch			\
   %D%/packages/patches/slurm-23-salloc-fallback-shell.patch	\
   %D%/packages/patches/stex-copy-from-immutable-store.patch	\
+  %D%/packages/patches/sysdig-falcosecurity-libs-0.20.patch	\
   %D%/packages/patches/sysdig-shared-falcosecurity-libs.patch	\
   %D%/packages/patches/syslinux-gcc10.patch			\
   %D%/packages/patches/syslinux-strip-gnu-property.patch	\
diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index 89879bf486..a789c5c47b 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -35,7 +35,7 @@
 ;;; Copyright © 2020, 2021, 2022 Michael Rohleder <[email-masked]>
 ;;; Copyright © 2020 Vincent Legoll <[email-masked]>
 ;;; Copyright © 2020 Morgan Smith <[email-masked]>
-;;; Copyright © 2021, 2022, 2023 Maxim Cournoyer <[email-masked]>
+;;; Copyright © 2021-2025 Maxim Cournoyer <[email-masked]>
 ;;; Copyright © 2021, 2023, 2024 Zheng Junjie <[email-masked]>
 ;;; Copyright © 2021 Stefan Reichör <[email-masked]>
 ;;; Copyright © 2021 qblade <[email-masked]>
@@ -5990,44 +5990,41 @@ (define-public seatd
     (license license:expat)))
 
 (define-public sysdig
-  ;; Use the latest commit for now, as the latest 0.36.1 release does not yet
-  ;; support the falcosecurity-libs 0.16 API.
-  (let ((commit "598ad292b659425e475e5814d9e92c3c29188480")
-        (revision "0"))
-    (package
-      (name "sysdig")
-      (version (git-version "0.36.1" revision commit))
-      (source (origin
-                (method git-fetch)
-                (uri (git-reference
-                      (url "https://github.com/draios/sysdig")
-                      (commit commit)))
-                (file-name (git-file-name name version))
-                (sha256
-                 (base32
-                  "0yyins3rb286dfibadfwwp2gwmdj7fsz3pdkpdvx05yvdqfkqds7"))
-                (patches
-                 (search-patches "sysdig-shared-falcosecurity-libs.patch"))))
-      (build-system cmake-build-system)
-      (arguments
-       (list #:tests? #f                ;no test suite
-             #:configure-flags
-             #~(list "-DUSE_BUNDLED_DEPS=OFF"
-                     ;; Already built and part of falcosecurity-libs, but
-                     ;; needed for the 'HAS_MODERN_BPF' define.
-                     "-DBUILD_SYSDIG_MODERN_BPF=ON"
-                     #$(string-append "-DSYSDIG_VERSION=" version))))
-      (native-inputs (list pkg-config))
-      (inputs
-       (list falcosecurity-libs
-             luajit
-             ncurses
-             nlohmann-json
-             yaml-cpp
-             zlib))
-      (home-page "https://github.com/draios/sysdig")
-      (synopsis "System exploration and troubleshooting tool")
-      (description "Sysdig is a simple tool for deep system visibility, with
+  (package
+    (name "sysdig")
+    (version "0.40.0-alpha2")           ;for the 0.20 patch to apply
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/draios/sysdig")
+                    (commit version)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "071xbyp9ykjb6wh9n7c8qw3iq0r8wz58xkf1r8p3x84mn674ibm6"))
+              (patches
+               (search-patches "sysdig-shared-falcosecurity-libs.patch"
+                               "sysdig-falcosecurity-libs-0.20.patch"))))
+    (build-system cmake-build-system)
+    (arguments
+     (list #:tests? #f                  ;no test suite
+           #:configure-flags
+           #~(list "-DUSE_BUNDLED_DEPS=OFF"
+                   ;; Already built and part of falcosecurity-libs, but
+                   ;; needed for the 'HAS_MODERN_BPF' define.
+                   "-DBUILD_SYSDIG_MODERN_BPF=ON"
+                   #$(string-append "-DSYSDIG_VERSION=" version))))
+    (native-inputs (list pkg-config))
+    (inputs
+     (list falcosecurity-libs
+           luajit
+           ncurses
+           nlohmann-json
+           yaml-cpp
+           zlib))
+    (home-page "https://github.com/draios/sysdig")
+    (synopsis "System exploration and troubleshooting tool")
+    (description "Sysdig is a simple tool for deep system visibility, with
 native support for containers.  It combines features of multiple system
 administration tools such as the @command{strace}, @command{tcpdump},
 @command{htop}, @command{iftop} and @command{lsof} into a single interface.
@@ -6045,7 +6042,7 @@ (define-public sysdig
 alias sysdig=sudo sysdig --modern-bpf
 alias cysdig=sudo csysdig --modern-bpf
 ")                                      ;XXX no @example Texinfo support
-      (license license:asl2.0))))
+    (license license:asl2.0)))
 
 (define-public fail2ban
   (package
diff --git a/gnu/packages/patches/sysdig-falcosecurity-libs-0.20.patch b/gnu/packages/patches/sysdig-falcosecurity-libs-0.20.patch
new file mode 100644
index 0000000000..cba7b4afe1
--- /dev/null
+++ b/gnu/packages/patches/sysdig-falcosecurity-libs-0.20.patch
@@ -0,0 +1,54 @@
+Upstream-status: Merged but not yet released.
+
+diff --git a/cmake/modules/falcosecurity-libs.cmake b/cmake/modules/falcosecurity-libs.cmake
+index 64d387477..c4db6037a 100644
+--- a/cmake/modules/falcosecurity-libs.cmake
++++ b/cmake/modules/falcosecurity-libs.cmake
+@@ -22,7 +22,7 @@ option(USE_BUNDLED_FALCOSECURITY_LIBS
+ 
+ if(NOT USE_BUNDLED_FALCOSECURITY_LIBS)
+     find_package(PkgConfig REQUIRED)
+-    pkg_check_modules(LIBSINSP REQUIRED IMPORTED_TARGET libsinsp)
++    pkg_check_modules(LIBSINSP REQUIRED IMPORTED_TARGET libsinsp>=0.20.0)
+     message(STATUS "Found libsinsp:
+   include: ${LIBSINSP_INCLUDE_DIRS}
+   lib: ${LIBSINSP_LIBRARIES}
+@@ -47,8 +47,8 @@ else()
+   # In case you want to test against another falcosecurity/libs version (or branch, or commit) just pass the variable -
+   # ie., `cmake -DFALCOSECURITY_LIBS_VERSION=dev ..`
+   if(NOT FALCOSECURITY_LIBS_VERSION)
+-    set(FALCOSECURITY_LIBS_VERSION "0.19.0")
+-    set(FALCOSECURITY_LIBS_CHECKSUM "SHA256=77c38b45c8b29c4da4f8ce49da68278b347a403ff1075307ff0cf540596303ac")
++    set(FALCOSECURITY_LIBS_VERSION "0.20.0")
++    set(FALCOSECURITY_LIBS_CHECKSUM "SHA256=4ae6ddb42a1012bacd88c63abdaa7bd27ca0143c4721338a22c45597e63bc99d")
+   endif()
+ 
+   # cd /path/to/build && cmake /path/to/source
+diff --git a/userspace/chisel/chisel_api.cpp b/userspace/chisel/chisel_api.cpp
+index 04fcb60be..53c02e3f5 100644
+--- a/userspace/chisel/chisel_api.cpp
++++ b/userspace/chisel/chisel_api.cpp
+@@ -842,10 +842,10 @@ int lua_cbacks::get_thread_table_int(lua_State *ls, bool include_fds, bool bareb
+ 			lua_pushnumber(ls, (uint32_t)tinfo.m_fdlimit);
+ 			lua_settable(ls, -3);
+ 			lua_pushliteral(ls, "uid");
+-			lua_pushnumber(ls, (uint32_t)tinfo.m_user.uid());
++			lua_pushnumber(ls, (uint32_t)tinfo.m_uid);
+ 			lua_settable(ls, -3);
+ 			lua_pushliteral(ls, "gid");
+-			lua_pushnumber(ls, (uint32_t)tinfo.m_group.gid());
++			lua_pushnumber(ls, (uint32_t)tinfo.m_gid);
+ 			lua_settable(ls, -3);
+ 			lua_pushliteral(ls, "nchilds");
+ 			lua_pushnumber(ls, (uint32_t)tinfo.get_num_not_leader_threads());
+@@ -872,8 +872,9 @@ int lua_cbacks::get_thread_table_int(lua_State *ls, bool include_fds, bool bareb
+ 			//
+ 			// Extract the user name
+ 			//
++			auto user = tinfo.get_user();
+ 			lua_pushliteral(ls, "username");
+-			lua_pushstring(ls, tinfo.m_user.name().c_str());
++			lua_pushstring(ls, user->name);
+ 			lua_settable(ls, -3);
+ 
+ 			//
diff --git a/gnu/packages/patches/sysdig-shared-falcosecurity-libs.patch b/gnu/packages/patches/sysdig-shared-falcosecurity-libs.patch
index 5d0fd4d1fb..1fa331ad0d 100644
--- a/gnu/packages/patches/sysdig-shared-falcosecurity-libs.patch
+++ b/gnu/packages/patches/sysdig-shared-falcosecurity-libs.patch
@@ -1,14 +1,16 @@
 Upstream status: https://github.com/draios/sysdig/pull/2093
 
 diff --git a/cmake/modules/falcosecurity-libs.cmake b/cmake/modules/falcosecurity-libs.cmake
-index 7cee8a3c4..dd59c1b32 100644
+index 61782da69..14b13ce24 100644
 --- a/cmake/modules/falcosecurity-libs.cmake
 +++ b/cmake/modules/falcosecurity-libs.cmake
-@@ -16,6 +16,19 @@
+@@ -16,6 +16,21 @@
  # limitations under the License.
  #
  
-+option(USE_BUNDLED_FALCOSECURITY_LIBS "Enable building of the bundled falcosecurity libraries" ${USE_BUNDLED_DEPS})
++option(USE_BUNDLED_FALCOSECURITY_LIBS
++	"Enable building of the bundled falcosecurity libraries"
++	${USE_BUNDLED_DEPS})
 +
 +if(NOT USE_BUNDLED_FALCOSECURITY_LIBS)
 +    find_package(PkgConfig REQUIRED)
@@ -25,18 +27,10 @@ index 7cee8a3c4..dd59c1b32 100644
  set(FALCOSECURITY_LIBS_CMAKE_WORKING_DIR "${CMAKE_BINARY_DIR}/falcosecurity-libs-repo")
  
 diff --git a/userspace/sysdig/CMakeLists.txt b/userspace/sysdig/CMakeLists.txt
-index 60f8072ad..0cb179ccc 100644
+index c1602d543..cd2e08f4c 100644
 --- a/userspace/sysdig/CMakeLists.txt
 +++ b/userspace/sysdig/CMakeLists.txt
-@@ -20,7 +20,6 @@ if(NOT WIN32)
- 	include(ncurses)
- endif() # NOT WIN32
- 
--include(zlib)
- include(luajit)
- 
- include_directories("${PROJECT_BINARY_DIR}/userspace/sinspui")
-@@ -84,6 +83,12 @@ if(USE_BUNDLED_DEPS)
+@@ -84,6 +84,12 @@ if(USE_BUNDLED_DEPS)
  	add_dependencies(csysdig luajit)
  endif()
  
@@ -49,16 +43,16 @@ index 60f8072ad..0cb179ccc 100644
  target_include_directories(
  	sysdig
  	PUBLIC
-@@ -108,7 +113,7 @@ if(NOT WIN32)
+@@ -106,7 +112,7 @@ if(NOT WIN32)
  	include_directories(${PROJECT_BINARY_DIR}/driver/src)
  
  	target_link_libraries(sysdig
 -		sinsp
 +		"${SINSP_LIB}"
  		"${LUAJIT_LIB}"
- 		"${YAMLCPP_LIB}")
+ 		yaml-cpp)
  
-@@ -117,7 +122,7 @@ if(NOT WIN32)
+@@ -115,7 +121,7 @@ if(NOT WIN32)
  	endif()
  
  	target_link_libraries(csysdig
@@ -66,19 +60,19 @@ index 60f8072ad..0cb179ccc 100644
 +		"${SINSP_LIB}"
  		"${LUAJIT_LIB}"
  		"${CURSES_LIBRARIES}"
- 		"${YAMLCPP_LIB}")
-@@ -140,12 +145,12 @@ else()
+ 		yaml-cpp)
+@@ -138,12 +144,12 @@ else()
  	add_definitions(-DNOCURSESUI)
  
  	target_link_libraries(sysdig
 -		sinsp
 +		"${SINSP_LIB}"
  		"${LUAJIT_LIB}"
- 		"${YAMLCPP_LIB}")
+ 		yaml-cpp)
  
  	target_link_libraries(csysdig
 -		sinsp
 +		"${SINSP_LIB}"
  		"${LUAJIT_LIB}"
- 		"${YAMLCPP_LIB}")
+ 		yaml-cpp)
  
-- 
2.47.1