Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 | |
| 7 | SUMMARY = "Alsa scenario files to enable alsa state restoration" |
| 8 | DESCRIPTION = "Alsa Scenario Files - an init script and state files to restore \ |
| 9 | sound state at system boot and save it at system shut down." |
| 10 | LICENSE = "MIT" |
| 11 | LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" |
| 12 | PV = "0.2.0" |
| 13 | PR = "r5" |
| 14 | |
| 15 | SRC_URI = "\ |
| 16 | file://asound.conf \ |
| 17 | file://asound.state \ |
| 18 | file://alsa-state-init \ |
| 19 | " |
| 20 | |
| 21 | S = "${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. |
| 25 | python __anonymous() { |
| 26 | if not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d): |
| 27 | d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1") |
| 28 | } |
| 29 | |
| 30 | inherit update-rc.d |
| 31 | |
| 32 | INITSCRIPT_NAME = "alsa-state" |
| 33 | INITSCRIPT_PARAMS = "start 39 S . stop 31 0 6 ." |
| 34 | |
| 35 | do_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 | |
| 49 | PACKAGES += "alsa-states" |
| 50 | |
| 51 | RRECOMMENDS_alsa-state = "alsa-states" |
| 52 | |
| 53 | RDEPENDS_${PN} = "alsa-utils-alsactl" |
| 54 | FILES_${PN} = "${sysconfdir}/init.d ${sysconfdir}/asound.conf" |
| 55 | CONFFILES_${PN} = "${sysconfdir}/asound.conf" |
| 56 | |
| 57 | FILES_alsa-states = "${localstatedir}/lib/alsa/*.state" |
| 58 | |
| 59 | pkg_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 | } |