diff options
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 0000000000..b269e33c44 --- /dev/null +++ b/meta-oe/recipes-support/libusbgx/libusbgx-config.bb | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | SUMMARY = "USB Gadget Configuration Files" | ||
| 2 | LICENSE = "MIT" | ||
| 3 | LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" | ||
| 4 | |||
| 5 | SRC_URI = "file://usbgx.default" | ||
| 6 | |||
| 7 | do_configure[noexec] = "1" | ||
| 8 | do_compile[noexec] = "1" | ||
| 9 | |||
| 10 | do_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 0000000000..f690dfe2ab --- /dev/null +++ b/meta-oe/recipes-support/libusbgx/libusbgx-config/usbgx.default | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | IMPORT_SCHEMAS="" | ||
| 2 | ENABLED_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 0000000000..1a106b7851 --- /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 | |||
| 5 | for i in $IMPORT_SCHEMAS; do | ||
| 6 | /usr/bin/gadget-import "$i" /etc/usbgx/"$i".schema | ||
| 7 | done | ||
| 8 | |||
| 9 | for i in $ENABLED_SCHEMAS; do | ||
| 10 | ls /sys/class/udc/ > /sys/kernel/config/usb_gadget/"$i"/UDC | ||
| 11 | done | ||
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 0000000000..d1938078f0 --- /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 | ||
| 16 | PATH=/sbin:/usr/sbin:/bin:/usr/bin | ||
| 17 | |||
| 18 | DESC="Load USB gadget schemas" | ||
| 19 | NAME="usbgx" | ||
| 20 | DAEMON=/usr/bin/gadget-start | ||
| 21 | DAEMON_ARGS="" | ||
| 22 | PIDFILE=/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 | # | ||
| 35 | do_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 | # | ||
| 57 | do_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 | # | ||
| 79 | do_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 | # | ||
| 103 | status_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 | |||
| 121 | case "$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 | ;; | ||
| 143 | esac | ||
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 0000000000..74541d3c2d --- /dev/null +++ b/meta-oe/recipes-support/libusbgx/libusbgx/usbgx.service | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | [Unit] | ||
| 2 | Description=Load USB gadget schemas | ||
| 3 | |||
| 4 | [Service] | ||
| 5 | Type=oneshot | ||
| 6 | ExecStart=/usr/bin/gadget-start | ||
| 7 | |||
| 8 | [Install] | ||
| 9 | WantedBy=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 0000000000..d73ca61060 --- /dev/null +++ b/meta-oe/recipes-support/libusbgx/libusbgx_git.bb | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | SUMMARY = "USB Gadget neXt Configfs Library" | ||
| 2 | LICENSE = "GPLv2 & LGPLv2.1" | ||
| 3 | LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \ | ||
| 4 | file://COPYING.LGPL;md5=4fbd65380cdd255951079008b364516c" | ||
| 5 | |||
| 6 | DEPENDS = "libconfig" | ||
| 7 | |||
| 8 | inherit autotools pkgconfig systemd update-rc.d | ||
| 9 | |||
| 10 | PV = "0.2.0+git${SRCPV}" | ||
| 11 | SRCREV = "45c14ef4d5d7ced0fbf984208de44ced6d5ed898" | ||
| 12 | SRCBRANCH = "master" | ||
| 13 | SRC_URI = " \ | ||
| 14 | git://github.com/libusbgx/libusbgx.git;branch=${SRCBRANCH} \ | ||
| 15 | file://gadget-start \ | ||
| 16 | file://usbgx.initd \ | ||
| 17 | file://usbgx.service \ | ||
| 18 | " | ||
| 19 | |||
| 20 | S = "${WORKDIR}/git" | ||
| 21 | |||
| 22 | SYSTEMD_PACKAGES = "${PN}" | ||
| 23 | SYSTEMD_SERVICE_${PN} = "usbgx.service" | ||
| 24 | |||
| 25 | INITSCRIPT_NAME = "usbgx" | ||
| 26 | INITSCRIPT_PARAMS = "defaults" | ||
| 27 | |||
| 28 | EXTRA_OECONF = "--includedir=${includedir}/usbgx" | ||
| 29 | |||
| 30 | do_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 | |||
| 40 | RDEPENDS_${PN} += "libusbgx-config" | ||
