summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOtavio Salvador <otavio@ossystems.com.br>2018-11-30 20:43:36 -0200
committerKhem Raj <raj.khem@gmail.com>2018-11-30 17:12:36 -0800
commitf29268ee21106dfd9f578088745c43aa5e6ed3a3 (patch)
tree853ad416cd3f3056b59e94f55a0b361879d92e52
parentebc7b9e20ac22f6f2ad373621917f53e8a9af81c (diff)
downloadmeta-openembedded-f29268ee21106dfd9f578088745c43aa5e6ed3a3.tar.gz
libusbgx: Add recipe
The libusbgx allow easier use and setup of USB gadgets. To easy integration on different systems a libusbgx-config package is provided so it can be used to start and enable respective USB gadget schema. Signed-off-by: Otavio Salvador <otavio@ossystems.com.br> Signed-off-by: Khem Raj <raj.khem@gmail.com>
-rw-r--r--meta-oe/recipes-support/libusbgx/libusbgx-config.bb12
-rw-r--r--meta-oe/recipes-support/libusbgx/libusbgx-config/usbgx.default2
-rw-r--r--meta-oe/recipes-support/libusbgx/libusbgx/gadget-start11
-rw-r--r--meta-oe/recipes-support/libusbgx/libusbgx/usbgx.initd143
-rw-r--r--meta-oe/recipes-support/libusbgx/libusbgx/usbgx.service9
-rw-r--r--meta-oe/recipes-support/libusbgx/libusbgx_git.bb40
6 files changed, 217 insertions, 0 deletions
diff --git a/meta-oe/recipes-support/libusbgx/libusbgx-config.bb b/meta-oe/recipes-support/libusbgx/libusbgx-config.bb
new file mode 100644
index 000000000..b269e33c4
--- /dev/null
+++ b/meta-oe/recipes-support/libusbgx/libusbgx-config.bb
@@ -0,0 +1,12 @@
1SUMMARY = "USB Gadget Configuration Files"
2LICENSE = "MIT"
3LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
4
5SRC_URI = "file://usbgx.default"
6
7do_configure[noexec] = "1"
8do_compile[noexec] = "1"
9
10do_install() {
11 install -Dm 0644 ${WORKDIR}/usbgx.default ${D}${sysconfdir}/default/usbgx
12}
diff --git a/meta-oe/recipes-support/libusbgx/libusbgx-config/usbgx.default b/meta-oe/recipes-support/libusbgx/libusbgx-config/usbgx.default
new file mode 100644
index 000000000..f690dfe2a
--- /dev/null
+++ b/meta-oe/recipes-support/libusbgx/libusbgx-config/usbgx.default
@@ -0,0 +1,2 @@
1IMPORT_SCHEMAS=""
2ENABLED_SCHEMAS="$IMPORT_SCHEMAS"
diff --git a/meta-oe/recipes-support/libusbgx/libusbgx/gadget-start b/meta-oe/recipes-support/libusbgx/libusbgx/gadget-start
new file mode 100644
index 000000000..1a106b785
--- /dev/null
+++ b/meta-oe/recipes-support/libusbgx/libusbgx/gadget-start
@@ -0,0 +1,11 @@
1#!/bin/sh
2
3[ -r /etc/default/usbgx ] && . /etc/default/usbgx
4
5for i in $IMPORT_SCHEMAS; do
6 /usr/bin/gadget-import "$i" /etc/usbgx/"$i".schema
7done
8
9for i in $ENABLED_SCHEMAS; do
10 ls /sys/class/udc/ > /sys/kernel/config/usb_gadget/"$i"/UDC
11done
diff --git a/meta-oe/recipes-support/libusbgx/libusbgx/usbgx.initd b/meta-oe/recipes-support/libusbgx/libusbgx/usbgx.initd
new file mode 100644
index 000000000..d1938078f
--- /dev/null
+++ b/meta-oe/recipes-support/libusbgx/libusbgx/usbgx.initd
@@ -0,0 +1,143 @@
1#! /bin/sh
2### BEGIN INIT INFO
3# Provides: usbg
4# Required-Start: $local_fs
5# Should-Start:
6# Required-Stop: $local_fs
7# Should-Stop:
8# Default-Start: 2 3 4 5
9# Default-Stop: 0 1 6
10# Short-Description: Example initscript
11# Description: This file should be used to construct scripts to be
12# placed in /etc/init.d
13### END INIT INFO
14
15# PATH should only include /usr/* if it runs after the mountnfs.sh script
16PATH=/sbin:/usr/sbin:/bin:/usr/bin
17
18DESC="Load USB gadget schemas"
19NAME="usbgx"
20DAEMON=/usr/bin/gadget-start
21DAEMON_ARGS=""
22PIDFILE=/var/run/$NAME.pid
23
24. /etc/init.d/functions || exit 1
25
26# Exit if the package is not installed
27[ -x "$DAEMON" ] || exit 0
28
29# Read configuration variable file if it is present
30[ -r /etc/default/$NAME ] && . /etc/default/$NAME
31
32#
33# Function that starts the daemon/service
34#
35do_start() {
36 local status pid
37
38 status=0
39 pid=`pidofproc $NAME` || status=$?
40 case $status in
41 0)
42 echo "$DESC already running ($pid)."
43 exit 1
44 ;;
45 *)
46 echo "Starting $DESC ..."
47 exec $DAEMON $DAEMON_ARGS >/dev/null 2>&1 || status=$?
48 echo "ERROR: Failed to start $DESC."
49 exit $status
50 ;;
51 esac
52}
53
54#
55# Function that stops the daemon/service
56#
57do_stop() {
58 local pid status
59
60 status=0
61 pid=`pidofproc $NAME` || status=$?
62 case $status in
63 0)
64 # Exit when fail to stop, the kill would complain when fail
65 kill -s 15 $pid >/dev/null && rm -f $PIDFILE && \
66 echo "Stopped $DESC ($pid)." || exit $?
67 ;;
68 *)
69 echo "$DESC is not running; none killed." >&2
70 ;;
71 esac
72
73 return $status
74}
75
76#
77# Function that sends a SIGHUP to the daemon/service
78#
79do_reload() {
80 local pid status
81
82 status=0
83 # If the daemon can reload its configuration without
84 # restarting (for example, when it is sent a SIGHUP),
85 # then implement that here.
86 pid=`pidofproc $NAME` || status=$?
87 case $status in
88 0)
89 echo "Reloading $DESC ..."
90 kill -s 1 $pid || exit $?
91 ;;
92 *)
93 echo "$DESC is not running; none reloaded." >&2
94 ;;
95 esac
96 exit $status
97}
98
99
100#
101# Function that shows the daemon/service status
102#
103status_of_proc () {
104 local pid status
105
106 status=0
107 # pidof output null when no program is running, so no "2>/dev/null".
108 pid=`pidofproc $NAME` || status=$?
109 case $status in
110 0)
111 echo "$DESC is running ($pid)."
112 exit 0
113 ;;
114 *)
115 echo "$DESC is not running." >&2
116 exit $status
117 ;;
118 esac
119}
120
121case "$1" in
122 start)
123 do_start
124 ;;
125 stop)
126 do_stop || exit $?
127 ;;
128 status)
129 status_of_proc
130 ;;
131 restart)
132 # Always start the service regardless the status of do_stop
133 do_stop
134 do_start
135 ;;
136 try-restart|force-reload)
137 do_stop && do_start
138 ;;
139 *)
140 echo "Usage: $0 {start|stop|status|restart|try-restart|force-reload}" >&2
141 exit 3
142 ;;
143esac
diff --git a/meta-oe/recipes-support/libusbgx/libusbgx/usbgx.service b/meta-oe/recipes-support/libusbgx/libusbgx/usbgx.service
new file mode 100644
index 000000000..74541d3c2
--- /dev/null
+++ b/meta-oe/recipes-support/libusbgx/libusbgx/usbgx.service
@@ -0,0 +1,9 @@
1[Unit]
2Description=Load USB gadget schemas
3
4[Service]
5Type=oneshot
6ExecStart=/usr/bin/gadget-start
7
8[Install]
9WantedBy=multi-user.target
diff --git a/meta-oe/recipes-support/libusbgx/libusbgx_git.bb b/meta-oe/recipes-support/libusbgx/libusbgx_git.bb
new file mode 100644
index 000000000..d73ca6106
--- /dev/null
+++ b/meta-oe/recipes-support/libusbgx/libusbgx_git.bb
@@ -0,0 +1,40 @@
1SUMMARY = "USB Gadget neXt Configfs Library"
2LICENSE = "GPLv2 & LGPLv2.1"
3LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
4 file://COPYING.LGPL;md5=4fbd65380cdd255951079008b364516c"
5
6DEPENDS = "libconfig"
7
8inherit autotools pkgconfig systemd update-rc.d
9
10PV = "0.2.0+git${SRCPV}"
11SRCREV = "45c14ef4d5d7ced0fbf984208de44ced6d5ed898"
12SRCBRANCH = "master"
13SRC_URI = " \
14 git://github.com/libusbgx/libusbgx.git;branch=${SRCBRANCH} \
15 file://gadget-start \
16 file://usbgx.initd \
17 file://usbgx.service \
18"
19
20S = "${WORKDIR}/git"
21
22SYSTEMD_PACKAGES = "${PN}"
23SYSTEMD_SERVICE_${PN} = "usbgx.service"
24
25INITSCRIPT_NAME = "usbgx"
26INITSCRIPT_PARAMS = "defaults"
27
28EXTRA_OECONF = "--includedir=${includedir}/usbgx"
29
30do_install_append() {
31 install -Dm 0755 ${WORKDIR}/gadget-start ${D}/${bindir}/gadget-start
32 if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
33 install -Dm 0644 ${WORKDIR}/usbgx.service ${D}${systemd_system_unitdir}/usbgx.service
34 fi
35 if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
36 install -Dm 0755 ${WORKDIR}/usbgx.initd ${D}${sysconfdir}/init.d/usbgx
37 fi
38}
39
40RDEPENDS_${PN} += "libusbgx-config"