blob: d0f7bb3305f3f7956c6bacbf14f11c501b710338 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001# 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"
8DESCRIPTION = "Alsa Scenario Files - an init script and state files to restore \
9sound state at system boot and save it at system shut down."
10LICENSE = "MIT"
11LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
12PV = "0.2.0"
13PR = "r5"
14
15SRC_URI = "\
16 file://asound.conf \
17 file://asound.state \
18 file://alsa-state-init \
19"
20
21S = "${WORKDIR}"
22
23# As the recipe doesn't inherit systemd.bbclass, we need to set this variable
24# manually to avoid unnecessary postinst/preinst generated.
25python __anonymous() {
26 if not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d):
27 d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1")
28}
29
30inherit update-rc.d
31
32INITSCRIPT_NAME = "alsa-state"
33INITSCRIPT_PARAMS = "start 39 S . stop 31 0 6 ."
34
35do_install() {
36 # Only install the init script when 'sysvinit' is in DISTRO_FEATURES.
37 if ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then
38 sed -i -e "s:#STATEDIR#:${localstatedir}/lib/alsa:g" ${WORKDIR}/alsa-state-init
39 install -d ${D}${sysconfdir}/init.d
40 install -m 0755 ${WORKDIR}/alsa-state-init ${D}${sysconfdir}/init.d/alsa-state
41 fi
42
43 install -d ${D}/${localstatedir}/lib/alsa
44 install -d ${D}${sysconfdir}
45 install -m 0644 ${WORKDIR}/asound.conf ${D}${sysconfdir}
46 install -m 0644 ${WORKDIR}/*.state ${D}${localstatedir}/lib/alsa
47}
48
49PACKAGES += "alsa-states"
50
51RRECOMMENDS_alsa-state = "alsa-states"
52
53RDEPENDS_${PN} = "alsa-utils-alsactl"
54FILES_${PN} = "${sysconfdir}/init.d ${sysconfdir}/asound.conf"
55CONFFILES_${PN} = "${sysconfdir}/asound.conf"
56
57FILES_alsa-states = "${localstatedir}/lib/alsa/*.state"
58
59pkg_postinst_${PN}() {
60 if test -z "$D"
61 then
62 if test -x ${sbindir}/alsactl
63 then
64 ${sbindir}/alsactl -f ${localstatedir}/lib/alsa/asound.state restore
65 fi
66 fi
67}