From 038507969699230fdc0b3086ad9cfaad7058f389 Mon Sep 17 00:00:00 2001 From: Volth Date: Sat, 12 Aug 2017 14:22:45 +0000 Subject: [PATCH 1/3] fontforge: 20160404 -> 20170730 + support reproducible builds --- pkgs/tools/misc/fontforge/default.nix | 28 ++++++++++------- ...fontforge-20140813-use-system-uthash.patch | 30 +++++++++++++++++++ .../misc/fontforge/fontforge-fonttools.nix | 14 +++++++-- 3 files changed, 59 insertions(+), 13 deletions(-) create mode 100644 pkgs/tools/misc/fontforge/fontforge-20140813-use-system-uthash.patch diff --git a/pkgs/tools/misc/fontforge/default.nix b/pkgs/tools/misc/fontforge/default.nix index ca636420854..f79bb123b34 100644 --- a/pkgs/tools/misc/fontforge/default.nix +++ b/pkgs/tools/misc/fontforge/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchFromGitHub, fetchpatch, lib +{ stdenv, fetchFromGitHub, fetchpatch, lib, runCommand , autoconf, automake, gnum4, libtool, perl, gnulib, uthash, pkgconfig, gettext , python, freetype, zlib, glib, libungif, libpng, libjpeg, libtiff, libxml2, pango , withSpiro ? false, libspiro @@ -9,22 +9,30 @@ stdenv.mkDerivation rec { name = "fontforge-${version}"; - version = "20160404"; + version = "20170730"; + + # The way $version propagates to $version of .pe-scripts (https://github.com/dejavu-fonts/dejavu-fonts/blob/358190f/scripts/generate.pe#L19) + SOURCE_DATE_EPOCH = lib.fileContents (runCommand "unixtime-of-${version}" {} "date -d ${version} +%s > $out"); src = fetchFromGitHub { owner = "fontforge"; repo = "fontforge"; rev = version; - sha256 = "15nacq84n9gvlzp3slpmfrrbh57kfb6lbdlc46i7aqgci4qv6fg0"; + sha256 = "15k6x97383p8l40jvcivalhwgbbcdg5vciyjz6m9r0lrlnjqkv99"; }; - patches = [(fetchpatch { - name = "use-system-uthash.patch"; - url = "http://pkgs.fedoraproject.org/cgit/fontforge.git/plain/" - + "fontforge-20140813-use-system-uthash.patch?id=8bdf933"; - sha256 = "0n8i62qv2ygfii535rzp09vvjx4qf9zp5qq7qirrbzm1l9gykcjy"; - })]; - patchFlags = "-p0"; + patches = [ + ./fontforge-20140813-use-system-uthash.patch + + (fetchpatch { + url = "https://github.com/fontforge/fontforge/compare/${version}...volth:rb-${version}.patch"; + name = "fontforge-${version}-reproducible-build.patch"; + sha256 = "089w94xnc0ik3rfx9b7q124x9n1nzbyzzcyynl1x31d22byxgl34"; + }) + ]; + + # do not use x87's 80-bit arithmetic, rouding errors result in very different font binaries + NIX_CFLAGS_COMPILE = lib.optionals stdenv.isi686 [ "-msse2" "-mfpmath=sse" ]; buildInputs = [ autoconf automake gnum4 libtool perl pkgconfig gettext uthash diff --git a/pkgs/tools/misc/fontforge/fontforge-20140813-use-system-uthash.patch b/pkgs/tools/misc/fontforge/fontforge-20140813-use-system-uthash.patch new file mode 100644 index 00000000000..27c8274c1d2 --- /dev/null +++ b/pkgs/tools/misc/fontforge/fontforge-20140813-use-system-uthash.patch @@ -0,0 +1,30 @@ +--- a/Makefile.am.old 2014-08-12 10:07:32.000000000 +0530 ++++ b/Makefile.am 2014-09-08 16:23:56.046996941 +0530 +@@ -43,7 +43,6 @@ + AM_CPPFLAGS = + AM_LDFLAGS = + +-BUILT_SOURCES = uthash/src + EXTRA_DIST = + CLEANFILES = + MOSTLYCLEANFILES = +@@ -113,7 +112,6 @@ + Packaging/FontForge-doc.spec \ + Packaging/FontForge.spec \ + Packaging/FontForge.static.spec \ +- uthash/src \ + $(NULL) + + #-------------------------------------------------------------------------- +@@ -129,11 +127,6 @@ + + + #-------------------------------------------------------------------------- +-uthash/src: +- if [ ! -e uthash/src ]; then \ +- if [ -e uthash ] ; then rm -r uthash ; fi ; \ +- git clone https://github.com/troydhanson/uthash ; \ +- fi ; + + # We import a selection of targets from Frank's standard packaging Makefile. + diff --git a/pkgs/tools/misc/fontforge/fontforge-fonttools.nix b/pkgs/tools/misc/fontforge/fontforge-fonttools.nix index 046c1d44920..0f82f4ad638 100644 --- a/pkgs/tools/misc/fontforge/fontforge-fonttools.nix +++ b/pkgs/tools/misc/fontforge/fontforge-fonttools.nix @@ -1,7 +1,15 @@ -{stdenv, fontforge, zlib}: +{stdenv, fetchFromGitHub, zlib}: + stdenv.mkDerivation rec { - name = "fontforge-fonttools-${fontforge.version}"; - src = fontforge.src; + version = "20160404"; + name = "fontforge-fonttools-${version}"; + + src = fetchFromGitHub { + owner = "fontforge"; + repo = "fontforge"; + rev = version; + sha256 = "15nacq84n9gvlzp3slpmfrrbh57kfb6lbdlc46i7aqgci4qv6fg0"; + }; buildInputs = [zlib]; From c4fb72cbb573ddc2ad3c73526cdde7e47440dfd8 Mon Sep 17 00:00:00 2001 From: Volth Date: Sat, 12 Aug 2017 22:53:29 +0000 Subject: [PATCH 2/3] $SOURCE_DATE_EPOCH moved to preConfigure --- pkgs/tools/misc/fontforge/default.nix | 8 ++++---- pkgs/tools/misc/fontforge/fontforge-fonttools.nix | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/tools/misc/fontforge/default.nix b/pkgs/tools/misc/fontforge/default.nix index f79bb123b34..04abaa87611 100644 --- a/pkgs/tools/misc/fontforge/default.nix +++ b/pkgs/tools/misc/fontforge/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchFromGitHub, fetchpatch, lib, runCommand +{ stdenv, fetchFromGitHub, fetchpatch, lib , autoconf, automake, gnum4, libtool, perl, gnulib, uthash, pkgconfig, gettext , python, freetype, zlib, glib, libungif, libpng, libjpeg, libtiff, libxml2, pango , withSpiro ? false, libspiro @@ -11,9 +11,6 @@ stdenv.mkDerivation rec { name = "fontforge-${version}"; version = "20170730"; - # The way $version propagates to $version of .pe-scripts (https://github.com/dejavu-fonts/dejavu-fonts/blob/358190f/scripts/generate.pe#L19) - SOURCE_DATE_EPOCH = lib.fileContents (runCommand "unixtime-of-${version}" {} "date -d ${version} +%s > $out"); - src = fetchFromGitHub { owner = "fontforge"; repo = "fontforge"; @@ -49,6 +46,9 @@ stdenv.mkDerivation rec { # work-around: git isn't really used, but configuration fails without it preConfigure = '' + # The way $version propagates to $version of .pe-scripts (https://github.com/dejavu-fonts/dejavu-fonts/blob/358190f/scripts/generate.pe#L19) + export SOURCE_DATE_EPOCH=$(date -d ${version} +%s) + export GIT="$(type -P true)" cp -r "${gnulib}" ./gnulib chmod +w -R ./gnulib diff --git a/pkgs/tools/misc/fontforge/fontforge-fonttools.nix b/pkgs/tools/misc/fontforge/fontforge-fonttools.nix index 0f82f4ad638..c65d8ed375d 100644 --- a/pkgs/tools/misc/fontforge/fontforge-fonttools.nix +++ b/pkgs/tools/misc/fontforge/fontforge-fonttools.nix @@ -25,7 +25,7 @@ stdenv.mkDerivation rec { meta = with stdenv.lib; { description = ''Small font tools shipped in FontForge contrib''; - license = fontforge.meta.license; + license = licenses.bsd3; maintainers = with maintainers; [ raskin ]; platforms = with platforms; unix; }; From 97db36a70765b43fbbd1e0d31b6c25d8a6c1e700 Mon Sep 17 00:00:00 2001 From: Volth Date: Tue, 15 Aug 2017 18:41:56 +0000 Subject: [PATCH 3/3] use sed instead of patch --- pkgs/tools/misc/fontforge/default.nix | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pkgs/tools/misc/fontforge/default.nix b/pkgs/tools/misc/fontforge/default.nix index 04abaa87611..ee7854c539e 100644 --- a/pkgs/tools/misc/fontforge/default.nix +++ b/pkgs/tools/misc/fontforge/default.nix @@ -18,15 +18,16 @@ stdenv.mkDerivation rec { sha256 = "15k6x97383p8l40jvcivalhwgbbcdg5vciyjz6m9r0lrlnjqkv99"; }; - patches = [ - ./fontforge-20140813-use-system-uthash.patch + patches = [ ./fontforge-20140813-use-system-uthash.patch ]; - (fetchpatch { - url = "https://github.com/fontforge/fontforge/compare/${version}...volth:rb-${version}.patch"; - name = "fontforge-${version}-reproducible-build.patch"; - sha256 = "089w94xnc0ik3rfx9b7q124x9n1nzbyzzcyynl1x31d22byxgl34"; - }) - ]; + # use $SOURCE_DATE_EPOCH instead of non-determenistic timestamps + postPatch = '' + find . -type f -name '*.c' -exec sed -r -i 's#\btime\(&(.+)\)#if (getenv("SOURCE_DATE_EPOCH")) \1=atol(getenv("SOURCE_DATE_EPOCH")); else &#g' {} \; + sed -r -i 's#author\s*!=\s*NULL#& \&\& !getenv("SOURCE_DATE_EPOCH")#g' fontforge/cvexport.c fontforge/dumppfa.c fontforge/print.c fontforge/svg.c fontforge/splineutil2.c + sed -r -i 's#\bb.st_mtime#getenv("SOURCE_DATE_EPOCH") ? atol(getenv("SOURCE_DATE_EPOCH")) : &#g' fontforge/parsepfa.c fontforge/sfd.c fontforge/svg.c + sed -r -i 's#^\s*ttf_fftm_dump#if (!getenv("SOURCE_DATE_EPOCH")) ttf_fftm_dump#g' fontforge/tottf.c + sed -r -i 's#sprintf\(.+ author \);#if (!getenv("SOURCE_DATE_EPOCH")) &#g' fontforgeexe/fontinfo.c + ''; # do not use x87's 80-bit arithmetic, rouding errors result in very different font binaries NIX_CFLAGS_COMPILE = lib.optionals stdenv.isi686 [ "-msse2" "-mfpmath=sse" ];