[PATCH] gnu: Add n2n.

  • Done
  • quality assurance status badge
Details
3 participants
  • ??
  • Nicolas Goaziou
  • Maxime Devos
Owner
unassigned
Submitted by
??
Severity
normal
?
(address . guix-patches@gnu.org)
CAGNyvehn=j+kGhwQ-8E0qOocfdYUDvnXU0tCYnaB2v9847QuLQ@mail.gmail.com
From c9d69917251e377c3291443dda0090cfa5e46956 Mon Sep 17 00:00:00 2001
From: Lu Hui <luhux76@gmail.com>
Date: Mon, 17 Jan 2022 10:48:44 +0800
Subject: [PATCH] gnu: Add n2n.

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

Toggle diff (55 lines)
diff --git a/gnu/packages/vpn.scm b/gnu/packages/vpn.scm
index 4ad555ef1b..542d6518fd 100644
--- a/gnu/packages/vpn.scm
+++ b/gnu/packages/vpn.scm
@@ -18,6 +18,7 @@
;;; Copyright © 2021 Domagoj Stolfa <ds815@gmx.com>
;;; Copyright © 2021 Raghav Gururajan <rg@raghavgururajan.name>
;;; Copyright © 2021 jgart <jgart@dismail.de>
+;;; Copyright © 2022 Lu hui <luhux76@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -1093,3 +1094,39 @@ (define-public xl2tpd
"xl2tpd is an implementation of the Layer 2 Tunnelling Protocol
(RFC 2661).
L2TP allows you to tunnel PPP over UDP.")
(license license:gpl2)))
+
+(define-public n2n-2
+ (package
+ (name "n2n")
+ (version "2.8")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/ntop/n2n")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1ph2npvnqh1xnmkp96pdzpxm033jkb8zznd3nc59l9arhn0pq4nv"))))
+ (build-system gnu-build-system)
+ (native-inputs (list autoconf automake))
+ (arguments
+ `(#:make-flags (list (string-append "PREFIX=" %output) "CC=gcc")
+ #:phases
+ (modify-phases %standard-phases
+ (add-before 'bootstrap 'move-configure
+ ;; don't execute configure script in bootstrap
+ (lambda* (#:key inputs #:allow-other-keys)
+ (substitute* "autogen.sh"
+ (("./configure") ""))))
+ (add-before 'configure 'fix-configure
+ (lambda* (#:key inputs #:allow-other-keys)
+ (substitute* "configure"
+ (("/bin/sh") (which "sh"))))))
+ #:tests? #f)) ;there is no check target
+ (home-page "https://github.com/ntop/n2n")
+ (synopsis "Peer-to-peer VPN client and server")
+ (description
+ "A light VPN software which makes it
+easy to create virtual networks bypassing intermediate firewalls.")
+ (license license:gpl3+)))
--
2.34.0
N
N
Nicolas Goaziou wrote on 28 Jan 2022 11:10
(name . ??)(address . luhux76@gmail.com)(address . 53319@debbugs.gnu.org)
87r18stbll.fsf@nicolasgoaziou.fr
Hello,

?? <luhux76@gmail.com> writes:

Toggle quote (2 lines)
> Subject: [PATCH] gnu: Add n2n.

Thank you. Some comments follow.

Toggle quote (2 lines)
> +(define-public n2n-2

I think the variable should be "n2n" only.

Toggle quote (4 lines)
> + (native-inputs (list autoconf automake))
> + (arguments
> + `(#:make-flags (list (string-append "PREFIX=" %output) "CC=gcc")

CC=gcc is not cross-compilation friendly. Also, %output is being phased
out. I suggest using G-expressions:

(arguments
(list
#:make-flags
#~(list (string-append "PREFIX=" #$output)
#$(string-append "CC=" (cc-for-target)))
...))

Toggle quote (3 lines)
> + #:phases
> + (modify-phases %standard-phases

If you use G-expressions, you'll need to start with:

#~(modify-phases %standard-phases
...)

Toggle quote (5 lines)
> + (add-before 'configure 'fix-configure
> + (lambda* (#:key inputs #:allow-other-keys)
> + (substitute* "configure"
> + (("/bin/sh") (which "sh"))))))

Instead of using `which', you can use `search-input-file':

(("/bin/sh") (search-input-file inputs "/bin/sh"))

Toggle quote (7 lines)
> + #:tests? #f)) ;there is no check target
> + (home-page "https://github.com/ntop/n2n")
> + (synopsis "Peer-to-peer VPN client and server")
> + (description
> + "A light VPN software which makes it
> +easy to create virtual networks bypassing intermediate firewalls.")

Description should consist of full sentences. I suggest:

n2n is a light VPN software which makes it easy to create virtual
networks bypassing intermediate firewalls.

Also, the package brings third-party software: libnatpmp and libupnp.
Would it be possible to unbundle them, since Guix already ships both?

Could you send an updated patch?

Regards,
--
Nicolas Goaziou
N
N
Nicolas Goaziou wrote on 22 Feb 2022 12:20
(name . ??)(address . luhux76@gmail.com)(address . 53319-done@debbugs.gnu.org)
87sfsb2ln0.fsf@nicolasgoaziou.fr
Hello,

?? <luhux76@gmail.com> writes:

Toggle quote (2 lines)
> Subject: [PATCH] gnu: Add n2n.

Thank you. I applied your patch with the changes below.
Toggle quote (3 lines)
>
> +(define-public n2n-2

I renamed it to n2n.

Toggle quote (2 lines)
> + (native-inputs (list autoconf automake))

I added pkg-config and bash-minimal.

Toggle quote (3 lines)
> + (arguments
> + `(#:make-flags (list (string-append "PREFIX=" %output) "CC=gcc")

Using G-expressions I wrote

#:make-flags
#~(list (string-append "PREFIX=" #$output)
(string-append "CC=" #$(cc-for-target)))
...

Toggle quote (3 lines)
> + (substitute* "configure"
> + (("/bin/sh") (which "sh"))))))

Here I wrote

(("/bin/sh") (search-inputs-file input "/bin/sh"))

Toggle quote (6 lines)
> + #:tests? #f)) ;there is no check target
> + (home-page "https://github.com/ntop/n2n")
> + (synopsis "Peer-to-peer VPN client and server")
> + (description
> + "A light VPN software which makes it

I turned the description into complete sentences.

Regards,
--
Nicolas Goaziou
Closed
M
M
Maxime Devos wrote on 22 Feb 2022 12:36
(address . 53319@debbugs.gnu.org)
c691ad56a7cd5c32b53487ba661d2d9881a589f6.camel@telenet.be
Nicolas Goaziou schreef op vr 28-01-2022 om 11:10 [+0100]:
Toggle quote (9 lines)
> > +         (add-before 'configure 'fix-configure
> > +           (lambda* (#:key inputs #:allow-other-keys)
> > +             (substitute* "configure"
> > +               (("/bin/sh") (which "sh"))))))
>
> Instead of using `which', you can use `search-input-file':
>
>   (("/bin/sh") (search-input-file inputs "/bin/sh")) 

'configure' is run during build, so for cross-compilation, a sh from
'native-inputs' shoud be used instead of 'inputs':

(("/bin/sh") (search-input-file (or native-inputs inputs) "/bin/sh"))

or simpler:

(("/bin/sh") (which "sh"))

Also, this package definition packages version 2.8. Why not package
the latest version instead? In the latest version, 'autogen.sh' does
not run "./configure" and hence 'move-configure' and 'fix-configure'
should not be necessary.

Also, looking at
it seems that n2n might not be bit-for-bit reproducible.

Greetings,
Maxime
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYhTKuBccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7gDaAPwLFUpDQgDwi0vnvd/jebJC9xZk
jKNygGJJe7tRhRXTfAEAuRPfq1qjnghlX9bvGcex/B8YvkhVeNRWpIpmsb/Gngg=
=UGQC
-----END PGP SIGNATURE-----


N
N
Nicolas Goaziou wrote on 22 Feb 2022 19:49
(name . Maxime Devos)(address . maximedevos@telenet.be)
87ilt63fep.fsf@nicolasgoaziou.fr
Hello,

Maxime Devos <maximedevos@telenet.be> writes:

Toggle quote (5 lines)
> 'configure' is run during build, so for cross-compilation, a sh from
> 'native-inputs' shoud be used instead of 'inputs':
>
> (("/bin/sh") (search-input-file (or native-inputs inputs) "/bin/sh"))

True, I keep forgetting about this. It would be more natural to use
(search-input-file native-inputs "/bin/sh"), but, IIRC, native-inputs
may be empty if we are not cross-compiling.

I will fix it.

Toggle quote (4 lines)
> or simpler:
>
> (("/bin/sh") (which "sh"))

IIUC, search-input-file is a replacement for `which', so that seems to
be going backwards.

Of course, if `which' is the preferred solution for package style, I'd
love to hear a confirmation about it.

Toggle quote (3 lines)
> Also, this package definition packages version 2.8. Why not package
> the latest version instead?

The OP waited one month without any feedback. I consider this is more
respectful to apply the patch in its current version rather than
requesting more changes now. YMMV.

Of course, the update can happen in a later, very welcome, patch.

Toggle quote (4 lines)
> Also, looking at
> <https://github.com/ntop/n2n/blob/472a9878f72299466ddbce2a232ea9e081159fa9/configure.seed#L94>,
> it seems that n2n might not be bit-for-bit reproducible.

I agree this package has room for improvement. Hopefully, ?? can have
a look at it.

Regards,
--
Nicolas Goaziou
?
(name . Nicolas Goaziou)(address . mail@nicolasgoaziou.fr)
CAGNyvej_2Sus+6Sbhb_DtLB81MZms_6TNEdpXEpQH3zXU+cdgQ@mail.gmail.com
Nicolas Goaziou <mail@nicolasgoaziou.fr> ?2022?2?22??? 18:49???
Toggle quote (45 lines)
>
> Hello,
>
> Maxime Devos <maximedevos@telenet.be> writes:
>
> > 'configure' is run during build, so for cross-compilation, a sh from
> > 'native-inputs' shoud be used instead of 'inputs':
> >
> > (("/bin/sh") (search-input-file (or native-inputs inputs) "/bin/sh"))
>
> True, I keep forgetting about this. It would be more natural to use
> (search-input-file native-inputs "/bin/sh"), but, IIRC, native-inputs
> may be empty if we are not cross-compiling.
>
> I will fix it.
>
> > or simpler:
> >
> > (("/bin/sh") (which "sh"))
>
> IIUC, search-input-file is a replacement for `which', so that seems to
> be going backwards.
>
> Of course, if `which' is the preferred solution for package style, I'd
> love to hear a confirmation about it.
>
> > Also, this package definition packages version 2.8. Why not package
> > the latest version instead?
>
> The OP waited one month without any feedback. I consider this is more
> respectful to apply the patch in its current version rather than
> requesting more changes now. YMMV.
>
> Of course, the update can happen in a later, very welcome, patch.
>
> > Also, looking at
> > <https://github.com/ntop/n2n/blob/472a9878f72299466ddbce2a232ea9e081159fa9/configure.seed#L94>,
> > it seems that n2n might not be bit-for-bit reproducible.
>
> I agree this package has room for improvement. Hopefully, ?? can have
> a look at it.
>
> Regards,
> --
> Nicolas Goaziou
From de6bd8d8dd3d4b14999361f66d15f0827ada0b1b Mon Sep 17 00:00:00 2001
From: Lu Hui <luhux76@gmail.com>
Date: Sun, 20 Mar 2022 20:13:13 +0800
Subject: [PATCH 4/4] gnu: n2n: Update to 3.0

* gnu/packages/vpn.scm (n2n): [version]: Update to 3.0.
---
gnu/packages/vpn.scm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Toggle diff (24 lines)
diff --git a/gnu/packages/vpn.scm b/gnu/packages/vpn.scm
index f066bfa689..6c63c3d671 100644
--- a/gnu/packages/vpn.scm
+++ b/gnu/packages/vpn.scm
@@ -299,7 +299,7 @@ (define-public gvpe
(define-public n2n
(package
(name "n2n")
- (version "2.8")
+ (version "3.0")
(source (origin
(method git-fetch)
(uri (git-reference
@@ -308,7 +308,7 @@ (define-public n2n
(file-name (git-file-name name version))
(sha256
(base32
- "1ph2npvnqh1xnmkp96pdzpxm033jkb8zznd3nc59l9arhn0pq4nv"))))
+ "0kgqmqcn6s2y2rxa0i6myq3sgk2aliv1gkfhzvn32zgym9rrqy9r"))))
(build-system gnu-build-system)
(arguments
(list
--
2.34.0
From f9f12ca9c8a890322385d0ad695f370e21f4465b Mon Sep 17 00:00:00 2001
From: Lu Hui <luhux76@gmail.com>
Date: Sun, 20 Mar 2022 19:45:33 +0800
Subject: [PATCH 2/4] gnu: n2n: remove hardcodepath

* gnu/packages/vpn.scm (n2n): [phases]: New phase
---
gnu/packages/vpn.scm | 7 +++++++
1 file changed, 7 insertions(+)

Toggle diff (20 lines)
diff --git a/gnu/packages/vpn.scm b/gnu/packages/vpn.scm
index 4b0e7d751a..db9e8cb059 100644
--- a/gnu/packages/vpn.scm
+++ b/gnu/packages/vpn.scm
@@ -327,6 +327,13 @@ (define-public n2n
(substitute* "configure.seed"
(("DATE=`date +\"%Y-%m-%d\"`")
"DATE=`TZ=utc date -d @0 +\"%Y-%m-%d\"`"))))
+ (add-before 'bootstrap 'remove-hardcodepath
+ (lambda _
+ (substitute* "configure.seed"
+ (("-I/usr/local/opt/openssl@1.1/include")
+ "")
+ (("-I/usr/local/opt/openssl@1.1/lib")
+ ""))))
(add-before 'configure 'fix-configure
(lambda* (#:key inputs native-inputs #:allow-other-keys)
(substitute* "configure"
--
2.34.0
From 85c40a89ea1458f5abc9ac8c22f4a6968b48decf Mon Sep 17 00:00:00 2001
From: Lu Hui <luhux76@gmail.com>
Date: Sun, 20 Mar 2022 20:07:23 +0800
Subject: [PATCH 3/4] gnu: n2n: add compression,AES crypto method support.

* gnu/packages/vpn.scm (n2n): [inputs]: Add zstd-lib libpcap openssl libcap.
---
gnu/packages/vpn.scm | 2 ++
1 file changed, 2 insertions(+)

Toggle diff (15 lines)
diff --git a/gnu/packages/vpn.scm b/gnu/packages/vpn.scm
index db9e8cb059..f066bfa689 100644
--- a/gnu/packages/vpn.scm
+++ b/gnu/packages/vpn.scm
@@ -340,6 +340,8 @@ (define-public n2n
(("/bin/sh")
(search-input-file (or native-inputs inputs) "/bin/sh"))))))
#:tests? #f)) ;there is no check target
+ (inputs
+ (list `(,zstd "lib") libpcap openssl libcap))
(native-inputs
(list autoconf automake bash-minimal pkg-config))
(home-page "https://github.com/ntop/n2n")
--
2.34.0
From a6c98dfaedebba172d451d62ba2d4c9b18aea3b8 Mon Sep 17 00:00:00 2001
From: Lu Hui <luhux76@gmail.com>
Date: Sun, 20 Mar 2022 19:16:52 +0800
Subject: [PATCH 1/4] gnu: n2n: more reproducible.

* gnu/packages/vpn.scm (n2n): [phases]: New Variable.
---
gnu/packages/vpn.scm | 5 +++++
1 file changed, 5 insertions(+)

Toggle diff (18 lines)
diff --git a/gnu/packages/vpn.scm b/gnu/packages/vpn.scm
index 5bf5a62481..4b0e7d751a 100644
--- a/gnu/packages/vpn.scm
+++ b/gnu/packages/vpn.scm
@@ -322,6 +322,11 @@ (define-public n2n
(lambda _
(substitute* "autogen.sh"
(("./configure") ""))))
+ (add-before 'bootstrap 'more-reproducible
+ (lambda _
+ (substitute* "configure.seed"
+ (("DATE=`date +\"%Y-%m-%d\"`")
+ "DATE=`TZ=utc date -d @0 +\"%Y-%m-%d\"`"))))
(add-before 'configure 'fix-configure
(lambda* (#:key inputs native-inputs #:allow-other-keys)
(substitute* "configure"
--
2.34.0
?