Skip to contentSkip to conversation

vpnc: splitout the vpnc-script into its own package

PATCH New Max Krummenacher 1 participant 3 messages Feb 15, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 vpnc: splitout the vpnc-script into its own package

The vpnc-script can be used unchanged with the openconnect package. Provide it in its own package and make vpnc RDEPEND on it.

---
 meta-networking/recipes-connectivity/vpnc/vpnc_0.5.3.bb | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
meta-networking/recipes-connectivity/vpnc/vpnc_0.5.3.bb +5 -1
index ea2179985..54e855a09 100644
@@ -28,6 +28,8 @@ PACKAGECONFIG ?= "gnutls"
 PACKAGECONFIG[gnutls] = ",,gnutls"
 PACKAGECONFIG[openssl] = ",,openssl"
 
+PACKAGES =+ "${PN}-script"
+
 S = "${WORKDIR}/git"
 
 inherit perlnative pkgconfig
@@ -54,6 +56,8 @@ vpnc_sysroot_preprocess () {
     install -m 755 ${D}${sysconfdir}/vpnc/vpnc-script ${SYSROOT_DESTDIR}${sysconfdir}/vpnc
 }
 
+FILES_${PN}-script = "${sysconfdir}/vpnc/vpnc-script"
+
 CONFFILES_${PN} = "${sysconfdir}/vpnc/default.conf"
-RDEPENDS_${PN} = "perl-module-io-file"
+RDEPENDS_${PN} = "perl-module-io-file ${PN}-script"
 RRECOMMENDS_${PN} = "kernel-module-tun"
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/3 openconnect: build with python3

---
 ...s-tncc-wrapper.py-convert-to-python3.patch | 71 +++++++++++++++++++
 .../openconnect/openconnect_8.03.bb           | 12 ++--
 2 files changed, 76 insertions(+), 7 deletions(-)
 create mode 100644 meta-networking/recipes-connectivity/openconnect/openconnect/0001-trojans-tncc-wrapper.py-convert-to-python3.patch
meta-networking/recipes-connectivity/openconnect/openconnect/0001-trojans-tncc-wrapper.py-convert-to-python3.patch new file +71 -0
new file mode 100644
index 000000000..623ec101d
@@ -0,0 +1,71 @@
+From de78bcac5e1fd13de0371c8e14b062b8786ade56 Mon Sep 17 00:00:00 2001
+From: Max Krummenacher <[email protected]>
+Date: Sun, 2 Feb 2020 15:53:05 +0000
+Subject: [PATCH] trojans/tncc-wrapper.py: convert to python3
+
+Use 2to3 to convert the script to python3.
+
+Upstream-Status: Pending
+
+Signed-off-by: Max Krummenacher <[email protected]>
+---
+ trojans/tncc-wrapper.py | 14 +++++++-------
+ 1 file changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/trojans/tncc-wrapper.py b/trojans/tncc-wrapper.py
+index 0d4587bf..1a9a1f4d 100755
+--- a/trojans/tncc-wrapper.py
++++ b/trojans/tncc-wrapper.py
+@@ -1,4 +1,4 @@
+-#!/usr/bin/python2
++#!/usr/bin/python3
+ 
+ # Lifted from Russ Dill's juniper-vpn-wrap.py, thus:
+ #
+@@ -18,19 +18,19 @@
+ 
+ import subprocess
+ import mechanize
+-import cookielib
++import http.cookiejar
+ import getpass
+ import sys
+ import os
+ import zipfile
+-import urllib
++import urllib.request, urllib.parse, urllib.error
+ import socket
+ import ssl
+ import errno
+ import argparse
+ import atexit
+ import signal
+-import ConfigParser
++import configparser
+ import time
+ import binascii
+ import hmac
+@@ -39,7 +39,7 @@ import hashlib
+ def mkdir_p(path):
+     try:
+         os.mkdir(path)
+-    except OSError, exc:
++    except OSError as exc:
+         if exc.errno == errno.EEXIST and os.path.isdir(path):
+             pass
+         else:
+@@ -64,9 +64,9 @@ class Tncc:
+             if zipfile.ZipFile(self.tncc_jar, 'r').testzip() is not None:
+                 raise Exception()
+         except:
+-            print 'Downloading tncc.jar...'
++            print('Downloading tncc.jar...')
+             mkdir_p(os.path.expanduser('~/.juniper_networks'))
+-            urllib.urlretrieve('https://' + self.vpn_host
++            urllib.request.urlretrieve('https://' + self.vpn_host
+                                + '/dana-cached/hc/tncc.jar', self.tncc_jar)
+ 
+         with zipfile.ZipFile(self.tncc_jar, 'r') as jar:
+-- 
+2.20.1
+
meta-networking/recipes-connectivity/openconnect/openconnect_8.03.bb +5 -7
index ec36a375a..974ff4547 100644
@@ -2,11 +2,14 @@ SUMMARY = "Open client for Cisco AnyConnect VPN"
 LICENSE = "LGPLv2.1"
 LIC_FILES_CHKSUM = "file://COPYING.LGPL;md5=243b725d71bb5df4a1e5920b344b86ad"
 
-SRC_URI = "git://git.infradead.org/users/dwmw2/openconnect.git"
+SRC_URI = " \
+    git://git.infradead.org/users/dwmw2/openconnect.git \
+    file://0001-trojans-tncc-wrapper.py-convert-to-python3.patch \
+"
 SRCREV = "ea73851969ae7a6ea54fdd2d2b8c94776af24b2a"
 
 DEPENDS = "vpnc libxml2 krb5 gettext-native"
-RDEPENDS_${PN} = "bash python"
+RDEPENDS_${PN} = "bash python3-core"
 
 PACKAGECONFIG ??= "gnutls lz4 libproxy"
 
@@ -24,8 +27,3 @@ inherit autotools pkgconfig
 
 EXTRA_OECONF += "--with-vpnc-script=${SYSROOT_DESTDIR}${sysconfdir}/vpnc/vpnc-script \
                  --disable-static"
-
-do_configure_append() {
-    # script has /usr/bin/python2 path hardcoded
-    sed -i -e 's=python2\.*=python=g' ${S}/trojans/tncc-wrapper.py
-}
Signature · 1 line
2.20.1
#2 lore raw

PATCH 3/3 openconnect: use target path to script

In reply to Max Krummenacher

openconnect puts the default absolute path to the vpnc-script into its binary from the --with-vpnc-script configure options. So do not prepend the value with the path to the OE sysroot.

RDEPEND on vpnc-script to have the script from vpnc installed on target.

---
 .../recipes-connectivity/openconnect/openconnect_8.03.bb      | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta-networking/recipes-connectivity/openconnect/openconnect_8.03.bb +2 -2
index 974ff4547..597c1920c 100644
@@ -9,7 +9,7 @@ SRC_URI = " \
 SRCREV = "ea73851969ae7a6ea54fdd2d2b8c94776af24b2a"
 
 DEPENDS = "vpnc libxml2 krb5 gettext-native"
-RDEPENDS_${PN} = "bash python3-core"
+RDEPENDS_${PN} = "bash python3-core vpnc-script"
 
 PACKAGECONFIG ??= "gnutls lz4 libproxy"
 
@@ -25,5 +25,5 @@ S = "${WORKDIR}/git"
 
 inherit autotools pkgconfig
 
-EXTRA_OECONF += "--with-vpnc-script=${SYSROOT_DESTDIR}${sysconfdir}/vpnc/vpnc-script \
+EXTRA_OECONF += "--with-vpnc-script=${sysconfdir}/vpnc/vpnc-script \
                  --disable-static"
Signature · 1 line
2.20.1