From 9096d43ade3b73afd450891309fb9adf4ebb69a9 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Fri, 30 Dec 2022 20:17:39 +0100 Subject: [PATCH 1/5] giflib: clean up - use `makeFlags` to override `PREFIX` - change spacing and split some attributes into multiple lines for cleaner diffs and blames - add `meta.homepage` - format the expression - remove unused arguments - move `nativeBuildInputs` to more common place --- pkgs/development/libraries/giflib/default.nix | 39 ++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/pkgs/development/libraries/giflib/default.nix b/pkgs/development/libraries/giflib/default.nix index 5202dc0edabc..1eaa16583d6a 100644 --- a/pkgs/development/libraries/giflib/default.nix +++ b/pkgs/development/libraries/giflib/default.nix @@ -1,8 +1,15 @@ -{ lib, stdenv, fetchurl, fetchpatch, xmlto, docbook_xml_dtd_412, docbook_xsl, libxml2, fixDarwinDylibNames, pkgsStatic }: +{ stdenv +, lib +, fetchurl +, fetchpatch +, fixDarwinDylibNames +, pkgsStatic +}: stdenv.mkDerivation rec { pname = "giflib"; version = "5.2.1"; + src = fetchurl { url = "mirror://sourceforge/giflib/giflib-${version}.tar.gz"; sha256 = "1gbrg03z1b6rlrvjyc6d41bc8j1bsr7rm8206gb1apscyii5bnii"; @@ -14,33 +21,39 @@ stdenv.mkDerivation rec { url = "https://src.fedoraproject.org/rpms/giflib/raw/2e9917bf13df114354163f0c0211eccc00943596/f/CVE-2022-28506.patch"; sha256 = "sha256-TBemEXkuox8FdS9RvjnWcTWPaHRo4crcwSR9czrUwBY="; }) - ] ++ lib.optional stdenv.hostPlatform.isDarwin + ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ + # https://sourceforge.net/p/giflib/bugs/133/ (fetchpatch { - # https://sourceforge.net/p/giflib/bugs/133/ name = "darwin-soname.patch"; url = "https://sourceforge.net/p/giflib/bugs/_discuss/thread/4e811ad29b/c323/attachment/Makefile.patch"; sha256 = "12afkqnlkl3n1hywwgx8sqnhp3bz0c5qrwcv8j9hifw1lmfhv67r"; extraPrefix = "./"; - }); + }) + ]; - postPatch = '' - substituteInPlace Makefile \ - --replace 'PREFIX = /usr/local' 'PREFIX = ${builtins.placeholder "out"}' - '' - # Upstream build system does not support NOT building shared libraries. - + lib.optionalString stdenv.hostPlatform.isStatic '' + nativeBuildInputs = lib.optionals stdenv.isDarwin [ + fixDarwinDylibNames + ]; + + makeFlags = [ + "PREFIX=${builtins.placeholder "out"}" + ]; + + postPatch = lib.optionalString stdenv.hostPlatform.isStatic '' + # Upstream build system does not support NOT building shared libraries. sed -i '/all:/ s/libgif.so//' Makefile sed -i '/all:/ s/libutil.so//' Makefile sed -i '/-m 755 libgif.so/ d' Makefile sed -i '/ln -sf libgif.so/ d' Makefile ''; - nativeBuildInputs = lib.optionals stdenv.isDarwin [ fixDarwinDylibNames ]; - - passthru.tests.static = pkgsStatic.giflib; + passthru.tests = { + static = pkgsStatic.giflib; + }; meta = { description = "A library for reading and writing gif images"; + homepage = "https://giflib.sourceforge.net/"; platforms = lib.platforms.unix; license = lib.licenses.mit; maintainers = with lib.maintainers; [ ]; From 007173a9dbdebdb94cec37cb88a01480a47c0e15 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Fri, 30 Dec 2022 20:12:33 +0100 Subject: [PATCH 2/5] pkgsCross.mingwW64.giflib: fix build It was failing with: x86_64-w64-mingw32-ld: qprintf.o:qprintf.c:(.text+0xb9): undefined reference to `GifErrorString' and then install gif2rgb gifbuild giffix giftext giftool gifclrmp "/nix/store/vcik0mlp8756g2lpmzbjw3v8mhn1529i-giflib-x86_64-w64-mingw32-5.2.1/bin" install: cannot stat 'gif2rgb': No such file or directory --- pkgs/development/libraries/giflib/default.nix | 9 +++++++++ .../libraries/giflib/mingw-install-exes.patch | 11 +++++++++++ 2 files changed, 20 insertions(+) create mode 100644 pkgs/development/libraries/giflib/mingw-install-exes.patch diff --git a/pkgs/development/libraries/giflib/default.nix b/pkgs/development/libraries/giflib/default.nix index 1eaa16583d6a..8c8a587ed548 100644 --- a/pkgs/development/libraries/giflib/default.nix +++ b/pkgs/development/libraries/giflib/default.nix @@ -29,6 +29,15 @@ stdenv.mkDerivation rec { sha256 = "12afkqnlkl3n1hywwgx8sqnhp3bz0c5qrwcv8j9hifw1lmfhv67r"; extraPrefix = "./"; }) + ] ++ lib.optionals stdenv.hostPlatform.isMinGW [ + # Build dll libraries. + (fetchurl { + url = "https://aur.archlinux.org/cgit/aur.git/plain/001-mingw-build.patch?h=mingw-w64-giflib&id=4cf1e519bcf51338dc607d23388fca47d71790c0"; + sha256 = "KyJi3eqH/Ae+guEK6znraZI5+IPImaoYoW5NTkCvjsg="; + }) + + # Install executables. + ./mingw-install-exes.patch ]; nativeBuildInputs = lib.optionals stdenv.isDarwin [ diff --git a/pkgs/development/libraries/giflib/mingw-install-exes.patch b/pkgs/development/libraries/giflib/mingw-install-exes.patch new file mode 100644 index 000000000000..5ec3fdad7e65 --- /dev/null +++ b/pkgs/development/libraries/giflib/mingw-install-exes.patch @@ -0,0 +1,11 @@ +--- a/Makefile ++++ b/Makefile +@@ -92,7 +92,7 @@ + install: all install-bin install-include install-lib install-man + install-bin: $(INSTALLABLE) + $(INSTALL) -d "$(DESTDIR)$(BINDIR)" +- $(INSTALL) $^ "$(DESTDIR)$(BINDIR)" ++ $(INSTALL) $(^:=.exe) "$(DESTDIR)$(BINDIR)" + install-include: + $(INSTALL) -d "$(DESTDIR)$(INCDIR)" + $(INSTALL) -m 644 gif_lib.h "$(DESTDIR)$(INCDIR)" From 7bc650eccac8ee2d032a5beee6d44ff18527f7b6 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Fri, 30 Dec 2022 23:34:50 +0100 Subject: [PATCH 3/5] pkgsCross.mingwW64.gettext: fix build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We are unable to build bash so let’s drop it for now on MinGW (partially reverting 7d0399279a6949ad4bddd95a4023ab02dc2286be there). This will cause shebangs not to be patched. --- pkgs/development/libraries/gettext/default.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/gettext/default.nix b/pkgs/development/libraries/gettext/default.nix index a8e8fde96f63..ec929272dea0 100644 --- a/pkgs/development/libraries/gettext/default.nix +++ b/pkgs/development/libraries/gettext/default.nix @@ -54,9 +54,13 @@ stdenv.mkDerivation rec { xz xz.bin ]; - buildInputs = [ bash ] - # HACK, see #10874 (and 14664) - ++ lib.optionals (!stdenv.isLinux && !stdenv.hostPlatform.isCygwin) [ libiconv ]; + buildInputs = lib.optionals (!stdenv.hostPlatform.isMinGW) [ + bash + ] + ++ lib.optionals (!stdenv.isLinux && !stdenv.hostPlatform.isCygwin) [ + # HACK, see #10874 (and 14664) + libiconv + ]; setupHooks = [ ../../../build-support/setup-hooks/role.bash From ce6bf3bb54d95b7f8e9cc0e0506c123f8f349768 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sat, 31 Dec 2022 14:40:00 +0100 Subject: [PATCH 4/5] cfitsio: clean up - format the expression - change spacing and split some attributes into multiple lines for cleaner diffs and blames - move `patches` atributes to a more conventional place --- .../science/astronomy/cfitsio/default.nix | 45 ++++++++++++------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/pkgs/development/libraries/science/astronomy/cfitsio/default.nix b/pkgs/development/libraries/science/astronomy/cfitsio/default.nix index 8a6b72f52130..87aa5a701c31 100644 --- a/pkgs/development/libraries/science/astronomy/cfitsio/default.nix +++ b/pkgs/development/libraries/science/astronomy/cfitsio/default.nix @@ -1,4 +1,9 @@ -{ stdenv, lib, fetchurl, bzip2, zlib }: +{ stdenv +, lib +, fetchurl +, bzip2 +, zlib +}: stdenv.mkDerivation rec { pname = "cfitsio"; @@ -9,31 +14,41 @@ stdenv.mkDerivation rec { sha256 = "sha256-66U9Gz9uNFYyuwmnt1LsfO09Y+xRU6hIOA84gMXWGIk="; }; - buildInputs = [ bzip2 zlib ]; + patches = [ + ./darwin-rpath-universal.patch + ]; - patches = [ ./darwin-rpath-universal.patch ]; + buildInputs = [ + bzip2 + zlib + ]; - configureFlags = [ "--with-bzip2=${bzip2.out}" "--enable-reentrant" ]; + configureFlags = [ + "--with-bzip2=${bzip2.out}" + "--enable-reentrant" + ]; hardeningDisable = [ "format" ]; # Shared-only build buildFlags = [ "shared" ]; - postPatch = '' sed -e '/^install:/s/libcfitsio.a //' -e 's@/bin/@@g' -i Makefile.in - ''; + + postPatch = '' + sed -e '/^install:/s/libcfitsio.a //' -e 's@/bin/@@g' -i Makefile.in + ''; meta = with lib; { homepage = "https://heasarc.gsfc.nasa.gov/fitsio/"; description = "Library for reading and writing FITS data files"; - longDescription = - '' CFITSIO is a library of C and Fortran subroutines for reading and - writing data files in FITS (Flexible Image Transport System) data - format. CFITSIO provides simple high-level routines for reading and - writing FITS files that insulate the programmer from the internal - complexities of the FITS format. CFITSIO also provides many - advanced features for manipulating and filtering the information in - FITS files. - ''; + longDescription = '' + CFITSIO is a library of C and Fortran subroutines for reading and + writing data files in FITS (Flexible Image Transport System) data + format. CFITSIO provides simple high-level routines for reading and + writing FITS files that insulate the programmer from the internal + complexities of the FITS format. CFITSIO also provides many + advanced features for manipulating and filtering the information in + FITS files. + ''; changelog = "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/docs/changes.txt"; license = licenses.mit; maintainers = with maintainers; [ xbreak hjones2199 ]; From 2cb203a61d6e4856f2ed84e4bfea9e7ccf563ed9 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Wed, 4 Jan 2023 00:37:35 +0100 Subject: [PATCH 5/5] pkgsCross.mingwW64.popt: Fix build First it fails to compile: popthelp.c:15:10: fatal error: sys/ioctl.h: No such file or directory 15 | #include | ^~~~~~~~~~~~~ And then it does not want to link: /nix/store/k35kvfyhzhlpx71gf05zm6gy23alg571-x86_64-w64-mingw32-binutils-2.39/bin/x86_64-w64-mingw32-ld: .libs/popt.o: in function `execCommand': /build/popt-1.19/src/popt.c:521: undefined reference to `getuid' /nix/store/k35kvfyhzhlpx71gf05zm6gy23alg571-x86_64-w64-mingw32-binutils-2.39/bin/x86_64-w64-mingw32-ld: /build/popt-1.19/src/popt.c:521: undefined reference to `geteuid' /nix/store/k35kvfyhzhlpx71gf05zm6gy23alg571-x86_64-w64-mingw32-binutils-2.39/bin/x86_64-w64-mingw32-ld: /build/popt-1.19/src/popt.c:521: undefined reference to `getgid' /nix/store/k35kvfyhzhlpx71gf05zm6gy23alg571-x86_64-w64-mingw32-binutils-2.39/bin/x86_64-w64-mingw32-ld: /build/popt-1.19/src/popt.c:521: undefined reference to `getegid' --- pkgs/development/libraries/popt/default.nix | 23 ++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/popt/default.nix b/pkgs/development/libraries/popt/default.nix index 37d83ff5b2b2..fdccb4d09336 100644 --- a/pkgs/development/libraries/popt/default.nix +++ b/pkgs/development/libraries/popt/default.nix @@ -1,4 +1,8 @@ -{ lib, stdenv, fetchurl }: +{ lib +, stdenv +, fetchurl +, fetchpatch2 +}: stdenv.mkDerivation rec { pname = "popt"; @@ -12,6 +16,23 @@ stdenv.mkDerivation rec { patches = lib.optionals stdenv.isCygwin [ ./1.16-cygwin.patch ./1.16-vpath.patch + ] ++ lib.optionals stdenv.hostPlatform.isMinGW [ + # Do not require + (fetchpatch2 { + url = "https://aur.archlinux.org/cgit/aur.git/plain/get-w32-console-maxcols.mingw32.patch?h=mingw-w64-popt&id=63f2cdb0de116362c49681cef20f7a8b4355e85a"; + sha256 = "zv43l1RBqNzT/JG+jQaMVFaFv+ZYPuIiAtKUDzJJBbc="; + stripLen = 1; + extraPrefix = "src/"; + }) + + # Do not try to detect setuid, it is not a thing. + (fetchpatch2 { + url = "https://github.com/rpm-software-management/popt/commit/905544c5d9767894edaf71a1e3ce5126944c5695.patch"; + sha256 = "3PmcxeiEZ/Hof0zoVFSytEXvQ8gE8Sp5UdagExPVICU="; + stripLen = 1; + extraPrefix = "src/"; + revert = true; + }) ]; doCheck = false; # fails