Patchwork [v2,1/5] connman: Add VPN support

login
register
mail settings
Submitter Jukka Rissanen
Date May 13, 2013, 12:49 p.m.
Message ID <1368449357-3191-2-git-send-email-jukka.rissanen@linux.intel.com>
Download mbox | patch
Permalink /patch/49849/
State New
Headers show

Comments

Jukka Rissanen - May 13, 2013, 12:49 p.m.
One needs to add following statement into local.conf or distro config

PACKAGECONFIG_append_pn-connman = " openvpn vpnc l2tp pptp"

in order to activate support for these VPN technogies in ConnMan.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
---
 meta/recipes-connectivity/connman/connman.inc | 48 ++++++++++++++++++++++++---
 1 file changed, 43 insertions(+), 5 deletions(-)
Phil Blundell - May 13, 2013, 3:20 p.m.
On Mon, 2013-05-13 at 15:49 +0300, Jukka Rissanen wrote:
> +do_install_append_${PN}-vpn() {
> +	mkdir -p ${D}${libdir}/connman/scripts
> +	mkdir -p ${D}${libdir}/connman/plugins-vpn
> +}
> +

Does that actually do anything useful?

>+bb.note( "Adding rdependency on %s to %s" % ( rdepends, package ) )

I know the existing connman.inc does the same thing, but I don't think
we want to proliferate this sort of debugging chit-chat in new code.

Also, the way that this code (both the existing stuff and the new block
you've added) interacts with do_split_packages() is a bit hokey.  You
have a hook function which basically just adds an entry to a list, and
then a separate loop which iterates over the resulting list and fiddles
with the RDEPENDS.  As far as I can tell there's no reason that the
RDEPENDS tinkering couldn't be done inside the hook function itself,
which would avoid having two copies of essentially the same code.

> -FILES_${PN} = "${bindir}/* ${sbindir}/* ${libexecdir}/* ${libdir}/lib*.so.* \
> +FILES_${PN} = "${sbindir}/connmand ${libexecdir}/* ${libdir}/lib*.so.* \
>              ${libdir}/connman/plugins \
> -            ${sysconfdir} ${sharedstatedir} ${localstatedir} \
> -            ${base_bindir}/* ${base_sbindir}/* ${base_libdir}/*.so* ${datadir}/${PN} \
> -            ${datadir}/dbus-1/system-services/*"
> +            ${sysconfdir}/connman ${sysconfdir}/dbus-1/system.d/connman.conf \
> +            @base_contains('DISTRO_FEATURES','sysvinit','${sysconfdir}/init.d','',d)} \
> +            ${sharedstatedir} ${localstatedir} \
> +            ${base_bindir}/* ${base_sbindir}/* ${base_libdir}/*.so* \
> +            ${datadir}/${PN}"

That seems like rather a wide-ranging set of changes.  You prepended
${PN}-vpn to PACKAGES which should mean that it gets first pick of the
FILES.  Are all those changes to FILES_${PN} actually necessary?

p.

Patch

diff --git a/meta/recipes-connectivity/connman/connman.inc b/meta/recipes-connectivity/connman/connman.inc
index afc361c..73c7215 100644
--- a/meta/recipes-connectivity/connman/connman.inc
+++ b/meta/recipes-connectivity/connman/connman.inc
@@ -38,6 +38,10 @@  PACKAGECONFIG ??= "\
                    ${@base_contains('DISTRO_FEATURES', '3g','3g', '', d)} \
 "
 
+# If you want ConnMan to support VPN, add following statement into
+# local.conf or distro config
+# PACKAGECONFIG_append_pn-connman = " openvpn vpnc l2tp pptp"
+
 PACKAGECONFIG[wifi] = "--enable-wifi, --disable-wifi, wpa-supplicant"
 PACKAGECONFIG[bluetooth] = "--enable-bluetooth, --disable-bluetooth, bluez4"
 PACKAGECONFIG[3g] = "--enable-ofono, --disable-ofono, ofono"
@@ -47,6 +51,7 @@  INITSCRIPT_NAME = "connman"
 INITSCRIPT_PARAMS = "start 05 5 2 3 . stop 22 0 1 6 ."
 
 SYSTEMD_SERVICE_${PN} = "connman.service"
+SYSTEMD_SERVICE_${PN}-vpn = "connman-vpn.service"
 SYSTEMD_WIRED_SETUP = "ExecStartPre=-/usr/lib/connman/wired-setup"
 
 # IMPORTANT: because xuser is shared with rootless X, please make sure the
@@ -67,6 +72,7 @@  do_configure_append () {
 # both this and the xuser patch can be dropped.
 do_compile_append() {
 	sed -i -e s:deny:allow:g src/connman-dbus.conf
+	sed -i -e s:deny:allow:g vpn/vpn-dbus.conf
 }
 
 do_install_append() {
@@ -81,13 +87,18 @@  do_install_append() {
 	install -m 0755 ${B}/client/connmanctl ${D}${bindir}
 
 	# We don't need to package an empty directory
-	rmdir ${D}${libdir}/connman/scripts
+	rmdir --ignore-fail-on-non-empty ${D}${libdir}/connman/scripts
 
 	# Automake 1.12 won't install empty directories, but we need the
 	# plugins directory to be present for ownership
 	mkdir -p ${D}${libdir}/connman/plugins
 }
 
+do_install_append_${PN}-vpn() {
+	mkdir -p ${D}${libdir}/connman/scripts
+	mkdir -p ${D}${libdir}/connman/plugins-vpn
+}
+
 # These used to be plugins, but now they are core
 RPROVIDES_${PN} = "\
 	connman-plugin-loopback \
@@ -120,6 +131,17 @@  python populate_packages_prepend() {
             rdepends = map(lambda x: multilib_prefix + x,  depmap[plugintype].split())
             bb.note( "Adding rdependency on %s to %s" % ( rdepends, package ) )
             d.setVar("RDEPENDS_%s" % package, " ".join(rdepends))
+
+    packages = []
+    plugin_dir = d.expand('${libdir}/connman/plugins-vpn/')
+    plugin_name = d.expand('${PN}-plugin-vpn-%s')
+    do_split_packages(d, plugin_dir, '^(.*).so$', plugin_name, '${PN} VPN plugin for %s', extra_depends='', hook=hook, prepend=True )
+    for (file, package) in packages:
+        plugintype = package.split( '-' )[-1]
+        if plugintype in depmap:
+            rdepends = map(lambda x: multilib_prefix + x,  depmap[plugintype].split())
+            bb.note( "Adding rdependency on %s to %s" % ( rdepends, package ) )
+            d.setVar("RDEPENDS_%s" % package, " ".join(rdepends))
 }
 
 PACKAGES =+ "${PN}-tools ${PN}-tests ${PN}-client"
@@ -131,12 +153,28 @@  RDEPENDS_${PN}-tests = "python-dbus python-pygobject python-textutils python-sub
 
 FILES_${PN}-client = "${bindir}/connmanctl"
 
-FILES_${PN} = "${bindir}/* ${sbindir}/* ${libexecdir}/* ${libdir}/lib*.so.* \
+FILES_${PN} = "${sbindir}/connmand ${libexecdir}/* ${libdir}/lib*.so.* \
             ${libdir}/connman/plugins \
-            ${sysconfdir} ${sharedstatedir} ${localstatedir} \
-            ${base_bindir}/* ${base_sbindir}/* ${base_libdir}/*.so* ${datadir}/${PN} \
-            ${datadir}/dbus-1/system-services/*"
+            ${sysconfdir}/connman ${sysconfdir}/dbus-1/system.d/connman.conf \
+            @base_contains('DISTRO_FEATURES','sysvinit','${sysconfdir}/init.d','',d)} \
+            ${sharedstatedir} ${localstatedir} \
+            ${base_bindir}/* ${base_sbindir}/* ${base_libdir}/*.so* \
+            ${datadir}/${PN}"
 
 FILES_${PN}-dbg += "${libdir}/connman/*/.debug"
 
 FILES_${PN}-dev += "${libdir}/connman/*/*.la"
+
+PACKAGES =+ "${PN}-vpn"
+
+SUMMARY_${PN}-vpn = "A daemon for managing VPN connections within embedded devices"
+DESCRIPTION_${PN}-vpn = "The ConnMan VPN provides a daemon for \
+managing VPN connections within embedded devices running the Linux \
+operating system.  The connman-vpnd handles all the VPN connections \
+and starts/stops VPN client processes when necessary. The connman-vpnd \
+provides a DBus API for managing VPN connections. All the different \
+VPN technogies are implemented using plug-ins."
+FILES_${PN}-vpn += "${sbindir}/connman-vpnd \
+                    ${sysconfdir}/dbus-1/system.d/connman-vpn-dbus.conf \
+                    ${datadir}/dbus-1/system-services/net.connman.vpn.service \
+                    ${systemd_unitdir}/system/connman-vpn.service"