diff mbox series

[bug#39961] gnu: Add traceroute.

Message ID CAEwRq=qLnNS2HzekK-PVPc3Pytk9+uz+F4K+H2BWP2Xo3DEk=Q@mail.gmail.com
State Work in progress
Headers show
Series [bug#39961] gnu: Add traceroute. | expand

Checks

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

Commit Message

Vincent Legoll March 6, 2020, 11:13 p.m. UTC
This need an in-depth review, as there is something strange, I had to
set LIBRARY_PATH to overcome gcc/ld not finding crt{i,1}.o

I found the following bug:
https://issues.guix.gnu.org/issue/32131
that met a similar issue...

Please advise how to proceed further.

Comments

Vincent Legoll March 7, 2020, 1:28 a.m. UTC | #1
tracerouted OK to 9.9.9.9
Vincent Legoll March 7, 2020, 11:06 a.m. UTC | #2
I've since seen a few other issues on the same subject, but cannot
find a way to get it work without setting LIBRARY_PATH...

I tried guix environment --ad-hoc gcc-toolchain, adding the missed
GUIX_PROFILE to .bash_profile, etc.
Vincent Legoll March 7, 2020, 11:08 a.m. UTC | #3
I am running all this through ssh into a VM, so I also tried to run
with bash -l...

This is probably misconfiguration on my end...
Leo Famulari March 7, 2020, 1:09 p.m. UTC | #4
On Sat, Mar 07, 2020 at 12:13:18AM +0100, Vincent Legoll wrote:
> +       (uri (string-append "mirror://sourceforge/traceroute/traceroute/"
> +               "traceroute-" version "/traceroute-" version ".tar.gz"))

How does this compare to the traceroute provided by the inetutils
package?
Vincent Legoll March 7, 2020, 1:23 p.m. UTC | #5
On Sat, Mar 7, 2020 at 2:09 PM Leo Famulari <leo@famulari.name> wrote:
> How does this compare to the traceroute provided by the inetutils
> package?

It looks like this one does not need special permissions to run:

guest@guixsd ~/dev/repo/guix [env]$
/gnu/store/3h3h9qr14l7m1cwxi9598jzc3qd5pzaf-traceroute-2.1.0/bin/traceroute
-n 9.9.9.9
traceroute to 9.9.9.9 (9.9.9.9), 30 hops max, 60 byte packets
[...]
 7  212.27.56.30  45.227 ms  41.741 ms  41.734 ms
 8  212.27.56.38  48.909 ms  49.304 ms  48.599 ms
 9  212.27.56.41  55.846 ms  50.545 ms  51.603 ms
10  195.66.225.238  54.105 ms  51.924 ms  56.401 ms
11  9.9.9.9  54.743 ms !X  50.748 ms !X  52.979 ms !X

guest@guixsd ~/dev/repo/guix [env]$
/gnu/store/ljwvyw48n2j28q0w96qykr04wcgwzcnh-inetutils-1.9.4/bin/traceroute
9.9.9.9
traceroute to 9.9.9.9 (9.9.9.9), 64 hops max
/gnu/store/ljwvyw48n2j28q0w96qykr04wcgwzcnh-inetutils-1.9.4/bin/traceroute:
socket: Operation not permitted

guest@guixsd ~/dev/repo/guix [env]$ sudo
/gnu/store/ljwvyw48n2j28q0w96qykr04wcgwzcnh-inetutils-1.9.4/bin/traceroute
9.9.9.9
traceroute to 9.9.9.9 (9.9.9.9), 64 hops max
[...]
  7   212.27.56.30  51.092ms  38.423ms  34.532ms
  8   212.27.56.38  44.764ms  41.931ms  44.963ms
  9   212.27.56.41  55.887ms  50.083ms  49.295ms
 10   195.66.225.238  51.184ms  62.666ms  57.945ms
 11   9.9.9.9  48.800ms !*  48.870ms !*  61.399ms !*

guest@guixsd ~/dev/repo/guix [env]$ ls -lh
/gnu/store/3h3h9qr14l7m1cwxi9598jzc3qd5pzaf-traceroute-2.1.0/bin/traceroute
/gnu/store/ljwvyw48n2j28q0w96qykr04wcgwzcnh-inetutils-1.9.4/bin/traceroute
-r-xr-xr-x 8 root root 85K Jan  1  1970
/gnu/store/3h3h9qr14l7m1cwxi9598jzc3qd5pzaf-traceroute-2.1.0/bin/traceroute
-r-xr-xr-x 2 root root 70K Jan  1  1970
/gnu/store/ljwvyw48n2j28q0w96qykr04wcgwzcnh-inetutils-1.9.4/bin/traceroute
Vincent Legoll Dec. 28, 2020, 2:45 p.m. UTC | #6
ping ?

Anything I should add ?
Christopher Baines Jan. 1, 2021, 12:08 p.m. UTC | #7
Vincent Legoll <vincent.legoll@gmail.com> writes:

> ping ?
>
> Anything I should add ?

This traceroute implementation looks to be particularly difficult to
build, just searching the web for some of the errors brings up other
people having problems with it (like [1]).

1: https://patchwork.ozlabs.org/project/buildroot/patch/1539902241-10211-1-git-send-email-sergio.prado@e-labworks.com/

Some comments though, I'd suggest transforming what you're doing with
make flags from modifying the phases to adding to the #:make-flags
argument, so something like this:

       #:make-flags
       (list (string-append "LIBRARY_PATH="
                            (assoc-ref %build-inputs "libc")
                            "/lib")
             (string-append "CFLAGS=-I"
                            (assoc-ref %build-inputs "kernel-headers")
                            "/include")
             "LDFLAGS=-lm -L../libsupp"
             (string-append "prefix=" (assoc-ref %outputs "out")))

What I've also done here is used the %build-inputs alist, which includes
the implicit libc and kernel-headers inputs, so you can remove those
inputs from the package definition.

As for the -lm issue with the Makefile, that's pretty frustrating. The
best thing I could come up with is something like this:

             (substitute* "default.rules"
               ((" \\$\\(LIBDEPS\\)") "$(filter-out -l%,$(LIBDEPS))"))

That has the advantage of still passing the -lm flag to gcc, and just
avoiding make tripping up over it.

Finally, I think the license might be gpl2+, with lgpl2.1+ for libsupp,
so it would be good to list both of those, with a comment describing
what the lgpl license applies to.

Could you send an updated patch?

Thanks,

Chris
Vincent Legoll Jan. 11, 2021, 4:31 p.m. UTC | #8
Hello,

following this is an updated patch, with
Christopher's feddback applied.

The nice thing is it now builds properly
without the LIBRABRY_PATH and the other
hacks. The licenses should be also good
now.

Is this OK ?
diff mbox series

Patch

From 5252f45030c9d725befcba698b0e5e9f9c49e00d Mon Sep 17 00:00:00 2001
From: Vincent Legoll <vincent.legoll@gmail.com>
Date: Sat, 7 Mar 2020 00:05:39 +0100
Subject: [PATCH] gnu: Add traceroute.

* gnu/packages/networking.scm (traceroute): New variable.
---
 gnu/packages/networking.scm | 45 +++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/gnu/packages/networking.scm b/gnu/packages/networking.scm
index eddfffd662..92b6391a53 100644
--- a/gnu/packages/networking.scm
+++ b/gnu/packages/networking.scm
@@ -2864,6 +2864,51 @@  Such interfaces are useful for VPN software, virtualization, emulation,
 simulation, and a number of other applications.")
     (license license:gpl2)))
 
+(define-public traceroute
+  (package
+    (name "traceroute")
+    (version "2.1.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "mirror://sourceforge/traceroute/traceroute/"
+               "traceroute-" version "/traceroute-" version ".tar.gz"))
+       (sha256
+        (base32 "1dh32vcfawkl1p9g4ral1p0camds4paqr8db1kaqxwyk6hmd4s9n"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f ; No tests.
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'patch-make
+           (lambda _
+               (substitute* "Make.rules"
+                 ((" -lm ") " "))
+             #t))
+         (replace 'build
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let* ((libglibc (assoc-ref inputs "glibc"))
+                    (headers (assoc-ref inputs "linux-libre-headers")))
+               (invoke "make" "LDFLAGS=-lm -L../libsupp"
+                              (string-append "LIBRARY_PATH=" libglibc "/lib")
+                              (string-append "CFLAGS=-I" headers "/include")))))
+         (replace 'install
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (invoke "make" (string-append "prefix=" out) "install"))))
+         (delete 'bootstrap)            ;there is no configure.ac file
+         (delete 'configure))))         ;there is no configure script
+    (native-inputs
+     `(("glibc" ,glibc)
+       ("linux-libre-headers" ,linux-libre-headers)))
+    (home-page "http://traceroute.sourceforge.net/")
+    (synopsis "Tracks the route taken by packets over an IP network")
+    (description "Traceroute tracks the route packets taken from an IP network
+on their way to a given host.  It utilizes the IP protocol's time to live (TTL)
+field and attempts to elicit an ICMP TIME_EXCEEDED response from each gateway
+along the path to the host.")
+    (license license:gpl2)))
+
 (define-public vde2
   (package
     (name "vde2")
-- 
2.25.1