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" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8 | HOMEPAGE = "http://www.alsa-project.org/" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9 | DESCRIPTION = "Alsa Scenario Files - an init script and state files to restore \ |
| 10 | sound state at system boot and save it at system shut down." |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 11 | LICENSE = "MIT & GPL-2.0-or-later" |
| 12 | LIC_FILES_CHKSUM = " \ |
| 13 | file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420 \ |
| 14 | file://alsa-state-init;beginline=3;endline=4;md5=3ff7ecbf534d7d503941abe8e268ef50 \ |
| 15 | " |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 16 | PV = "0.2.0" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 17 | |
| 18 | SRC_URI = "\ |
| 19 | file://asound.conf \ |
| 20 | file://asound.state \ |
| 21 | file://alsa-state-init \ |
| 22 | " |
| 23 | |
| 24 | S = "${WORKDIR}" |
| 25 | |
| 26 | # As the recipe doesn't inherit systemd.bbclass, we need to set this variable |
| 27 | # manually to avoid unnecessary postinst/preinst generated. |
| 28 | python __anonymous() { |
| 29 | if not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d): |
| 30 | d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1") |
| 31 | } |
| 32 | |
| 33 | inherit update-rc.d |
| 34 | |
| 35 | INITSCRIPT_NAME = "alsa-state" |
| 36 | INITSCRIPT_PARAMS = "start 39 S . stop 31 0 6 ." |
| 37 | |
| 38 | do_install() { |
| 39 | # Only install the init script when 'sysvinit' is in DISTRO_FEATURES. |
| 40 | if ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then |
| 41 | sed -i -e "s:#STATEDIR#:${localstatedir}/lib/alsa:g" ${WORKDIR}/alsa-state-init |
| 42 | install -d ${D}${sysconfdir}/init.d |
| 43 | install -m 0755 ${WORKDIR}/alsa-state-init ${D}${sysconfdir}/init.d/alsa-state |
| 44 | fi |
| 45 | |
| 46 | install -d ${D}/${localstatedir}/lib/alsa |
| 47 | install -d ${D}${sysconfdir} |
| 48 | install -m 0644 ${WORKDIR}/asound.conf ${D}${sysconfdir} |
| 49 | install -m 0644 ${WORKDIR}/*.state ${D}${localstatedir}/lib/alsa |
| 50 | } |
| 51 | |
| 52 | PACKAGES += "alsa-states" |
| 53 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 54 | RRECOMMENDS:alsa-state = "alsa-states" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 55 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 56 | RDEPENDS:${PN} = "alsa-utils-alsactl" |
| 57 | FILES:${PN} = "${sysconfdir}/init.d ${sysconfdir}/asound.conf" |
| 58 | CONFFILES:${PN} = "${sysconfdir}/asound.conf" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 59 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 60 | FILES:alsa-states = "${localstatedir}/lib/alsa/*.state" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 61 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 62 | pkg_postinst:${PN}() { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 63 | if test -z "$D" |
| 64 | then |
| 65 | if test -x ${sbindir}/alsactl |
| 66 | then |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 67 | ${sbindir}/alsactl -g -f ${localstatedir}/lib/alsa/asound.state restore |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 68 | fi |
| 69 | fi |
| 70 | } |