Subject: bug#26386: [PATCH 1/1] gnu: openconnect: Use a newer vpnc script.

From: Ludovic Courtès <[email-masked]>
Date: Thu, 6 Apr 2017 21:13:12 +0200

* gnu/packages/vpn.scm (openconnect)[native-inputs]: Add "vpnc-script".
[arguments]: Add 'copy-vpnc-script' phase.
---
 gnu/packages/vpn.scm | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/vpn.scm b/gnu/packages/vpn.scm
index efb46f73d..a46c1e25f 100644
--- a/gnu/packages/vpn.scm
+++ b/gnu/packages/vpn.scm
@@ -1,6 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2013 Andreas Enge <[email-masked]>
-;;; Copyright © 2013, 2016 Ludovic Courtès <[email-masked]>
+;;; Copyright © 2013, 2016, 2017 Ludovic Courtès <[email-masked]>
 ;;; Copyright © 2014 Eric Bavier <[email-masked]>
 ;;; Copyright © 2015 Jeff Mickey <[email-masked]>
 ;;; Copyright © 2016, 2017 Efraim Flashner <[email-masked]>
@@ -135,12 +135,36 @@ Only \"Universal TUN/TAP device driver support\" is needed in the kernel.")
       ("zlib" ,zlib)))
    (native-inputs
     `(("gettext" ,gettext-minimal)
-      ("pkg-config" ,pkg-config)))
+      ("pkg-config" ,pkg-config)
+      ("vpnc-script" ,(origin
+                        (method url-fetch)
+                        (uri
+                         "http://git.infradead.org/users/dwmw2/vpnc-scripts.git/\
+blob_plain/6f87b0fe7b20d802a0747cc310217920047d58d3:/vpnc-script")
+                        (sha256
+                         (base32
+                          "0v22x0bjfdawma1dwnjczz3bqifh6r8ys0lv5nhnwsghs1imk7hn"))))))
    (arguments
     `(#:configure-flags
       `(,(string-append "--with-vpnc-script="
-                        (assoc-ref %build-inputs "vpnc")
-                        "/etc/vpnc/vpnc-script"))))
+                        (string-append %output "/etc/vpnc/vpnc-script")))
+      #:phases (modify-phases %standard-phases
+                 (add-after 'unpack 'copy-vpnc-script
+                   (lambda* (#:key inputs outputs #:allow-other-keys)
+                     ;; Override the script that comes with vpnc to work
+                     ;; around vpnc error:
+                     ;;
+                     ;;   Error: either "to" is duplicate, or "ipid" is a garbage.
+                     ;;
+                     ;; See <http://blog.nowherelan.com/2011/10/10/vpnc-on-ubuntu-oneiric-error-either-to-is-duplicate-or-ipid-is-a-garbage/>.
+                     (let* ((out    (assoc-ref outputs "out"))
+                            (script (string-append out
+                                                   "/etc/vpnc/vpnc-script")))
+                       (mkdir-p (dirname script))
+                       (copy-file (assoc-ref inputs "vpnc-script")
+                                  script)
+                       (chmod script #o755)
+                       #t))))))
    (synopsis "Client for Cisco VPN")
    (description
     "OpenConnect is a client for Cisco's AnyConnect SSL VPN, which is
-- 
2.12.2