foobillard++: fix location of data directory.

Remove the code that it uses to guess the data directory and simply
default to /usr/share/foobillardplus. Without this, the program panics
at launch (it was likely panicking ever since it was updated, given that
the sed command for src/language.c no longer had any effect).

At the moment, the game more often that not segfaults at launch on musl,
but I'm not marking it broken because it's been in the repos for a long
time already. If anyone complains, we can try to fix the issue then
(extremely likely to be a race condition; maybe tries to pthread_join a
dead thread?).

Also xlint.

Fixes #27598
This commit is contained in:
Érico Rolim 2021-01-01 21:08:48 -03:00
parent 6e69bc9807
commit 4ad43e8df1
2 changed files with 54 additions and 10 deletions

View file

@ -0,0 +1,43 @@
diff --git src/sys_stuff.c src/sys_stuff.c
index 8f65f6b..7b905cf 100644
--- src/sys_stuff.c
+++ src/sys_stuff.c
@@ -756,37 +756,18 @@ void sys_main_loop(void) {
* Find the program's "data" directory and chdir into it *
***********************************************************************/
-static char data_dir[512];
+static char data_dir[512] = "/usr/share/foobillardplus";
void enter_data_dir() {
int success = 1;
#ifdef POSIX
- char proc_exe[20];
- char *slash_pos;
#endif
do {
success = 0;
#ifdef POSIX
- snprintf(proc_exe, sizeof(proc_exe), "/proc/%d/exe", getpid());
- if (readlink(proc_exe, data_dir, sizeof(data_dir)) < 0) {
- perror("readlink failed");
- break;
- }
-
- // Remove program name
- slash_pos = strrchr(data_dir, '/');
- if (!slash_pos) break;
- *slash_pos = '\0';
-
- // Go one dir up
- slash_pos = strrchr(data_dir, '/');
- if (!slash_pos) break;
-
- // Add "/data"
- strncpy(slash_pos, "/data", sizeof(data_dir) - (slash_pos - data_dir));
#else
/* ### TODO ### Get the working directory of the program
* Mac OS X: _NSGetExecutablePath() (man 3 dyld)

View file

@ -1,29 +1,30 @@
# Template file for 'foobillard++'
# often segfaults at launch on musl, but not marking broken yet
pkgname=foobillard++
version=3.42beta
revision=3
revision=4
wrksrc=foobillardplus-${version}
build_style=gnu-configure
configure_args="--enable-standard"
homepage="http://foobillardplus.sourceforge.net/"
distfiles="${SOURCEFORGE_SITE}/foobillardplus/foobillardplus-$version.tar.gz"
hostmakedepends="automake pkg-config"
makedepends="libICE-devel freetype-devel libpng-devel glu-devel SDL_mixer-devel SDL_net-devel"
depends="desktop-file-utils"
short_desc="An OpenGL billard game - fork of foobillard"
short_desc="OpenGL billard game - fork of foobillard"
maintainer="Orphaned <orphan@voidlinux.org>"
license="GPL-2"
license="GPL-2.0-only"
homepage="http://foobillardplus.sourceforge.net/"
distfiles="${SOURCEFORGE_SITE}/foobillardplus/foobillardplus-$version.tar.gz"
checksum=e276b70674a7d788c45eeff89f1f5db5d48d871a1ab92103813d424a3761e1d9
CFLAGS+=" -fgnu89-inline"
pre_configure() {
autoreconf -fi
sed -i 's|$prefix/foobillardplus|$prefix|' configure
sed -i 's|$prefix/data|$prefix/share/foobillardplus|' configure
sed -i 's|"/data"|"/share/foobillardplus"|' src/language.c
sed -i 's|/opt/foobillardplus/bin/||' foobillardplus.desktop
sed -i 's|/opt/foobillardplus/||' foobillardplus.desktop
vsed -i 's|$prefix/foobillardplus|$prefix|' configure
vsed -i 's|$prefix/data|$prefix/share/foobillardplus|' configure
vsed -i 's|/opt/foobillardplus/bin/||' foobillardplus.desktop
vsed -i 's|/opt/foobillardplus/||' foobillardplus.desktop
}
do_install() {
vbin src/foobillardplus
vmkdir usr/share/foobillardplus