From 4ad43e8df1916c2bca1c3585eaef3d3fc96cff66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Rolim?= Date: Fri, 1 Jan 2021 21:08:48 -0300 Subject: [PATCH] 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 --- srcpkgs/foobillard++/patches/data-dir.patch | 43 +++++++++++++++++++++ srcpkgs/foobillard++/template | 21 +++++----- 2 files changed, 54 insertions(+), 10 deletions(-) create mode 100644 srcpkgs/foobillard++/patches/data-dir.patch diff --git a/srcpkgs/foobillard++/patches/data-dir.patch b/srcpkgs/foobillard++/patches/data-dir.patch new file mode 100644 index 00000000000..986b1e14a34 --- /dev/null +++ b/srcpkgs/foobillard++/patches/data-dir.patch @@ -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) diff --git a/srcpkgs/foobillard++/template b/srcpkgs/foobillard++/template index 6d73a67f4ed..98923393e99 100644 --- a/srcpkgs/foobillard++/template +++ b/srcpkgs/foobillard++/template @@ -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 " -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