From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 8Cb9J4BAwF60YgAA0tVLHw (envelope-from ) for ; Sat, 16 May 2020 19:35:28 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id MOu7I4BAwF6ABAAAbx9fmQ (envelope-from ) for ; Sat, 16 May 2020 19:35:28 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id AF0BD94042C for ; Sat, 16 May 2020 19:35:26 +0000 (UTC) Received: from localhost ([::1]:57912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ja2aj-0000k7-1M for larch@yhetil.org; Sat, 16 May 2020 15:35:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ja2aM-0000jv-3L for bug-guix@gnu.org; Sat, 16 May 2020 15:35:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:58460) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ja2aL-0002Kv-Pi for bug-guix@gnu.org; Sat, 16 May 2020 15:35:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ja2aL-00041d-M3 for bug-guix@gnu.org; Sat, 16 May 2020 15:35:01 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#40832: [PATCH 2/2] gnu: Help alsa-lib find its plugins on foreign distros. Resent-From: Leo Famulari Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Sat, 16 May 2020 19:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40832 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 40832@debbugs.gnu.org Received: via spool by 40832-submit@debbugs.gnu.org id=B40832.158965768215430 (code B ref 40832); Sat, 16 May 2020 19:35:01 +0000 Received: (at 40832) by debbugs.gnu.org; 16 May 2020 19:34:42 +0000 Received: from localhost ([127.0.0.1]:41768 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ja2Zy-00040j-CV for submit@debbugs.gnu.org; Sat, 16 May 2020 15:34:42 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:47459) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ja2Zt-00040H-1j for 40832@debbugs.gnu.org; Sat, 16 May 2020 15:34:37 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id CF6595C00B4; Sat, 16 May 2020 15:34:27 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sat, 16 May 2020 15:34:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=famulari.name; h=from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=mesmtp; bh=usJjXtoBp6 OjqLZLmxP+FsaRCIVLajc1WkD8rUapuiQ=; b=aN4xN9rriW59/OZMtEvaVa9YJ5 Kc4pu2vCNCv6AoEoNtIkQAilMeQL2xmeKFxO1KcTKZGHGwMPsA6RSkACAQOJwxAQ XcZNEaF46AFu1rIoaUP7DmOlqU0xviXzvcoxEqgcE3q2pWtxTOY/lCoB7Df4//p0 4ssl8surkD4Ca5R3o= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=usJjXtoBp6OjqLZLmxP+FsaRCIVLajc1WkD8rUapuiQ=; b=HVAXRHqz L0OqP706g0vwBACkDn53k4+ShqrHZ44R0/f4IZ2plabxxdtxRtthqK/1EjUMHPx8 F0D8I+qGqKnaz9FBEu/CZE4q5uM5XKyLfxoq8c1zZbXEYYQ3PSiURhyXsoJ5115K 7cNOeLNxl7fRfVnWgYSZdmljU2ItK7f8HSUp4DttjDuUMXqpXWm9TWecuzQ1y26Q tktFY3MbPyfT95Vh547EsTSGNcQjrDbOnh3o2qJgdMh+ZaQOTIDzPeH/YC6fhyQr 7pqeooWUKk3J8LCZEFmYNxM3sIZmROJklRHojRKeMHRgRNHl1RJ64vQ86FlAUlFv t1DNUs7u+xrJTw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedruddttddgudefjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefnvghoucfhrghmuhhlrghrihcuoehlvghosehfrghmuhhl rghrihdrnhgrmhgvqeenucggtffrrghtthgvrhhnpefhvdehgfetueehhfehfedvgfdthe efkeeuudeltdduudeuveelfeefhfefveekheenucffohhmrghinhepghhnuhdrohhrghen ucfkphepjeeirdduvdegrddufeekrdeifeenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehlvghosehfrghmuhhlrghrihdrnhgrmhgv X-ME-Proxy: Received: from jasmine.lan (c-76-124-138-63.hsd1.pa.comcast.net [76.124.138.63]) by mail.messagingengine.com (Postfix) with ESMTPA id 8FA97306639B for <40832@debbugs.gnu.org>; Sat, 16 May 2020 15:34:27 -0400 (EDT) From: Leo Famulari Date: Sat, 16 May 2020 15:34:01 -0400 Message-Id: <30199c186ff45e84c629765a2d23e04ca6737d70.1589657580.git.leo@famulari.name> X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.7 (-) X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=famulari.name header.s=mesmtp header.b=aN4xN9rr; dkim=fail (rsa verify failed) header.d=messagingengine.com header.s=fm2 header.b=HVAXRHqz; dmarc=none; spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Spam-Score: 4.99 X-TUID: QuBvKdLOwoes Fixes . * gnu/packages/linux.scm (alsa-lib)[replacement]: New field. (alsa-lib/fixed): New variable. * gnu/packages/patches/alsa-lib-plugin-dirs.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. --- gnu/local.mk | 1 + gnu/packages/linux.scm | 10 ++ .../patches/alsa-lib-plugin-dirs.patch | 149 ++++++++++++++++++ 3 files changed, 160 insertions(+) create mode 100644 gnu/packages/patches/alsa-lib-plugin-dirs.patch diff --git a/gnu/local.mk b/gnu/local.mk index 39267f2765..78e63fe7ff 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -741,6 +741,7 @@ dist_patch_DATA = \ %D%/packages/patches/akonadi-not-relocatable.patch \ %D%/packages/patches/akonadi-timestamps.patch \ %D%/packages/patches/allegro-mesa-18.2.5-and-later.patch \ + %D%/packages/patches/alsa-lib-plugin-dirs.patch \ %D%/packages/patches/amule-crypto-6.patch \ %D%/packages/patches/anki-mpv-args.patch \ %D%/packages/patches/antiword-CVE-2014-8123.patch \ diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index 4fb29b8490..8ea5bb909a 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -1771,6 +1771,7 @@ intercept and print the system calls executed by the program.") (define-public alsa-lib (package (name "alsa-lib") + (replacement alsa-lib/fixed) (version "1.2.2") (source (origin (method url-fetch) @@ -1792,6 +1793,15 @@ intercept and print the system calls executed by the program.") MIDI functionality to the Linux-based operating system.") (license license:lgpl2.1+))) +(define alsa-lib/fixed + (package + (inherit alsa-lib) + (source (origin + (inherit (package-source alsa-lib)) + (patches (append + (origin-patches (package-source alsa-lib)) + (search-patches "alsa-lib-plugin-dirs.patch"))))))) + (define-public alsa-utils (package (name "alsa-utils") diff --git a/gnu/packages/patches/alsa-lib-plugin-dirs.patch b/gnu/packages/patches/alsa-lib-plugin-dirs.patch new file mode 100644 index 0000000000..0d6cb57f4e --- /dev/null +++ b/gnu/packages/patches/alsa-lib-plugin-dirs.patch @@ -0,0 +1,149 @@ +From 5bc1a490fa68187bce15eb9e8305b88ff6fbdbe5 Mon Sep 17 00:00:00 2001 +From: Leo Famulari +Date: Mon, 27 Apr 2020 13:09:54 -0400 +Subject: [PATCH] Search for plugins in $GUIX_ALSA_PLUGIN_DIRS. + +* src/control/control.c (snd_ctl_open_conf): If ALSA plugins cannot be found in +the default locations, look in the directories in $GUIX_ALSA_PLUGIN_DIRS. +* src/dlmisc.c (snd_dlopen): Likewise. +* src/pcm/pcm.c (snd_pcm_open_conf): Likewise. +--- + src/control/control.c | 35 ++++++++++++++++++++++++++++++++++- + src/dlmisc.c | 26 +++++++++++++++++++++----- + src/pcm/pcm.c | 35 ++++++++++++++++++++++++++++++++++- + 3 files changed, 89 insertions(+), 7 deletions(-) + +diff --git a/src/control/control.c b/src/control/control.c +index 27f42135..108a560b 100644 +--- a/src/control/control.c ++++ b/src/control/control.c +@@ -1342,8 +1342,41 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name, + err = -ENOMEM; + goto _err; + } ++ sprintf(buf1, "%s/libasound_module_pcm_%s.so", ALSA_PLUGIN_DIR, str); ++ if (access(buf1, F_OK) != 0) { ++ const char *plugindirs = getenv("GUIX_ALSA_PLUGIN_DIRS"); ++ ++ if (plugindirs) { ++ char *plugindirs_copy = alloca(strlen(plugindirs) + 1); ++ if (plugindirs_copy == NULL) { ++ err = -ENOMEM; ++ goto _err; ++ } ++ strcpy(plugindirs_copy, plugindirs); ++ char *saveptr; ++ while (1) { ++ char *dir_tok = strtok_r(plugindirs_copy, ":", &saveptr); ++ if (dir_tok == NULL) ++ break; ++ char *so_file = malloc(strlen(dir_tok) + 1 + strlen(str) + 32); ++ if (so_file == NULL) { ++ err = -ENOMEM; ++ goto _err; ++ } ++ ++ sprintf(so_file, "%s/libasound_module_ctl_%s.so", dir_tok, str); ++ ++ if (access(so_file, F_OK) == 0) { ++ buf1 = so_file; ++ break; ++ } else { ++ free (so_file); ++ } ++ plugindirs_copy = NULL; ++ } ++ } ++ } + lib = buf1; +- sprintf(buf1, "%s/libasound_module_ctl_%s.so", ALSA_PLUGIN_DIR, str); + } + } + #ifndef PIC +diff --git a/src/dlmisc.c b/src/dlmisc.c +index 8c8f3ff7..b115447c 100644 +--- a/src/dlmisc.c ++++ b/src/dlmisc.c +@@ -82,11 +82,27 @@ void *snd_dlopen(const char *name, int mode, char *errbuf, size_t errbuflen) + char *filename = NULL; + + if (name && name[0] != '/') { +- filename = alloca(sizeof(ALSA_PLUGIN_DIR) + 1 + strlen(name) + 1); +- if (filename) { +- strcpy(filename, ALSA_PLUGIN_DIR); +- strcat(filename, "/"); +- strcat(filename, name); ++ const char *plugindirs = getenv("GUIX_ALSA_PLUGIN_DIRS"); ++ if (plugindirs) { ++ char *plugindirs_copy = alloca(strlen(plugindirs) + 1); ++ if (plugindirs_copy == NULL) ++ goto errpath; ++ strcpy(plugindirs_copy, plugindirs); ++ char *saveptr; ++ while (1) { ++ char *dir_tok = strtok_r(plugindirs_copy, ":", &saveptr); ++ if (dir_tok == NULL) ++ break; ++ char *sofilename = malloc(strlen(dir_tok) + 1 + strlen(name) + 1); ++ sprintf(sofilename, "%s/%s" ,dir_tok, name); ++ if (access(sofilename, F_OK) == 0) { ++ filename = sofilename; ++ break; ++ } else { ++ free (sofilename); ++ } ++ plugindirs_copy = NULL; ++ } + handle = dlopen(filename, mode); + if (!handle) { + /* if the filename exists and cannot be opened */ +diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c +index 1064044c..90ba00ac 100644 +--- a/src/pcm/pcm.c ++++ b/src/pcm/pcm.c +@@ -2578,8 +2578,41 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name, + err = -ENOMEM; + goto _err; + } +- lib = buf1; + sprintf(buf1, "%s/libasound_module_pcm_%s.so", ALSA_PLUGIN_DIR, str); ++ if (access(buf1, F_OK) != 0) { ++ const char *plugindirs = getenv("GUIX_ALSA_PLUGIN_DIRS"); ++ ++ if (plugindirs) { ++ char *plugindirs_copy = alloca(strlen(plugindirs) + 1); ++ if (plugindirs_copy == NULL) { ++ err = -ENOMEM; ++ goto _err; ++ } ++ strcpy(plugindirs_copy, plugindirs); ++ char *saveptr; ++ while (1) { ++ char *dir_tok = strtok_r(plugindirs_copy, ":", &saveptr); ++ if (dir_tok == NULL) ++ break; ++ char *so_file = malloc(strlen(dir_tok) + 1 + strlen(str) + 32); ++ if (so_file == NULL) { ++ err = -ENOMEM; ++ goto _err; ++ } ++ ++ sprintf(so_file, "%s/libasound_module_pcm_%s.so", dir_tok, str); ++ ++ if (access(so_file, F_OK) == 0) { ++ buf1 = so_file; ++ break; ++ } else { ++ free (so_file); ++ } ++ plugindirs_copy = NULL; ++ } ++ } ++ } ++ lib = buf1; + } + } + #ifndef PIC +-- +2.26.2 + -- 2.26.2