xref: /OK3568_Linux_fs/yocto/poky/meta/recipes-bsp/alsa-state/alsa-state.bb (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1# Copyright Matthias Hentges <devel@hentges.net> (c) 2007
2# License: MIT (see http://www.opensource.org/licenses/mit-license.php
3#               for a copy of the license)
4#
5# Filename: alsa-state.bb
6
7SUMMARY = "Alsa scenario files to enable alsa state restoration"
8HOMEPAGE = "http://www.alsa-project.org/"
9DESCRIPTION = "Alsa Scenario Files - an init script and state files to restore \
10sound state at system boot and save it at system shut down."
11LICENSE = "MIT & GPL-2.0-or-later"
12LIC_FILES_CHKSUM = " \
13    file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420 \
14    file://alsa-state-init;beginline=3;endline=4;md5=3ff7ecbf534d7d503941abe8e268ef50 \
15"
16PV = "0.2.0"
17PR = "r5"
18
19SRC_URI = "\
20  file://asound.conf \
21  file://asound.state \
22  file://alsa-state-init \
23"
24
25S = "${WORKDIR}"
26
27# As the recipe doesn't inherit systemd.bbclass, we need to set this variable
28# manually to avoid unnecessary postinst/preinst generated.
29python __anonymous() {
30    if not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d):
31        d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1")
32}
33
34inherit update-rc.d
35
36INITSCRIPT_NAME = "alsa-state"
37INITSCRIPT_PARAMS = "start 39 S . stop 31 0 6 ."
38
39do_install() {
40    # Only install the init script when 'sysvinit' is in DISTRO_FEATURES.
41    if ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then
42	sed -i -e "s:#STATEDIR#:${localstatedir}/lib/alsa:g" ${WORKDIR}/alsa-state-init
43	install -d ${D}${sysconfdir}/init.d
44	install -m 0755 ${WORKDIR}/alsa-state-init ${D}${sysconfdir}/init.d/alsa-state
45    fi
46
47    install -d ${D}/${localstatedir}/lib/alsa
48    install -d ${D}${sysconfdir}
49    install -m 0644 ${WORKDIR}/asound.conf ${D}${sysconfdir}
50    install -m 0644 ${WORKDIR}/*.state ${D}${localstatedir}/lib/alsa
51}
52
53PACKAGES += "alsa-states"
54
55RRECOMMENDS:alsa-state = "alsa-states"
56
57RDEPENDS:${PN} = "alsa-utils-alsactl"
58FILES:${PN} = "${sysconfdir}/init.d ${sysconfdir}/asound.conf"
59CONFFILES:${PN} = "${sysconfdir}/asound.conf"
60
61FILES:alsa-states = "${localstatedir}/lib/alsa/*.state"
62
63pkg_postinst:${PN}() {
64	if test -z "$D"
65	then
66		if test -x ${sbindir}/alsactl
67		then
68			${sbindir}/alsactl -g -f ${localstatedir}/lib/alsa/asound.state restore
69		fi
70	fi
71}
72