From eea3344e9171c80e59e157c2c5739b8150d782dc Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Wed, 30 Jun 2021 04:19:12 +0200 Subject: [PATCH 1/3] ploticus: Modernize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Split pname & version. - Format the expression. - Do not use custom builder, the generic one is good enough. - Install the man pages to datadir instead of $out, where they would be moved anyway. – Allowing us to drop the postFixup. - Use patch instead of wrapper for pointing to prefabs. This is what Debian does and it will also apply to the pl binary, not just the ploticus alias. - Since the wrapping is no longer necessary, let’s create the alias using a symlink. --- pkgs/tools/graphics/ploticus/builder.sh | 33 ----------- pkgs/tools/graphics/ploticus/default.nix | 57 +++++++++++++++---- .../graphics/ploticus/set-prefabs-dir.patch | 10 ++++ 3 files changed, 56 insertions(+), 44 deletions(-) delete mode 100644 pkgs/tools/graphics/ploticus/builder.sh create mode 100644 pkgs/tools/graphics/ploticus/set-prefabs-dir.patch diff --git a/pkgs/tools/graphics/ploticus/builder.sh b/pkgs/tools/graphics/ploticus/builder.sh deleted file mode 100644 index 2fb16b259bdc..000000000000 --- a/pkgs/tools/graphics/ploticus/builder.sh +++ /dev/null @@ -1,33 +0,0 @@ -source $stdenv/setup - -preBuild() { - cd src -} - -preInstall() { - mkdir -p $out/bin -} - -postInstall() { - # Install the "prefabs". - mkdir -p $out/share/ploticus/prefabs && \ - cd .. && \ - cp -rv prefabs/* $out/share/ploticus/prefabs - - # Create a wrapper that knows where to find them. Debian's package - # does something similar by patching directly the C file that looks - # for `$PLOTICUS_PREFABS'. - cat > $out/bin/ploticus < Date: Wed, 30 Jun 2021 04:53:01 +0200 Subject: [PATCH 2/3] =?UTF-8?q?ploticus:=202.41=20=E2=86=92=202.42?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/NixOS/nixpkgs/commit/65f1e8e048db75be3e97048fecb99ed39b0ce2e5 bumped the version but forgot to update the tarball URL. Unfortunately, this version does not seem to ship makefiles. --- pkgs/tools/graphics/ploticus/default.nix | 10 +++------- .../graphics/ploticus/set-prefabs-dir.patch | 17 +++++++++-------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/pkgs/tools/graphics/ploticus/default.nix b/pkgs/tools/graphics/ploticus/default.nix index e5d9f7160789..6b1b50bca02b 100644 --- a/pkgs/tools/graphics/ploticus/default.nix +++ b/pkgs/tools/graphics/ploticus/default.nix @@ -6,13 +6,13 @@ , libpng }: -stdenv.mkDerivation { +stdenv.mkDerivation rec { pname = "ploticus"; version = "2.42"; src = fetchurl { - url = "mirror://sourceforge/ploticus/ploticus/2.41/pl241src.tar.gz"; - sha256 = "1065r0nizjixi9sxxfxrnwg10r458i6fgsd23nrxa200rypvdk7c"; + url = "mirror://sourceforge/ploticus/ploticus/${version}/ploticus${lib.replaceStrings [ "." ] [ "" ] version}_src.tar.gz"; + sha256 = "PynkufQFIDqT7+yQDlgW2eG0OBghiB4kHAjKt91m4LA="; }; patches = [ @@ -46,11 +46,7 @@ stdenv.mkDerivation { mkdir -p "$out/share/ploticus/prefabs" cp -rv prefabs/* "$out/share/ploticus/prefabs" - # Install the man pages. - cp -rv man $out/share - # Add aliases for backwards compatibility. - ln -s "pl.1" "$out/share/man/man1/ploticus.1" ln -s "pl" "$out/bin/ploticus" ''; diff --git a/pkgs/tools/graphics/ploticus/set-prefabs-dir.patch b/pkgs/tools/graphics/ploticus/set-prefabs-dir.patch index 3955d34972e5..82871654fdea 100644 --- a/pkgs/tools/graphics/ploticus/set-prefabs-dir.patch +++ b/pkgs/tools/graphics/ploticus/set-prefabs-dir.patch @@ -1,10 +1,11 @@ ---- a/src/Makefile -+++ b/src/Makefile -@@ -133,6 +133,6 @@ - #### To set a hard-coded directory for prefabs files, uncomment & edit the following.. - #### If done, users won't be required to have PLOTICUS_PREFABS environment variable defined. - #### This option not available for win32 --# PREFABS_DIR = "/usr/lib/ploticus/prefabs" -+PREFABS_DIR = "$(out)/share/ploticus/prefabs" +--- a/src/pl.h ++++ b/src/pl.h +@@ -8,7 +8,7 @@ + #include + #include "plg.h" +-#define PREFABS_DIR "" /* INSTALLERS can set this to a valid pathname, so that users don't need to set PLOTICUS_PREFABS env var */ ++#define PREFABS_DIR "@out@/share/ploticus/prefabs" /* INSTALLERS can set this to a valid pathname, so that users don't need to set PLOTICUS_PREFABS env var */ + + #define PLVERSION "2.42-May2013" /* see also the Copyright page, and page headers and footers */ From b236fe3d52d86143446e215bdf92121ee119a7f1 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Wed, 30 Jun 2021 05:03:07 +0200 Subject: [PATCH 3/3] ploticus: Use gd from Nixpkgs instead of the vendored one The gd version shipped with ploticus only contains a single font that does not support anything but ASCII. In order for the package to be able to render Unicode texts, we need freetype support: http://ploticus.sourceforge.net/doc/fonts.html --- pkgs/tools/graphics/ploticus/default.nix | 9 +++++ .../graphics/ploticus/use-gd-package.patch | 34 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 pkgs/tools/graphics/ploticus/use-gd-package.patch diff --git a/pkgs/tools/graphics/ploticus/default.nix b/pkgs/tools/graphics/ploticus/default.nix index 6b1b50bca02b..50b7aad48a04 100644 --- a/pkgs/tools/graphics/ploticus/default.nix +++ b/pkgs/tools/graphics/ploticus/default.nix @@ -4,6 +4,8 @@ , zlib , libX11 , libpng +, gd +, freetype }: stdenv.mkDerivation rec { @@ -21,12 +23,19 @@ stdenv.mkDerivation rec { # Set the location of the PREFABS directory. ./set-prefabs-dir.patch + + # Use gd from Nixpkgs instead of the vendored one. + # This is required for non-ASCII fonts to work: + # http://ploticus.sourceforge.net/doc/fonts.html + ./use-gd-package.patch ]; buildInputs = [ zlib libX11 libpng + gd + freetype ]; hardeningDisable = [ "format" ]; diff --git a/pkgs/tools/graphics/ploticus/use-gd-package.patch b/pkgs/tools/graphics/ploticus/use-gd-package.patch new file mode 100644 index 000000000000..9a72489ddaad --- /dev/null +++ b/pkgs/tools/graphics/ploticus/use-gd-package.patch @@ -0,0 +1,34 @@ +--- a/src/Makefile ++++ b/src/Makefile +@@ -91,10 +91,10 @@ + + + ########### Option 1: use bundled GD16 (PNG only). Requires libpng and zlib. +-exetarget: plpng +-GD16LIBS = -lpng -lz +-GD16H = -I/usr/local/include +-ZFLAG = -DWZ ++# exetarget: plpng ++# GD16LIBS = -lpng -lz ++# GD16H = -I/usr/local/include ++# ZFLAG = -DWZ + ### These should remain commented unless your libs are not in usual places, then alter to suit... + ### GD16LIBS = /home/scg/lib/libpng.a /home/scg/lib/libz.a + ### GD16H = -I/home/scg/lib +@@ -111,11 +111,11 @@ + + ########### Option 4: use your own GD resource with FreeType2 (ttf) fonts enabled. + ########### Requires GD 1.84+, libpng, zlib, libjpeg and libfreetype +-# exetarget: plgd18 +-# GD18LIBS = -lgd -lpng -lz -ljpeg -lfreetype +-# GD18H = +-# GDFREETYPE = -DGDFREETYPE +-# ZFLAG = -DWZ ++exetarget: plgd18 ++GD18LIBS = -lgd -lpng -lz -ljpeg -lfreetype ++GD18H = ++GDFREETYPE = -DGDFREETYPE ++ZFLAG = -DWZ + + ########### Option 5: don't use GD at all. + # exetarget: plnogd