Subject: pkg/31268: devel/allegro can't find esd module because of hardcoded path
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <tatsuyak@e-mail.ne.jp>
List: pkgsrc-bugs
Date: 09/09/2005 07:57:53
>Number:         31268
>Category:       pkg
>Synopsis:       devel/allegro can't find esd module because of hardcoded path
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Sep 09 07:57:53 +0000 2005
>Originator:     Tatsuya Kobayashi
>Release:        NetBSD 3.99.8
>Organization:
tatsuyak@e-mail.ne.jp
>Environment:
NetBSD gradriel 3.99.8 NetBSD 3.99.8 (PCMM20) #0: Mon Aug 29 22:36:17 JST 2005  root@gradriel:/build/src.build/obj/sys/arch/i386/compile/PCMM20 i386
>Description:
Now, allegro library of pkgsrc supports esound module.
But program which use allegro library can't detect esd driver.

Because allegro searches modules under hardcoded path, and it doesn't include pkgsrc library path.
>How-To-Repeat:
For example, install allegro with PKG_OPTION.allegro=esound.
And then installed emulator/raine.
Raine has graphical configuration menu, and we can not choose esound as sound driver. (because detect_sound_driver() doesn't return esound, only oss would be returned.)
>Fix:
example patches as below.

* The search path for cfg files of allegro is also hard coded, I also fixed as well as module path.

* And allegro uses 'ls' command internally with '-f' option. But NetBSD doesn't have '-f' option and I saw some errors when programs which link against allegro are executed. So I removed '-f' option only for NetBSD. I checked the source and I think this is no problem. I don't check for the other platforms.

diff -x .svn -urN ../devel/allegro/Makefile ./allegro/Makefile
--- ../devel/allegro/Makefile	2005-06-02 03:02:42.000000000 +0900
+++ ./allegro/Makefile	2005-09-08 11:59:19.000000000 +0900
@@ -24,11 +24,15 @@
 
 .include "options.mk"
 
-SUBST_CLASSES=		oss
+SUBST_CLASSES=		oss path
 SUBST_STAGE.oss=	post-patch
 SUBST_FILES.oss=	src/unix/uoss.c setup/setup.c
 SUBST_SED.oss=		-e "s,/dev/dsp,${DEVOSSAUDIO},g"
 SUBST_MESSAGE.oss=	"Fixing harcoded audio device."
+SUBST_STAGE.path=	post-patch
+SUBST_FILES.path=	src/unix/umodules.c src/unix/usystem.c
+SUBST_SED.path=	-e "s,@@PREFIX@@,${PREFIX},g"
+SUBST_MESSAGE.path=	"Fixing harcoded path"
 
 .include "../../mk/ossaudio.buildlink3.mk"
 .include "../../mk/pthread.buildlink3.mk"
diff -x .svn -urN ../devel/allegro/distinfo ./allegro/distinfo
--- ../devel/allegro/distinfo	2005-05-23 21:05:46.000000000 +0900
+++ ./allegro/distinfo	2005-09-09 15:16:55.000000000 +0900
@@ -8,3 +8,5 @@
 SHA1 (patch-ac) = 78f99723b095f460f20e8367fffb443a8f3d6ab6
 SHA1 (patch-ad) = 52f694e1b0053cff94c53ee10f603d535eba5fa5
 SHA1 (patch-ae) = 89839ee94e798c08d4121521a64a549d46535f74
+SHA1 (patch-ax) = 5a60e3f993bc0238837c82f245d9e396b297c075
+SHA1 (patch-ay) = 48cf33b773270676255561518998b7bcefb07daa
diff -x .svn -urN ../devel/allegro/patches/patch-ax ./allegro/patches/patch-ax
--- ../devel/allegro/patches/patch-ax	1970-01-01 09:00:00.000000000 +0900
+++ ./allegro/patches/patch-ax	2005-09-09 15:16:40.000000000 +0900
@@ -0,0 +1,35 @@
+--- src/unix/usystem.c.orig	2005-09-08 11:51:43.000000000 +0900
++++ src/unix/usystem.c	2005-09-08 11:53:54.000000000 +0900
+@@ -130,6 +130,7 @@
+    }
+ 
+    /* if it is a .dat, look in /usr/share/ and /usr/local/share/ */
++   /* and @@PREFIX@@/share in NetBSD */
+    if (ustricmp(get_extension(resource), uconvert_ascii("dat", tmp)) == 0) {
+       ustrzcpy(buf, sizeof(buf), uconvert_ascii("/usr/share/allegro/", tmp));
+       ustrzcat(buf, sizeof(buf), resource);
+@@ -137,6 +138,12 @@
+ 	 ustrzcpy(dest, size, buf);
+ 	 return 0;
+       }
++      ustrzcpy(buf, sizeof(buf), uconvert_ascii("@@PREFIX@@/share/allegro/", tmp));
++      ustrzcat(buf, sizeof(buf), resource);
++      if (exists(buf)) {
++	 ustrzcpy(dest, size, buf);
++	 return 0;
++      }
+       ustrzcpy(buf, sizeof(buf), uconvert_ascii("/usr/local/share/allegro/", tmp));
+       ustrzcat(buf, sizeof(buf), resource);
+       if (exists(buf)) {
+@@ -376,7 +376,11 @@
+    
+    /* Last resort: try using the output of the ps command to at least find */
+    /* the name of the file if not the full path */
++#ifdef __NetBSD__
++   uszprintf (linkname, sizeof(linkname), "ps -p %d", pid);
++#else
+    uszprintf (linkname, sizeof(linkname), "ps -f -p %d", pid);
++#endif
+    do_uconvert (linkname, U_CURRENT, filename, U_ASCII, size);
+    pipe = popen(filename, "r");
+    if (pipe) {
diff -x .svn -urN ../devel/allegro/patches/patch-ay ./allegro/patches/patch-ay
--- ../devel/allegro/patches/patch-ay	1970-01-01 09:00:00.000000000 +0900
+++ ./allegro/patches/patch-ay	2005-09-08 11:55:20.000000000 +0900
@@ -0,0 +1,14 @@
+--- src/unix/umodules.c.orig	2005-09-08 11:48:35.000000000 +0900
++++ src/unix/umodules.c	2005-09-08 11:53:04.000000000 +0900
+@@ -43,7 +43,10 @@
+ /* where to look for modules.lst */
+ static char *module_path[] =
+ {
+-   "/usr/local/lib/allegro/", "/usr/lib/allegro/", NULL
++   "@@PREFIX@@/lib/allegro/",
++   "/usr/local/lib/allegro/",
++   "/usr/lib/allegro/",
++   NULL
+ };
+ 
+