diff options
author | Sabin Floares <sabin.floares@intel.com> | 2016-08-22 17:22:47 +0300 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-08-28 12:09:46 -0700 |
commit | 94e6f4da18fb0c4ee17a8e4b95f92d5de7f2f526 (patch) | |
tree | 7d68f64b4cac65efc2cb7dc2dae86595314aec57 | |
parent | 2222e7f3b756bdc3fb7825727c85302b75a892df (diff) | |
download | adhd-94e6f4da18fb0c4ee17a8e4b95f92d5de7f2f526.tar.gz |
cras: Adding systemd unit files.
Renamed "upstart" dir to "init". Pulled the main script to a separate
file which is shared between systemd and Upstart.
BUG=chromium:583671
CQ-DEPEND=CL:373478
TEST=Checked that the sound works.
Change-Id: I643b1fd151f22e9c6a56cfb96eea6fa9d6556eb7
Reviewed-on: https://chromium-review.googlesource.com/373379
Commit-Ready: Sabin Floares <sabin.floares@intel.com>
Tested-by: Sabin Floares <sabin.floares@intel.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
-rw-r--r-- | Makefile | 40 | ||||
-rw-r--r-- | defs/utilities.mk | 1 | ||||
-rw-r--r-- | init/cras-directories.conf | 1 | ||||
-rw-r--r-- | init/cras.conf | 25 | ||||
-rw-r--r-- | init/cras.service | 14 | ||||
-rw-r--r-- | init/cras.sh | 24 | ||||
-rw-r--r-- | upstart/cras.conf | 46 |
7 files changed, 99 insertions, 52 deletions
@@ -19,9 +19,36 @@ cras-scripts: $(INSTALL) --mode 755 -D $(ADHD_DIR)/scripts/audio_diagnostics \ $(DESTDIR)usr/bin/ -$(DESTDIR)/etc/init/cras.conf: $(ADHD_DIR)/upstart/cras.conf - $(ECHO) "Installing '$<' to '$@'" - $(INSTALL) --mode 644 -D $< $@ +cras_init_upstart: $(ADHD_DIR)/init/cras.conf + $(ECHO) "Installing upstart file" + $(INSTALL) --mode 644 -D $< $(DESTDIR)/etc/init/cras.conf + +cras_init_scripts: $(ADHD_DIR)/init/cras.sh + $(INSTALL) --mode 644 -D $< $(DESTDIR)/usr/share/cros/init/cras.sh + +SYSTEMD_UNIT_DIR := /usr/lib/systemd/system/ +SYSTEMD_TMPFILESD_DIR := /usr/lib/tmpfiles.d/ + +cras_init_systemd: $(ADHD_DIR)/init/cras.service \ + $(ADHD_DIR)/init/cras-directories.conf + $(ECHO) "Installing systemd files" + $(INSTALL) --mode 644 -D $(ADHD_DIR)/init/cras.service \ + $(DESTDIR)/$(SYSTEMD_UNIT_DIR)/cras.service + $(INSTALL) --mode 755 -d $(DESTDIR)/$(SYSTEMD_UNIT_DIR)/system-services.target.wants + $(LINK) -s ../cras.service \ + $(DESTDIR)/$(SYSTEMD_UNIT_DIR)/system-services.target.wants/cras.service + $(INSTALL) --mode 644 -D $(ADHD_DIR)/init/cras-directories.conf \ + $(DESTDIR)/$(SYSTEMD_TMPFILESD_DIR)/cras-directories.conf + +ifeq ($(strip $(SYSTEMD)), yes) + +cras_init: cras_init_systemd cras_init_scripts + +else + +cras_init: cras_init_upstart cras_init_scripts + +endif $(DESTDIR)/etc/cras/device_blacklist: $(ADHD_DIR)/cras-config/device_blacklist $(ECHO) "Installing '$<' to '$@'" @@ -51,10 +78,11 @@ install: $(DESTDIR)/lib/firmware/$(BOARD)_alsa.fw endif -install: $(DESTDIR)/etc/init/cras.conf \ - $(DESTDIR)/etc/cras/device_blacklist \ +install: $(DESTDIR)/etc/cras/device_blacklist \ cras-scripts \ - cras_install + cras_install \ + cras_init + clean: @rm -rf $(ADHD_BUILD_DIR) diff --git a/defs/utilities.mk b/defs/utilities.mk index 230eae5c..8bc4c046 100644 --- a/defs/utilities.mk +++ b/defs/utilities.mk @@ -15,3 +15,4 @@ export AR = /usr/bin/ar export ECHO = /bin/echo export MESSAGE = $(ECHO) "$(foreach v,$(shell seq $(MAKELEVEL))," ") [$(MAKELEVEL)] " export INSTALL = /usr/bin/install +export LINK = /bin/ln diff --git a/init/cras-directories.conf b/init/cras-directories.conf new file mode 100644 index 00000000..1df52c4a --- /dev/null +++ b/init/cras-directories.conf @@ -0,0 +1 @@ +d /var/run/cras 1770 cras cras - diff --git a/init/cras.conf b/init/cras.conf new file mode 100644 index 00000000..b21c7675 --- /dev/null +++ b/init/cras.conf @@ -0,0 +1,25 @@ +# Copyright (c) 2012 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Installed by ADHD package. +# cras upstart job. + +description "ChromeOS audio server" +author "chromium-os-dev@chromium.org" + +env CRAS_SOCKET_DIR=/var/run/cras + +start on starting system-services +stop on stopping system-services +respawn + +# Allow the audio server real time priority. +limit rtprio 12 12 + +pre-start script + mkdir -p -m 1770 "${CRAS_SOCKET_DIR}" + chown -R cras:cras "${CRAS_SOCKET_DIR}" +end script + +exec /bin/sh /usr/share/cros/init/cras.sh diff --git a/init/cras.service b/init/cras.service new file mode 100644 index 00000000..bda61c12 --- /dev/null +++ b/init/cras.service @@ -0,0 +1,14 @@ +# Copyright 2016 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +[Unit] +Description=ChromeOS audio server +PartOf=system-services.target +After=system-services.target + +[Service] +Restart=on-failure +LimitRTPRIO=12 +TimeoutStopSec=20 +ExecStart=/bin/sh /usr/share/cros/init/cras.sh diff --git a/init/cras.sh b/init/cras.sh new file mode 100644 index 00000000..d4b02921 --- /dev/null +++ b/init/cras.sh @@ -0,0 +1,24 @@ +# Copyright 2016 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# For Samus only, check which dsp.ini to load. +if [ "$(mosys platform name)" = "Samus" ]; then + hw_version="$(mosys platform version)" + if [ "$hw_version" = "MP.A" ] || + [ "$hw_version" = "EVT" ] || + [ "$hw_version" = "DVT" ] || + [ "$hw_version" = "PVT" ]; then + DSP_CONFIG="--dsp_config=/etc/cras/dsp.samus.orig.ini" + fi +fi +# For board needs different device configs, check which config +# directory to use. Use that directory for both volume curves +# and dsp config. +if [ -f /etc/cras/get_device_config_dir ]; then + device_config_dir="$(sh /etc/cras/get_device_config_dir)" + DEVICE_CONFIG_DIR="--device_config_dir=${device_config_dir}" + DSP_CONFIG="--dsp_config=${device_config_dir}/dsp.ini" +fi +exec minijail0 -u cras -g cras -G -- /usr/bin/cras \ + ${DSP_CONFIG} ${DEVICE_CONFIG_DIR} diff --git a/upstart/cras.conf b/upstart/cras.conf deleted file mode 100644 index 8f528fe6..00000000 --- a/upstart/cras.conf +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (c) 2012 The Chromium OS Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Installed by ADHD package. -# cras upstart job. - -description "ChromeOS audio server" -author "chromium-os-dev@chromium.org" - -env CRAS_SOCKET_DIR=/var/run/cras - -start on starting system-services -stop on stopping system-services -respawn - -# Allow the audio server real time priority. -limit rtprio 12 12 - -pre-start script - mkdir -p -m 1770 "${CRAS_SOCKET_DIR}" - chown -R cras:cras "${CRAS_SOCKET_DIR}" -end script - -script - # For Samus only, check which dsp.ini to load. - if [ "$(mosys platform name)" = "Samus" ]; then - local hw_version="$(mosys platform version)" - if [ "$hw_version" = "MP.A" ] || - [ "$hw_version" = "EVT" ] || - [ "$hw_version" = "DVT" ] || - [ "$hw_version" = "PVT" ]; then - DSP_CONFIG="--dsp_config=/etc/cras/dsp.samus.orig.ini" - fi - fi - # For board needs different device configs, check which config - # directory to use. Use that directory for both volume curves - # and dsp config. - if [ -f /etc/cras/get_device_config_dir ]; then - local device_config_dir="$(sh /etc/cras/get_device_config_dir)" - DEVICE_CONFIG_DIR="--device_config_dir=${device_config_dir}" - DSP_CONFIG="--dsp_config=${device_config_dir}/dsp.ini" - fi - exec minijail0 -u cras -g cras -G -- /usr/bin/cras ${ENABLE_HFP} \ - ${DSP_CONFIG} ${DEVICE_CONFIG_DIR} -end script |