Trying to run alsa inside daemon snap, I have add system-usernames:
part to make the snap daemon not run root.
The snap works when it is not running as daemon
This is my yaml file:
name: app-name
base: core18
version: '0.2' # Just for humans, typically '1.2+git' or '1.3.2'
summary: Single-line elevator pitch for your amazing snap # 79 char long summary
description: |
This is my-snap's description. You have a paragraph or two to tell the
most important story about your snap. Keep it under 100 words though,
we live in tweetspace and your description wants to look good in the snap
store.
#grade: stable # must be 'stable' to release into candidate/stable channels
#confinement: strict # use 'strict' once you have the right plugs and slots
grade: devel # Must be 'stable' to release into candidate/stable channels
confinement: devmode
#architectures: [all]
parts:
alsa-mixin:
plugin: dump
source: https://github.com/diddlesnaps/snapcraft-alsa.git
source-subdir: snapcraft-assets
build-packages:
- libasound2-dev
stage-packages:
- libasound2
- libasound2-plugins
app-name:
after: [alsa-mixin]
plugin: dump
source: .
override-build: |
cd scripts/bashScripts/
./compileAllCFiles.sh # Have to be executed when working directory is this file location
cd ../..
snapcraftctl build
build-packages:
- wget
- unzip
- git
- gcc
- g++
- make
# - python3-pip
# - libevent-dev
# - libperl-dev
- libatlas-base-dev
# - libasound2-plugins
- libasound-dev
stage-packages:
- libatlas-base-dev
- libevent-dev
layout:
/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/alsa-lib:
bind: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/alsa-lib
system-usernames:
snap_daemon: shared
apps:
demo:
command-chain: ["snap/command-chain/alsa-launch"]
command: scripts/cScripts/demo $SNAP
daemon: simple
plugs: [network, network-bind, gpio, hardware-observe, audio-playback, audio-record, pulseaudio, alsa]
And this is the output that I get:
ubuntu@ubuntu:~$ sudo systemctl status -n 100 snap.app-name.demo.service
● snap.app-name.demo.service - Service for snap application app-name.demo
Loaded: loaded (/etc/systemd/system/snap.app-name.demo.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2020-07-14 14:42:13 UTC; 13s ago
Process: 6969 ExecStart=/usr/bin/snap run app-name.demo (code=exited, status=1/FAILURE)
Main PID: 6969 (code=exited, status=1/FAILURE)
Jul 14 14:42:13 ubuntu systemd[1]: snap.app-name.demo.service: Service hold-off time over, scheduling restart.
Jul 14 14:42:13 ubuntu systemd[1]: snap.app-name.demo.service: Scheduled restart job, restart counter is at 5.
Jul 14 14:42:13 ubuntu systemd[1]: Stopped Service for snap application app-name.demo.
Jul 14 14:42:13 ubuntu systemd[1]: snap.app-name.demo.service: Start request repeated too quickly.
Jul 14 14:42:13 ubuntu systemd[1]: snap.app-name.demo.service: Failed with result 'exit-code'.
Jul 14 14:42:13 ubuntu systemd[1]: Failed to start Service for snap application app-name.demo.
This is a link to the project if it more convenient for you.
The .c file that I run is located in Alsa-snap-not-working/Again/scripts/cScripts/snowboy/examples/C/demo.c