Subject: [bug#77038] [PATCH 3/3] gnu: uftrace: Make python and luajit inputs optional

From: Arseniy Zaostrovnykh <[email-masked]>
Date: Sat, 15 Mar 2025 18:56:27 +0100

gnu/packages/instrumentation.scm (uftrace): Make scripting inputs
optional. If user removes these inputs they will still be able to enjoy
uftrace except for the scripting part.

Change-Id: Ice8f9ce8aba38322ff34a38f112512186bd98c1d
---
 gnu/packages/instrumentation.scm | 47 +++++++++++++++++++-------------
 1 file changed, 28 insertions(+), 19 deletions(-)

diff --git a/gnu/packages/instrumentation.scm b/gnu/packages/instrumentation.scm
index 05e74b6f4f..09314519a9 100644
--- a/gnu/packages/instrumentation.scm
+++ b/gnu/packages/instrumentation.scm
@@ -604,10 +604,22 @@ (define-public uftrace
                 (when target
                   (setenv "CROSS_COMPILE" (string-append target "-"))))
               (setenv "SHELL" (which "sh"))
-              (let ((python #$(this-package-input "python"))
-                    (luajit #$(this-package-input "luajit")))
-                (setenv "LDFLAGS" (string-append "-Wl," "-rpath=" python "/lib"
-                                                 ":" luajit "/lib")))
+              (let* ((python #$(this-package-input "python"))
+                     (luajit #$(this-package-input "luajit"))
+                     (libs (cond
+                             ((and python luajit)
+                              (list "-Wl,-rpath="
+                                    python
+                                    "/lib"
+                                    ":"
+                                    luajit
+                                    "/lib"))
+                             (python (list "-Wl,-rpath=" python "/lib"))
+                             (luajit (list "-Wl,-rpath=" luajit "/lib"))
+                             (#t #f))))
+                (when libs
+                  (setenv "LDFLAGS"
+                          (apply string-append libs))))
               (invoke "./configure"
                       (string-append "--prefix="
                                      #$output))))
@@ -616,7 +628,7 @@ (define-public uftrace
               (substitute* "tests/t220_trace_script.py"
                 (("/bin/sh")
                  (search-input-file inputs "bin/sh")))))
-          (add-after 'unpack 'delete-network-tests
+          (add-before 'check 'delete-network-tests
             (lambda _
               ;; These tests require network capability (localhost)
               (for-each delete-file
@@ -626,23 +638,20 @@ (define-public uftrace
                           "tests/t150_recv_event.py"
                           "tests/t151_recv_runcmd.py"
                           "tests/t167_recv_sched.py")))))))
-    (inputs
-     (list capstone
-           elfutils
-           libunwind
-           python ;; libpython3.10.so for python scripting
-           luajit ;; libluajit-5.1.so for lua scripting
-           ncurses))
-    (native-inputs
-     (list luajit
-           pandoc
-           pkg-config
-           python-wrapper))
+    (inputs (list capstone
+                  elfutils
+                  libunwind
+                  python ;(optional) libpython3.10.so for python scripting
+                  luajit ;(optional) libluajit-5.1.so for lua scripting
+                  ncurses))
+    (native-inputs (list luajit pandoc pkg-config python-wrapper))
     (home-page "https://github.com/namhyung/uftrace")
     (synopsis "Function graph tracer for C/C++/Rust")
-    (description "uftrace is a tool for tracing and analyzing the execution of
+    (description
+     "uftrace is a tool for tracing and analyzing the execution of
 programs written in C/C++.  It is heavily inspired by the ftrace framework of
 the Linux kernel, while supporting userspace programs.  It supports various
 kind of commands and filters to help analysis of the program execution and
-performance.  It provides the command @command{uftrace}.")
+performance.  It provides the command @command{uftrace}.  By default, it is
+bundled with python-3 and luajit that you can delete in a package variant.")
     (license license:gpl2)))
-- 
2.48.1