summary refs log tree commit diff
path: root/pkgs/applications/graphics/dia
diff options
context:
space:
mode:
authorThiago Kenji Okada <thiagokokada@gmail.com>2023-01-07 23:09:31 +0000
committerThiago Kenji Okada <thiagokokada@gmail.com>2023-01-08 00:06:56 +0000
commit467e2a2397f974f116ccfa9295b511a8b5604784 (patch)
treece774c0a3d73ea56166ab1219225e4046c1555ad /pkgs/applications/graphics/dia
parentb29899b83fb9fb96966eb8ee51572857211b58c4 (diff)
downloadnixpkgs-467e2a2397f974f116ccfa9295b511a8b5604784.tar
nixpkgs-467e2a2397f974f116ccfa9295b511a8b5604784.tar.gz
nixpkgs-467e2a2397f974f116ccfa9295b511a8b5604784.tar.bz2
nixpkgs-467e2a2397f974f116ccfa9295b511a8b5604784.tar.lz
nixpkgs-467e2a2397f974f116ccfa9295b511a8b5604784.tar.xz
nixpkgs-467e2a2397f974f116ccfa9295b511a8b5604784.tar.zst
nixpkgs-467e2a2397f974f116ccfa9295b511a8b5604784.zip
dia: 0.97.3.20170622 -> unstable-2022-12-14
Diffstat (limited to 'pkgs/applications/graphics/dia')
-rw-r--r--pkgs/applications/graphics/dia/CVE-2019-19451.patch11
-rw-r--r--pkgs/applications/graphics/dia/default.nix80
-rw-r--r--pkgs/applications/graphics/dia/poppler-22_09-build-fix.patch93
3 files changed, 147 insertions, 37 deletions
diff --git a/pkgs/applications/graphics/dia/CVE-2019-19451.patch b/pkgs/applications/graphics/dia/CVE-2019-19451.patch
deleted file mode 100644
index 28d6598330a..00000000000
--- a/pkgs/applications/graphics/dia/CVE-2019-19451.patch
+++ /dev/null
@@ -1,11 +0,0 @@
-diff -ru a/app/app_procs.c b/app/app_procs.c
---- a/app/app_procs.c	2021-01-30 11:09:52.000000000 -0500
-+++ b/app/app_procs.c	2021-01-30 11:11:05.000000000 -0500
-@@ -785,6 +785,7 @@
- 
- 	if (!filename) {
- 	  g_print (_("Filename conversion failed: %s\n"), filenames[i]);
-+	  ++i;
- 	  continue;
- 	}
- 
diff --git a/pkgs/applications/graphics/dia/default.nix b/pkgs/applications/graphics/dia/default.nix
index d391ca75544..6b75bf11d42 100644
--- a/pkgs/applications/graphics/dia/default.nix
+++ b/pkgs/applications/graphics/dia/default.nix
@@ -1,40 +1,68 @@
-{ lib, stdenv, fetchgit, autoconf, automake, libtool, gtk2, pkg-config, perlPackages,
-libxml2, gettext, python2, libxml2Python, docbook5, docbook_xsl,
-libxslt, intltool, libart_lgpl, withGNOME ? false, libgnomeui,
-gtk-mac-integration-gtk2 }:
+{ lib
+, stdenv
+, fetchFromGitLab
+, appstream-glib
+, cmake
+, dblatex
+, desktop-file-utils
+, graphene
+, gtk2
+, gtk-mac-integration-gtk2
+, intltool
+, libxml2
+, libxslt
+, meson
+, ninja
+, pkg-config
+, poppler
+, python3
+  # Building with docs are failing in unstable-2022-12-14
+, withDocs ? false
+}:
 
 stdenv.mkDerivation {
   pname = "dia";
-  version = "0.97.3.20170622";
+  version = "unstable-2022-12-14";
 
-  src = fetchgit {
-    url = "https://gitlab.gnome.org/GNOME/dia.git";
-    rev = "b86085dfe2b048a2d37d587adf8ceba6fb8bc43c";
-    sha256 = "1fyxfrzdcs6blxhkw3bcgkksaf3byrsj4cbyrqgb4869k3ynap96";
+  src = fetchFromGitLab {
+    owner = "GNOME";
+    repo = "dia";
+    domain = "gitlab.gnome.org";
+    rev = "4a619ec7cc93be5ddfbcc48d9e1572d04943bcad";
+    hash = "sha256-xi45Ak4rlDQjs/FNkdkm145mx76GNHjE6Nrs1dc94ww=";
   };
 
-  patches = [
-    ./CVE-2019-19451.patch
-  ];
-
-  buildInputs =
-    [ gtk2 libxml2 gettext python2 libxml2Python docbook5
-      libxslt docbook_xsl libart_lgpl ]
-      ++ lib.optional withGNOME libgnomeui
-      ++ lib.optional stdenv.isDarwin gtk-mac-integration-gtk2;
-
-  nativeBuildInputs = [ autoconf automake libtool pkg-config intltool ]
-    ++ (with perlPackages; [ perl XMLParser ]);
+  patches = [ ./poppler-22_09-build-fix.patch ];
 
   preConfigure = ''
-    NOCONFIGURE=1 ./autogen.sh # autoreconfHook is not enough
+    patchShebangs .
   '';
-  configureFlags = lib.optional withGNOME "--enable-gnome";
 
-  # error: implicitly declaring library function 'finite' with type 'int (double)'
-  NIX_CFLAGS_COMPILE = lib.optionalString (stdenv.isDarwin && stdenv.isAarch64) "-Dfinite=isfinite";
+  buildInputs = [
+    graphene
+    gtk2
+    libxml2
+    python3
+    poppler
+  ] ++
+  lib.optionals withDocs [
+    libxslt
+  ] ++
+  lib.optionals stdenv.isDarwin [
+    gtk-mac-integration-gtk2
+  ];
 
-  hardeningDisable = [ "format" ];
+  nativeBuildInputs = [
+    appstream-glib
+    desktop-file-utils
+    intltool
+    meson
+    ninja
+    pkg-config
+  ] ++
+  lib.optionals withDocs [
+    dblatex
+  ];
 
   meta = with lib; {
     description = "Gnome Diagram drawing software";
diff --git a/pkgs/applications/graphics/dia/poppler-22_09-build-fix.patch b/pkgs/applications/graphics/dia/poppler-22_09-build-fix.patch
new file mode 100644
index 00000000000..c461d8a6429
--- /dev/null
+++ b/pkgs/applications/graphics/dia/poppler-22_09-build-fix.patch
@@ -0,0 +1,93 @@
+diff --git a/plug-ins/pdf/pdf-import.cpp b/plug-ins/pdf/pdf-import.cpp
+index 189737908..a2a479693 100644
+--- a/plug-ins/pdf/pdf-import.cpp
++++ b/plug-ins/pdf/pdf-import.cpp
+@@ -152,12 +152,12 @@ public :
+   void
+   updateLineDash (GfxState *state)
+   {
+-    double *dashPattern;
+-    int dashLength;
+-    double dashStart;
+-
+-    state->getLineDash (&dashPattern, &dashLength, &dashStart);
+-    this->dash_length = dashLength ? dashPattern[0] * scale : 1.0;
++    const double *dashPattern=NULL;
++    int dashLength=0;
++    double dashStart=0;
++    const std::vector<double> &dash = state->getLineDash(&dashStart);  // > Poppler 22.09 ...
++    dashPattern = dash.data();
++    dashLength = dash.size();
+ 
+     if (dashLength == 0)
+       this->line_style = DIA_LINE_STYLE_SOLID;
+@@ -318,10 +318,11 @@ public :
+     //FIXME: Dia is really unhappy about zero size fonts
+     if (!(state->getFontSize() > 0.0))
+       return;
+-    GfxFont *f = state->getFont();
++    const std::shared_ptr<GfxFont> f = state->getFont();  // poppler 22.05 ... header changed
++    gconstpointer f1 = &f;  // GLib typedef const void * gconstpointer;
+ 
+     // instead of building the same font over and over again
+-    if (g_hash_table_lookup (this->font_map, f)) {
++    if (g_hash_table_lookup (this->font_map, f1)) {
+       ++font_map_hits;
+       return;
+     }
+@@ -333,8 +334,9 @@ public :
+     gchar *family = g_strdup (f->getFamily() ? f->getFamily()->c_str() : "sans");
+ 
+     // we are (not anymore) building the same font over and over again
++    f1  = &f;
+     g_print ("Font 0x%x: '%s' size=%g (* %g)\n",
+-	     GPOINTER_TO_INT (f), family, state->getTransformedFontSize(), scale);
++	     GPOINTER_TO_INT (f1), family, state->getTransformedFontSize(), scale);
+ 
+     // now try to make a fontname Dia/Pango can cope with
+     // strip style postfix - we already have extracted the style bits above
+@@ -354,7 +356,9 @@ public :
+       fsize *= fabs(fm[3] / fm[0]);
+     font = dia_font_new (family, style, fsize * scale / 0.8);
+ 
+-    g_hash_table_insert (this->font_map, f, font);
++    f1 = &f;
++    gpointer f2 = (gpointer)f1;  // GLib typedef void* gpointer;
++    g_hash_table_insert (this->font_map, f2, font);
+     g_free (family);
+   }
+   void updateTextShift(GfxState *state, double shift)
+@@ -721,11 +725,12 @@ DiaOutputDev::drawString(GfxState *state, GooString *s)
+     return;
+   if (!(state->getFontSize() > 0.0))
+     return;
+-  font = (DiaFont *)g_hash_table_lookup (this->font_map, state->getFont());
++  gconstpointer f_1 = &state->getFont();
++  font = (DiaFont *)g_hash_table_lookup (this->font_map, f_1);
+ 
+   // we have to decode the string data first
+   {
+-    GfxFont *f = state->getFont();
++    const std::shared_ptr<GfxFont> f = state->getFont();
+     const char *p = s->c_str();
+     CharCode code;
+     int   j = 0, m, n;
+@@ -870,8 +875,8 @@ import_pdf(const gchar *filename, DiagramData *dia, DiaContext *ctx, void* user_
+   std::unique_ptr<PDFDoc> doc;
+   GooString *fileName = new GooString(filename);
+   // no passwords yet
+-  GooString *ownerPW = NULL;
+-  GooString *userPW = NULL;
++  const std::optional<GooString> ownerPW;
++  const std::optional<GooString> userPW;
+   gboolean ret = FALSE;
+ 
+   // without this we will get strange crashes (at least with /O2 build)
+@@ -899,6 +904,7 @@ import_pdf(const gchar *filename, DiagramData *dia, DiaContext *ctx, void* user_
+     delete diaOut;
+     ret = TRUE;
+   }
++  doc.reset();
+   delete fileName;
+ 
+   return ret;