[OE-core] [PATCH 4/4] pulseaudio: improve reproducibility

Juro Bystricky juro.bystricky at intel.com
Wed Dec 13 21:31:16 UTC 2017


1. Remove build host references from CFLAGS in generated config.h file.
   They end up compiled in the image, but are only used for information.
2. Remove PA_BUILDDIR hardcoded references: safe to remove as we are guaranteed
   not to run from the build directory when the image is cross-compiled
3. Take care of any embedded __FILE__ strings, but only if the compiler supports
   -ffile-prefix-map option.

Signed-off-by: Juro Bystricky <juro.bystricky at intel.com>
---
 .../pulseaudio/pulseaudio/no-builddir.patch        | 74 ++++++++++++++++++++++
 .../pulseaudio/pulseaudio_11.1.bb                  | 12 +++-
 2 files changed, 85 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-multimedia/pulseaudio/pulseaudio/no-builddir.patch

diff --git a/meta/recipes-multimedia/pulseaudio/pulseaudio/no-builddir.patch b/meta/recipes-multimedia/pulseaudio/pulseaudio/no-builddir.patch
new file mode 100644
index 0000000..fcef858
--- /dev/null
+++ b/meta/recipes-multimedia/pulseaudio/pulseaudio/no-builddir.patch
@@ -0,0 +1,74 @@
+Improve reproducibility.
+Remove hard coded build host references (PA_BUILDDIR) from the cross-compiled
+image. For cross-compiled images we are guaranteed not to run from build directory.
+
+Upstream-Status: Inappropriate [embedded specific]
+Signed-off-by: Juro Bystricky <juro.bystricky at intel.com>
+
+diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c
+index f0ed0b4..94a56d3 100644
+--- a/src/daemon/daemon-conf.c
++++ b/src/daemon/daemon-conf.c
+@@ -153,11 +153,7 @@ pa_daemon_conf *pa_daemon_conf_new(void) {
+     c->dl_search_path = pa_sprintf_malloc("%s" PA_PATH_SEP "lib" PA_PATH_SEP "pulse-%d.%d" PA_PATH_SEP "modules",
+                                           pa_win32_get_toplevel(NULL), PA_MAJOR, PA_MINOR);
+ #else
+-    if (pa_run_from_build_tree()) {
+-        pa_log_notice("Detected that we are run from the build tree, fixing search path.");
+-        c->dl_search_path = pa_xstrdup(PA_BUILDDIR);
+-    } else
+-        c->dl_search_path = pa_xstrdup(PA_DLSEARCHPATH);
++    c->dl_search_path = pa_xstrdup(PA_DLSEARCHPATH);
+ #endif
+ 
+     return c;
+diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
+index 3dbf6b1..98cb738 100644
+--- a/src/modules/alsa/alsa-mixer.c
++++ b/src/modules/alsa/alsa-mixer.c
+@@ -2505,10 +2505,7 @@ static int path_verify(pa_alsa_path *p) {
+ }
+ 
+ static const char *get_default_paths_dir(void) {
+-    if (pa_run_from_build_tree())
+-        return PA_SRCDIR "/modules/alsa/mixer/paths/";
+-    else
+-        return PA_ALSA_PATHS_DIR;
++    return PA_ALSA_PATHS_DIR;
+ }
+ 
+ pa_alsa_path* pa_alsa_path_new(const char *paths_dir, const char *fname, pa_alsa_direction_t direction) {
+@@ -4383,9 +4380,7 @@ pa_alsa_profile_set* pa_alsa_profile_set_new(const char *fname, const pa_channel
+     if (!fname)
+         fname = "default.conf";
+ 
+-    fn = pa_maybe_prefix_path(fname,
+-                              pa_run_from_build_tree() ? PA_SRCDIR "/modules/alsa/mixer/profile-sets/" :
+-                              PA_ALSA_PROFILE_SETS_DIR);
++    fn = pa_maybe_prefix_path(fname, PA_ALSA_PROFILE_SETS_DIR);
+ 
+     r = pa_config_parse(fn, NULL, items, NULL, false, ps);
+     pa_xfree(fn);
+diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
+index 873f86a..937bac6 100644
+--- a/src/pulsecore/core-util.c
++++ b/src/pulsecore/core-util.c
+@@ -3397,17 +3397,7 @@ void pa_reset_personality(void) {
+ }
+ 
+ bool pa_run_from_build_tree(void) {
+-    char *rp;
+-    static bool b = false;
+-
+-    PA_ONCE_BEGIN {
+-        if ((rp = pa_readlink("/proc/self/exe"))) {
+-            b = pa_startswith(rp, PA_BUILDDIR);
+-            pa_xfree(rp);
+-        }
+-    } PA_ONCE_END;
+-
+-    return b;
++    return false;
+ }
+ 
+ const char *pa_get_temp_dir(void) {
diff --git a/meta/recipes-multimedia/pulseaudio/pulseaudio_11.1.bb b/meta/recipes-multimedia/pulseaudio/pulseaudio_11.1.bb
index a50b5a0..c9c2d2d 100644
--- a/meta/recipes-multimedia/pulseaudio/pulseaudio_11.1.bb
+++ b/meta/recipes-multimedia/pulseaudio/pulseaudio_11.1.bb
@@ -5,10 +5,20 @@ SRC_URI = "http://freedesktop.org/software/pulseaudio/releases/${BP}.tar.xz \
            file://0001-client-conf-Add-allow-autospawn-for-root.patch \
            file://volatiles.04_pulse \
 "
+
+SRC_URI_append_class-target = " \
+           file://no-builddir.patch \
+"
+
 SRC_URI[md5sum] = "390de38231d5cdd6b43ada8939eb74f1"
 SRC_URI[sha256sum] = "f2521c525a77166189e3cb9169f75c2ee2b82fa3fcf9476024fbc2c3a6c9cd9e"
 
-do_compile_prepend() {
+inherit compiler-options
+
+do_compile() {
     mkdir -p ${S}/libltdl
+    sed -i -e 's|${DEBUG_PREFIX_MAP}||g' ${B}/config.h
     cp ${STAGING_LIBDIR}/libltdl* ${S}/libltdl
+    cc_extra=$(file_prefix_map_option_supported ${CC})
+    oe_runmake CFLAGS="${CFLAGS} $cc_extra"
 }
-- 
2.7.4




More information about the Openembedded-core mailing list