Subject: [bug#52043] [PATCH 2/2] gnu: Move instrumentation tools to instrumentation module.

From: Olivier Dion <[email-masked]>
Date: Mon, 22 Nov 2021 14:16:05 -0500

* gnu/packages/linux.scm (lttng-ust, lttng-tools, babeltrace): Move to ...
* gnu/packages/instrumentation.scm: ... here.
---
 gnu/packages/instrumentation.scm | 162 +++++++++++++++++++++++++++++++
 gnu/packages/linux.scm           | 147 ----------------------------
 2 files changed, 162 insertions(+), 147 deletions(-)

diff --git a/gnu/packages/instrumentation.scm b/gnu/packages/instrumentation.scm
index cacd74ac0a..b876551673 100644
--- a/gnu/packages/instrumentation.scm
+++ b/gnu/packages/instrumentation.scm
@@ -17,15 +17,86 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages instrumentation)
+  #:use-module (gnu packages perl)
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages bison)
   #:use-module (gnu packages boost)
+  #:use-module (gnu packages datastructures)
+  #:use-module (gnu packages documentation)
   #:use-module (gnu packages elf)
+  #:use-module (gnu packages flex)
+  #:use-module (gnu packages glib)
+  #:use-module (gnu packages linux)
   #:use-module (gnu packages llvm)
+  #:use-module (gnu packages man)
+  #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages popt)
+  #:use-module (gnu packages python)
+  #:use-module (gnu packages sphinx)
+  #:use-module (gnu packages swig)
   #:use-module (gnu packages tbb)
+  #:use-module (gnu packages xml)
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix build-system cmake)
+  #:use-module (guix build-system gnu)
   #:use-module ((guix licenses) #:prefix license:))
 
+(define-public babeltrace
+  (package
+    (name "babeltrace")
+    (version "2.0.4")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://www.efficios.com/files/babeltrace/babeltrace2-"
+                                  version ".tar.bz2"))
+              (sha256
+               (base32 "1jlv925pr7hykc48mdvbmqm4ipy1r11xwzapa6fdpdfshmk12kvp"))))
+
+    (build-system gnu-build-system)
+
+    (arguments
+     `(;; FIXME - When Python's bindings are enabled, tests do not pass.
+       #:configure-flags '("--enable-debug-info"
+                           "--enable-man-pages"
+                           "--disable-python-bindings"
+                           "--disable-python-plugins")
+                         #:phases
+                         (modify-phases %standard-phases
+                           ;; These are recommended in the project's README for a development
+                           ;; build configuration.
+                           (add-before 'configure 'set-environment-variables
+                             (lambda _
+                               (setenv "BABELTRACE_DEV_MODE" "1")
+                               (setenv "BABELTRACE_MINIMAL_LOG_LEVEL" "TRACE"))))))
+    (inputs
+     `(("glib" ,glib)))
+    ;; NOTE - elfutils is used for the LTTng debug information filter
+    ;; component class.  This can be moved to `native-inputs` if
+    ;; `--enable-debug-info` is replaced by `--disable-debug-info` in
+    ;; `#:configure-flags`.
+    (propagated-inputs
+     `(("elfutils" ,elfutils)))
+    ;; NOTE - python-3 is set here for generating the bindings.  Users need to
+    ;; install python-3 in their profile in order to use these bindings.
+    (native-inputs
+     `(("asciidoc" ,asciidoc)
+       ("bison" ,bison)
+       ("flex" ,flex)
+       ("pkg-config" ,pkg-config)
+       ("python-3" ,python-3)
+       ("python-sphinx" ,python-sphinx)
+       ("swig", swig)
+       ("xmltoman" ,xmltoman)))
+    (home-page "https://babeltrace.org/")
+    (synopsis "Trace manipulation toolkit")
+    (description "Babeltrace 2 is a framework for viewing, converting,
+transforming, and analyzing traces.  It is also the reference parser
+implementation of the Common Trace Format (CTF), produced by tools such as
+LTTng and barectf.  This package provides a library with a C API, Python 3
+bindings, and the command-line tool @command{babeltrace2}.")
+    (license license:expat)))
+
 (define-public dyninst
   (package
     (name "dyninst")
@@ -54,3 +125,94 @@ (define-public dyninst
     (synopsis "Dynamic instrumentation")
     (description "Tools for binary instrumentation, analysis, and modification.")
     (license license:lgpl2.0)))
+
+(define-public lttng-ust
+  (package
+    (name "lttng-ust")
+    (version "2.13.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://lttng.org/files/lttng-ust/"
+                                  "lttng-ust-" version ".tar.bz2"))
+              (sha256
+               (base32
+                "0l0p6y2zrd9hgd015dhafjmpcj7waz762n6wf5ws1xlwcwrwkr2l"))))
+    (build-system gnu-build-system)
+    (inputs
+     `(("liburcu" ,liburcu)
+       ("numactl" ,numactl)))
+    (native-inputs
+     `(("python" ,python-3)
+       ("pkg-config", pkg-config)))
+    (home-page "https://lttng.org/")
+    (synopsis "LTTng userspace tracer libraries")
+    (description "The user space tracing library, liblttng-ust, is the LTTng
+user space tracer.  It receives commands from a session daemon, for example to
+enable and disable specific instrumentation points, and writes event records
+to ring buffers shared with a consumer daemon.")
+    (license license:lgpl2.1+)))
+
+(define-public lttng-tools
+  (package
+    (name "lttng-tools")
+    (version "2.13.1")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://lttng.org/files/lttng-tools/"
+                                  "lttng-tools-" version ".tar.bz2"))
+              (sha256
+               (base32
+                "1df8ag2a1yyjn6hz6wxgcz0p847cq91b8inf0zyhgz1im1yxzrng"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(;; FIXME - Currently there's a segmentation fault by swig when enabling
+       ;; Python's bindings.  Thus, bindings are disable here.  Replace
+       ;; `disable` by `enable` in #:configure-flags when this is fixed.
+       #:configure-flags '("--disable-python-bindings")
+                         ;; FIXME - Tests are disabled for now because one test hangs
+                         ;; indefinetely.  Also, parallel testing is not possible because of how
+                         ;; the lttng-daemon handles sessions.  Thus, keep parallel testing
+                         ;; disabled even after tests are enabled!
+                         #:tests? #f
+                         #:parallel-tests? #f
+                         #:phases
+                         (modify-phases %standard-phases
+                           (add-before 'configure 'set-environment-variables
+                             (lambda _
+                               (setenv "HOME" "/tmp")
+                               (setenv "LTTNG_HOME" "/tmp")))
+                           ;; We don't put (which "man") here because LTTng uses execlp.
+                           (add-after 'unpack 'patch-default-man-path
+                             (lambda _
+                               (substitute* "src/common/defaults.h"
+                                 (("/usr/bin/man") "man")))))))
+    ;; NOTE - Users have to install python-3 in their profile to use the
+    ;; bindings.  We don't put it in the inputs, because the rest of the tools
+    ;; can work without it.
+    (inputs
+     `(("liburcu" ,liburcu)
+       ("popt" ,popt)
+       ("numactl" ,numactl)))
+    (propagated-inputs
+     `(("kmod" ,kmod)
+       ("module-init-tools" ,module-init-tools)))
+    (native-inputs
+     `(("pkg-config" ,pkg-config)
+       ("perl" ,perl)
+       ("libpfm4" ,libpfm4)
+       ("python-3" ,python-3)
+       ("swig" ,swig)
+       ("procps" ,procps)
+       ("which" ,which)
+       ("flex" ,flex)
+       ("bison" ,bison)
+       ("asciidoc" ,asciidoc)
+       ("libxml2" ,libxml2)
+       ("lttng-ust" ,lttng-ust)))
+    (home-page "https://lttng.org/")
+    (synopsis "LTTng userspace tracer libraries")
+    (description "The lttng-tools project provides a session
+daemon @code{lttng-sessiond} that acts as a tracing registry, the @command{lttng} command
+line for tracing control, a @code{lttng-ctl} library for tracing control and a
+@code{lttng-relayd} for network streaming.")
+    (license (list  license:gpl2 license:lgpl2.1))))
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index ece3c588e8..8456450e52 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -131,7 +131,6 @@ (define-module (gnu packages linux)
   #:use-module (gnu packages sdl)
   #:use-module (gnu packages serialization)
   #:use-module (gnu packages slang)
-  #:use-module (gnu packages sphinx)
   #:use-module (gnu packages sqlite)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages tls)
@@ -8110,152 +8109,6 @@ (define-public ell
 platforms, it is not limited to resource-constrained systems.")
     (license license:lgpl2.1+)))
 
-(define-public lttng-ust
-  (package
-    (name "lttng-ust")
-    (version "2.13.0")
-    (source (origin
-              (method url-fetch)
-              (uri (string-append "https://lttng.org/files/lttng-ust/"
-                                  "lttng-ust-" version ".tar.bz2"))
-              (sha256
-               (base32
-                "0l0p6y2zrd9hgd015dhafjmpcj7waz762n6wf5ws1xlwcwrwkr2l"))))
-    (build-system gnu-build-system)
-    (inputs
-     `(("liburcu" ,liburcu)
-       ("numactl" ,numactl)))
-    (native-inputs
-     `(("python" ,python-3)
-       ("pkg-config", pkg-config)))
-    (home-page "https://lttng.org/")
-    (synopsis "LTTng userspace tracer libraries")
-    (description "The user space tracing library, liblttng-ust, is the LTTng
-user space tracer.  It receives commands from a session daemon, for example to
-enable and disable specific instrumentation points, and writes event records
-to ring buffers shared with a consumer daemon.")
-    (license license:lgpl2.1+)))
-
-(define-public lttng-tools
-  (package
-    (name "lttng-tools")
-    (version "2.13.1")
-    (source (origin
-              (method url-fetch)
-              (uri (string-append "https://lttng.org/files/lttng-tools/"
-                                  "lttng-tools-" version ".tar.bz2"))
-              (sha256
-               (base32
-                "1df8ag2a1yyjn6hz6wxgcz0p847cq91b8inf0zyhgz1im1yxzrng"))))
-    (build-system gnu-build-system)
-    (arguments
-     `(;; FIXME - Currently there's a segmentation fault by swig when enabling
-       ;; Python's bindings.  Thus, bindings are disable here.  Replace
-       ;; `disable` by `enable` in #:configure-flags when this is fixed.
-       #:configure-flags '("--disable-python-bindings")
-       ;; FIXME - Tests are disabled for now because one test hangs
-       ;; indefinetely.  Also, parallel testing is not possible because of how
-       ;; the lttng-daemon handles sessions.  Thus, keep parallel testing
-       ;; disabled even after tests are enabled!
-       #:tests? #f
-       #:parallel-tests? #f
-       #:phases
-       (modify-phases %standard-phases
-         (add-before 'configure 'set-environment-variables
-           (lambda _
-             (setenv "HOME" "/tmp")
-             (setenv "LTTNG_HOME" "/tmp")))
-         ;; We don't put (which "man") here because LTTng uses execlp.
-         (add-after 'unpack 'patch-default-man-path
-           (lambda _
-             (substitute* "src/common/defaults.h"
-               (("/usr/bin/man") "man")))))))
-    ;; NOTE - Users have to install python-3 in their profile to use the
-    ;; bindings.  We don't put it in the inputs, because the rest of the tools
-    ;; can work without it.
-    (inputs
-     `(("liburcu" ,liburcu)
-       ("popt" ,popt)
-       ("numactl" ,numactl)))
-    (propagated-inputs
-     `(("kmod" ,kmod)
-       ("module-init-tools" ,module-init-tools)))
-    (native-inputs
-     `(("pkg-config" ,pkg-config)
-       ("perl" ,perl)
-       ("libpfm4" ,libpfm4)
-       ("python-3" ,python-3)
-       ("swig" ,swig)
-       ("procps" ,procps)
-       ("which" ,which)
-       ("flex" ,flex)
-       ("bison" ,bison)
-       ("asciidoc" ,asciidoc)
-       ("libxml2" ,libxml2)
-       ("lttng-ust" ,lttng-ust)))
-    (home-page "https://lttng.org/")
-    (synopsis "LTTng userspace tracer libraries")
-    (description "The lttng-tools project provides a session
-daemon @code{lttng-sessiond} that acts as a tracing registry, the @command{lttng} command
-line for tracing control, a @code{lttng-ctl} library for tracing control and a
-@code{lttng-relayd} for network streaming.")
-    (license (list  license:gpl2 license:lgpl2.1))))
-
-(define-public babeltrace
-  (package
-    (name "babeltrace")
-    (version "2.0.4")
-    (source (origin
-              (method url-fetch)
-              (uri (string-append "https://www.efficios.com/files/babeltrace/babeltrace2-"
-                                  version ".tar.bz2"))
-              (sha256
-               (base32 "1jlv925pr7hykc48mdvbmqm4ipy1r11xwzapa6fdpdfshmk12kvp"))))
-
-    (build-system gnu-build-system)
-
-    (arguments
-     `(;; FIXME - When Python's bindings are enabled, tests do not pass.
-       #:configure-flags '("--enable-debug-info"
-                           "--enable-man-pages"
-                           "--disable-python-bindings"
-                           "--disable-python-plugins")
-       #:phases
-       (modify-phases %standard-phases
-         ;; These are recommended in the project's README for a development
-         ;; build configuration.
-         (add-before 'configure 'set-environment-variables
-           (lambda _
-             (setenv "BABELTRACE_DEV_MODE" "1")
-             (setenv "BABELTRACE_MINIMAL_LOG_LEVEL" "TRACE"))))))
-    (inputs
-     `(("glib" ,glib)))
-    ;; NOTE - elfutils is used for the LTTng debug information filter
-    ;; component class.  This can be moved to `native-inputs` if
-    ;; `--enable-debug-info` is replaced by `--disable-debug-info` in
-    ;; `#:configure-flags`.
-    (propagated-inputs
-     `(("elfutils" ,elfutils)))
-    ;; NOTE - python-3 is set here for generating the bindings.  Users need to
-    ;; install python-3 in their profile in order to use these bindings.
-    (native-inputs
-     `(("asciidoc" ,asciidoc)
-       ("bison" ,bison)
-       ("flex" ,flex)
-       ("pkg-config" ,pkg-config)
-       ("python-3" ,python-3)
-       ("python-sphinx" ,python-sphinx)
-       ("swig", swig)
-       ("xmltoman" ,xmltoman)))
-    (home-page "https://babeltrace.org/")
-    (synopsis "Trace manipulation toolkit")
-    (description "Babeltrace 2 is a framework for viewing, converting,
-transforming, and analyzing traces.  It is also the reference parser
-implementation of the Common Trace Format (CTF), produced by tools such as
-LTTng and barectf.  This package provides a library with a C API, Python 3
-bindings, and the command-line tool @command{babeltrace2}.")
-    (license license:expat)))
-
 (define-public kexec-tools
   (package
     (name "kexec-tools")
-- 
2.34.0