about summary refs log tree commit diff
path: root/pkgs/by-name/gr
diff options
context:
space:
mode:
authorAnderson Torres <torres.anderson.85@protonmail.com>2024-03-25 17:30:44 -0300
committerGitHub <noreply@github.com>2024-03-25 21:30:44 +0100
commit4535b714c66c01b2e647207a5df12b62c1b6889d (patch)
tree4d241a867f868de8ff953baf952496eb00492da0 /pkgs/by-name/gr
parent5b5f24497fccabe128503c510089b597f4f04949 (diff)
graphicsmagick: 1.3.42 -> 1.3.43 (#298535)
* graphicsmagick: adopt and refactor

- finalAttrs design pattern
- split man output
- rename patches
- update link that explains the patch

* graphicsmagick-imagemagick-compat: rename filename

* graphicsmagick-imagemagick-compat: hide it inside graphicsmagick.passthru

* graphicsmagick-imagemagick-compat: refactor

- use stdenvNoCC (since no compiler is called)
- split man output
- do not expose attributes
- set `dontBuild = true` instead of using a fake `buildPhase`
- install the artifacts via an elegant but questionable, Lispy dark magic

* graphicsmagick: migrate to by-name

* graphicsmagick: 1.3.42 -> 1.3.43

Co-authored-by: R. Ryantm <ryantm-bot@ryantm.com>

* graphicsmagick: remove patch

Since the security breach was solved upstream.

---------

Co-authored-by: R. Ryantm <ryantm-bot@ryantm.com>
Diffstat (limited to 'pkgs/by-name/gr')
-rw-r--r--pkgs/by-name/gr/graphicsmagick/imagemagick-compat.nix48
-rw-r--r--pkgs/by-name/gr/graphicsmagick/package.nix105
2 files changed, 153 insertions, 0 deletions
diff --git a/pkgs/by-name/gr/graphicsmagick/imagemagick-compat.nix b/pkgs/by-name/gr/graphicsmagick/imagemagick-compat.nix
new file mode 100644
index 0000000000000..9e278da037bc8
--- /dev/null
+++ b/pkgs/by-name/gr/graphicsmagick/imagemagick-compat.nix
@@ -0,0 +1,48 @@
+{ lib
+, graphicsmagick
+, stdenvNoCC
+}:
+
+stdenvNoCC.mkDerivation {
+  pname = "graphicsmagick-imagemagick-compat";
+  inherit (graphicsmagick) version;
+
+  outputs = [ "out" "man" ];
+
+  dontUnpack = true;
+  dontBuild = true;
+
+  # TODO: symlink libraries?
+  installPhase = let
+    utilities = [
+      "animate"
+      "composite"
+      "conjure"
+      "convert"
+      "display"
+      "identify"
+      "import"
+      "mogrify"
+      "montage"
+    ];
+    linkUtilityBin = utility: ''
+      ln -s ${lib.getExe graphicsmagick} "$out/bin/${utility}"
+    '';
+    linkUtilityMan = utility: ''
+      ln -s ${lib.getMan graphicsmagick}/share/man/man1/gm.1.gz "$man/share/man/man1/${utility}.1.gz"
+    '';
+  in ''
+    runHook preInstall
+
+    mkdir -p "$out"/bin
+    ${lib.concatStringsSep "\n" (map linkUtilityBin utilities)}
+    mkdir -p "$man"/share/man/man1
+    ${lib.concatStringsSep "\n" (map linkUtilityMan utilities)}
+
+    runHook postInstall
+  '';
+
+  meta = graphicsmagick.meta // {
+    description = "A repack of GraphicsMagick that provides compatibility with ImageMagick interfaces";
+  };
+}
diff --git a/pkgs/by-name/gr/graphicsmagick/package.nix b/pkgs/by-name/gr/graphicsmagick/package.nix
new file mode 100644
index 0000000000000..fb6a9fbd29af0
--- /dev/null
+++ b/pkgs/by-name/gr/graphicsmagick/package.nix
@@ -0,0 +1,105 @@
+{ lib
+, bzip2
+, callPackage
+, coreutils
+, fetchurl
+, fixDarwinDylibNames
+, freetype
+, ghostscript
+, graphviz
+, libX11
+, libjpeg
+, libpng
+, libtiff
+, libtool
+, libwebp
+, libxml2
+, nukeReferences
+, quantumdepth ? 8
+, runCommand
+, stdenv
+, xz
+, zlib
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "graphicsmagick";
+  version = "1.3.43";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/graphicsmagick/GraphicsMagick-${finalAttrs.version}.tar.xz";
+    hash = "sha256-K4hYBzLNfkCdniLGEWI4vvSuBvzaEUUb8z0ln5y/OZ8=";
+  };
+
+  outputs = [ "out" "man" ];
+
+  buildInputs = [
+    bzip2
+    freetype
+    ghostscript
+    graphviz
+    libX11
+    libjpeg
+    libpng
+    libtiff
+    libtool
+    libwebp
+    libxml2
+    zlib
+  ];
+
+  nativeBuildInputs = [
+    nukeReferences
+    xz
+  ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ fixDarwinDylibNames ];
+
+  configureFlags = [
+    # specify delegates explicitly otherwise `gm` will invoke the build
+    # coreutils for filetypes it doesn't natively support.
+    "MVDelegate=${lib.getExe' coreutils "mv"}"
+    (lib.enableFeature true "shared")
+    (lib.withFeature true "frozenpaths")
+    (lib.withFeatureAs true "quantum-depth" (toString quantumdepth))
+    (lib.withFeatureAs true "gslib" "yes")
+  ];
+
+  # Remove CFLAGS from the binaries to avoid closure bloat.
+  # In the past we have had -dev packages in the closure of the binaries soley
+  # due to the string references.
+  postConfigure = ''
+    nuke-refs -e $out ./magick/magick_config.h
+  '';
+
+  postInstall = ''
+    sed -i 's/-ltiff.*'\'/\'/ $out/bin/*
+  '';
+
+  passthru = {
+    imagemagick-compat = callPackage ./imagemagick-compat.nix {
+      graphicsmagick = finalAttrs.finalPackage;
+    };
+    tests = {
+      issue-157920 = runCommand "issue-157920-regression-test" {
+        buildInputs = [ finalAttrs.finalPackage ];
+      } ''
+        gm convert ${graphviz}/share/doc/graphviz/neatoguide.pdf jpg:$out
+      '';
+    };
+  };
+
+  meta = {
+    homepage = "http://www.graphicsmagick.org";
+    description = "Swiss army knife of image processing";
+    longDescription = ''
+      GraphicsMagick is the swiss army knife of image processing, providing a
+      robust and efficient collection of tools and libraries which support
+      reading, writing, and manipulating an image in over 92 major formats
+      including important formats like DPX, GIF, JPEG, JPEG-2000, JXL, PNG, PDF,
+      PNM, TIFF, and WebP.
+    '';
+    license = with lib.licenses; [ mit ];
+    maintainers = with lib.maintainers; [ AndersonTorres ];
+    mainProgram = "gm";
+    platforms = lib.platforms.all;
+  };
+})