diff mbox series

[bug#52472] gnu: Add libtree

Message ID 87zgo0jori.fsf@gmail.com
State New
Headers show
Series [bug#52472] gnu: Add libtree | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Artyom V. Poptsov Jan. 13, 2022, 3:30 a.m. UTC
Hello,

this is the updated version of the patch with changes suggested by
Mathieu Othacehe and Julien Lepiller.

A note for Mathieu: I used to build libtree with "-static" flag as it is
recommended by the official documentation.  But libtree builds fine
without the flag so I removed it.

Thanks,

- Artyom

Comments

Maxime Devos Jan. 13, 2022, 7:38 a.m. UTC | #1
Hi,

Artyom V. Poptsov schreef op do 13-01-2022 om 06:30 [+0300]:
> +     (list #:tests? #f

There's a check target in
<https://github.com/haampie/libtree/blob/master/Makefile>
and a bunch of tests in
<https://github.com/haampie/libtree/tree/master/tests>.

Greetings,
Maxime.
Artyom V. Poptsov Jan. 13, 2022, 5:18 p.m. UTC | #2
Hello Maxime,

to my understanding some libtree tests (namely 07 and 08) are made in
such way that they finish with a non-zero code when they pass, that
makes Guix stop during the build with an error.  For example, the test
"07_origin_is_relative_to_symlink_location_not_realpath" expects that
libtree will fail.  I checked a compiled "exe" file from a failed build
and got this:

--8<---------------cut here---------------start------------->8---
$ libtree /tmp/guix-build-libtree-3.0.1.drv-0/source/tests/07_origin_is_relative_to_symlink_location_not_realpath/exe 
exe 
└── libg.so [runpath]
    └── libf.so not found
        ┊ Paths considered in this order:
        ┊ 1. rpath is skipped because runpath was set
        ┊ 2. LD_LIBRARY_PATH was not set
        ┊ 3. runpath:
        ┊    /tmp/guix-build-libtree-3.0.1.drv-0/source/tests/07_origin_is_relative_to_symlink_location_not_realpath/b
        ┊ 4. ld config files:
        ┊    /usr/lib/x86_64-linux-gnu/libfakeroot
        ┊    /usr/local/lib
        ┊    /usr/local/lib/x86_64-linux-gnu
        ┊    /lib/x86_64-linux-gnu
        ┊    /usr/lib/x86_64-linux-gnu
        ┊    /lib32
        ┊    /usr/lib32
        ┊ 5. Standard paths:
        ┊    /lib
        ┊    /lib64
        ┊    /usr/lib
        ┊    /usr/lib64
Error [/tmp/guix-build-libtree-3.0.1.drv-0/source/tests/07_origin_is_relative_to_symlink_location_not_realpath/exe]: Not all dependencies were found
$ echo $?
28
--8<---------------cut here---------------end--------------->8---

Yet libtree itself seems to work fine after installation from Guix.
Here's an example of the output for a correct binary:

--8<---------------cut here---------------start------------->8---
$ libtree guix-daemon 
guix-daemon 
├── libz.so.1 [runpath]
├── libbz2.so.1.0 [runpath]
├── libgcrypt.so.20 [runpath]
│   └── libgpg-error.so.0 [runpath]
└── libsqlite3.so.0 [runpath]
--8<---------------cut here---------------end--------------->8---

I suggest that we keep "#f" for tests unless the libtree author fix this
behavior.

For now I opened an issue for libtree:
  https://github.com/haampie/libtree/issues/65

Thanks!

- Artyom
Maxime Devos Jan. 13, 2022, 5:37 p.m. UTC | #3
Artyom V. Poptsov schreef op do 13-01-2022 om 20:18 [+0300]:
> [...]
> 
> I suggest that we keep "#f" for tests unless the libtree author fix this
> behavior.
> 
> For now I opened an issue for libtree:
>   https://github.com/haampie/libtree/issues/65

Seems reasonable to me, though I would add a comment

  ;; See <https://github.com/haampie/libtree/issues/65>

next to the #:tests? #false such that the reasons won't be lost to
time.

Greetings,
Maxime.
diff mbox series

Patch

From 4ce9098e6fe8525e1e68d97458cb246ddc901266 Mon Sep 17 00:00:00 2001
From: "Artyom V. Poptsov" <poptsov.artyom@gmail.com>
Date: Mon, 13 Dec 2021 23:34:29 +0300
Subject: [PATCH] gnu: Add libtree

* gnu/packages/linux.scm (libtree): New variable.
---
 gnu/packages/linux.scm | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index da2ce602a7..f73e235a3c 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -60,6 +60,8 @@ 
 ;;; Copyright © 2021 Olivier Dion <olivier.dion@polymtl.ca>
 ;;; Copyright © 2021 Solene Rapenne <solene@perso.pw>
 ;;; Copyright © 2021 Petr Hodina <phodina@protonmail.com>
+;;; Copyright © 2022 Artyom V. Poptsov <poptsov.artyom@gmail.com>
+
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -8789,3 +8791,38 @@  older system-wide @file{/sys} interface.")
     (license (list license:lgpl2.1+   ;; libgpiod
                    license:gpl2+      ;; gpio-tools
                    license:lgpl3+)))) ;; C++ bindings
+
+(define-public libtree
+  (package
+    (name "libtree")
+    (version "3.0.1")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/haampie/libtree")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "1j56j1k4rlm0wi6jvdmk7j7nf4wrmc5gyhgp6vjf180hpgwlqz92"))))
+    (arguments
+     (list #:tests? #f
+           #:make-flags
+           ;; NOTE: Official documentation recommends to build libtree with
+           ;; "-static" flag.
+           #~(list (string-append "CC=" #$(cc-for-target))
+                   "PREFIX=/"
+                   (string-append "DESTDIR=" #$output))
+           #:phases
+           #~(modify-phases %standard-phases
+               (delete 'configure)
+               (replace 'build
+                 (lambda* (#:key make-flags #:allow-other-keys)
+                   (apply invoke "make" make-flags))))))
+    (build-system gnu-build-system)
+    (home-page "https://github.com/haampie/libtree")
+    (synopsis "Show output of @command{ldd} as a tree")
+    (description
+     "This tool turns @command{ldd} into a tree and explains how shared
+libraries are found or why they cannot be located.")
+    (license license:expat)))
-- 
2.25.1