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