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

Proposed by Ondrej Kubik
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
Oliver Grawert 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.
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 4a74ba660a7c2d7d7923f471607cc34fef7fb288

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

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

@ondra, please rebase and propose again against master.

Unmerged commits

4a74ba6... by Ondrej Kubik

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

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

4bd2143... by Ondrej Kubik

add pulseaudio snap patch

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

a9a20f4... by Ondrej Kubik

add alsa-lib snap patch

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

0b6c7b9... by Ondrej Kubik

snapcraft: dummy part to triger autobuild for pulse and libsound2

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

87dfa3f... by Ondrej Kubik

snapcraft: build snap from upstream source

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

531a7fe... by Ondrej Kubik

glue: pulseaudion: add optional service start delay

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

4259e17... by Ondrej Kubik

hooks: add support for config file modification using snap set

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

a7923d3... by Ondrej Kubik

snapcraft: making configuration writable

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

7f548c4... by Ondrej Kubik

snapcraft: refactor to new syntax and plugings

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

b8c0cdf... by Ondrej Kubik

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
diff --git a/.gitignore b/.gitignore
0new file mode 1006440new file mode 100644
index 0000000..3ed44be
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
1parts/
2prime/
3stage/
4*.snap
5snap/plugins/__pycache__
6snap/.snapcraft/
diff --git a/alsa-lib-snap.patch b/alsa-lib-snap.patch
0new file mode 1006447new file mode 100644
index 0000000..d57a937
--- /dev/null
+++ b/alsa-lib-snap.patch
@@ -0,0 +1,181 @@
1From a763fcf93e6957f9edd8cd49948507d5a0728412 Mon Sep 17 00:00:00 2001
2From: Ondrej Kubik <ondrej.kubik@canonical.com>
3Date: Fri, 14 Jun 2019 21:32:14 +0100
4Subject: [PATCH] xenial: snap: snap changes
5
6Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>
7---
8 src/alisp/alisp.c | 3 ++-
9 src/conf.c | 7 +++++--
10 src/confmisc.c | 4 ++--
11 src/control/control.c | 7 +++++--
12 src/dlmisc.c | 7 +++++--
13 src/pcm/pcm.c | 8 ++++++--
14 src/pcm/pcm_rate.c | 5 ++++-
15 7 files changed, 29 insertions(+), 12 deletions(-)
16
17diff --git a/src/alisp/alisp.c b/src/alisp/alisp.c
18index 3c61bb1..1474b97 100644
19--- a/src/alisp/alisp.c
20+++ b/src/alisp/alisp.c
21@@ -2399,7 +2399,8 @@ struct alisp_object * F_path(struct alisp_instance *instance, struct alisp_objec
22 }
23 if (!strcmp(p1->value.s, "data")) {
24 delete_tree(instance, p1);
25- return new_string(instance, ALSA_CONFIG_DIR);
26+ const char *config_dir = getenv("ALSA_CONFIG_DIR");
27+ return new_string(instance, config_dir ? config_dir : ALSA_CONFIG_DIR );
28 }
29 delete_tree(instance, p1);
30 return &alsa_lisp_nil;
31diff --git a/src/conf.c b/src/conf.c
32index a4f2a4f..29e48a9 100644
33--- a/src/conf.c
34+++ b/src/conf.c
35@@ -622,6 +622,9 @@ static int get_delimstring(char **string, int delim, input_t *input);
36 static int get_char_skip_comments(input_t *input)
37 {
38 int c;
39+ char *config_dir = getenv("ALSA_CONFIG_DIR");
40+ if (!config_dir)
41+ config_dir = ALSA_CONFIG_DIR;
42 while (1) {
43 c = get_char(input);
44 if (c == '<') {
45@@ -632,12 +635,12 @@ static int get_char_skip_comments(input_t *input)
46 if (err < 0)
47 return err;
48 if (!strncmp(str, "confdir:", 8)) {
49- char *tmp = malloc(strlen(ALSA_CONFIG_DIR) + 1 + strlen(str + 8) + 1);
50+ char *tmp = malloc(strlen(config_dir) + 1 + strlen(str + 8) + 1);
51 if (tmp == NULL) {
52 free(str);
53 return -ENOMEM;
54 }
55- sprintf(tmp, ALSA_CONFIG_DIR "/%s", str + 8);
56+ sprintf(tmp, "%s/%s", config_dir, str + 8);
57 free(str);
58 str = tmp;
59 }
60diff --git a/src/confmisc.c b/src/confmisc.c
61index ae0275f..8ca70de 100644
62--- a/src/confmisc.c
63+++ b/src/confmisc.c
64@@ -584,11 +584,11 @@ int snd_func_datadir(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNUSED,
65 {
66 int err;
67 const char *id;
68-
69+ const char *config_dir = getenv("ALSA_CONFIG_DIR");
70 err = snd_config_get_id(src, &id);
71 if (err < 0)
72 return err;
73- return snd_config_imake_string(dst, id, ALSA_CONFIG_DIR);
74+ return snd_config_imake_string(dst, id, config_dir ? config_dir : ALSA_CONFIG_DIR);
75 }
76 #ifndef DOC_HIDDEN
77 SND_DLSYM_BUILD_VERSION(snd_func_datadir, SND_CONFIG_DLSYM_VERSION_EVALUATE);
78diff --git a/src/control/control.c b/src/control/control.c
79index 4a28cf6..7c92db9 100644
80--- a/src/control/control.c
81+++ b/src/control/control.c
82@@ -835,6 +835,9 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
83 const char *lib = NULL, *open_name = NULL;
84 const char *id;
85 int (*open_func)(snd_ctl_t **, const char *, snd_config_t *, snd_config_t *, int) = NULL;
86+ char *plugin_dir = getenv("ALSA_PLUGIN_DIR");
87+ if (!plugin_dir)
88+ plugin_dir = ALSA_PLUGIN_DIR;
89 #ifndef PIC
90 extern void *snd_control_open_symbols(void);
91 #endif
92@@ -912,13 +915,13 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
93 build_in++;
94 }
95 if (*build_in == NULL) {
96- buf1 = malloc(strlen(str) + sizeof(ALSA_PLUGIN_DIR) + 32);
97+ buf1 = malloc(strlen(str) + sizeof(plugin_dir) + 32);
98 if (buf1 == NULL) {
99 err = -ENOMEM;
100 goto _err;
101 }
102 lib = buf1;
103- sprintf(buf1, "%s/libasound_module_ctl_%s.so", ALSA_PLUGIN_DIR, str);
104+ sprintf(buf1, "%s/libasound_module_ctl_%s.so", plugin_dir, str);
105 }
106 }
107 #ifndef PIC
108diff --git a/src/dlmisc.c b/src/dlmisc.c
109index b36c48f..b8c4db3 100644
110--- a/src/dlmisc.c
111+++ b/src/dlmisc.c
112@@ -74,10 +74,13 @@ void *snd_dlopen(const char *name, int mode)
113 */
114 void *handle = NULL;
115 char *filename;
116+ char *plugin_dir = getenv("ALSA_PLUGIN_DIR");
117+ if (!plugin_dir)
118+ plugin_dir = ALSA_PLUGIN_DIR;
119
120 if (name && name[0] != '/') {
121- filename = malloc(sizeof(ALSA_PLUGIN_DIR) + 1 + strlen(name) + 1);
122- strcpy(filename, ALSA_PLUGIN_DIR);
123+ filename = malloc(sizeof(plugin_dir) + 1 + strlen(name) + 1);
124+ strcpy(filename, plugin_dir);
125 strcat(filename, "/");
126 strcat(filename, name);
127 handle = dlopen(filename, mode);
128diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c
129index cbbc55a..60c410f 100644
130--- a/src/pcm/pcm.c
131+++ b/src/pcm/pcm.c
132@@ -2117,6 +2117,10 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
133 int (*open_func)(snd_pcm_t **, const char *,
134 snd_config_t *, snd_config_t *,
135 snd_pcm_stream_t, int) = NULL;
136+ char *plugin_dir = getenv("ALSA_PLUGIN_DIR");
137+ if (!plugin_dir)
138+ plugin_dir = ALSA_PLUGIN_DIR;
139+
140 #ifndef PIC
141 extern void *snd_pcm_open_symbols(void);
142 #endif
143@@ -2197,13 +2201,13 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
144 build_in++;
145 }
146 if (*build_in == NULL) {
147- buf1 = malloc(strlen(str) + sizeof(ALSA_PLUGIN_DIR) + 32);
148+ buf1 = malloc(strlen(str) + sizeof(plugin_dir) + 32);
149 if (buf1 == NULL) {
150 err = -ENOMEM;
151 goto _err;
152 }
153 lib = buf1;
154- sprintf(buf1, "%s/libasound_module_pcm_%s.so", ALSA_PLUGIN_DIR, str);
155+ sprintf(buf1, "%s/libasound_module_pcm_%s.so", plugin_dir, str);
156 }
157 }
158 #ifndef PIC
159diff --git a/src/pcm/pcm_rate.c b/src/pcm/pcm_rate.c
160index c76db25..ae920bc 100644
161--- a/src/pcm/pcm_rate.c
162+++ b/src/pcm/pcm_rate.c
163@@ -1226,11 +1226,14 @@ static int rate_open_func(snd_pcm_rate_t *rate, const char *type, int verbose)
164 char open_name[64], lib_name[128], *lib = NULL;
165 snd_pcm_rate_open_func_t open_func;
166 int err;
167+ char *plugin_dir = getenv("ALSA_PLUGIN_DIR");
168+ if (!plugin_dir)
169+ plugin_dir = ALSA_PLUGIN_DIR;
170
171 snprintf(open_name, sizeof(open_name), "_snd_pcm_rate_%s_open", type);
172 if (!is_builtin_plugin(type)) {
173 snprintf(lib_name, sizeof(lib_name),
174- "%s/libasound_module_rate_%s.so", ALSA_PLUGIN_DIR, type);
175+ "%s/libasound_module_rate_%s.so", plugin_dir, type);
176 lib = lib_name;
177 }
178 open_func = snd_dlobj_cache_get(lib, open_name, NULL, verbose);
179--
1802.20.1
181
diff --git a/bin/client-wrapper b/glue/bin/client-wrapper
0similarity index 90%182similarity index 90%
1rename from bin/client-wrapper183rename from bin/client-wrapper
2rename to glue/bin/client-wrapper184rename to glue/bin/client-wrapper
index 255187c..fc66e93 100755
--- a/bin/client-wrapper
+++ b/glue/bin/client-wrapper
@@ -19,11 +19,6 @@ if [ "$(id -u)" -ne 0 ]; then
19 exit 119 exit 1
20fi20fi
2121
22export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SNAP/usr/lib/pulseaudio:$SNAP/usr/lib/pulse-8.0/modules/
23export PULSE_CLIENTCONFIG=$SNAP/etc/pulse/client.conf
24export PULSE_RUNTIME_PATH=/var/run/pulse
25export PULSE_SYSTEM=1
26
27unset XDG_RUNTIME_DIR22unset XDG_RUNTIME_DIR
2823
29export HOME=$SNAP_DATA/home24export HOME=$SNAP_DATA/home
diff --git a/bin/config b/glue/bin/config
30similarity index 100%25similarity index 100%
31rename from bin/config26rename from bin/config
32rename to glue/bin/config27rename to glue/bin/config
diff --git a/bin/pulseaudio b/glue/bin/pulseaudio
33similarity index 62%28similarity index 62%
34rename from bin/pulseaudio29rename from bin/pulseaudio
35rename to glue/bin/pulseaudio30rename to glue/bin/pulseaudio
index 40c9a85..e966e92 100755
--- a/bin/pulseaudio
+++ b/glue/bin/pulseaudio
@@ -2,14 +2,6 @@
2set -e2set -e
3set -x3set -x
44
5export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SNAP/usr/lib/pulseaudio:$SNAP/usr/lib/pulse-8.0/modules/
6export PULSE_RUNTIME_PATH=/var/run/pulse
7export PULSE_STATE_PATH=$SNAP_DATA/state
8export ALSA_CONFIG_UCM=$SNAP/usr/share/alsa/ucm
9export ALSA_CONFIG_TPLG=$SNAP/usr/share/alsa/topology
10export ALSA_CONFIG_PATH=$SNAP/usr/share/alsa/alsa.conf
11export ALSA_MIXER_SIMPLE=$SNAP/usr/share/alsa/smixer.conf
12
13mkdir -p $PULSE_STATE_PATH5mkdir -p $PULSE_STATE_PATH
146
15EXTRA_ARGS=7EXTRA_ARGS=
@@ -19,12 +11,20 @@ if [ -e $SNAP_DATA/config/debug ] ; then
19 export LIBASOUND_DEBUG=111 export LIBASOUND_DEBUG=1
20fi12fi
2113
14# on some hw, hw requires init steps before pulseaudio can be started
15# as we do not have socket activated service yet, add optional delayed start
16DELAY=$(snapctl get pulseaudio.delay-service)
17if [ -n "${DELAY}" ]; then
18 # ignore any error is delay is boggus number
19 sleep ${DELAY} || true
20fi
21
22$SNAP/usr/bin/pulseaudio \22$SNAP/usr/bin/pulseaudio \
23 --exit-idle-time=-1 \23 --exit-idle-time=-1 \
24 --disallow-exit=yes \24 --disallow-exit=yes \
25 --disallow-module-loading \25 --disallow-module-loading \
26 --system \26 --system \
27 -F $SNAP/etc/pulse/default.pa \27 -F ${SNAP_DATA}/etc/pulse/default.pa \
28 -p $SNAP/usr/lib/pulse-8.0/modules \28 -p ${SNAP}/usr/lib/pulse-8.0/modules \
29 -n \29 -n \
30 $EXTRA_ARGS30 $EXTRA_ARGS
diff --git a/data/copyright b/glue/usr/share/doc/pulseaudio/copyright
31similarity index 100%31similarity index 100%
32rename from data/copyright32rename from data/copyright
33rename to glue/usr/share/doc/pulseaudio/copyright33rename to glue/usr/share/doc/pulseaudio/copyright
diff --git a/pulseaudio-snap.patch b/pulseaudio-snap.patch
34new file mode 10064434new file mode 100644
index 0000000..4ffbcdb
--- /dev/null
+++ b/pulseaudio-snap.patch
@@ -0,0 +1,89 @@
1From e0eaeecf7b028a238c9ba4c8fd15e794eaefc2af Mon Sep 17 00:00:00 2001
2From: Ondrej Kubik <ondrej.kubik@canonical.com>
3Date: Fri, 14 Jun 2019 22:01:35 +0100
4Subject: [PATCH] xenial: snap: snap changes
5
6Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>
7---
8 configure.ac | 2 +-
9 src/daemon/main.c | 12 ++++++------
10 src/modules/alsa/alsa-mixer.c | 6 ++++--
11 3 files changed, 11 insertions(+), 9 deletions(-)
12
13diff --git a/configure.ac b/configure.ac
14index 9250c05d..f8e7673c 100644
15--- a/configure.ac
16+++ b/configure.ac
17@@ -177,7 +177,7 @@ esac
18 #### Compiler flags ####
19
20 AX_APPEND_COMPILE_FLAGS(
21- [-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],
22+ [-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],
23 [], [-pedantic -Werror])
24
25 AS_CASE([" $CFLAGS "], [*" -O0 "*], [], [
26diff --git a/src/daemon/main.c b/src/daemon/main.c
27index c2f47b69..f4887554 100644
28--- a/src/daemon/main.c
29+++ b/src/daemon/main.c
30@@ -175,16 +175,16 @@ static int change_user(void) {
31 return -1;
32 }
33
34- if (!pa_streq(pw->pw_dir, PA_SYSTEM_RUNTIME_PATH))
35- pa_log_warn(_("Home directory of user '%s' is not '%s', ignoring."), PA_SYSTEM_USER, PA_SYSTEM_RUNTIME_PATH);
36+ if (!pa_streq(pw->pw_dir, getenv("PULSE_RUNTIME_PATH")))
37+ pa_log_warn(_("Home directory of user '%s' is not '%s', ignoring."), PA_SYSTEM_USER, getenv("PULSE_RUNTIME_PATH"));
38
39- if (pa_make_secure_dir(PA_SYSTEM_RUNTIME_PATH, 0755, pw->pw_uid, gr->gr_gid, true) < 0) {
40- pa_log(_("Failed to create '%s': %s"), PA_SYSTEM_RUNTIME_PATH, pa_cstrerror(errno));
41+ if (pa_make_secure_dir(getenv("PULSE_RUNTIME_PATH"), 0755, pw->pw_uid, gr->gr_gid, true) < 0) {
42+ pa_log(_("Failed to create '%s': %s"), getenv("PULSE_RUNTIME_PATH"), pa_cstrerror(errno));
43 return -1;
44 }
45
46- if (pa_make_secure_dir(PA_SYSTEM_STATE_PATH, 0700, pw->pw_uid, gr->gr_gid, true) < 0) {
47- pa_log(_("Failed to create '%s': %s"), PA_SYSTEM_STATE_PATH, pa_cstrerror(errno));
48+ if (pa_make_secure_dir(getenv("PULSE_STATE_PATH"), 0700, pw->pw_uid, gr->gr_gid, true) < 0) {
49+ pa_log(_("Failed to create '%s': %s"), getenv("PULSE_STATE_PATH"), pa_cstrerror(errno));
50 return -1;
51 }
52
53diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
54index 1fe2a024..4cbc8277 100644
55--- a/src/modules/alsa/alsa-mixer.c
56+++ b/src/modules/alsa/alsa-mixer.c
57@@ -2529,10 +2529,11 @@ static int path_verify(pa_alsa_path *p) {
58 }
59
60 static const char *get_default_paths_dir(void) {
61+ const char *alsa_paths_dir = getenv("PULSE_ALSA_PATHS_DIR");
62 if (pa_run_from_build_tree())
63 return PA_SRCDIR "/modules/alsa/mixer/paths/";
64 else
65- return PA_ALSA_PATHS_DIR;
66+ return alsa_paths_dir ? alsa_paths_dir : PA_ALSA_PATHS_DIR;
67 }
68
69 pa_alsa_path* pa_alsa_path_new(const char *paths_dir, const char *fname, pa_alsa_direction_t direction) {
70@@ -4365,6 +4366,7 @@ pa_alsa_profile_set* pa_alsa_profile_set_new(const char *fname, const pa_channel
71 char *fn;
72 int r;
73 void *state;
74+ const char *alsa_profile_sets_dir = getenv("PULSE_ALSA_PROFILE_SETS_DIR");
75
76 static pa_config_item items[] = {
77 /* [General] */
78@@ -4409,7 +4411,7 @@ pa_alsa_profile_set* pa_alsa_profile_set_new(const char *fname, const pa_channel
79
80 fn = pa_maybe_prefix_path(fname,
81 pa_run_from_build_tree() ? PA_SRCDIR "/modules/alsa/mixer/profile-sets/" :
82- PA_ALSA_PROFILE_SETS_DIR);
83+ alsa_profile_sets_dir ? alsa_profile_sets_dir : PA_ALSA_PROFILE_SETS_DIR);
84
85 r = pa_config_parse(fn, NULL, items, NULL, false, ps);
86 pa_xfree(fn);
87--
882.20.1
89
diff --git a/quiltrc b/quiltrc
0new file mode 10064490new file mode 100644
index 0000000..f2568ce
--- /dev/null
+++ b/quiltrc
@@ -0,0 +1,6 @@
1for where in ./ ../ ../../ ../../../ ../../../../ ../../../../../; do
2 if [ -e ${where}debian/rules -a -d ${where}debian/patches ]; then
3 export QUILT_PATCHES=debian/patches
4 break
5 fi
6done
diff --git a/snap/hooks/configure b/snap/hooks/configure
0new file mode 1007557new file mode 100755
index 0000000..844be89
--- /dev/null
+++ b/snap/hooks/configure
@@ -0,0 +1,201 @@
1#!/bin/bash
2#
3# Copyright (C) 2016 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17if [ -e $SNAP_DATA/config/debug ] ; then
18 DEBUG=1
19 set -x
20fi
21
22exec >> $SNAP_COMMON/hook.log 2>&1
23echo "$(date '+%Y-%m-%d %H:%M:%S') $(basename $0): Entering hook"
24
25# traverse in three directories
26# -etc/pulse
27# -usr/share/alsa
28# -usr/share/pulseaudio
29# when file config is reached, it has three values, filaname, remove and add
30# - filename: is relative file path, without $SNAP_DATA part
31# - remove: list of strings to be removed from given file
32# this can be multi line value, each line is process separatelly
33# - add: list of strings to be appended to given file
34# this could be multi line value, all lines are appended to config file
35# - replace: list of pairs match replace values, values on separate lines
36# at least two lines needed match <> replace
37#
38# example:
39# 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"}'
40# 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"}'
41# 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"}}'
42# 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"}'
43# providing way to alter configuration files through snap set command
44# not full example of supported config options
45# {
46# "etc": {
47# "pulse": {
48# "client-conf": {
49# "filename": "etc/pulse/client.conf",
50# "replace": ""
51# "remove": "",
52# "add": ""
53# },
54# "daemon-conf": {
55# "filename": "etc/pulse/daemon.conf",
56# "remove": "",
57# "add": ""
58# },
59# "default-pa": {
60# "filename": "etc/pulse/default.pa",
61# "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",
62# "remove": "load-module module-alsa-sink device=.*\nload-module module-alsa-source device=.*",
63# "add": "load-module module-alsa-sink device=hw:0,0\nload-module module-alsa-source device=hw:0,1"
64# },
65# "system-pa": {
66# "filename": "etc/pulse/system.pa",
67# "remove": "",
68# "add": ""
69# }
70# }
71# },
72# "usr": {
73# "share": {
74# "alsa": {
75# "alsa-conf": {
76# "filename": "usr/share/alsa/alsa.conf",
77# "remove": "",
78# "add": ""
79# },
80# "topology": {
81# "broadwell": {
82# "filename": "usr/share/alsa/topology/broadwell/broadwell.conf",
83# "remove": "",
84# "add": ""
85# }
86# }
87# },
88# "pulseaudio": {
89# "alsa-mixer": {
90# "paths": {
91# "analog-output-conf": {
92# "filename": "usr/share/pulseaudio/alsa-mixer/paths/analog-output.conf",
93# "remove": "",
94# "add": ""
95# }
96# },
97# "profile-sets": {
98# "default-conf": {
99# "filename": "usr/share/pulseaudio/alsa-mixer/profile-sets/default.conf",
100# "remove": "",
101# "add": ""
102# }
103# }
104# }
105# }
106# }
107# }
108# }
109
110process_file_remove() {
111 filename="${1}"
112 shift
113 remove="${@}"
114 if [ -n "${remove}" ]; then
115 # remove all matching lines from config, there could be more patterns, process by lines
116 while read -r line
117 do
118 if [ -n "${line}" ]; then
119 echo "removing from [${filename}] strings [$line]"
120 sed -i "s/$(echo ${line} | sed -e 's/\\/\\\\/g; s/\//\\\//g; s/&/\\\&/g')//g" ${SNAP_DATA}/${filename}
121 fi
122 done < <(echo "${remove}")
123 fi
124}
125
126process_file_add() {
127 filename="${1}"
128 shift
129 add="${@}"
130 if [ -n "${add}" ]; then
131 echo "adding from [${filename}] strings [$add]"
132 [ "${DEBUG}" = "1" ] && echo -e "\n# start: added by snap configure" >> ${SNAP_DATA}/${filename}
133 echo "${add}" >> ${SNAP_DATA}/${filename}
134 [ "${DEBUG}" = "1" ] && echo -e "# end: added by snap configure" >> ${SNAP_DATA}/${filename}
135 fi
136}
137
138process_file_replace() {
139 filename="${1}"
140 shift
141 if [ -n "${@}" ]; then
142 # we need to process two lines at the time, first line is match, following line is replacing value
143 while read -r match
144 do
145 read -r replace
146 if [ -n "${match}" ] && [ -n "${replace}" ]; then
147 echo "replace from [${filename}] string [${match}] with [${replace}]"
148 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}
149 fi
150 done < <(echo "${@}")
151 fi
152}
153
154process_line() {
155 [ "${DEBUG}" = "1" ] && echo "process_line << $@"
156 # each line starts with key name and end with variable
157 local key=$1
158 shift
159 # check if we have valid json in first place
160 if ! jq -e . >/dev/null 2>&1 <<<"$@"; then
161 type -p handle_key_value && handle_key_value ${key} $@
162 return
163 fi
164 filename=$(echo $@ | jq -r '.filename')
165 # if we have filename, no need to traverse further
166 if [ "${filename}" == "null" ]; then
167 type -p processing_top_key_start && processing_top_key_start ${key}
168 while read -r line
169 do
170 process_line ${key}.${line}
171 done < <(echo "$@" | jq -r 'keys[] as $k | "\($k) \(.[$k] )"')
172 type -p processing_top_key_end && processing_top_key_end ${key}
173 else
174 ADD=$(echo $@ | jq -r '.add')
175 [ "${ADD}" == "null" ] && ADD=""
176 REMOVE=$(echo $@ | jq -r '.remove')
177 [ "${REMOVE}" == "null" ] && REMOVE=""
178 REPLACE=$(echo $@ | jq -r '.replace')
179 [ "${REPLACE}" == "null" ] && REPLACE=""
180 type -p process_file_replace && process_file_replace "${filename}" "${REPLACE}"
181 type -p process_file_remove && process_file_remove "${filename}" "${REMOVE}"
182 type -p process_file_add && process_file_add "${filename}" "${ADD}"
183 fi
184}
185
186CONFIGURATION="etc usr"
187
188echo "Process config changes"
189
190for conf in $CONFIGURATION
191do
192 [ "${DEBUG}" = "1" ] && echo "processing: ${conf}"
193 # only process if we get valid json
194 key_val=$(snapctl get -d "${conf}")
195 if jq -e . >/dev/null 2>&1 <<<"${key_val}"; then
196 process_line $(jq -r 'keys[] as $k | "\($k) \(.[$k] )"' <<< $(snapctl get -d ${conf}))
197 fi
198done
199
200# restart pulse service
201snapctl restart ${SNAP_INSTANCE_NAME}.pulseaudio
diff --git a/snap/hooks/install b/snap/hooks/install
0new file mode 100755202new file mode 100755
index 0000000..db735a4
--- /dev/null
+++ b/snap/hooks/install
@@ -0,0 +1,29 @@
1#!/bin/bash
2
3#
4# Copyright (C) 2016 Canonical Ltd
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License version 3 as
8# published by the Free Software Foundation.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18set -x
19exec >> $SNAP_COMMON/hook.log 2>&1
20echo "$(date '+%Y-%m-%d %H:%M:%S') $(basename $0): Entering hook"
21
22# copy initial client configuration
23mkdir -p ${SNAP_DATA}/var/lib/pulse
24mkdir -p ${SNAP_DATA}/etc
25mkdir -p ${SNAP_DATA}/usr/share
26
27cp -r ${SNAP}/etc/pulse ${SNAP_DATA}/etc
28cp -r ${SNAP}/usr/share/alsa ${SNAP_DATA}/usr/share
29cp -r ${SNAP}/usr/share/pulseaudio ${SNAP_DATA}/usr/share
diff --git a/snap/hooks/post-refresh b/snap/hooks/post-refresh
0new file mode 10075530new file mode 100755
index 0000000..83eecc4
--- /dev/null
+++ b/snap/hooks/post-refresh
@@ -0,0 +1,33 @@
1#!/bin/bash
2#
3# Copyright (C) 2016 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17set -x
18exec >> ${SNAP_COMMON}/hook.log 2>&1
19echo "$(date '+%Y-%m-%d %H:%M:%S') $(basename $0): Entering hook"
20
21# make sure we have initial configuration handy
22mkdir -p ${SNAP_DATA}/var/lib/pulse
23mkdir -p ${SNAP_DATA}/etc
24mkdir -p ${SNAP_DATA}/usr/share
25
26cp -r -n ${SNAP}/etc/pulse ${SNAP_DATA}/etc
27cp -r -n ${SNAP}/usr/share/alsa ${SNAP_DATA}/usr/share
28cp -r -n ${SNAP}/usr/share/pulseaudio ${SNAP_DATA}/usr/share
29
30# clean snapctl as we cannot do it from configure hooks
31# so we not repeaase same steps again
32snapctl set env=""
33snapctl set usr=""
diff --git a/snapcraft.yaml b/snap/snapcraft.yaml
0similarity index 50%34similarity index 50%
1rename from snapcraft.yaml35rename from snapcraft.yaml
2rename to snap/snapcraft.yaml36rename to snap/snapcraft.yaml
index 605243c..172eaa1 100644
--- a/snapcraft.yaml
+++ b/snap/snapcraft.yaml
@@ -1,5 +1,4 @@
1name: pulseaudio1name: pulseaudio
2version: 8.0-4
3summary: PulseAudio sound server2summary: PulseAudio sound server
4description: |3description: |
5 PulseAudio, previously known as Polypaudio, is a sound server for POSIX and4 PulseAudio, previously known as Polypaudio, is a sound server for POSIX and
@@ -10,27 +9,62 @@ description: |
10 https://code.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/pulseaudio9 https://code.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/pulseaudio
11grade: stable10grade: stable
12confinement: strict11confinement: strict
12adopt-info: pulseaudio
13base: core
14
15environment:
16 PATH: ${SNAP}/usr/sbin:${SNAP}/usr/bin:${SNAP}/sbin:${SNAP}/bin:${PATH}
17 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}
18 PULSE_DLPATH: ${SNAP}/usr/lib/pulse-8.0/modules
19 PULSE_CLIENTCONFIG: ${SNAP_DATA}/etc/pulse/client.conf
20 PULSE_RUNTIME_PATH: /var/run/pulse
21 PULSE_SYSTEM: 1
22 PULSE_STATE_PATH: ${SNAP_DATA}/state
23 PULSE_SCRIPT: ${SNAP_DATA}/etc/pulse/default.pa
24 PULSE_CONFIG: ${SNAP_DATA}/etc/pulse/daemon.conf
25 PULSE_CONFIG_PATH: ${SNAP_DATA}/var/lib/pulse
26 PULSE_ALSA_PATHS_DIR: ${SNAP_DATA}/usr/share/pulseaudio/alsa-mixer
27 ALSA_CONFIG_UCM: ${SNAP_DATA}/usr/share/alsa/ucm
28 ALSA_CONFIG_TPLG: ${SNAP_DATA}/usr/share/alsa/topology
29 ALSA_CONFIG_PATH: ${SNAP_DATA}/usr/share/alsa/alsa.conf
30 ALSA_MIXER_SIMPLE: ${SNAP_DATA}/usr/share/alsa/smixer.conf
31 ALSA_CONFIG_DIR: ${SNAP_DATA}/usr/share/alsa/
32 ALSA_CONFIG_UCM_VAR: ${SNAP_DATA}/usr/share/alsa/ucm
33 ALSA_CONFIG_TPLG_VAR: ${SNAP_DATA}/usr/share/alsa/topology
34 ALSA_PLUGIN_DIR: ${SNAP}/usr/lib/alsa-lib
35 ALSA_MIXER_SIMPLE_MODULES: ${SNAP}/usr/lib/alsa-lib/smixer
36 ALSA_MIXER_SIMPLE_MPYTHON: ${SNAP}/usr/lib/alsa-lib/smixer/python/main.py
1337
14apps:38apps:
15 pulseaudio:39 pulseaudio:
16 command: bin/pulseaudio40 command: bin/pulseaudio
17 daemon: simple41 daemon: simple
18 slots: [service]42 slots:
43 - service
44 plugs:
45 - network
46 - network-bind
47
19 pactl:48 pactl:
20 command: bin/client-wrapper usr/bin/pactl49 command: bin/client-wrapper usr/bin/pactl
21 plugs: [client, network]50 plugs:
22 aliases:51 - client
23 - pactl52 - network
53
24 paplay:54 paplay:
25 command: bin/client-wrapper usr/bin/paplay55 command: bin/client-wrapper usr/bin/paplay
26 plugs: [client, home, network]56 plugs:
27 aliases:57 - client
28 - paplay58 - home
59 - network
60
29 parec:61 parec:
30 command: bin/client-wrapper usr/bin/parec62 command: bin/client-wrapper usr/bin/parec
31 plugs: [client, home, network]63 plugs:
32 aliases:64 - client
33 - parec65 - home
66 - network
67
34 config:68 config:
35 command: bin/config69 command: bin/config
3670
@@ -43,21 +77,21 @@ plugs:
43 interface: pulseaudio77 interface: pulseaudio
4478
45parts:79parts:
46 pulseaudio-common:80 glue:
47 plugin: copy81 plugin: dump
48 files:82 source: glue
49 bin/pulseaudio: bin/pulseaudio
50 bin/client-wrapper: bin/client-wrapper
51 bin/config: bin/config
52 data/copyright: usr/share/doc/pulseaudio/copyright
5383
54 alsa-lib:84 alsa-lib:
55 plugin: autotools85 plugin: autotools
5686 source: https://git.launchpad.net/ubuntu/+source/alsa-lib
57 source: https://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/pulseaudio
58 source-type: git87 source-type: git
59 source-branch: alsa-lib/xenial/1.1.088 source-branch: ubuntu/xenial
6089 override-pull: |
90 snapcraftctl pull
91 rm -rf manual
92 [ -z "${SNAPCRAFT_PROJECT_DIR}" ] && SNAPCRAFT_PROJECT_DIR="../../.."
93 quilt push -afq --leave-rejects --quiltrc=${SNAPCRAFT_PROJECT_DIR}/quiltrc
94 git apply ${SNAPCRAFT_PROJECT_DIR}/alsa-lib-snap.patch
61 configflags:95 configflags:
62 - --prefix=/usr96 - --prefix=/usr
63 - --sysconfdir=/etc97 - --sysconfdir=/etc
@@ -68,27 +102,26 @@ parts:
68 - --disable-silent-rules102 - --disable-silent-rules
69 - --disable-static103 - --disable-static
70 - --disable-python104 - --disable-python
71105 stage:
72 filesets:106 - usr/lib/libasound.so*
73 libasound2:107 - usr/lib/alsa-lib
74 - usr/lib/libasound.so*108 - usr/share/alsa
75 - usr/lib/alsa-lib/*
76 - usr/share/alsa/*
77
78 snap:
79 - $libasound2
80109
81110
82 pulseaudio:111 pulseaudio:
83 after:112 after:
84 - alsa-lib113 - alsa-lib
85
86 plugin: autotools114 plugin: autotools
87115 source: https://git.launchpad.net/ubuntu/+source/pulseaudio
88 source: https://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/pulseaudio
89 source-type: git116 source-type: git
90 source-branch: pulseaudio/8.0117 source-branch: ubuntu/xenial
91118 override-pull: |
119 snapcraftctl pull
120 snapcraftctl set-version $(git describe --tags | cut -c 19-)
121 rm -rf manual
122 [ -z "${SNAPCRAFT_PROJECT_DIR}" ] && SNAPCRAFT_PROJECT_DIR="../../.."
123 quilt push -afq --leave-rejects --quiltrc=../../../quiltrc
124 git apply ${SNAPCRAFT_PROJECT_DIR}/pulseaudio-snap.patch
92 build-packages:125 build-packages:
93 - intltool126 - intltool
94 - libasound2-dev127 - libasound2-dev
@@ -106,7 +139,8 @@ parts:
106 - libudev-dev139 - libudev-dev
107 - libasyncns-dev140 - libasyncns-dev
108 - libxcb1-dev141 - libxcb1-dev
109142 - libsbc-dev
143 - quilt
110 configflags:144 configflags:
111 - --prefix=/usr145 - --prefix=/usr
112 - --sysconfdir=/etc146 - --sysconfdir=/etc
@@ -133,22 +167,44 @@ parts:
133 - --disable-x11167 - --disable-x11
134 - --with-system-user=root168 - --with-system-user=root
135 - --with-system-group=root169 - --with-system-group=root
136170 stage-packages:
137 filesets:171 - libavahi-client3
138 wanted:172 - libavahi-common3
139 - etc/*173 - libasyncns0
140 - lib/*174 - libflac8
141 - usr/bin/pacat175 - libltdl7
142 - usr/bin/pactl176 - libtdb1
143 - usr/bin/paplay177 - libogg0
144 - usr/bin/parec178 - libsndfile1
145 - usr/bin/pulseaudio179 - libspeexdsp1
146 - usr/lib/libpulse-mainloop-glib.so*180 - libvorbis0a
147 - usr/lib/libpulse-simple.so*181 - libvorbisenc2
148 - usr/lib/libpulse.so*182 - libxcb1
149 - usr/lib/pulse-8.0/*183 - liborc-0.4-0
150 - usr/lib/pulseaudio/*.so184 - libxdmcp6
151 - usr/share/pulseaudio/*185 - libxau6
152186 - libsbc1
153 snap:187 - jq
154 - $wanted188 stage:
189 - etc
190 - lib
191 - usr/bin/pacat
192 - usr/bin/pactl
193 - usr/bin/paplay
194 - usr/bin/parec
195 - usr/bin/pulseaudio
196 - usr/bin/jq
197 - usr/lib
198 - usr/share/pulseaudio
199
200 # part to simulate pulseaudio and alsa dependencies, to trigger auto builds
201 # as we build from source,we don't actually consume binaries
202 dummy-pulse:
203 plugin: nil
204 stage-packages:
205 - pulseaudio
206 - libasound2
207 stage:
208 - -*
209 prime:
210 - -*

Subscribers

People subscribed via source and target branches

to all changes: