Merge ~ondrak/snappy-hwe-snaps/+git/pulseaudio:stable-xenial into ~snappy-hwe-team/snappy-hwe-snaps/+git/pulseaudio:stable

Proposed by Ondrej Kubik on 2019-10-02
Status: Needs review
Proposed branch: ~ondrak/snappy-hwe-snaps/+git/pulseaudio:stable-xenial
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/pulseaudio:stable
Diff against target: 893 lines (+667/-71)
10 files modified
.gitignore (+6/-0)
alsa-lib-snap.patch (+181/-0)
glue/bin/client-wrapper (+0/-5)
glue/bin/pulseaudio (+10/-10)
pulseaudio-snap.patch (+89/-0)
quiltrc (+6/-0)
snap/hooks/configure (+201/-0)
snap/hooks/install (+29/-0)
snap/hooks/post-refresh (+33/-0)
snap/snapcraft.yaml (+112/-56)
Reviewer Review Type Date Requested Status
System Enablement Bot continuous-integration Needs Fixing on 2019-10-10
Oliver Grawert 2019-10-02 Pending
Review via email: mp+373533@code.launchpad.net

Commit message

Update of snapcraft to use modern way of snap building
adding options to alter configurations if required by hw

To post a comment you must log in.

PASSED: Successfully build documentation, rev: 4a74ba660a7c2d7d7923f471607cc34fef7fb288

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/1268/

Unmerged commits

4a74ba6... by Ondrej Kubik on 2019-10-01

snap: add network, network-bind plug to pulse server

Signed-off-by: Ondrej Kubik <email address hidden>

4bd2143... by Ondrej Kubik on 2019-06-14

add pulseaudio snap patch

Signed-off-by: Ondrej Kubik <email address hidden>

a9a20f4... by Ondrej Kubik on 2019-06-14

add alsa-lib snap patch

Signed-off-by: Ondrej Kubik <email address hidden>

0b6c7b9... by Ondrej Kubik on 2019-06-14

snapcraft: dummy part to triger autobuild for pulse and libsound2

Signed-off-by: Ondrej Kubik <email address hidden>

87dfa3f... by Ondrej Kubik on 2019-06-16

snapcraft: build snap from upstream source

Signed-off-by: Ondrej Kubik <email address hidden>

531a7fe... by Ondrej Kubik on 2019-06-18

glue: pulseaudion: add optional service start delay

Signed-off-by: Ondrej Kubik <email address hidden>

4259e17... by Ondrej Kubik on 2019-06-17

hooks: add support for config file modification using snap set

Signed-off-by: Ondrej Kubik <email address hidden>

a7923d3... by Ondrej Kubik on 2019-06-13

snapcraft: making configuration writable

Signed-off-by: Ondrej Kubik <email address hidden>

7f548c4... by Ondrej Kubik on 2019-06-13

snapcraft: refactor to new syntax and plugings

Signed-off-by: Ondrej Kubik <email address hidden>

b8c0cdf... by Ondrej Kubik on 2019-06-14

add gitignore

Signed-off-by: Ondrej Kubik <email address hidden>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/.gitignore b/.gitignore
2new file mode 100644
3index 0000000..3ed44be
4--- /dev/null
5+++ b/.gitignore
6@@ -0,0 +1,6 @@
7+parts/
8+prime/
9+stage/
10+*.snap
11+snap/plugins/__pycache__
12+snap/.snapcraft/
13diff --git a/alsa-lib-snap.patch b/alsa-lib-snap.patch
14new file mode 100644
15index 0000000..d57a937
16--- /dev/null
17+++ b/alsa-lib-snap.patch
18@@ -0,0 +1,181 @@
19+From a763fcf93e6957f9edd8cd49948507d5a0728412 Mon Sep 17 00:00:00 2001
20+From: Ondrej Kubik <ondrej.kubik@canonical.com>
21+Date: Fri, 14 Jun 2019 21:32:14 +0100
22+Subject: [PATCH] xenial: snap: snap changes
23+
24+Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>
25+---
26+ src/alisp/alisp.c | 3 ++-
27+ src/conf.c | 7 +++++--
28+ src/confmisc.c | 4 ++--
29+ src/control/control.c | 7 +++++--
30+ src/dlmisc.c | 7 +++++--
31+ src/pcm/pcm.c | 8 ++++++--
32+ src/pcm/pcm_rate.c | 5 ++++-
33+ 7 files changed, 29 insertions(+), 12 deletions(-)
34+
35+diff --git a/src/alisp/alisp.c b/src/alisp/alisp.c
36+index 3c61bb1..1474b97 100644
37+--- a/src/alisp/alisp.c
38++++ b/src/alisp/alisp.c
39+@@ -2399,7 +2399,8 @@ struct alisp_object * F_path(struct alisp_instance *instance, struct alisp_objec
40+ }
41+ if (!strcmp(p1->value.s, "data")) {
42+ delete_tree(instance, p1);
43+- return new_string(instance, ALSA_CONFIG_DIR);
44++ const char *config_dir = getenv("ALSA_CONFIG_DIR");
45++ return new_string(instance, config_dir ? config_dir : ALSA_CONFIG_DIR );
46+ }
47+ delete_tree(instance, p1);
48+ return &alsa_lisp_nil;
49+diff --git a/src/conf.c b/src/conf.c
50+index a4f2a4f..29e48a9 100644
51+--- a/src/conf.c
52++++ b/src/conf.c
53+@@ -622,6 +622,9 @@ static int get_delimstring(char **string, int delim, input_t *input);
54+ static int get_char_skip_comments(input_t *input)
55+ {
56+ int c;
57++ char *config_dir = getenv("ALSA_CONFIG_DIR");
58++ if (!config_dir)
59++ config_dir = ALSA_CONFIG_DIR;
60+ while (1) {
61+ c = get_char(input);
62+ if (c == '<') {
63+@@ -632,12 +635,12 @@ static int get_char_skip_comments(input_t *input)
64+ if (err < 0)
65+ return err;
66+ if (!strncmp(str, "confdir:", 8)) {
67+- char *tmp = malloc(strlen(ALSA_CONFIG_DIR) + 1 + strlen(str + 8) + 1);
68++ char *tmp = malloc(strlen(config_dir) + 1 + strlen(str + 8) + 1);
69+ if (tmp == NULL) {
70+ free(str);
71+ return -ENOMEM;
72+ }
73+- sprintf(tmp, ALSA_CONFIG_DIR "/%s", str + 8);
74++ sprintf(tmp, "%s/%s", config_dir, str + 8);
75+ free(str);
76+ str = tmp;
77+ }
78+diff --git a/src/confmisc.c b/src/confmisc.c
79+index ae0275f..8ca70de 100644
80+--- a/src/confmisc.c
81++++ b/src/confmisc.c
82+@@ -584,11 +584,11 @@ int snd_func_datadir(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNUSED,
83+ {
84+ int err;
85+ const char *id;
86+-
87++ const char *config_dir = getenv("ALSA_CONFIG_DIR");
88+ err = snd_config_get_id(src, &id);
89+ if (err < 0)
90+ return err;
91+- return snd_config_imake_string(dst, id, ALSA_CONFIG_DIR);
92++ return snd_config_imake_string(dst, id, config_dir ? config_dir : ALSA_CONFIG_DIR);
93+ }
94+ #ifndef DOC_HIDDEN
95+ SND_DLSYM_BUILD_VERSION(snd_func_datadir, SND_CONFIG_DLSYM_VERSION_EVALUATE);
96+diff --git a/src/control/control.c b/src/control/control.c
97+index 4a28cf6..7c92db9 100644
98+--- a/src/control/control.c
99++++ b/src/control/control.c
100+@@ -835,6 +835,9 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
101+ const char *lib = NULL, *open_name = NULL;
102+ const char *id;
103+ int (*open_func)(snd_ctl_t **, const char *, snd_config_t *, snd_config_t *, int) = NULL;
104++ char *plugin_dir = getenv("ALSA_PLUGIN_DIR");
105++ if (!plugin_dir)
106++ plugin_dir = ALSA_PLUGIN_DIR;
107+ #ifndef PIC
108+ extern void *snd_control_open_symbols(void);
109+ #endif
110+@@ -912,13 +915,13 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
111+ build_in++;
112+ }
113+ if (*build_in == NULL) {
114+- buf1 = malloc(strlen(str) + sizeof(ALSA_PLUGIN_DIR) + 32);
115++ buf1 = malloc(strlen(str) + sizeof(plugin_dir) + 32);
116+ if (buf1 == NULL) {
117+ err = -ENOMEM;
118+ goto _err;
119+ }
120+ lib = buf1;
121+- sprintf(buf1, "%s/libasound_module_ctl_%s.so", ALSA_PLUGIN_DIR, str);
122++ sprintf(buf1, "%s/libasound_module_ctl_%s.so", plugin_dir, str);
123+ }
124+ }
125+ #ifndef PIC
126+diff --git a/src/dlmisc.c b/src/dlmisc.c
127+index b36c48f..b8c4db3 100644
128+--- a/src/dlmisc.c
129++++ b/src/dlmisc.c
130+@@ -74,10 +74,13 @@ void *snd_dlopen(const char *name, int mode)
131+ */
132+ void *handle = NULL;
133+ char *filename;
134++ char *plugin_dir = getenv("ALSA_PLUGIN_DIR");
135++ if (!plugin_dir)
136++ plugin_dir = ALSA_PLUGIN_DIR;
137+
138+ if (name && name[0] != '/') {
139+- filename = malloc(sizeof(ALSA_PLUGIN_DIR) + 1 + strlen(name) + 1);
140+- strcpy(filename, ALSA_PLUGIN_DIR);
141++ filename = malloc(sizeof(plugin_dir) + 1 + strlen(name) + 1);
142++ strcpy(filename, plugin_dir);
143+ strcat(filename, "/");
144+ strcat(filename, name);
145+ handle = dlopen(filename, mode);
146+diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c
147+index cbbc55a..60c410f 100644
148+--- a/src/pcm/pcm.c
149++++ b/src/pcm/pcm.c
150+@@ -2117,6 +2117,10 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
151+ int (*open_func)(snd_pcm_t **, const char *,
152+ snd_config_t *, snd_config_t *,
153+ snd_pcm_stream_t, int) = NULL;
154++ char *plugin_dir = getenv("ALSA_PLUGIN_DIR");
155++ if (!plugin_dir)
156++ plugin_dir = ALSA_PLUGIN_DIR;
157++
158+ #ifndef PIC
159+ extern void *snd_pcm_open_symbols(void);
160+ #endif
161+@@ -2197,13 +2201,13 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
162+ build_in++;
163+ }
164+ if (*build_in == NULL) {
165+- buf1 = malloc(strlen(str) + sizeof(ALSA_PLUGIN_DIR) + 32);
166++ buf1 = malloc(strlen(str) + sizeof(plugin_dir) + 32);
167+ if (buf1 == NULL) {
168+ err = -ENOMEM;
169+ goto _err;
170+ }
171+ lib = buf1;
172+- sprintf(buf1, "%s/libasound_module_pcm_%s.so", ALSA_PLUGIN_DIR, str);
173++ sprintf(buf1, "%s/libasound_module_pcm_%s.so", plugin_dir, str);
174+ }
175+ }
176+ #ifndef PIC
177+diff --git a/src/pcm/pcm_rate.c b/src/pcm/pcm_rate.c
178+index c76db25..ae920bc 100644
179+--- a/src/pcm/pcm_rate.c
180++++ b/src/pcm/pcm_rate.c
181+@@ -1226,11 +1226,14 @@ static int rate_open_func(snd_pcm_rate_t *rate, const char *type, int verbose)
182+ char open_name[64], lib_name[128], *lib = NULL;
183+ snd_pcm_rate_open_func_t open_func;
184+ int err;
185++ char *plugin_dir = getenv("ALSA_PLUGIN_DIR");
186++ if (!plugin_dir)
187++ plugin_dir = ALSA_PLUGIN_DIR;
188+
189+ snprintf(open_name, sizeof(open_name), "_snd_pcm_rate_%s_open", type);
190+ if (!is_builtin_plugin(type)) {
191+ snprintf(lib_name, sizeof(lib_name),
192+- "%s/libasound_module_rate_%s.so", ALSA_PLUGIN_DIR, type);
193++ "%s/libasound_module_rate_%s.so", plugin_dir, type);
194+ lib = lib_name;
195+ }
196+ open_func = snd_dlobj_cache_get(lib, open_name, NULL, verbose);
197+--
198+2.20.1
199+
200diff --git a/bin/client-wrapper b/glue/bin/client-wrapper
201similarity index 90%
202rename from bin/client-wrapper
203rename to glue/bin/client-wrapper
204index 255187c..fc66e93 100755
205--- a/bin/client-wrapper
206+++ b/glue/bin/client-wrapper
207@@ -19,11 +19,6 @@ if [ "$(id -u)" -ne 0 ]; then
208 exit 1
209 fi
210
211-export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SNAP/usr/lib/pulseaudio:$SNAP/usr/lib/pulse-8.0/modules/
212-export PULSE_CLIENTCONFIG=$SNAP/etc/pulse/client.conf
213-export PULSE_RUNTIME_PATH=/var/run/pulse
214-export PULSE_SYSTEM=1
215-
216 unset XDG_RUNTIME_DIR
217
218 export HOME=$SNAP_DATA/home
219diff --git a/bin/config b/glue/bin/config
220similarity index 100%
221rename from bin/config
222rename to glue/bin/config
223diff --git a/bin/pulseaudio b/glue/bin/pulseaudio
224similarity index 62%
225rename from bin/pulseaudio
226rename to glue/bin/pulseaudio
227index 40c9a85..e966e92 100755
228--- a/bin/pulseaudio
229+++ b/glue/bin/pulseaudio
230@@ -2,14 +2,6 @@
231 set -e
232 set -x
233
234-export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SNAP/usr/lib/pulseaudio:$SNAP/usr/lib/pulse-8.0/modules/
235-export PULSE_RUNTIME_PATH=/var/run/pulse
236-export PULSE_STATE_PATH=$SNAP_DATA/state
237-export ALSA_CONFIG_UCM=$SNAP/usr/share/alsa/ucm
238-export ALSA_CONFIG_TPLG=$SNAP/usr/share/alsa/topology
239-export ALSA_CONFIG_PATH=$SNAP/usr/share/alsa/alsa.conf
240-export ALSA_MIXER_SIMPLE=$SNAP/usr/share/alsa/smixer.conf
241-
242 mkdir -p $PULSE_STATE_PATH
243
244 EXTRA_ARGS=
245@@ -19,12 +11,20 @@ if [ -e $SNAP_DATA/config/debug ] ; then
246 export LIBASOUND_DEBUG=1
247 fi
248
249+# on some hw, hw requires init steps before pulseaudio can be started
250+# as we do not have socket activated service yet, add optional delayed start
251+DELAY=$(snapctl get pulseaudio.delay-service)
252+if [ -n "${DELAY}" ]; then
253+ # ignore any error is delay is boggus number
254+ sleep ${DELAY} || true
255+fi
256+
257 $SNAP/usr/bin/pulseaudio \
258 --exit-idle-time=-1 \
259 --disallow-exit=yes \
260 --disallow-module-loading \
261 --system \
262- -F $SNAP/etc/pulse/default.pa \
263- -p $SNAP/usr/lib/pulse-8.0/modules \
264+ -F ${SNAP_DATA}/etc/pulse/default.pa \
265+ -p ${SNAP}/usr/lib/pulse-8.0/modules \
266 -n \
267 $EXTRA_ARGS
268diff --git a/data/copyright b/glue/usr/share/doc/pulseaudio/copyright
269similarity index 100%
270rename from data/copyright
271rename to glue/usr/share/doc/pulseaudio/copyright
272diff --git a/pulseaudio-snap.patch b/pulseaudio-snap.patch
273new file mode 100644
274index 0000000..4ffbcdb
275--- /dev/null
276+++ b/pulseaudio-snap.patch
277@@ -0,0 +1,89 @@
278+From e0eaeecf7b028a238c9ba4c8fd15e794eaefc2af Mon Sep 17 00:00:00 2001
279+From: Ondrej Kubik <ondrej.kubik@canonical.com>
280+Date: Fri, 14 Jun 2019 22:01:35 +0100
281+Subject: [PATCH] xenial: snap: snap changes
282+
283+Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>
284+---
285+ configure.ac | 2 +-
286+ src/daemon/main.c | 12 ++++++------
287+ src/modules/alsa/alsa-mixer.c | 6 ++++--
288+ 3 files changed, 11 insertions(+), 9 deletions(-)
289+
290+diff --git a/configure.ac b/configure.ac
291+index 9250c05d..f8e7673c 100644
292+--- a/configure.ac
293++++ b/configure.ac
294+@@ -177,7 +177,7 @@ esac
295+ #### Compiler flags ####
296+
297+ AX_APPEND_COMPILE_FLAGS(
298+- [-Wall -W -Wextra -pipe -Wno-long-long -Wno-overlength-strings -Wunsafe-loop-optimizations -Wundef -Wformat=2 -Wlogical-op -Wsign-compare -Wformat-security -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Winit-self -Wdeclaration-after-statement -Wfloat-equal -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-align -Wstrict-aliasing -Wwrite-strings -Wno-unused-parameter -ffast-math -fno-common -fdiagnostics-show-option -fdiagnostics-color=auto],
299++ [-Wall -W -Wextra -pipe -Wno-long-long -Wno-overlength-strings -Wunsafe-loop-optimizations -Wundef -Wformat=2 -Wlogical-op -Wsign-compare -Wformat-security -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Winit-self -Wdeclaration-after-statement -Wfloat-equal -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-align -Wstrict-aliasing -Wwrite-strings -Wno-unused-parameter -ffast-math -fno-common -fdiagnostics-show-option -fdiagnostics-color=auto -fomit-frame-pointer],
300+ [], [-pedantic -Werror])
301+
302+ AS_CASE([" $CFLAGS "], [*" -O0 "*], [], [
303+diff --git a/src/daemon/main.c b/src/daemon/main.c
304+index c2f47b69..f4887554 100644
305+--- a/src/daemon/main.c
306++++ b/src/daemon/main.c
307+@@ -175,16 +175,16 @@ static int change_user(void) {
308+ return -1;
309+ }
310+
311+- if (!pa_streq(pw->pw_dir, PA_SYSTEM_RUNTIME_PATH))
312+- pa_log_warn(_("Home directory of user '%s' is not '%s', ignoring."), PA_SYSTEM_USER, PA_SYSTEM_RUNTIME_PATH);
313++ if (!pa_streq(pw->pw_dir, getenv("PULSE_RUNTIME_PATH")))
314++ pa_log_warn(_("Home directory of user '%s' is not '%s', ignoring."), PA_SYSTEM_USER, getenv("PULSE_RUNTIME_PATH"));
315+
316+- if (pa_make_secure_dir(PA_SYSTEM_RUNTIME_PATH, 0755, pw->pw_uid, gr->gr_gid, true) < 0) {
317+- pa_log(_("Failed to create '%s': %s"), PA_SYSTEM_RUNTIME_PATH, pa_cstrerror(errno));
318++ if (pa_make_secure_dir(getenv("PULSE_RUNTIME_PATH"), 0755, pw->pw_uid, gr->gr_gid, true) < 0) {
319++ pa_log(_("Failed to create '%s': %s"), getenv("PULSE_RUNTIME_PATH"), pa_cstrerror(errno));
320+ return -1;
321+ }
322+
323+- if (pa_make_secure_dir(PA_SYSTEM_STATE_PATH, 0700, pw->pw_uid, gr->gr_gid, true) < 0) {
324+- pa_log(_("Failed to create '%s': %s"), PA_SYSTEM_STATE_PATH, pa_cstrerror(errno));
325++ if (pa_make_secure_dir(getenv("PULSE_STATE_PATH"), 0700, pw->pw_uid, gr->gr_gid, true) < 0) {
326++ pa_log(_("Failed to create '%s': %s"), getenv("PULSE_STATE_PATH"), pa_cstrerror(errno));
327+ return -1;
328+ }
329+
330+diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
331+index 1fe2a024..4cbc8277 100644
332+--- a/src/modules/alsa/alsa-mixer.c
333++++ b/src/modules/alsa/alsa-mixer.c
334+@@ -2529,10 +2529,11 @@ static int path_verify(pa_alsa_path *p) {
335+ }
336+
337+ static const char *get_default_paths_dir(void) {
338++ const char *alsa_paths_dir = getenv("PULSE_ALSA_PATHS_DIR");
339+ if (pa_run_from_build_tree())
340+ return PA_SRCDIR "/modules/alsa/mixer/paths/";
341+ else
342+- return PA_ALSA_PATHS_DIR;
343++ return alsa_paths_dir ? alsa_paths_dir : PA_ALSA_PATHS_DIR;
344+ }
345+
346+ pa_alsa_path* pa_alsa_path_new(const char *paths_dir, const char *fname, pa_alsa_direction_t direction) {
347+@@ -4365,6 +4366,7 @@ pa_alsa_profile_set* pa_alsa_profile_set_new(const char *fname, const pa_channel
348+ char *fn;
349+ int r;
350+ void *state;
351++ const char *alsa_profile_sets_dir = getenv("PULSE_ALSA_PROFILE_SETS_DIR");
352+
353+ static pa_config_item items[] = {
354+ /* [General] */
355+@@ -4409,7 +4411,7 @@ pa_alsa_profile_set* pa_alsa_profile_set_new(const char *fname, const pa_channel
356+
357+ fn = pa_maybe_prefix_path(fname,
358+ pa_run_from_build_tree() ? PA_SRCDIR "/modules/alsa/mixer/profile-sets/" :
359+- PA_ALSA_PROFILE_SETS_DIR);
360++ alsa_profile_sets_dir ? alsa_profile_sets_dir : PA_ALSA_PROFILE_SETS_DIR);
361+
362+ r = pa_config_parse(fn, NULL, items, NULL, false, ps);
363+ pa_xfree(fn);
364+--
365+2.20.1
366+
367diff --git a/quiltrc b/quiltrc
368new file mode 100644
369index 0000000..f2568ce
370--- /dev/null
371+++ b/quiltrc
372@@ -0,0 +1,6 @@
373+for where in ./ ../ ../../ ../../../ ../../../../ ../../../../../; do
374+ if [ -e ${where}debian/rules -a -d ${where}debian/patches ]; then
375+ export QUILT_PATCHES=debian/patches
376+ break
377+ fi
378+done
379diff --git a/snap/hooks/configure b/snap/hooks/configure
380new file mode 100755
381index 0000000..844be89
382--- /dev/null
383+++ b/snap/hooks/configure
384@@ -0,0 +1,201 @@
385+#!/bin/bash
386+#
387+# Copyright (C) 2016 Canonical Ltd
388+#
389+# This program is free software: you can redistribute it and/or modify
390+# it under the terms of the GNU General Public License version 3 as
391+# published by the Free Software Foundation.
392+#
393+# This program is distributed in the hope that it will be useful,
394+# but WITHOUT ANY WARRANTY; without even the implied warranty of
395+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
396+# GNU General Public License for more details.
397+#
398+# You should have received a copy of the GNU General Public License
399+# along with this program. If not, see <http://www.gnu.org/licenses/>.
400+
401+if [ -e $SNAP_DATA/config/debug ] ; then
402+ DEBUG=1
403+ set -x
404+fi
405+
406+exec >> $SNAP_COMMON/hook.log 2>&1
407+echo "$(date '+%Y-%m-%d %H:%M:%S') $(basename $0): Entering hook"
408+
409+# traverse in three directories
410+# -etc/pulse
411+# -usr/share/alsa
412+# -usr/share/pulseaudio
413+# when file config is reached, it has three values, filaname, remove and add
414+# - filename: is relative file path, without $SNAP_DATA part
415+# - remove: list of strings to be removed from given file
416+# this can be multi line value, each line is process separatelly
417+# - add: list of strings to be appended to given file
418+# this could be multi line value, all lines are appended to config file
419+# - replace: list of pairs match replace values, values on separate lines
420+# at least two lines needed match <> replace
421+#
422+# example:
423+# snap set pulseaudio etc.pulse.default-pa='{"filename": "etc/pulse/default.pa", "remove": "", "add": "load-module module-alsa-sink device=hw:0,0\nload-module module-alsa-source device=hw:0,1"}'
424+# snap set pulseaudio etc.pulse='{"daemon-conf": { "filename": "etc/pulse/daemon.conf", "remove": "", "add": "" }, "default-pa": { "filename": "etc/pulse/default.pa", "remove": "", "add": "load-module module-alsa-sink device=hw:0,0\nload-module module-alsa-source device=hw:0,1"}'
425+# snap set pulseaudio etc.pulse='{"daemon-conf": { "filename": "etc/pulse/daemon.conf", "remove": "", "add": "" }, "default-pa": { "filename": "etc/pulse/default.pa", "remove": "load-module module-alsa-sink device=.*\nload-module module-alsa-source device=.*", "add": "load-module module-alsa-sink device=hw:0,0\nload-module module-alsa-source device=hw:0,1"}}'
426+# snap set pulseaudio etc.pulse.default-pa='{"filename": "etc/pulse/default.pa", "replace": ".*load-module module-alsa-sink.*\nload-module module-alsa-sink device=hw:0,0\n.*load-module module-alsa-source.*\nload-module module-alsa-source device=hw:0,1"}'
427+# providing way to alter configuration files through snap set command
428+# not full example of supported config options
429+# {
430+# "etc": {
431+# "pulse": {
432+# "client-conf": {
433+# "filename": "etc/pulse/client.conf",
434+# "replace": ""
435+# "remove": "",
436+# "add": ""
437+# },
438+# "daemon-conf": {
439+# "filename": "etc/pulse/daemon.conf",
440+# "remove": "",
441+# "add": ""
442+# },
443+# "default-pa": {
444+# "filename": "etc/pulse/default.pa",
445+# "replace": ".*load-module module-alsa-sink.*\nload-module module-alsa-sink device=hw:0,0\n.*load-module module-alsa-source.*\nload-module module-alsa-source device=hw:0,1",
446+# "remove": "load-module module-alsa-sink device=.*\nload-module module-alsa-source device=.*",
447+# "add": "load-module module-alsa-sink device=hw:0,0\nload-module module-alsa-source device=hw:0,1"
448+# },
449+# "system-pa": {
450+# "filename": "etc/pulse/system.pa",
451+# "remove": "",
452+# "add": ""
453+# }
454+# }
455+# },
456+# "usr": {
457+# "share": {
458+# "alsa": {
459+# "alsa-conf": {
460+# "filename": "usr/share/alsa/alsa.conf",
461+# "remove": "",
462+# "add": ""
463+# },
464+# "topology": {
465+# "broadwell": {
466+# "filename": "usr/share/alsa/topology/broadwell/broadwell.conf",
467+# "remove": "",
468+# "add": ""
469+# }
470+# }
471+# },
472+# "pulseaudio": {
473+# "alsa-mixer": {
474+# "paths": {
475+# "analog-output-conf": {
476+# "filename": "usr/share/pulseaudio/alsa-mixer/paths/analog-output.conf",
477+# "remove": "",
478+# "add": ""
479+# }
480+# },
481+# "profile-sets": {
482+# "default-conf": {
483+# "filename": "usr/share/pulseaudio/alsa-mixer/profile-sets/default.conf",
484+# "remove": "",
485+# "add": ""
486+# }
487+# }
488+# }
489+# }
490+# }
491+# }
492+# }
493+
494+process_file_remove() {
495+ filename="${1}"
496+ shift
497+ remove="${@}"
498+ if [ -n "${remove}" ]; then
499+ # remove all matching lines from config, there could be more patterns, process by lines
500+ while read -r line
501+ do
502+ if [ -n "${line}" ]; then
503+ echo "removing from [${filename}] strings [$line]"
504+ sed -i "s/$(echo ${line} | sed -e 's/\\/\\\\/g; s/\//\\\//g; s/&/\\\&/g')//g" ${SNAP_DATA}/${filename}
505+ fi
506+ done < <(echo "${remove}")
507+ fi
508+}
509+
510+process_file_add() {
511+ filename="${1}"
512+ shift
513+ add="${@}"
514+ if [ -n "${add}" ]; then
515+ echo "adding from [${filename}] strings [$add]"
516+ [ "${DEBUG}" = "1" ] && echo -e "\n# start: added by snap configure" >> ${SNAP_DATA}/${filename}
517+ echo "${add}" >> ${SNAP_DATA}/${filename}
518+ [ "${DEBUG}" = "1" ] && echo -e "# end: added by snap configure" >> ${SNAP_DATA}/${filename}
519+ fi
520+}
521+
522+process_file_replace() {
523+ filename="${1}"
524+ shift
525+ if [ -n "${@}" ]; then
526+ # we need to process two lines at the time, first line is match, following line is replacing value
527+ while read -r match
528+ do
529+ read -r replace
530+ if [ -n "${match}" ] && [ -n "${replace}" ]; then
531+ echo "replace from [${filename}] string [${match}] with [${replace}]"
532+ sed -i "s/$(echo ${match} | sed -e 's/\\/\\\\/g; s/\//\\\//g; s/&/\\\&/g')/$(echo ${replace} | sed -e 's/\\/\\\\/g; s/\//\\\//g; s/&/\\\&/g')/g" ${SNAP_DATA}/${filename}
533+ fi
534+ done < <(echo "${@}")
535+ fi
536+}
537+
538+process_line() {
539+ [ "${DEBUG}" = "1" ] && echo "process_line << $@"
540+ # each line starts with key name and end with variable
541+ local key=$1
542+ shift
543+ # check if we have valid json in first place
544+ if ! jq -e . >/dev/null 2>&1 <<<"$@"; then
545+ type -p handle_key_value && handle_key_value ${key} $@
546+ return
547+ fi
548+ filename=$(echo $@ | jq -r '.filename')
549+ # if we have filename, no need to traverse further
550+ if [ "${filename}" == "null" ]; then
551+ type -p processing_top_key_start && processing_top_key_start ${key}
552+ while read -r line
553+ do
554+ process_line ${key}.${line}
555+ done < <(echo "$@" | jq -r 'keys[] as $k | "\($k) \(.[$k] )"')
556+ type -p processing_top_key_end && processing_top_key_end ${key}
557+ else
558+ ADD=$(echo $@ | jq -r '.add')
559+ [ "${ADD}" == "null" ] && ADD=""
560+ REMOVE=$(echo $@ | jq -r '.remove')
561+ [ "${REMOVE}" == "null" ] && REMOVE=""
562+ REPLACE=$(echo $@ | jq -r '.replace')
563+ [ "${REPLACE}" == "null" ] && REPLACE=""
564+ type -p process_file_replace && process_file_replace "${filename}" "${REPLACE}"
565+ type -p process_file_remove && process_file_remove "${filename}" "${REMOVE}"
566+ type -p process_file_add && process_file_add "${filename}" "${ADD}"
567+ fi
568+}
569+
570+CONFIGURATION="etc usr"
571+
572+echo "Process config changes"
573+
574+for conf in $CONFIGURATION
575+do
576+ [ "${DEBUG}" = "1" ] && echo "processing: ${conf}"
577+ # only process if we get valid json
578+ key_val=$(snapctl get -d "${conf}")
579+ if jq -e . >/dev/null 2>&1 <<<"${key_val}"; then
580+ process_line $(jq -r 'keys[] as $k | "\($k) \(.[$k] )"' <<< $(snapctl get -d ${conf}))
581+ fi
582+done
583+
584+# restart pulse service
585+snapctl restart ${SNAP_INSTANCE_NAME}.pulseaudio
586diff --git a/snap/hooks/install b/snap/hooks/install
587new file mode 100755
588index 0000000..db735a4
589--- /dev/null
590+++ b/snap/hooks/install
591@@ -0,0 +1,29 @@
592+#!/bin/bash
593+
594+#
595+# Copyright (C) 2016 Canonical Ltd
596+#
597+# This program is free software: you can redistribute it and/or modify
598+# it under the terms of the GNU General Public License version 3 as
599+# published by the Free Software Foundation.
600+#
601+# This program is distributed in the hope that it will be useful,
602+# but WITHOUT ANY WARRANTY; without even the implied warranty of
603+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
604+# GNU General Public License for more details.
605+#
606+# You should have received a copy of the GNU General Public License
607+# along with this program. If not, see <http://www.gnu.org/licenses/>.
608+
609+set -x
610+exec >> $SNAP_COMMON/hook.log 2>&1
611+echo "$(date '+%Y-%m-%d %H:%M:%S') $(basename $0): Entering hook"
612+
613+# copy initial client configuration
614+mkdir -p ${SNAP_DATA}/var/lib/pulse
615+mkdir -p ${SNAP_DATA}/etc
616+mkdir -p ${SNAP_DATA}/usr/share
617+
618+cp -r ${SNAP}/etc/pulse ${SNAP_DATA}/etc
619+cp -r ${SNAP}/usr/share/alsa ${SNAP_DATA}/usr/share
620+cp -r ${SNAP}/usr/share/pulseaudio ${SNAP_DATA}/usr/share
621diff --git a/snap/hooks/post-refresh b/snap/hooks/post-refresh
622new file mode 100755
623index 0000000..83eecc4
624--- /dev/null
625+++ b/snap/hooks/post-refresh
626@@ -0,0 +1,33 @@
627+#!/bin/bash
628+#
629+# Copyright (C) 2016 Canonical Ltd
630+#
631+# This program is free software: you can redistribute it and/or modify
632+# it under the terms of the GNU General Public License version 3 as
633+# published by the Free Software Foundation.
634+#
635+# This program is distributed in the hope that it will be useful,
636+# but WITHOUT ANY WARRANTY; without even the implied warranty of
637+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
638+# GNU General Public License for more details.
639+#
640+# You should have received a copy of the GNU General Public License
641+# along with this program. If not, see <http://www.gnu.org/licenses/>.
642+
643+set -x
644+exec >> ${SNAP_COMMON}/hook.log 2>&1
645+echo "$(date '+%Y-%m-%d %H:%M:%S') $(basename $0): Entering hook"
646+
647+# make sure we have initial configuration handy
648+mkdir -p ${SNAP_DATA}/var/lib/pulse
649+mkdir -p ${SNAP_DATA}/etc
650+mkdir -p ${SNAP_DATA}/usr/share
651+
652+cp -r -n ${SNAP}/etc/pulse ${SNAP_DATA}/etc
653+cp -r -n ${SNAP}/usr/share/alsa ${SNAP_DATA}/usr/share
654+cp -r -n ${SNAP}/usr/share/pulseaudio ${SNAP_DATA}/usr/share
655+
656+# clean snapctl as we cannot do it from configure hooks
657+# so we not repeaase same steps again
658+snapctl set env=""
659+snapctl set usr=""
660diff --git a/snapcraft.yaml b/snap/snapcraft.yaml
661similarity index 50%
662rename from snapcraft.yaml
663rename to snap/snapcraft.yaml
664index 605243c..172eaa1 100644
665--- a/snapcraft.yaml
666+++ b/snap/snapcraft.yaml
667@@ -1,5 +1,4 @@
668 name: pulseaudio
669-version: 8.0-4
670 summary: PulseAudio sound server
671 description: |
672 PulseAudio, previously known as Polypaudio, is a sound server for POSIX and
673@@ -10,27 +9,62 @@ description: |
674 https://code.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/pulseaudio
675 grade: stable
676 confinement: strict
677+adopt-info: pulseaudio
678+base: core
679+
680+environment:
681+ PATH: ${SNAP}/usr/sbin:${SNAP}/usr/bin:${SNAP}/sbin:${SNAP}/bin:${PATH}
682+ LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}:${SNAP}/usr/lib/pulseaudio:${SNAP}/usr/lib/pulse-8.0/modules/:${SNAP}/lib:${SNAP}/usr/lib:${SNAP}/lib/${SNAPCRAFT_ARCH_TRIPLET}:${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}
683+ PULSE_DLPATH: ${SNAP}/usr/lib/pulse-8.0/modules
684+ PULSE_CLIENTCONFIG: ${SNAP_DATA}/etc/pulse/client.conf
685+ PULSE_RUNTIME_PATH: /var/run/pulse
686+ PULSE_SYSTEM: 1
687+ PULSE_STATE_PATH: ${SNAP_DATA}/state
688+ PULSE_SCRIPT: ${SNAP_DATA}/etc/pulse/default.pa
689+ PULSE_CONFIG: ${SNAP_DATA}/etc/pulse/daemon.conf
690+ PULSE_CONFIG_PATH: ${SNAP_DATA}/var/lib/pulse
691+ PULSE_ALSA_PATHS_DIR: ${SNAP_DATA}/usr/share/pulseaudio/alsa-mixer
692+ ALSA_CONFIG_UCM: ${SNAP_DATA}/usr/share/alsa/ucm
693+ ALSA_CONFIG_TPLG: ${SNAP_DATA}/usr/share/alsa/topology
694+ ALSA_CONFIG_PATH: ${SNAP_DATA}/usr/share/alsa/alsa.conf
695+ ALSA_MIXER_SIMPLE: ${SNAP_DATA}/usr/share/alsa/smixer.conf
696+ ALSA_CONFIG_DIR: ${SNAP_DATA}/usr/share/alsa/
697+ ALSA_CONFIG_UCM_VAR: ${SNAP_DATA}/usr/share/alsa/ucm
698+ ALSA_CONFIG_TPLG_VAR: ${SNAP_DATA}/usr/share/alsa/topology
699+ ALSA_PLUGIN_DIR: ${SNAP}/usr/lib/alsa-lib
700+ ALSA_MIXER_SIMPLE_MODULES: ${SNAP}/usr/lib/alsa-lib/smixer
701+ ALSA_MIXER_SIMPLE_MPYTHON: ${SNAP}/usr/lib/alsa-lib/smixer/python/main.py
702
703 apps:
704 pulseaudio:
705 command: bin/pulseaudio
706 daemon: simple
707- slots: [service]
708+ slots:
709+ - service
710+ plugs:
711+ - network
712+ - network-bind
713+
714 pactl:
715 command: bin/client-wrapper usr/bin/pactl
716- plugs: [client, network]
717- aliases:
718- - pactl
719+ plugs:
720+ - client
721+ - network
722+
723 paplay:
724 command: bin/client-wrapper usr/bin/paplay
725- plugs: [client, home, network]
726- aliases:
727- - paplay
728+ plugs:
729+ - client
730+ - home
731+ - network
732+
733 parec:
734 command: bin/client-wrapper usr/bin/parec
735- plugs: [client, home, network]
736- aliases:
737- - parec
738+ plugs:
739+ - client
740+ - home
741+ - network
742+
743 config:
744 command: bin/config
745
746@@ -43,21 +77,21 @@ plugs:
747 interface: pulseaudio
748
749 parts:
750- pulseaudio-common:
751- plugin: copy
752- files:
753- bin/pulseaudio: bin/pulseaudio
754- bin/client-wrapper: bin/client-wrapper
755- bin/config: bin/config
756- data/copyright: usr/share/doc/pulseaudio/copyright
757+ glue:
758+ plugin: dump
759+ source: glue
760
761 alsa-lib:
762 plugin: autotools
763-
764- source: https://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/pulseaudio
765+ source: https://git.launchpad.net/ubuntu/+source/alsa-lib
766 source-type: git
767- source-branch: alsa-lib/xenial/1.1.0
768-
769+ source-branch: ubuntu/xenial
770+ override-pull: |
771+ snapcraftctl pull
772+ rm -rf manual
773+ [ -z "${SNAPCRAFT_PROJECT_DIR}" ] && SNAPCRAFT_PROJECT_DIR="../../.."
774+ quilt push -afq --leave-rejects --quiltrc=${SNAPCRAFT_PROJECT_DIR}/quiltrc
775+ git apply ${SNAPCRAFT_PROJECT_DIR}/alsa-lib-snap.patch
776 configflags:
777 - --prefix=/usr
778 - --sysconfdir=/etc
779@@ -68,27 +102,26 @@ parts:
780 - --disable-silent-rules
781 - --disable-static
782 - --disable-python
783-
784- filesets:
785- libasound2:
786- - usr/lib/libasound.so*
787- - usr/lib/alsa-lib/*
788- - usr/share/alsa/*
789-
790- snap:
791- - $libasound2
792+ stage:
793+ - usr/lib/libasound.so*
794+ - usr/lib/alsa-lib
795+ - usr/share/alsa
796
797
798 pulseaudio:
799 after:
800 - alsa-lib
801-
802 plugin: autotools
803-
804- source: https://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/pulseaudio
805+ source: https://git.launchpad.net/ubuntu/+source/pulseaudio
806 source-type: git
807- source-branch: pulseaudio/8.0
808-
809+ source-branch: ubuntu/xenial
810+ override-pull: |
811+ snapcraftctl pull
812+ snapcraftctl set-version $(git describe --tags | cut -c 19-)
813+ rm -rf manual
814+ [ -z "${SNAPCRAFT_PROJECT_DIR}" ] && SNAPCRAFT_PROJECT_DIR="../../.."
815+ quilt push -afq --leave-rejects --quiltrc=../../../quiltrc
816+ git apply ${SNAPCRAFT_PROJECT_DIR}/pulseaudio-snap.patch
817 build-packages:
818 - intltool
819 - libasound2-dev
820@@ -106,7 +139,8 @@ parts:
821 - libudev-dev
822 - libasyncns-dev
823 - libxcb1-dev
824-
825+ - libsbc-dev
826+ - quilt
827 configflags:
828 - --prefix=/usr
829 - --sysconfdir=/etc
830@@ -133,22 +167,44 @@ parts:
831 - --disable-x11
832 - --with-system-user=root
833 - --with-system-group=root
834-
835- filesets:
836- wanted:
837- - etc/*
838- - lib/*
839- - usr/bin/pacat
840- - usr/bin/pactl
841- - usr/bin/paplay
842- - usr/bin/parec
843- - usr/bin/pulseaudio
844- - usr/lib/libpulse-mainloop-glib.so*
845- - usr/lib/libpulse-simple.so*
846- - usr/lib/libpulse.so*
847- - usr/lib/pulse-8.0/*
848- - usr/lib/pulseaudio/*.so
849- - usr/share/pulseaudio/*
850-
851- snap:
852- - $wanted
853+ stage-packages:
854+ - libavahi-client3
855+ - libavahi-common3
856+ - libasyncns0
857+ - libflac8
858+ - libltdl7
859+ - libtdb1
860+ - libogg0
861+ - libsndfile1
862+ - libspeexdsp1
863+ - libvorbis0a
864+ - libvorbisenc2
865+ - libxcb1
866+ - liborc-0.4-0
867+ - libxdmcp6
868+ - libxau6
869+ - libsbc1
870+ - jq
871+ stage:
872+ - etc
873+ - lib
874+ - usr/bin/pacat
875+ - usr/bin/pactl
876+ - usr/bin/paplay
877+ - usr/bin/parec
878+ - usr/bin/pulseaudio
879+ - usr/bin/jq
880+ - usr/lib
881+ - usr/share/pulseaudio
882+
883+ # part to simulate pulseaudio and alsa dependencies, to trigger auto builds
884+ # as we build from source,we don't actually consume binaries
885+ dummy-pulse:
886+ plugin: nil
887+ stage-packages:
888+ - pulseaudio
889+ - libasound2
890+ stage:
891+ - -*
892+ prime:
893+ - -*

Subscribers

People subscribed via source and target branches

to all changes: