From ef34e71d89c299e7078fe45a5f0be0b522a4a8b1 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Wed, 25 Oct 2023 22:48:10 +0100 Subject: [PATCH] zsnes: fix build against zlib-1.3 Without the change builda fails on `master` as https://hydra.nixos.org/build/238481288/nixlog/3: checking for zlib - version >= 1.2.3... 1.3, bad version string given by zlib, sometimes due to very old zlibs that didnt correctly define their version. Please upgrade if you are running an old zlib... no The failure happens due to 2-digit zlib version string. Add a trivial change to allow 2-digit support in addition to existing 3-digit ones.. --- pkgs/applications/emulators/zsnes/default.nix | 2 + .../emulators/zsnes/zlib-1.3.patch | 41 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 pkgs/applications/emulators/zsnes/zlib-1.3.patch diff --git a/pkgs/applications/emulators/zsnes/default.nix b/pkgs/applications/emulators/zsnes/default.nix index 1583777a058f7..059c069d6069f 100644 --- a/pkgs/applications/emulators/zsnes/default.nix +++ b/pkgs/applications/emulators/zsnes/default.nix @@ -23,6 +23,8 @@ in stdenv.mkDerivation { sha256 = "1gy79d5wdaacph0cc1amw7mqm7i0716n6mvav16p1svi26iz193v"; }; + patches = [ ./zlib-1.3.patch ]; + buildInputs = [ nasm SDL zlib libpng ncurses libGLU libGL ]; prePatch = '' diff --git a/pkgs/applications/emulators/zsnes/zlib-1.3.patch b/pkgs/applications/emulators/zsnes/zlib-1.3.patch new file mode 100644 index 0000000000000..0c4771f089253 --- /dev/null +++ b/pkgs/applications/emulators/zsnes/zlib-1.3.patch @@ -0,0 +1,41 @@ +Add support for 2-digit zlib version like "1.3". +--- a/src/acinclude.m4 ++++ b/src/acinclude.m4 +@@ -67,7 +67,7 @@ char* my_strdup (char *str) + + int main (int argc, char *argv[]) + { +- int major, minor, micro, zlib_major_version, zlib_minor_version, zlib_micro_version; ++ int major, minor, micro, zlib_major_version, zlib_minor_version, zlib_micro_version = 0; + + char *zlibver, *tmp_version; + +@@ -85,7 +85,7 @@ int main (int argc, char *argv[]) + printf("%s, bad version string for\n\tmin_zlib_version... ", "$min_zlib_version"); + exit(1); + } +- if (sscanf(zlibver, "%d.%d.%d", &zlib_major_version, &zlib_minor_version, &zlib_micro_version) != 3) { ++ if (sscanf(zlibver, "%d.%d.%d", &zlib_major_version, &zlib_minor_version, &zlib_micro_version) != 3 && sscanf(zlibver, "%d.%d", &zlib_major_version, &zlib_minor_version) != 2) { + printf("%s, bad version string given\n", zlibver); + puts("\tby zlib, sometimes due to very old zlibs that didnt correctly"); + printf("\tdefine their version. Please upgrade if you are running an\n\told zlib... "); +--- a/src/configure ++++ b/src/configure +@@ -3817,7 +3817,7 @@ char* my_strdup (char *str) + + int main (int argc, char *argv[]) + { +- int major, minor, micro, zlib_major_version, zlib_minor_version, zlib_micro_version; ++ int major, minor, micro, zlib_major_version, zlib_minor_version, zlib_micro_version = 0; + + char *zlibver, *tmp_version; + +@@ -3835,7 +3835,7 @@ int main (int argc, char *argv[]) + printf("%s, bad version string for\n\tmin_zlib_version... ", "$min_zlib_version"); + exit(1); + } +- if (sscanf(zlibver, "%d.%d.%d", &zlib_major_version, &zlib_minor_version, &zlib_micro_version) != 3) { ++ if (sscanf(zlibver, "%d.%d.%d", &zlib_major_version, &zlib_minor_version, &zlib_micro_version) != 3 && sscanf(zlibver, "%d.%d", &zlib_major_version, &zlib_minor_version) != 2) { + printf("%s, bad version string given\n", zlibver); + puts("\tby zlib, sometimes due to very old zlibs that didnt correctly"); + printf("\tdefine their version. Please upgrade if you are running an\n\told zlib... ");