From a2024a55c8ff0a755b9fca06b35b0d337ce2e577 Mon Sep 17 00:00:00 2001 From: Rene Saavedra Date: Tue, 12 Jul 2016 08:02:03 -0500 Subject: [PATCH] gnu: Add fontconfig. * gnu/packages/fontutils.scm (fontconfig): Update to 2.12.0. * gnu/packages/patches/fontconfig-path-max.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. --- gnu/local.mk | 2 + gnu/packages/fontutils.scm | 9 ++- gnu/packages/patches/fontconfig-path-max.patch | 100 +++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 gnu/packages/patches/fontconfig-path-max.patch diff --git a/gnu/local.mk b/gnu/local.mk index 2238506..bdd8e78 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -5,6 +5,7 @@ # Copyright © 2013, 2014, 2015, 2016 Mark H Weaver # Copyright © 2016 Chris Marusich # Copyright © 2016 Kei Yamashita +# Copyright © 2016 Rene Saavedra # # This file is part of GNU Guix. # @@ -478,6 +479,7 @@ dist_patch_DATA = \ gnu/packages/patches/flint-ldconfig.patch \ gnu/packages/patches/fltk-shared-lib-defines.patch \ gnu/packages/patches/fltk-xfont-on-demand.patch \ + gnu/packages/patches/fontconfig-path-max.patch \ gnu/packages/patches/fontforge-svg-modtime.patch \ gnu/packages/patches/freeimage-CVE-2015-0852.patch \ gnu/packages/patches/gawk-fts-test.patch \ diff --git a/gnu/packages/fontutils.scm b/gnu/packages/fontutils.scm index 5f6ff15..c706e3e 100644 --- a/gnu/packages/fontutils.scm +++ b/gnu/packages/fontutils.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2014, 2016 Eric Bavier ;;; Copyright © 2016 Mark H Weaver ;;; Copyright © 2016 Efraim Flashner +;;; Copyright © 2016 Rene Saavedra ;;; ;;; This file is part of GNU Guix. ;;; @@ -225,14 +226,18 @@ fonts to/from the WOFF2 format.") (define-public fontconfig (package (name "fontconfig") - (version "2.11.94") + (version "2.12.0") (source (origin (method url-fetch) (uri (string-append "https://www.freedesktop.org/software/fontconfig/release/fontconfig-" version ".tar.bz2")) (sha256 (base32 - "1psrl4b4gi4wmbvwwh43lk491wsl8lgvqj146prlcha3vwjc0qyp")))) + "0942gl0n9zh3lwha1bfvzq7mh7pzycfys8f2mbcgss0zzzpy8cxl")) + ;; The patch originates from the Debian project, + ;; see https://www.debian.org/ + (patches (search-patches + "fontconfig-path-max.patch")))) (build-system gnu-build-system) (propagated-inputs `(("expat" ,expat) ("freetype" ,freetype))) diff --git a/gnu/packages/patches/fontconfig-path-max.patch b/gnu/packages/patches/fontconfig-path-max.patch new file mode 100644 index 0000000..1ceea12 --- /dev/null +++ b/gnu/packages/patches/fontconfig-path-max.patch @@ -0,0 +1,100 @@ +The patch replaces the use of macro PATH_MAX, in default.c and +fcstat.c files. +--- + src/fcdefault.c | 32 +++++++++++++++++++++++++------- + src/fcstat.c | 28 +++++++++++++++++++++++----- + 2 files changed, 48 insertions(+), 12 deletions(-) + +diff --git a/src/fcdefault.c b/src/fcdefault.c +index 6647a8f..4856777 100644 +--- a/src/fcdefault.c ++++ b/src/fcdefault.c +@@ -150,15 +150,33 @@ retry: + # if defined (HAVE_GETEXECNAME) + const char *p = getexecname (); + # elif defined (HAVE_READLINK) +- char buf[PATH_MAX + 1]; +- int len; ++ int size = 128; + char *p = NULL; + +- len = readlink ("/proc/self/exe", buf, sizeof (buf) - 1); +- if (len != -1) +- { +- buf[len] = '\0'; +- p = buf; ++ while (1) { ++ char *buf = malloc (size); ++ int len; ++ ++ if (buf == NULL) ++ break; ++ ++ len = readlink ("/proc/self/exe", buf, size - 1); ++ ++ if (len < 0) ++ { ++ free(buf); ++ break; ++ } ++ ++ if (len < size - 1) ++ { ++ buf[len] = '\0'; ++ p = buf; ++ break; ++ } ++ ++ free (buf); ++ size *= 2; + } + # else + char *p = NULL; +diff --git a/src/fcstat.c b/src/fcstat.c +index 1734fa4..b2a5ddb 100644 +--- a/src/fcstat.c ++++ b/src/fcstat.c +@@ -278,17 +278,35 @@ FcDirChecksum (const FcChar8 *dir, time_t *checksum) + { + #endif + struct stat statb; +- char f[PATH_MAX + 1]; ++ int size = 128; ++ char *f = malloc (size); + +- memcpy (f, dir, len); +- f[len] = FC_DIR_SEPARATOR; +- memcpy (&f[len + 1], files[n]->d_name, dlen); +- f[len + 1 + dlen] = 0; ++ if (f == NULL) ++ break; ++ ++ if (len < 0) ++ { ++ free(f); ++ break; ++ } ++ ++ if (len < size - 1) ++ { ++ memcpy (f, dir, len); ++ f[len] = FC_DIR_SEPARATOR; ++ memcpy (&f[len + 1], files[n]->d_name, dlen); ++ f[len + 1 + dlen] = 0; ++ } ++ + if (lstat (f, &statb) < 0) + { + ret = -1; + goto bail; + } ++ ++ free (f); ++ size *= 2; ++ + if (S_ISDIR (statb.st_mode)) + goto bail; + +-- +2.6.3 + -- 2.6.3