summaryrefslogtreecommitdiff
path: root/recipes-connectivity/usb-gadget-mode/usb-gadget-mode.bb
blob: 0f158305c0ad6ddd5e66c7ebc353d53cdc3d489c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Copyright Matthias Hentges <devel@hentges.net> (c) 2007
# License: MIT (see http://www.opensource.org/licenses/mit-license.php
#               for a copy of the license)
#
# Filename: usb-gadget-mode.bb
# Date: 20070606 (YMD)

DESCRIPTION = "Manage the default USB gadget mode"
SECTION = "console/network"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"
PV = "0.0.2"
PR = "r3"

SRC_URI = "\
  file://usb-gadget.conf \
  file://usb-gadget \
  file://usb-gadget.init \
"

do_install() {
	install -d ${D}${sysconfdir}
	install -d ${D}${sysconfdir}/init.d
	install -d ${D}${bindir}
	install -d ${D}${sysconfdir}/default

	install -m 0644 ${WORKDIR}/usb-gadget.conf ${D}${sysconfdir}/default/usb-gadget
	install -m 0755 ${WORKDIR}/usb-gadget.init ${D}${sysconfdir}/init.d/usb-gadget
	install -m 0755 ${WORKDIR}/usb-gadget ${D}${bindir}
}

# disbale usb-gadget for mtcap hardware
do_install_append_mtcap() {
    sed -i 's/ENABLED="yes"/ENABLED="no"/g' ${D}${sysconfdir}/default/usb-gadget
}

pkg_postinst_${PN}() {
	test -n "$D" && opt="-r $D"
	update-rc.d $opt usb-gadget defaults 50
}

pkg_postrm_${PN}() {
	update-rc.d -f usb-gadget remove
}

PACKAGE_ARCH = "${MACHINE_ARCH}"

# disable usb-gadget on mtr
do_install_append_mtr() {
    sed -i 's/ENABLED="yes"/ENABLED="no"/g' ${D}${sysconfdir}/default/usb-gadget
}

# disable usb-gadget on mtrv1
do_install_append_mtrv1() {
    sed -i 's/ENABLED="yes"/ENABLED="no"/g' ${D}${sysconfdir}/default/usb-gadget
}