From 96c99d0145b22456bc117eb0914f96df741346d3 Mon Sep 17 00:00:00 2001 From: sanana Date: Tue, 14 Jan 2025 21:11:36 +0300 Subject: [PATCH] freesweep: 1.0.2 -> 1.0.2-unstable-2024-04-19 freesweep has a new version in development and it seems to be usable, let's update to it. I included a few patches to allow it to build with and without mlibc (which I'm working on in #371092). --- .../fr/freesweep/0001-include-strings.h.patch | 15 ++++++++ .../freesweep/0002-fix-Wformat-security.patch | 13 +++++++ .../0003-remove-ac_func_malloc.patch | 12 +++++++ pkgs/by-name/fr/freesweep/package.nix | 35 ++++++++++++++----- 4 files changed, 67 insertions(+), 8 deletions(-) create mode 100644 pkgs/by-name/fr/freesweep/0001-include-strings.h.patch create mode 100644 pkgs/by-name/fr/freesweep/0002-fix-Wformat-security.patch create mode 100644 pkgs/by-name/fr/freesweep/0003-remove-ac_func_malloc.patch diff --git a/pkgs/by-name/fr/freesweep/0001-include-strings.h.patch b/pkgs/by-name/fr/freesweep/0001-include-strings.h.patch new file mode 100644 index 000000000000..e94e3b94f786 --- /dev/null +++ b/pkgs/by-name/fr/freesweep/0001-include-strings.h.patch @@ -0,0 +1,15 @@ +diff --git a/sweep.h b/sweep.h +index 198349d..549f39f 100644 +--- a/sweep.h ++++ b/sweep.h +@@ -32,6 +32,10 @@ + #include + #endif /* HAVE_STRING_H */ + ++#ifdef HAVE_STRINGS_H ++#include ++#endif /* HAVE_STRINGS_H */ ++ + #ifdef HAVE_GETOPT_H + #include + #endif /* HAVE_GETOPT_H */ diff --git a/pkgs/by-name/fr/freesweep/0002-fix-Wformat-security.patch b/pkgs/by-name/fr/freesweep/0002-fix-Wformat-security.patch new file mode 100644 index 000000000000..b37f0e7420ce --- /dev/null +++ b/pkgs/by-name/fr/freesweep/0002-fix-Wformat-security.patch @@ -0,0 +1,13 @@ +diff --git a/logs.c b/logs.c +index 5e87f52..29ad433 100644 +--- a/logs.c ++++ b/logs.c +@@ -128,7 +128,7 @@ static void log_display(const char *mesg) { + // Display the message on the screen. + if (log_win) { + wclear(log_win); +- mvwprintw(log_win, 0, 0, mesg); ++ mvwprintw(log_win, 0, 0, "%s", mesg); + wnoutrefresh(log_win); + wrefresh(log_win); + } diff --git a/pkgs/by-name/fr/freesweep/0003-remove-ac_func_malloc.patch b/pkgs/by-name/fr/freesweep/0003-remove-ac_func_malloc.patch new file mode 100644 index 000000000000..99579a8952d1 --- /dev/null +++ b/pkgs/by-name/fr/freesweep/0003-remove-ac_func_malloc.patch @@ -0,0 +1,12 @@ +diff --git a/configure.ac b/configure.ac +index ae08308..5262e56 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -32,7 +32,6 @@ AC_TYPE_SIZE_T + AC_TYPE_UID_T + + # Checks for library functions. +-AC_FUNC_MALLOC + AC_CHECK_FUNCS([alarm getcwd memset mkdir setlocale strdup strncasecmp + fileno flock lockf getopt getopt_long]) + diff --git a/pkgs/by-name/fr/freesweep/package.nix b/pkgs/by-name/fr/freesweep/package.nix index 7ade52101f7c..9fff2fa59719 100644 --- a/pkgs/by-name/fr/freesweep/package.nix +++ b/pkgs/by-name/fr/freesweep/package.nix @@ -3,31 +3,50 @@ ncurses, lib, stdenv, - updateAutotoolsGnuConfigScriptsHook, + autoconf, + automake, + pkg-config, installShellFiles, }: -stdenv.mkDerivation rec { +stdenv.mkDerivation { pname = "freesweep"; - version = "1.0.2"; + version = "1.0.2-unstable-2024-04-19"; src = fetchFromGitHub { owner = "rwestlund"; repo = "freesweep"; - rev = "v${version}"; - hash = "sha256-iuu81yHbNrjdPsimBrPK58PJ0d8i3ySM7rFUG/d8NJM"; + rev = "68c0ee5b29d1087d216d95875a7036713cd25fc0"; + hash = "sha256-ZnAH7mIuBMFLdrtJOY8PzNbxv+GDEFAgyEtWCpTH2Us="; }; + # These patches are sent upstream in github:rwestlund/freesweep#18 + patches = [ + # strncasecmp and friends are declared in strings.h and not string.h on + # systems with HAVE_STRINGS_H + ./0001-include-strings.h.patch + # Fixes a potential format string vulnerability and makes it compile with + # -Wformat-security + ./0002-fix-Wformat-security.patch + # autoconf believes systems that handle malloc(0) differently from glibc + # have a bad malloc implementation and will replace calls to malloc with + # rpl_malloc. freesweep does not define rpl_malloc so this macro prevents + # building for such systems, the easiest solution is to remove this macro + ./0003-remove-ac_func_malloc.patch + ]; + nativeBuildInputs = [ - updateAutotoolsGnuConfigScriptsHook + autoconf + automake + pkg-config installShellFiles ]; buildInputs = [ ncurses ]; - configureFlags = [ "--with-prefsdir=$out/share" ]; - enableParallelBuilding = true; + preConfigure = "./autogen.sh"; + installPhase = '' runHook preInstall install -D -m 0555 freesweep $out/bin/freesweep