[Pkg-pulseaudio-devel] Bug#522100: pulseaudio: FTBFS on hurd-i386

Samuel Thibault samuel.thibault at ens-lyon.org
Tue Mar 31 18:56:14 UTC 2009


Package: pulseaudio
Version: 0.9.14-2
Severity: important
Tags: patch

Hello,

Pulseaudio currently FTBFS on hurd-i386 because of unconditional use of
the static PATH_MAX, PIPE_BUF limits, which hurd-i386 doesn't
have since they can vary dynamically or even not exist. Also,
pthread_setaffinity_np() is a linux extension, and the debian/rules
trick for kfreebsd should be done for hurd-i386 as well.

Please see attached patch addressing all these concerns.

Samuel

-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.29 (SMP w/2 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages pulseaudio depends on:
ii  adduser                       3.110      add and remove users and groups
ii  consolekit                    0.3.0-2    framework for defining and trackin
ii  libasound2                    1.0.19-1   shared library for ALSA applicatio
ii  libasyncns0                   0.3-1      Asyncronous name service query lib
ii  libc6                         2.9-4      GNU C Library: Shared libraries
ii  libcap2                       2.16-2     support for getting/setting POSIX.
ii  libdbus-1-3                   1.2.12-1   simple interprocess messaging syst
ii  libgdbm3                      1.8.3-4    GNU dbm database routines (runtime
ii  libltdl3                      1.5.26-4   A system independent dlopen wrappe
ii  liboil0.3                     0.3.15-1   Library of Optimized Inner Loops
ii  libpolkit-dbus2               0.9-3      library for accessing PolicyKit vi
ii  libpolkit2                    0.9-3      library for accessing PolicyKit
ii  libpulsecore9                 0.9.14-2   PulseAudio sound server core
ii  libsamplerate0                0.1.7-2    audio rate conversion library
ii  libsndfile1                   1.0.18-2   Library for reading/writing audio 
ii  libspeexdsp1                  1.2~rc1-1  The Speex extended runtime library
ii  libwrap0                      7.6.q-16   Wietse Venema's TCP wrappers libra
ii  lsb-base                      3.2-20     Linux Standard Base 3.2 init scrip

Versions of packages pulseaudio recommends:
ii  gstreamer0.10-pulseaudio      0.10.14-2  GStreamer plugin for PulseAudio
ii  libasound2-plugins            1.0.19-2   ALSA library additional plugins
ii  padevchooser                  0.9.3-2    PulseAudio Device Chooser
ii  paprefs                       0.9.6-2    PulseAudio Preferences
ii  pulseaudio-esound-compat      0.9.14-2   PulseAudio ESD compatibility layer
ii  pulseaudio-module-hal         0.9.14-2   HAL device detection module for Pu
ii  pulseaudio-module-x11         0.9.14-2   X11 module for PulseAudio sound se

Versions of packages pulseaudio suggests:
ii  paman                0.9.4-1             PulseAudio Manager
ii  pavucontrol          0.9.6+svn20080426-1 PulseAudio Volume Control
ii  pavumeter            0.9.3-1             PulseAudio Volume Meter
ii  pulseaudio-utils     0.9.14-2            Command line tools for the PulseAu

-- no debconf information

-- 
Samuel
"2 + 2 = 5 pour d'assez grandes valeurs de 2"
-------------- next part --------------
--- src/pulsecore/authkey.c.orig	2009-03-31 01:55:38.450000000 +0100
+++ src/pulsecore/authkey.c	2009-03-31 02:12:17.570000000 +0100
@@ -36,6 +36,7 @@
 #include <sys/stat.h>
 
 #include <pulse/util.h>
+#include <pulse/xmalloc.h>
 #include <pulsecore/core-error.h>
 #include <pulsecore/core-util.h>
 #include <pulsecore/log.h>
@@ -158,16 +159,27 @@
 #else
     if (strlen(fn) < 3 || !isalpha(fn[0]) || fn[1] != ':' || fn[2] != '\\') {
 #endif
-        char homedir[PATH_MAX];
+        char *homedir;
+        size_t allocated = 128;
 
-        if (!pa_get_home_dir(homedir, sizeof(homedir)))
-            return NULL;
+        while (1) {
+            homedir = pa_xmalloc(allocated);
+            if (!pa_get_home_dir(homedir, allocated)) {
+                pa_xfree(homedir);
+                return NULL;
+            }
+            if (strlen(homedir) < allocated - 1)
+                break;
+            pa_xfree(homedir);
+            allocated *= 2;
+        }
 
 #ifndef OS_IS_WIN32
         pa_snprintf(s, l, "%s/%s", homedir, fn);
 #else
         pa_snprintf(s, l, "%s\\%s", homedir, fn);
 #endif
+        pa_xfree(homedir);
         return s;
     }
 
@@ -177,17 +189,35 @@
 /* Load a cookie from a file in the home directory. If the specified
  * path starts with /, use it as absolute path instead. */
 int pa_authkey_load_auto(const char *fn, void *data, size_t length) {
-    char path[PATH_MAX];
+    char *path;
     const char *p;
+    size_t allocated = 128;
+    int key;
 
     pa_assert(fn);
     pa_assert(data);
     pa_assert(length > 0);
 
-    if (!(p = normalize_path(fn, path, sizeof(path))))
-        return -2;
+    while (1) {
+        path = pa_xmalloc(allocated);
+
+        if (!(p = normalize_path(fn, path, allocated))) {
+            pa_xfree(path);
+            return -2;
+        }
+
+        if (p != path || strlen(path) < allocated - 1)
+            break;
+
+        pa_xfree(path);
+        allocated *= 2;
+    }
+
+    key = pa_authkey_load(p, data, length);
 
-    return pa_authkey_load(p, data, length);
+    pa_xfree(path);
+
+    return key;
 }
 
 /* Store the specified cookie in the speicified cookie file */
@@ -195,15 +225,28 @@
     int fd = -1;
     int unlock = 0, ret = -1;
     ssize_t r;
-    char path[PATH_MAX];
+    char *path;
     const char *p;
+    size_t allocated = 128;
 
     pa_assert(fn);
     pa_assert(data);
     pa_assert(length > 0);
 
-    if (!(p = normalize_path(fn, path, sizeof(path))))
-        return -2;
+    while (1) {
+        path = pa_xmalloc(allocated);
+
+        if (!(p = normalize_path(fn, path, allocated))) {
+            pa_xfree(path);
+            return -2;
+        }
+
+        if (p != path || strlen(path) < allocated - 1)
+            break;
+
+        pa_xfree(path);
+        allocated *= 2;
+    }
 
     if ((fd = open(p, O_RDWR|O_CREAT|O_NOCTTY, S_IRUSR|S_IWUSR)) < 0) {
         pa_log_warn("Failed to open cookie file '%s': %s", fn, pa_cstrerror(errno));
@@ -232,5 +275,7 @@
         }
     }
 
+    pa_xfree(path);
+
     return ret;
 }
--- src/pulsecore/core-util.c.orig	2009-03-31 02:12:50.960000000 +0100
+++ src/pulsecore/core-util.c	2009-03-31 02:22:25.750000000 +0100
@@ -1265,26 +1265,42 @@
 }
 
 static char *get_pulse_home(void) {
-    char h[PATH_MAX];
+    char *h;
     struct stat st;
+    size_t allocated = 128;
+    char *ret = NULL;
 
-    if (!pa_get_home_dir(h, sizeof(h))) {
-        pa_log_error("Failed to get home directory.");
-        return NULL;
+    while (1) {
+        h = pa_xmalloc(allocated);
+
+        if (!pa_get_home_dir(h, allocated)) {
+            pa_log_error("Failed to get home directory.");
+            goto out;
+        }
+
+        if (strlen(h) < allocated - 1)
+            break;
+
+        pa_xfree(h);
+        allocated *= 2;
     }
 
     if (stat(h, &st) < 0) {
         pa_log_error("Failed to stat home directory %s: %s", h, pa_cstrerror(errno));
-        return NULL;
+        goto out;
     }
 
     if (st.st_uid != getuid()) {
         pa_log_error("Home directory %s not ours.", h);
         errno = EACCES;
-        return NULL;
+        goto out;
     }
 
-    return pa_sprintf_malloc("%s" PA_PATH_SEP ".pulse", h);
+    ret = pa_sprintf_malloc("%s" PA_PATH_SEP ".pulse", h);
+
+out:
+    pa_xfree(h);
+    return ret;
 }
 
 char *pa_get_state_dir(void) {
@@ -1561,15 +1577,32 @@
     if (local) {
         const char *e;
         char *lfn;
-        char h[PATH_MAX];
         FILE *f;
 
         if ((e = getenv("PULSE_CONFIG_PATH")))
             fn = lfn = pa_sprintf_malloc("%s" PA_PATH_SEP "%s", e, local);
-        else if (pa_get_home_dir(h, sizeof(h)))
+        else {
+            char *h;
+            size_t allocated = 128;
+
+            while (1) {
+                h = pa_xmalloc(allocated);
+
+                if (!pa_get_home_dir(h, allocated)) {
+                    pa_xfree(h);
+                    return NULL;
+                }
+
+                if (strlen(h) < allocated - 1)
+                    break;
+
+                pa_xfree(h);
+                allocated *= 2;
+            }
+
             fn = lfn = pa_sprintf_malloc("%s" PA_PATH_SEP ".pulse" PA_PATH_SEP "%s", h, local);
-        else
-            return NULL;
+            pa_xfree(h);
+        }
 
 #ifdef OS_IS_WIN32
         if (!ExpandEnvironmentStrings(lfn, buf, PATH_MAX)) {
@@ -1648,14 +1681,31 @@
     if (local) {
         const char *e;
         char *lfn;
-        char h[PATH_MAX];
 
         if ((e = getenv("PULSE_CONFIG_PATH")))
             fn = lfn = pa_sprintf_malloc("%s" PA_PATH_SEP "%s", e, local);
-        else if (pa_get_home_dir(h, sizeof(h)))
+        else {
+            char *h;
+            size_t allocated = 128;
+
+            while (1) {
+                h = pa_xmalloc(allocated);
+
+                if (!pa_get_home_dir(h, allocated)) {
+                    pa_xfree(h);
+                    return NULL;
+                }
+
+                if (strlen(h) < allocated - 1)
+                    break;
+
+                pa_xfree(h);
+                allocated *= 2;
+            }
+
             fn = lfn = pa_sprintf_malloc("%s" PA_PATH_SEP ".pulse" PA_PATH_SEP "%s", h, local);
-        else
-            return NULL;
+            pa_xfree(h);
+        }
 
 #ifdef OS_IS_WIN32
         if (!ExpandEnvironmentStrings(lfn, buf, PATH_MAX)) {
--- src/pulsecore/proplist-util.c.orig	2009-03-31 02:26:05.500000000 +0100
+++ src/pulsecore/proplist-util.c	2009-03-31 02:32:09.080000000 +0100
@@ -103,17 +103,33 @@
     b = pa_proplist_contains(p, PA_PROP_APPLICATION_NAME);
 
     if (!a || !b) {
-        char t[PATH_MAX];
-        if (pa_get_binary_name(t, sizeof(t))) {
-            char *c = pa_utf8_filter(t);
-
-            if (!a)
-                pa_proplist_sets(p, PA_PROP_APPLICATION_PROCESS_BINARY, c);
-            if (!b)
-                pa_proplist_sets(p, PA_PROP_APPLICATION_NAME, c);
+        char *t;
+        size_t allocated = 128;
 
-            pa_xfree(c);
+        while (1) {
+            t = pa_xmalloc(allocated);
+
+            if (!pa_get_binary_name(t, allocated))
+                break;
+
+            if (strlen(t) < allocated - 1) {
+                char *c = pa_utf8_filter(t);
+
+                if (!a)
+                    pa_proplist_sets(p, PA_PROP_APPLICATION_PROCESS_BINARY, c);
+                if (!b)
+                    pa_proplist_sets(p, PA_PROP_APPLICATION_NAME, c);
+
+                pa_xfree(c);
+
+                break;
+            }
+
+            pa_xfree(t);
+            allocated *= 2;
         }
+
+        pa_xfree(t);
     }
 
     if (!pa_proplist_contains(p, PA_PROP_APPLICATION_LANGUAGE)) {
--- ./src/pulsecore/core-scache.c.orig	2009-03-31 02:26:15.740000000 +0100
+++ ./src/pulsecore/core-scache.c	2009-03-31 02:49:59.250000000 +0100
@@ -487,16 +487,25 @@
 #endif
     } else {
         struct dirent *e;
+        size_t allocated = 128;
+        char *p = pa_xmalloc(allocated);
 
         while ((e = readdir(dir))) {
-            char p[PATH_MAX];
-
             if (e->d_name[0] == '.')
                 continue;
 
-            pa_snprintf(p, sizeof(p), "%s/%s", pathname, e->d_name);
-            add_file(c, p);
+            while (1) {
+                if (pa_snprintf(p, allocated, "%s/%s", pathname, e->d_name) < allocated - 1) {
+                    add_file(c, p);
+                    break;
+                }
+
+                pa_xfree(p);
+                allocated *= 2;
+                p = pa_xmalloc(allocated);
+            }
         }
+        pa_xfree(p);
 
         closedir(dir);
     }
--- ./src/utils/padsp.c.orig	2009-03-31 02:24:59.120000000 +0100
+++ ./src/utils/padsp.c	2009-03-31 03:14:08.930000000 +0100
@@ -459,16 +459,31 @@
 }
 
 static const char *client_name(char *buf, size_t n) {
-    char p[PATH_MAX];
+    char *p;
     const char *e;
+    size_t allocated = 128;
 
     if ((e = getenv("PADSP_CLIENT_NAME")))
         return e;
 
-    if (pa_get_binary_name(p, sizeof(p)))
-        snprintf(buf, n, "OSS Emulation[%s]", p);
-    else
-        snprintf(buf, n, "OSS");
+    while(1) {
+        p = pa_xmalloc(allocated);
+
+        if (!pa_get_binary_name(p, allocated)) {
+            snprintf(buf, n, "OSS");
+            break;
+        }
+
+        if (strlen(p) < allocated - 1) {
+            snprintf(buf, n, "OSS Emulation[%s]", p);
+            break;
+        }
+
+        pa_xfree(p);
+        allocated *= 2;
+    }
+
+    pa_xfree(p);
 
     return buf;
 }
--- ./src/utils/pactl.c.orig	2009-03-31 02:24:53.220000000 +0100
+++ ./src/utils/pactl.c	2009-03-31 03:17:06.270000000 +0100
@@ -698,7 +698,6 @@
 
 int main(int argc, char *argv[]) {
     pa_mainloop* m = NULL;
-    char tmp[PATH_MAX];
     int ret = 1, r, c;
     char *server = NULL, *client_name = NULL, *bn;
 
@@ -780,9 +779,9 @@
                     f = argv[optind];
 
                 n = strcspn(f, ".");
-                strncpy(tmp, f, n);
-                tmp[n] = 0;
-                sample_name = pa_xstrdup(tmp);
+                sample_name = pa_xmalloc(n + 1);
+                memcpy(sample_name, f, n);
+                sample_name[n] = 0;
             }
 
             memset(&sfinfo, 0, sizeof(sfinfo));
--- ./src/tests/get-binary-name-test.c.orig	2009-03-31 02:25:15.650000000 +0100
+++ ./src/tests/get-binary-name-test.c	2009-03-31 03:19:26.980000000 +0100
@@ -25,10 +25,24 @@
 #include <stdio.h>
 
 #include <pulse/util.h>
+#include <pulse/xmalloc.h>
 
 int main(int argc, char *argv[]) {
-    char exename[PATH_MAX];
+    char *exename;
+    size_t allocated = 128;
 
-    printf("%s\n", pa_get_binary_name(exename, sizeof(exename)));
+    while (1) {
+        exename = pa_xmalloc(allocated);
+
+        pa_get_binary_name(exename, allocated);
+
+        if (strlen(exename) < allocated - 1) {
+            printf("%s\n", exename);
+            break;
+        }
+
+        pa_xfree(exename);
+        allocated *= 2;
+    }
     return 0;
 }
--- src/modules/module-pipe-sink.c.orig	2009-03-31 04:21:20.180000000 +0100
+++ src/modules/module-pipe-sink.c	2009-03-31 04:22:27.050000000 +0100
@@ -120,7 +120,11 @@
     pa_assert(u);
 
     if (u->memchunk.length <= 0)
+#ifdef PIPE_BUF
         pa_sink_render(u->sink, PIPE_BUF, &u->memchunk);
+#else
+        pa_sink_render(u->sink, SIZE_MAX, &u->memchunk);
+#endif	
 
     pa_assert(u->memchunk.length > 0);
 
--- src/modules/module-pipe-source.c.orig	2009-03-31 04:24:14.940000000 +0100
+++ src/modules/module-pipe-source.c	2009-03-31 04:25:06.670000000 +0100
@@ -141,7 +141,11 @@
             void *p;
 
             if (!u->memchunk.memblock) {
+#ifdef PIPE_BUF
                 u->memchunk.memblock = pa_memblock_new(u->core->mempool, PIPE_BUF);
+#else
+                u->memchunk.memblock = pa_memblock_new(u->core->mempool, -1);
+#endif
                 u->memchunk.index = u->memchunk.length = 0;
             }
 
--- src/tests/rtstutter.c.orig	2009-03-31 04:44:18.670000000 +0100
+++ src/tests/rtstutter.c	2009-03-31 04:44:33.880000000 +0100
@@ -42,7 +42,9 @@
 static void* work(void *p) PA_GCC_NORETURN;
 
 static void* work(void *p) {
+#ifdef __linux__
     cpu_set_t mask;
+#endif
     struct sched_param param;
 
     pa_log_notice("CPU%i: Created thread.", PA_PTR_TO_INT(p));
@@ -51,9 +53,11 @@
     param.sched_priority = 12;
     pa_assert_se(pthread_setschedparam(pthread_self(), SCHED_FIFO, &param) == 0);
 
+#ifdef __linux__
     CPU_ZERO(&mask);
     CPU_SET((size_t) PA_PTR_TO_INT(p), &mask);
     pa_assert_se(pthread_setaffinity_np(pthread_self(), sizeof(mask), &mask) == 0);
+#endif
 
     for (;;) {
         struct timespec now, end;
--- debian/rules.orig	2009-03-31 04:51:50.800000000 +0100
+++ debian/rules	2009-03-31 04:52:05.140000000 +0100
@@ -7,6 +7,8 @@
 
 common-build-arch::
 	grep -v -e alsa -e evdev debian/pulseaudio.install > \
+	    debian/pulseaudio.install.hurd-i386
+	grep -v -e alsa -e evdev debian/pulseaudio.install > \
 	    debian/pulseaudio.install.kfreebsd-i386
 	grep -v -e alsa -e evdev debian/pulseaudio.install > \
 	    debian/pulseaudio.install.kfreebsd-amd64
@@ -19,6 +21,7 @@
 common-binary-post-install-arch:: list-missing
 
 clean::
+	rm -f debian/pulseaudio.install.hurd-i386
 	rm -f debian/pulseaudio.install.kfreebsd-i386
 	rm -f debian/pulseaudio.install.kfreebsd-amd64
 


More information about the Pkg-pulseaudio-devel mailing list