alsa-state.bb 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. SUMMARY = "Alsa scenario files to enable alsa state restoration"
  7. HOMEPAGE = "http://www.alsa-project.org/"
  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. SRC_URI = "\
  15. file://asound.conf \
  16. file://asound.state \
  17. file://alsa-state-init \
  18. "
  19. S = "${WORKDIR}"
  20. # As the recipe doesn't inherit systemd.bbclass, we need to set this variable
  21. # manually to avoid unnecessary postinst/preinst generated.
  22. python __anonymous() {
  23. if not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d):
  24. d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1")
  25. }
  26. inherit update-rc.d
  27. INITSCRIPT_NAME = "alsa-state"
  28. INITSCRIPT_PARAMS = "start 39 S . stop 31 0 6 ."
  29. do_install() {
  30. # Only install the init script when 'sysvinit' is in DISTRO_FEATURES.
  31. if ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then
  32. sed -i -e "s:#STATEDIR#:${localstatedir}/lib/alsa:g" ${WORKDIR}/alsa-state-init
  33. install -d ${D}${sysconfdir}/init.d
  34. install -m 0755 ${WORKDIR}/alsa-state-init ${D}${sysconfdir}/init.d/alsa-state
  35. fi
  36. install -d ${D}/${localstatedir}/lib/alsa
  37. install -d ${D}${sysconfdir}
  38. install -m 0644 ${WORKDIR}/asound.conf ${D}${sysconfdir}
  39. install -m 0644 ${WORKDIR}/*.state ${D}${localstatedir}/lib/alsa
  40. }
  41. PACKAGES += "alsa-states"
  42. RRECOMMENDS_alsa-state = "alsa-states"
  43. RDEPENDS_${PN} = "alsa-utils-alsactl"
  44. FILES_${PN} = "${sysconfdir}/init.d ${sysconfdir}/asound.conf"
  45. CONFFILES_${PN} = "${sysconfdir}/asound.conf"
  46. FILES_alsa-states = "${localstatedir}/lib/alsa/*.state"
  47. pkg_postinst_${PN}() {
  48. if test -z "$D"
  49. then
  50. if test -x ${sbindir}/alsactl
  51. then
  52. ${sbindir}/alsactl -g -f ${localstatedir}/lib/alsa/asound.state restore
  53. fi
  54. fi
  55. }