summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKari Oikarinen <kari.oikarinen@qt.io>2017-03-10 09:22:09 +0200
committerKari Oikarinen <kari.oikarinen@qt.io>2017-05-03 07:05:51 +0000
commitf93f325ec96b2b76d92b19be71857e761d83620c (patch)
tree5412986e52eed222640d1a5e13e9fc957cd2d607
parent7f98458540db2eacea7277bfb294255bdd203d05 (diff)
downloadmeta-boot2qt-f93f325ec96b2b76d92b19be71857e761d83620c.tar.gz
qdbd: Add network configuration script
The script is called to reset the host-device network interface before starting qdbd. qdbd will call it to configure the network when it is told by the host what network to use. Due to dependency to systemd-networkd in the script and the overall system, working with SysV init is fiction, so remove that configuration. Change-Id: I86f8348e57077c8718cedf68af82796adef65f07 Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
-rw-r--r--recipes-qt/b2qt-addons/qdbd.bb12
-rwxr-xr-xrecipes-qt/b2qt-addons/qdbd/b2qt-gadget-network.sh103
-rwxr-xr-xrecipes-qt/b2qt-addons/qdbd/qdbd-init.sh2
3 files changed, 111 insertions, 6 deletions
diff --git a/recipes-qt/b2qt-addons/qdbd.bb b/recipes-qt/b2qt-addons/qdbd.bb
index 154369b..925b41c 100644
--- a/recipes-qt/b2qt-addons/qdbd.bb
+++ b/recipes-qt/b2qt-addons/qdbd.bb
@@ -32,9 +32,11 @@ SECTION = "devel"
32LICENSE = "The-Qt-Company-DCLA-2.1" 32LICENSE = "The-Qt-Company-DCLA-2.1"
33LIC_FILES_CHKSUM = "file://qdbd/main.cpp;md5=37093977d3f09e6366def8955c8c71e6;beginline=1;endline=18" 33LIC_FILES_CHKSUM = "file://qdbd/main.cpp;md5=37093977d3f09e6366def8955c8c71e6;beginline=1;endline=18"
34 34
35inherit distro_features_check
35inherit qmake5 36inherit qmake5
36 37
37SRC_URI = "git://codereview.qt-project.org/tqtc-boot2qt/qdb;branch=${BRANCH};protocol=ssh \ 38SRC_URI = "git://codereview.qt-project.org/tqtc-boot2qt/qdb;branch=${BRANCH};protocol=ssh \
39 file://b2qt-gadget-network.sh \
38 file://defaults \ 40 file://defaults \
39 file://qdbd.service \ 41 file://qdbd.service \
40 file://qdbd-init.sh \ 42 file://qdbd-init.sh \
@@ -44,6 +46,7 @@ SRCREV = "c3f54cedb1fc2805eb21b2499514284941445e85"
44BRANCH = "5.8" 46BRANCH = "5.8"
45PV = "1.0.0+git${SRCPV}" 47PV = "1.0.0+git${SRCPV}"
46 48
49REQUIRED_DISTRO_FEATURES = "systemd"
47DEPENDS = "qtbase" 50DEPENDS = "qtbase"
48RRECOMMENDS_${PN} += "kernel-module-usb-f-fs kernel-module-usb-f-rndis" 51RRECOMMENDS_${PN} += "kernel-module-usb-f-fs kernel-module-usb-f-rndis"
49 52
@@ -52,9 +55,9 @@ S = "${WORKDIR}/git"
52EXTRA_QMAKEVARS_PRE = "CONFIG+=daemon_only" 55EXTRA_QMAKEVARS_PRE = "CONFIG+=daemon_only"
53 56
54do_install_append() { 57do_install_append() {
58 install -m 0755 ${WORKDIR}/b2qt-gadget-network.sh ${D}${bindir}/
59
55 install -m 0755 ${WORKDIR}/qdbd-init.sh ${D}${bindir}/ 60 install -m 0755 ${WORKDIR}/qdbd-init.sh ${D}${bindir}/
56 install -m 0755 -d ${D}${sysconfdir}/init.d
57 ln -s ${bindir}/qdbd-init.sh ${D}${sysconfdir}/init.d/
58 61
59 install -m 0755 -d ${D}${systemd_unitdir}/system 62 install -m 0755 -d ${D}${systemd_unitdir}/system
60 install -m 0644 ${WORKDIR}/qdbd.service ${D}${systemd_unitdir}/system/ 63 install -m 0644 ${WORKDIR}/qdbd.service ${D}${systemd_unitdir}/system/
@@ -63,11 +66,8 @@ do_install_append() {
63 install -m 0644 ${WORKDIR}/defaults ${D}${sysconfdir}/default/qdbd 66 install -m 0644 ${WORKDIR}/defaults ${D}${sysconfdir}/default/qdbd
64} 67}
65 68
66INITSCRIPT_NAME = "qdbd-init.sh"
67INITSCRIPT_PARAMS = "defaults 96"
68
69SYSTEMD_SERVICE_${PN} = "qdbd.service" 69SYSTEMD_SERVICE_${PN} = "qdbd.service"
70# adbd is started by default instead of qdbd 70# adbd is started by default instead of qdbd
71SYSTEMD_AUTO_ENABLE = "disable" 71SYSTEMD_AUTO_ENABLE = "disable"
72 72
73inherit update-rc.d systemd 73inherit systemd
diff --git a/recipes-qt/b2qt-addons/qdbd/b2qt-gadget-network.sh b/recipes-qt/b2qt-addons/qdbd/b2qt-gadget-network.sh
new file mode 100755
index 0000000..3161db7
--- /dev/null
+++ b/recipes-qt/b2qt-addons/qdbd/b2qt-gadget-network.sh
@@ -0,0 +1,103 @@
1#!/bin/sh
2############################################################################
3##
4## Copyright (C) 2017 The Qt Company Ltd.
5## Contact: https://www.qt.io/licensing/
6##
7## This file is part of the Boot to Qt meta layer.
8##
9## $QT_BEGIN_LICENSE:GPL$
10## Commercial License Usage
11## Licensees holding valid commercial Qt licenses may use this file in
12## accordance with the commercial license agreement provided with the
13## Software or, alternatively, in accordance with the terms contained in
14## a written agreement between you and The Qt Company. For licensing terms
15## and conditions see https://www.qt.io/terms-conditions. For further
16## information use the contact form at https://www.qt.io/contact-us.
17##
18## GNU General Public License Usage
19## Alternatively, this file may be used under the terms of the GNU
20## General Public License version 3 or (at your option) any later version
21## approved by the KDE Free Qt Foundation. The licenses are as published by
22## the Free Software Foundation and appearing in the file LICENSE.GPL3
23## included in the packaging of this file. Please review the following
24## information to ensure the GNU General Public License requirements will
25## be met: https://www.gnu.org/licenses/gpl-3.0.html.
26##
27## $QT_END_LICENSE$
28##
29############################################################################
30
31set -e
32
33NETWORK_UNIT=/usr/lib/systemd/network/usb-rndis.network
34
35usage() {
36 echo "Usage: $(basename $0) --reset"
37 echo " $(basename $0) --set <network>"
38 echo
39 echo "Network is given as the device IPv4 address followed by the prefix length."
40 echo "For example \"192.168.0.1/24\"."
41 exit 1
42}
43
44while test -n "$1"; do
45 case "$1" in
46 "help" | "--help" | "-h")
47 usage
48 exit 0
49 ;;
50 "--reset")
51 if [ -n "$COMMAND" ]; then
52 usage
53 exit 1
54 fi
55 COMMAND="reset"
56 ;;
57 "--set")
58 if [ -n "$COMMAND" ]; then
59 usage
60 exit 1
61 fi
62 COMMAND="set"
63 shift
64 NETWORK=$1
65 ;;
66 esac
67 shift
68done
69
70if [ -z "$COMMAND" ]; then
71 usage
72 exit 1
73fi
74
75case "$COMMAND" in
76 "set")
77 cat <<EOF > $NETWORK_UNIT
78# This file is automatically written by b2qt-gadget-network.sh
79[Match]
80Type=gadget
81
82[Network]
83Address=${NETWORK}
84DHCPServer=yes
85
86[DHCPServer]
87EmitDNS=no
88EmitRouter=no
89EOF
90 ;;
91 "reset")
92 cat <<EOF > $NETWORK_UNIT
93# This file is automatically written by b2qt-gadget-network.sh
94[Match]
95Type=gadget
96
97[Network]
98DHCPServer=no
99EOF
100 ;;
101esac
102
103systemctl restart systemd-networkd
diff --git a/recipes-qt/b2qt-addons/qdbd/qdbd-init.sh b/recipes-qt/b2qt-addons/qdbd/qdbd-init.sh
index 446ea3f..10151c9 100755
--- a/recipes-qt/b2qt-addons/qdbd/qdbd-init.sh
+++ b/recipes-qt/b2qt-addons/qdbd/qdbd-init.sh
@@ -61,6 +61,7 @@ function disable_gadget() {
61 61
62case "$1" in 62case "$1" in
63start) 63start)
64 b2qt-gadget-network.sh --reset
64 modprobe libcomposite 65 modprobe libcomposite
65 # Gadget configuration 66 # Gadget configuration
66 mkdir -p $GADGET_CONFIG 67 mkdir -p $GADGET_CONFIG
@@ -104,6 +105,7 @@ stop)
104restart) 105restart)
105 disable_gadget 106 disable_gadget
106 start-stop-daemon --stop --quiet --exec $DAEMON 107 start-stop-daemon --stop --quiet --exec $DAEMON
108 b2qt-gadget-network.sh --reset
107 sleep 1 109 sleep 1
108 shift 110 shift
109 start-stop-daemon --start --quiet --exec $DAEMON -- $@ & 111 start-stop-daemon --start --quiet --exec $DAEMON -- $@ &