[PATCH]: gnu: vpnc: Fix cross-compilation.

DoneSubmitted by Jean Pierre De Jesus DIAZ.
Details
3 participants
  • Ludovic Courtès
  • Maxime Devos
  • Jean Pierre De Jesus DIAZ
Owner
unassigned
Severity
normal
J
J
Jean Pierre De Jesus DIAZ wrote on 27 Jun 12:52 +0200
(name . guix-patches@gnu.org)(address . guix-patches@gnu.org)
FLlgKC6siW3VOq_B4lWQxjFA3AAfEeBHTzV6qw0FIAP_isJ8bLu0QF0hr3LNVzfW2lre7jAAb3AHD4UgIpGfGQDdGhtSSYwQ386OVu_U5tE=@jeandudey.tech
Fix cross-compilation for `vpnc'.

The error was because the `Makefile' tried to execute the resulting binary and
failed as a result. This is done to generate the manpage.

The solution I found was to compile twice the binary, one for the host and the
other for the target, this way the manpage is generated and installed first and
the binary for the target is built later. When not cross-compiling this is not
done.

The error can be seen by executing:

guix build vpnc \
--target=aarch64-linux-gnu

I'm not entirely sure that I've made a correct git message, so feel free to
modify it if doesn't match the standards.


Jean-Pierre De Jesus DIAZ
From d9379ceef2a7f6ed7bf49839ed066eca06d2b874 Mon Sep 17 00:00:00 2001
Message-Id: <d9379ceef2a7f6ed7bf49839ed066eca06d2b874.1656326922.git.me@jeandudey.tech>
From: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
Date: Mon, 27 Jun 2022 12:41:35 +0200
Subject: [PATCH] gnu: vpnc: Fix cross-compilation.

* gnu/packages/vpn.scm (vpnc): Fix cross-compilation of package. Use
G-Exps. Remove substitutions in favour of `#:make-flags`. Fix manpage
generation error when cross-compiling, as the manpage generation
depends on the executable being built for the host machine it is built
twice for the host and the target machine, when not cross-compiling
the package is built only one time. Add bsd-2 to license section and
list the files as comments that are bsd-2. Remove duplicate
installation of license files.
---
gnu/packages/vpn.scm | 95 +++++++++++++++++++++++++++++++++++---------
1 file changed, 76 insertions(+), 19 deletions(-)

Toggle diff (123 lines)
diff --git a/gnu/packages/vpn.scm b/gnu/packages/vpn.scm
index e33821c97f..01f29996f2 100644
--- a/gnu/packages/vpn.scm
+++ b/gnu/packages/vpn.scm
@@ -21,6 +21,7 @@
 ;;; Copyright © 2022 Josselin Poiret <josselin.poiret@protonmail.ch>
 ;;; Copyright © 2022 Lu hui <luhux76@gmail.com>
 ;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2022 Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -477,25 +478,76 @@ (define-public vpnc
             (sha256 (base32
                      "1128860lis89g1s21hqxvap2nq426c9j4bvgghncc1zj0ays7kj6"))))
    (build-system gnu-build-system)
-   (inputs (list libgcrypt perl vpnc-scripts))
+   ;; libgcrypt and vpnc-scripts are duplicated on both inputs because when
+   ;; cross-compiling we build vpnc for the host (to generate the manpage)
+   ;; and the target system.
+   (native-inputs (list libgcrypt perl vpnc-scripts))
+   (inputs (list libgcrypt vpnc-scripts))
    (arguments
-    `(#:tests? #f ; there is no check target
-      #:phases
-      (modify-phases %standard-phases
-        (add-after 'unpack 'use-store-paths
-          (lambda* (#:key inputs outputs #:allow-other-keys)
-            (let ((out          (assoc-ref outputs "out"))
-                  (vpnc-scripts (assoc-ref inputs  "vpnc-scripts")))
-              (substitute* "config.c"
-                (("/etc/vpnc/vpnc-script")
-                 (string-append vpnc-scripts "/etc/vpnc/vpnc-script")))
-              (substitute* "Makefile"
-                (("ETCDIR=.*")
-                 (string-append "ETCDIR=" out "/etc/vpnc\n"))
-                (("PREFIX=.*")
-                 (string-append "PREFIX=" out "\n")))
-              #t)))
-        (delete 'configure))))          ; no configure script
+     (list #:tests? #f ;; There is no check target
+           #:make-flags
+           #~(let ((out (assoc-ref %outputs "out")))
+               (list (string-append "CC=" #$(cc-for-target))
+                     (string-append "ETCDIR=" out "/etc/vpnc")
+                     (string-append "PREFIX=" out)))
+           #:phases
+           #~(modify-phases %standard-phases
+               (delete 'configure) ;; No configure script.
+               (add-after 'unpack 'use-store-paths
+                 (lambda* (#:key inputs outputs #:allow-other-keys)
+                   (let ((vpnc-scripts (assoc-ref inputs  "vpnc-scripts")))
+                     (substitute* "config.c"
+                       (("/etc/vpnc/vpnc-script")
+                        (string-append vpnc-scripts "/etc/vpnc/vpnc-script"))))))
+               (add-before 'build 'build-manpage
+                 (lambda* (#:key outputs parallel-build? target
+                           #:allow-other-keys)
+                   ;; The Makefile tries to generate the manpage by executing
+                   ;; the resulting binary, so, when cross-compiling the vpnc
+                   ;; package must be built first on the host to generate the
+                   ;; manpage. This step is not necessary when the target is
+                   ;; the host.
+                   (when target
+                     (apply invoke "make" "vpnc.8" "CC=gcc"
+                            (if parallel-build?
+                               (list "-j" (number->string (parallel-job-count)))
+                               '()))
+                     (install-file "vpnc.8"
+                                   (string-append (assoc-ref outputs "out")
+                                                  "/share/man/man8"))
+                     (invoke "make" "clean"))))
+               (replace 'build
+                 (lambda* (#:key inputs make-flags parallel-build? target
+                           #:allow-other-keys)
+                   ;; When cross-compiling, the bash script 'libgcrypt-config'
+                   ;; must be accessible during the configure phase.
+                   (when target
+                     (setenv "PATH"
+                             (string-append
+                               (dirname
+                                 (search-input-file inputs
+                                                    "bin/libgcrypt-config"))
+                               ":" (getenv "PATH"))))
+                   (apply invoke "make" "vpnc" "cisco-decrypt" "vpnc-script"
+                          (append make-flags
+                                  ;; Build manpage only if not cross-compiling.
+                                  (if (not target) (list "vpnc.8") '())
+                                  (if parallel-build?
+                                    (list "-j" (number->string (parallel-job-count)))
+                                    '())))))
+               (add-before 'install 'patch-install
+                 (lambda* (#:key target #:allow-other-keys)
+                   ;; When cross-compiling the manpage is already installed by
+                   ;; this point.
+                   (when target
+                     (substitute* "Makefile"
+                       (("all : \\$\\(BINS\\) vpnc\\.8 vpnc-script")
+                        "all : $(BINS) vpnc-script")
+                       (("install -m644 vpnc\\.8.*") "")))
+                   ;; Remove installation of COPYING as 'install-license-files
+                   ;; phase does it with a proper version number.
+                   (substitute* "Makefile"
+                     (("install -m644 COPYING.*") "")))))))
    (synopsis "Client for Cisco VPN concentrators")
    (description
     "vpnc is a VPN client compatible with Cisco's EasyVPN equipment.
@@ -503,7 +555,12 @@ (define-public vpnc
 shared-secret IPSec authentication with Xauth, AES (256, 192, 128), 3DES,
 1DES, MD5, SHA1, DH1/2/5 and IP tunneling.  It runs entirely in userspace.
 Only \"Universal TUN/TAP device driver support\" is needed in the kernel.")
-   (license license:gpl2+) ; some file are bsd-2, see COPYING
+   (license (list license:gpl2+
+                  ;; dh.c
+                  ;; dh.h
+                  ;; math_group.c
+                  ;; math_group.h
+                  license:bsd-2))
    (home-page "https://www.unix-ag.uni-kl.de/~massar/vpnc/")))
 
 (define-public vpnc-scripts
-- 
2.36.1
M
M
Maxime Devos wrote on 27 Jun 13:27 +0200
e0cdb67c368e01d028063d9e9d824735031f8c00.camel@telenet.be
Jean Pierre De Jesus DIAZ via Guix-patches via schreef op ma 27-06-2022
om 10:52 [+0000]:
Toggle quote (15 lines)
> +               (replace 'build
> +                 (lambda* (#:key inputs make-flags parallel-build?
> target
> +                           #:allow-other-keys)
> +                   ;; When cross-compiling, the bash script
> 'libgcrypt-config'
> +                   ;; must be accessible during the configure phase.
> +                   (when target
> +                     (setenv "PATH"
> +                             (string-append
> +                               (dirname
> +                                 (search-input-file inputs
> +                                                    "bin/libgcrypt-
> config"))

It would be simpler to replace 'libgcrypt-config --libs' by 'pkg-config
--libs' (with a substitute*, post-unpack) and likewise for
'libgcrypt-config --libs', to avoid executing a script compiled for
another architecture locally (it works because of a preceding $(shell
..., though doesn't seem great to me).

(Additionally, maybe upstream would be interested in pkg-config which
mostly just works when cross-compiling, in constrast to ...-config
scripts?)

Toggle quote (2 lines)
> + #~(let ((out (assoc-ref %outputs "out")))

If you're using G-exps, you might as well replace (assoc-ref %outputs
"out") by #$output. Also, there's no configure phase, it has been
removed.


Toggle quote (12 lines)
>+ ;; manpage. This step is not necessary when the target is
>+ ;; the host.
>+ (when target
>+ (apply invoke "make" "vpnc.8" "CC=gcc"
>+ (if parallel-build?
>+ (list "-j" (number->string (parallel-job-count)))
>+ '()))
>+ (install-file "vpnc.8"
>+ (string-append (assoc-ref outputs "out")
>+ "/share/man/man8"))
>+ (invoke "make" "clean"))))

You can simplify this by adding vpnc itself to the native-inputs (conditional
on %current-target-system to avoid a cycle) and when cross-compiling, copy the
man page from the native input to vpnc.8 (pre-build, instead of replacing build,
then you don't needd to fiddle with parallelism flags or the install phase).

Toggle quote (1 lines)
>+ ;; Remove installation of COPYING as 'install-
license-files
Toggle quote (4 lines)
>+ ;; phase does it with a proper version number.
>+ (substitute* "Makefile"
>+ (("install -m644 COPYING.*") "")))))))

Independent change, so for a separate commit. Also, I don't think it's
worth it to remove the double installation -- we would be deviating
from upstream and at most some KB would be saved but we have automated
depulication. Or maybe it's nice for consistency, dunno.

Toggle quote (7 lines)
>+ (license (list license:gpl2+
>+ ;; dh.c
>+ ;; dh.h
>+ ;; math_group.c
>+ ;; math_group.h
>+ license:bsd-2))

Again independent change -- I don't think it was necessary to mention
the file names (but I don't think they have to be removed either). More
precise license information looks nice.

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

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYrmUHxccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7pZnAQD2W4SlMUm3Iwi8elCBxCpA2OHj
+fZ2uwRWHpfPCrykowEAs2NcSBjerhkOdcL31Qk/ePh83HlM8ctqBNWC/3vSswU=
=pAPA
-----END PGP SIGNATURE-----


J
J
Jean Pierre De Jesus DIAZ wrote on 29 Jun 13:04 +0200
[PATCH]: gnu: vpnc: Fix cross-compilation.
(name . 56253@debbugs.gnu.org)(address . 56253@debbugs.gnu.org)
GLlJUa75SYS6xoV29rej4ulOY7ojlZM7_CrnbERoAxpINvvOytcrLYkp6BWh8ABerbqWLR1pc41-yg5Ru5eNTFknSiHxLL2UL6fQD5p9Nww=@jeandudey.tech
Thanks for the review!

Did not know that packages could have themselves as an input.
Added it and modified the phases accordingly and made the use
of `pkg-config' in the build.

Made a separate patch for the license change.

And, I will try to push of `pkg-config' usage on upstream by
sending a patch (and hopefully reduce substitutions on the
package).

Jean-Pierre De Jesus DIAZ
From 7fdc511ecb23a79a6b701f972864349db5247467 Mon Sep 17 00:00:00 2001
Message-Id: <7fdc511ecb23a79a6b701f972864349db5247467.1656500364.git.me@jeandudey.tech>
In-Reply-To: <e4c1daacb42b56099ccee3f80ec022980f19efc1.1656500364.git.me@jeandudey.tech>
References: <e4c1daacb42b56099ccee3f80ec022980f19efc1.1656500364.git.me@jeandudey.tech>
From: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
Date: Wed, 29 Jun 2022 12:57:02 +0200
Subject: [PATCH 2/2] gnu: vpnc: Add bsd-2 license.

* gnu/packages/vpn.scm (vpnc)[license]: Add bsd-2.
---
gnu/packages/vpn.scm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Toggle diff (15 lines)
diff --git a/gnu/packages/vpn.scm b/gnu/packages/vpn.scm
index c4399f232b..19c2837a71 100644
--- a/gnu/packages/vpn.scm
+++ b/gnu/packages/vpn.scm
@@ -547,7 +547,7 @@ (define-public vpnc
 shared-secret IPSec authentication with Xauth, AES (256, 192, 128), 3DES,
 1DES, MD5, SHA1, DH1/2/5 and IP tunneling.  It runs entirely in userspace.
 Only \"Universal TUN/TAP device driver support\" is needed in the kernel.")
-   (license license:gpl2+) ; some file are bsd-2, see COPYING
+   (license (list license:gpl2+ license:bsd-2))
    (home-page "https://www.unix-ag.uni-kl.de/~massar/vpnc/")))
 
 (define-public vpnc-scripts
-- 
2.36.1
From e4c1daacb42b56099ccee3f80ec022980f19efc1 Mon Sep 17 00:00:00 2001
Message-Id: <e4c1daacb42b56099ccee3f80ec022980f19efc1.1656500364.git.me@jeandudey.tech>
From: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
Date: Wed, 29 Jun 2022 12:51:55 +0200
Subject: [PATCH 1/2] gnu: vpnc: Fix cross-compilation.

* gnu/packages/vpn.scm (vpnc): Fix cross-compilation.
[native-inputs]: Add conditional input of `this-package' (vpnc)
to reuse the man page and add `pkg-config'.
[arguments]: Use G-Expressions.
[arguments]: Make use of `make-flags' instead of using substitutions.
[arguments]: Remove unneeded deletion of `configure'.
[arguments]: Use `pkg-config' to search for libgcrypt.
---
gnu/packages/vpn.scm | 80 ++++++++++++++++++++++++++++++++++----------
1 file changed, 62 insertions(+), 18 deletions(-)

Toggle diff (101 lines)
diff --git a/gnu/packages/vpn.scm b/gnu/packages/vpn.scm
index e33821c97f..c4399f232b 100644
--- a/gnu/packages/vpn.scm
+++ b/gnu/packages/vpn.scm
@@ -21,6 +21,7 @@
 ;;; Copyright © 2022 Josselin Poiret <josselin.poiret@protonmail.ch>
 ;;; Copyright © 2022 Lu hui <luhux76@gmail.com>
 ;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2022 Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -477,25 +478,68 @@ (define-public vpnc
             (sha256 (base32
                      "1128860lis89g1s21hqxvap2nq426c9j4bvgghncc1zj0ays7kj6"))))
    (build-system gnu-build-system)
-   (inputs (list libgcrypt perl vpnc-scripts))
+   (native-inputs (append (list perl pkg-config vpnc-scripts)
+                          (if (%current-target-system)
+                            (list this-package)
+                            '())))
+   (inputs (list libgcrypt vpnc-scripts))
    (arguments
-    `(#:tests? #f ; there is no check target
-      #:phases
-      (modify-phases %standard-phases
-        (add-after 'unpack 'use-store-paths
-          (lambda* (#:key inputs outputs #:allow-other-keys)
-            (let ((out          (assoc-ref outputs "out"))
-                  (vpnc-scripts (assoc-ref inputs  "vpnc-scripts")))
-              (substitute* "config.c"
-                (("/etc/vpnc/vpnc-script")
-                 (string-append vpnc-scripts "/etc/vpnc/vpnc-script")))
-              (substitute* "Makefile"
-                (("ETCDIR=.*")
-                 (string-append "ETCDIR=" out "/etc/vpnc\n"))
-                (("PREFIX=.*")
-                 (string-append "PREFIX=" out "\n")))
-              #t)))
-        (delete 'configure))))          ; no configure script
+     (list #:tests? #f ;; There is no check target
+           #:make-flags
+           #~(list (string-append "CC=" #$(cc-for-target))
+                   (string-append "ETCDIR=" #$output "/etc/vpnc")
+                   (string-append "PREFIX=" #$output))
+           #:phases
+           #~(modify-phases %standard-phases
+               (delete 'configure) ;; No configure script.
+               (add-after 'unpack 'use-store-paths
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   (let ((vpnc-scripts (assoc-ref inputs  "vpnc-scripts")))
+                     (substitute* "config.c"
+                       (("/etc/vpnc/vpnc-script")
+                        (string-append vpnc-scripts
+                                       "/etc/vpnc/vpnc-script"))))))
+               (add-after 'unpack 'patch-Makefile
+                 (lambda* (#:key target #:allow-other-keys)
+                   (let* ((pkg-config #$(pkg-config-for-target))
+                          (includedir (string-append pkg-config
+                                                     " --variable=includedir"
+                                                     " libgcrypt"))
+                          (cflags (string-append pkg-config
+                                                 " --cflags"
+                                                 " liggcrypt"))
+                          (libdir (string-append pkg-config
+                                                 " --variable=libdir"
+                                                 " libgcrypt"))
+                          (libs (string-append pkg-config
+                                               " --libs"
+                                               " libgcrypt")))
+                     (substitute* "Makefile"
+                       (("\\$\\(shell libgcrypt-config --cflags\\)")
+                        (string-append "-I$(shell " includedir ") "
+                                       "$(shell " cflags ")"))
+                       (("\\$\\(shell libgcrypt-config --libs\\)")
+                        (string-append
+                          "-L$(shell " libdir ") "
+                          "$(shell " libs ")")))
+                     ;; When cross-compiling the manpage can't be generated as the
+                     ;; Makefile needs to execute the resulting `vpnc' binary.
+                     (when target
+                       (substitute* "Makefile"
+                         (("all : \\$\\(BINS\\) vpnc\\.8 vpnc-script")
+                          "all : $(BINS) vpnc-script")
+                         (("install -m644 vpnc\\.8.*") ""))))))
+               (add-after 'unpack 'install-manpage
+                 (lambda* (#:key native-inputs inputs target
+                           #:allow-other-keys)
+                   ;; As the manpage is not generated. Instead install it from
+                   ;; the input vpnc package.
+                   (when target
+                     (let* ((vpnc (assoc-ref native-inputs "vpnc"))
+                            (man (string-append vpnc
+                                                "/share/man/man8/vpnc.8.gz"))
+                            (output (string-append #$output "/share/man/man8")))
+                       (install-file man output))))))))
    (synopsis "Client for Cisco VPN concentrators")
    (description
     "vpnc is a VPN client compatible with Cisco's EasyVPN equipment.
-- 
2.36.1
M
M
Maxime Devos wrote on 29 Jun 13:09 +0200
f7660ac1ea35596650f9f5dbc22d784b0775bab8.camel@telenet.be
Maxime Devos schreef op ma 27-06-2022 om 13:27 [+0200]:
Toggle quote (4 lines)
> (Additionally, maybe upstream would be interested in pkg-config which
> mostly just works when cross-compiling, in constrast to ...-config
> scripts?)

TBC: those scripts can work, but things go messy if you both have a
native libgcrypt and a cross-compiled libgcrypt.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYrwy6RccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7n/HAP4u65tHQDPCx2YPSG3HOWrccdAN
efFY07QnGbAEYjLGHQEAwbZ+Qh3HBGqh8Rf23i0X1b0k1rSf9xSujrqN3OxSVwg=
=Iu2V
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 29 Jun 13:09 +0200
2e110844647d5ec64be97b3460210cc7f60a741b.camel@telenet.be
Jean Pierre De Jesus DIAZ via Guix-patches via schreef op wo 29-06-2022
om 11:04 [+0000]:
Toggle quote (4 lines)
> +                          (cflags (string-append pkg-config
> +                                                 " --cflags"
> +                                                 " liggcrypt"))

liggcrypt -> libgcrypt?
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYrwy+BccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7jHYAP9u5lMjGDXWeTIrZKASA0ECjT79
R+IZ5VR3IX9JB/FHRQD/ZQSfzjAivgi3JjcX1XG+k4jm61LeXgdewqqjZEsnAg4=
=K88z
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 29 Jun 20:35 +0200
(name . Jean Pierre De Jesus DIAZ)(address . me@jeandudey.tech)(name . 56253@debbugs.gnu.org)(address . 56253@debbugs.gnu.org)
34a13962a3091732e55861f32666c40339b8e8de.camel@telenet.be
Jean Pierre De Jesus DIAZ schreef op wo 29-06-2022 om 11:15 [+0000]:
Toggle quote (3 lines)
> Sorry, fixed the typo and re-built again to verify and everything is
> in order.

Was just a typo, no need for apologies :).

It looks good to me (though TBC: didn't compile it myself) but you seem
to have forgotten to keep 56253@debbugs.gnu.org in CC, so people that
can actually commit it haven't seen it, so you'll have to resend it.
(FWIW, reportedly the ‘reply all’ options of e-mail clients take care
of that)

Greeitngs,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYrybVhccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7uTrAQCojoFZ3jxtCaG8QVDF3oVAGplc
4HTL39wJM6upe9JqpAD/aknSgvHuwixX4CwcxoCrPhl9DGFLdf7oIsL1oi+oZwc=
=0igJ
-----END PGP SIGNATURE-----


J
J
Jean Pierre De Jesus DIAZ wrote on 29 Jun 21:01 +0200
(name . Maxime Devos)(address . maximedevos@telenet.be)(name . 56253@debbugs.gnu.org)(address . 56253@debbugs.gnu.org)
-NeN31Z3ZgphCpQMB6ZQBTc1zZD0Tujp0TnZr4EYreaQpMPRWBw5U2HHQlg9DJqtiQS3YMNR_Lgq2wgloWBfaTVcCCqRqDIgRdynhsYSOIw=@jeandudey.tech
Has happened multiple times, always using normal Reply despite
getting same results :D.

Added patches again.

Jean-Pierre De Jesus DIAZ


------- Original Message -------
On Wednesday, June 29th, 2022 at 8:35 PM, Maxime Devos <maximedevos@telenet.be> wrote:


Toggle quote (16 lines)
> Jean Pierre De Jesus DIAZ schreef op wo 29-06-2022 om 11:15 [+0000]:
>
> > Sorry, fixed the typo and re-built again to verify and everything is
> > in order.
>
>
> Was just a typo, no need for apologies :).
>
> It looks good to me (though TBC: didn't compile it myself) but you seem
> to have forgotten to keep 56253@debbugs.gnu.org in CC, so people that
> can actually commit it haven't seen it, so you'll have to resend it.
> (FWIW, reportedly the ‘reply all’ options of e-mail clients take care
> of that)
>
> Greeitngs,
> Maxime.
From 3d3cb006c249a303c59300f8760e7f7b103b1037 Mon Sep 17 00:00:00 2001
Message-Id: <3d3cb006c249a303c59300f8760e7f7b103b1037.1656501265.git.me@jeandudey.tech>
From: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
Date: Wed, 29 Jun 2022 12:51:55 +0200
Subject: [PATCH 1/2] gnu: vpnc: Fix cross-compilation.

* gnu/packages/vpn.scm (vpnc): Fix cross-compilation.
[native-inputs]: Add conditional input of `this-package' (vpnc)
to reuse the man page and add `pkg-config'.
[arguments]: Use G-Expressions.
[arguments]: Make use of `make-flags' instead of using substitutions.
[arguments]: Remove unneeded deletion of `configure'.
[arguments]: Use `pkg-config' to search for libgcrypt.
---
gnu/packages/vpn.scm | 80 ++++++++++++++++++++++++++++++++++----------
1 file changed, 62 insertions(+), 18 deletions(-)

Toggle diff (101 lines)
diff --git a/gnu/packages/vpn.scm b/gnu/packages/vpn.scm
index e33821c97f..807e741bc0 100644
--- a/gnu/packages/vpn.scm
+++ b/gnu/packages/vpn.scm
@@ -21,6 +21,7 @@
 ;;; Copyright © 2022 Josselin Poiret <josselin.poiret@protonmail.ch>
 ;;; Copyright © 2022 Lu hui <luhux76@gmail.com>
 ;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2022 Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -477,25 +478,68 @@ (define-public vpnc
             (sha256 (base32
                      "1128860lis89g1s21hqxvap2nq426c9j4bvgghncc1zj0ays7kj6"))))
    (build-system gnu-build-system)
-   (inputs (list libgcrypt perl vpnc-scripts))
+   (native-inputs (append (list perl pkg-config vpnc-scripts)
+                          (if (%current-target-system)
+                            (list this-package)
+                            '())))
+   (inputs (list libgcrypt vpnc-scripts))
    (arguments
-    `(#:tests? #f ; there is no check target
-      #:phases
-      (modify-phases %standard-phases
-        (add-after 'unpack 'use-store-paths
-          (lambda* (#:key inputs outputs #:allow-other-keys)
-            (let ((out          (assoc-ref outputs "out"))
-                  (vpnc-scripts (assoc-ref inputs  "vpnc-scripts")))
-              (substitute* "config.c"
-                (("/etc/vpnc/vpnc-script")
-                 (string-append vpnc-scripts "/etc/vpnc/vpnc-script")))
-              (substitute* "Makefile"
-                (("ETCDIR=.*")
-                 (string-append "ETCDIR=" out "/etc/vpnc\n"))
-                (("PREFIX=.*")
-                 (string-append "PREFIX=" out "\n")))
-              #t)))
-        (delete 'configure))))          ; no configure script
+     (list #:tests? #f ;; There is no check target
+           #:make-flags
+           #~(list (string-append "CC=" #$(cc-for-target))
+                   (string-append "ETCDIR=" #$output "/etc/vpnc")
+                   (string-append "PREFIX=" #$output))
+           #:phases
+           #~(modify-phases %standard-phases
+               (delete 'configure) ;; No configure script.
+               (add-after 'unpack 'use-store-paths
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   (let ((vpnc-scripts (assoc-ref inputs  "vpnc-scripts")))
+                     (substitute* "config.c"
+                       (("/etc/vpnc/vpnc-script")
+                        (string-append vpnc-scripts
+                                       "/etc/vpnc/vpnc-script"))))))
+               (add-after 'unpack 'patch-Makefile
+                 (lambda* (#:key target #:allow-other-keys)
+                   (let* ((pkg-config #$(pkg-config-for-target))
+                          (includedir (string-append pkg-config
+                                                     " --variable=includedir"
+                                                     " libgcrypt"))
+                          (cflags (string-append pkg-config
+                                                 " --cflags"
+                                                 " libgcrypt"))
+                          (libdir (string-append pkg-config
+                                                 " --variable=libdir"
+                                                 " libgcrypt"))
+                          (libs (string-append pkg-config
+                                               " --libs"
+                                               " libgcrypt")))
+                     (substitute* "Makefile"
+                       (("\\$\\(shell libgcrypt-config --cflags\\)")
+                        (string-append "-I$(shell " includedir ") "
+                                       "$(shell " cflags ")"))
+                       (("\\$\\(shell libgcrypt-config --libs\\)")
+                        (string-append
+                          "-L$(shell " libdir ") "
+                          "$(shell " libs ")")))
+                     ;; When cross-compiling the manpage can't be generated as the
+                     ;; Makefile needs to execute the resulting `vpnc' binary.
+                     (when target
+                       (substitute* "Makefile"
+                         (("all : \\$\\(BINS\\) vpnc\\.8 vpnc-script")
+                          "all : $(BINS) vpnc-script")
+                         (("install -m644 vpnc\\.8.*") ""))))))
+               (add-after 'unpack 'install-manpage
+                 (lambda* (#:key native-inputs inputs target
+                           #:allow-other-keys)
+                   ;; As the manpage is not generated. Instead install it from
+                   ;; the input vpnc package.
+                   (when target
+                     (let* ((vpnc (assoc-ref native-inputs "vpnc"))
+                            (man (string-append vpnc
+                                                "/share/man/man8/vpnc.8.gz"))
+                            (output (string-append #$output "/share/man/man8")))
+                       (install-file man output))))))))
    (synopsis "Client for Cisco VPN concentrators")
    (description
     "vpnc is a VPN client compatible with Cisco's EasyVPN equipment.
-- 
2.36.1
From d94babd41579d19d9cbbb2cca2285e0f3c8c1e77 Mon Sep 17 00:00:00 2001
Message-Id: <d94babd41579d19d9cbbb2cca2285e0f3c8c1e77.1656501265.git.me@jeandudey.tech>
In-Reply-To: <3d3cb006c249a303c59300f8760e7f7b103b1037.1656501265.git.me@jeandudey.tech>
References: <3d3cb006c249a303c59300f8760e7f7b103b1037.1656501265.git.me@jeandudey.tech>
From: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
Date: Wed, 29 Jun 2022 12:57:02 +0200
Subject: [PATCH 2/2] gnu: vpnc: Add bsd-2 license.

* gnu/packages/vpn.scm (vpnc)[license]: Add bsd-2.
---
gnu/packages/vpn.scm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Toggle diff (15 lines)
diff --git a/gnu/packages/vpn.scm b/gnu/packages/vpn.scm
index 807e741bc0..259d21cb01 100644
--- a/gnu/packages/vpn.scm
+++ b/gnu/packages/vpn.scm
@@ -547,7 +547,7 @@ (define-public vpnc
 shared-secret IPSec authentication with Xauth, AES (256, 192, 128), 3DES,
 1DES, MD5, SHA1, DH1/2/5 and IP tunneling.  It runs entirely in userspace.
 Only \"Universal TUN/TAP device driver support\" is needed in the kernel.")
-   (license license:gpl2+) ; some file are bsd-2, see COPYING
+   (license (list license:gpl2+ license:bsd-2))
    (home-page "https://www.unix-ag.uni-kl.de/~massar/vpnc/")))
 
 (define-public vpnc-scripts
-- 
2.36.1
L
L
Ludovic Courtès wrote on 4 Jul 12:28 +0200
Re: bug#56253: [PATCH]: gnu: vpnc: Fix cross-compilation.
(name . Jean Pierre De Jesus DIAZ)(address . me@jeandudey.tech)
877d4tf9ys.fsf_-_@gnu.org
Hi,

Jean Pierre De Jesus DIAZ <me@jeandudey.tech> skribis:

Toggle quote (14 lines)
> From 3d3cb006c249a303c59300f8760e7f7b103b1037 Mon Sep 17 00:00:00 2001
> Message-Id: <3d3cb006c249a303c59300f8760e7f7b103b1037.1656501265.git.me@jeandudey.tech>
> From: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
> Date: Wed, 29 Jun 2022 12:51:55 +0200
> Subject: [PATCH 1/2] gnu: vpnc: Fix cross-compilation.
>
> * gnu/packages/vpn.scm (vpnc): Fix cross-compilation.
> [native-inputs]: Add conditional input of `this-package' (vpnc)
> to reuse the man page and add `pkg-config'.
> [arguments]: Use G-Expressions.
> [arguments]: Make use of `make-flags' instead of using substitutions.
> [arguments]: Remove unneeded deletion of `configure'.
> [arguments]: Use `pkg-config' to search for libgcrypt.

[...]

Toggle quote (10 lines)
> From d94babd41579d19d9cbbb2cca2285e0f3c8c1e77 Mon Sep 17 00:00:00 2001
> Message-Id: <d94babd41579d19d9cbbb2cca2285e0f3c8c1e77.1656501265.git.me@jeandudey.tech>
> In-Reply-To: <3d3cb006c249a303c59300f8760e7f7b103b1037.1656501265.git.me@jeandudey.tech>
> References: <3d3cb006c249a303c59300f8760e7f7b103b1037.1656501265.git.me@jeandudey.tech>
> From: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
> Date: Wed, 29 Jun 2022 12:57:02 +0200
> Subject: [PATCH 2/2] gnu: vpnc: Add bsd-2 license.
>
> * gnu/packages/vpn.scm (vpnc)[license]: Add bsd-2.

Applied, thanks, and thanks Maxime for reviewing!

Ludo’.
Closed
?
Your comment

This issue is archived.

To comment on this conversation send email to 56253@debbugs.gnu.org