From e5c2e4b67a05f6ddf1b5db917ea6da924cfe0bc6 Mon Sep 17 00:00:00 2001 From: Kei Kebreau Date: Thu, 26 Jan 2017 23:49:06 -0500 Subject: [PATCH] gnu: Add fpc. * gnu/packages/pascal.scm: New file. * gnu/packages/patches/fpc-reproducibility.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add pascal.scm. (dist_patch_DATA): Register patch. --- gnu/local.mk | 4 +- gnu/packages/pascal.scm | 176 +++++++++++++++++++++++++ gnu/packages/patches/fpc-reproducibility.patch | 39 ++++++ 3 files changed, 218 insertions(+), 1 deletion(-) create mode 100644 gnu/packages/pascal.scm create mode 100644 gnu/packages/patches/fpc-reproducibility.patch diff --git a/gnu/local.mk b/gnu/local.mk index 59fc1a82c..fb24f32fb 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -4,7 +4,7 @@ # Copyright © 2016 Mathieu Lirzin # Copyright © 2013, 2014, 2015, 2016 Mark H Weaver # Copyright © 2016 Chris Marusich -# Copyright © 2016 Kei Kebreau +# Copyright © 2016, 2017 Kei Kebreau # Copyright © 2016 Rene Saavedra # Copyright © 2016 Adonay "adfeno" Felipe Nogueira # Copyright © 2016, 2017 Ricardo Wurmus @@ -290,6 +290,7 @@ GNU_SYSTEM_MODULES = \ %D%/packages/ots.scm \ %D%/packages/package-management.scm \ %D%/packages/parallel.scm \ + %D%/packages/pascal.scm \ %D%/packages/password-utils.scm \ %D%/packages/patchutils.scm \ %D%/packages/pciutils.scm \ @@ -554,6 +555,7 @@ dist_patch_DATA = \ %D%/packages/patches/fltk-shared-lib-defines.patch \ %D%/packages/patches/fltk-xfont-on-demand.patch \ %D%/packages/patches/fontforge-svg-modtime.patch \ + %D%/packages/patches/fpc-reproducibility.patch \ %D%/packages/patches/freeimage-CVE-2015-0852.patch \ %D%/packages/patches/freeimage-CVE-2016-5684.patch \ %D%/packages/patches/gawk-shell.patch \ diff --git a/gnu/packages/pascal.scm b/gnu/packages/pascal.scm new file mode 100644 index 000000000..92e06f1e9 --- /dev/null +++ b/gnu/packages/pascal.scm @@ -0,0 +1,176 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2017 Kei Kebreau +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu packages pascal) + #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix packages) + #:use-module (guix download) + #:use-module (guix build-system gnu) + #:use-module (gnu packages) + #:use-module (gnu packages base) + #:use-module (gnu packages bootstrap) + #:use-module (gnu packages compression) + #:use-module (gnu packages ncurses) + #:use-module (gnu packages xml)) + +(define fpc-bootstrap-x86_64-3.0.0 + (origin + (method url-fetch) + (uri + "mirror://sourceforge/freepascal/Linux/3.0.0/fpc-3.0.0.x86_64-linux.tar") + (sha256 + (base32 + "1m2xx3nda45cb3zidbjgdr8kddd19zk0khvp7xxdlclszkqscln9")))) + +(define fpc-bootstrap-i386-3.0.0 + (origin + (method url-fetch) + (uri + "mirror://sourceforge/freepascal/Linux/3.0.0/fpc-3.0.0.i386-linux.tar") + (sha256 + (base32 + "0h3f1dgs1zsx7vvk9kg67anjvgw5sslfbmjblif7ishbcp3k3g5k")))) + +(define-public fpc + (let ((arch (if (string-prefix? "x86_64" (or (%current-target-system) + (%current-system))) + "x86_64" + "i386"))) + (package + (name "fpc") + (version "3.0.0") + (source (origin + (method url-fetch) + (uri (string-append "mirror://sourceforge/freepascal/Source/" + version "/fpcbuild-" version ".tar.gz")) + (file-name (string-append name "-" version ".tar.gz")) + (sha256 + (base32 + "1v40bjp0kvsi8y0mndqvvhnsqjfssl2w6wpfww51j4rxblfkp4fm")) + (patches (search-patches "fpc-reproducibility.patch")))) + (build-system gnu-build-system) + (supported-systems '("i686-linux" "x86_64-linux")) + (inputs + `(("expat" ,expat) + ("ncurses" ,ncurses) + ("zlib" ,zlib))) + (native-inputs + ;; FPC is built with FPC, so we need bootstrap binaries. + `(("fpc-binary" + ,(if (string= arch "x86_64") + fpc-bootstrap-x86_64-3.0.0 + fpc-bootstrap-i386-3.0.0)))) + (arguments + `(#:tests? #f ; no tests available + #:phases + (let ((fpc-bootstrap-path + (string-append (getcwd) "/" ,name "-" ,version "/fpc-bin"))) + (modify-phases %standard-phases + (add-after 'unpack 'unpack-bin + (lambda* (#:key inputs #:allow-other-keys) + (mkdir-p fpc-bootstrap-path) + (with-directory-excursion fpc-bootstrap-path + (copy-file (assoc-ref inputs "fpc-binary") + "fpc-bin.tar") + (zero? (system* "tar" "xvf" "fpc-bin.tar"))))) + (add-after 'unpack-bin 'install-bin + (lambda* (#:key inputs #:allow-other-keys) + (with-directory-excursion + (string-append fpc-bootstrap-path "/fpc-" ,version "." + ,arch "-linux") + (let ((binary-tarball + (string-append "binary." ,arch "-linux.tar")) + (compiler-tarball + (string-append "base." ,arch "-linux.tar.gz")) + (fpcmake-tarball + (string-append "utils-fpcm." ,arch "-linux.tar.gz"))) + (and + ;; Only the base compiler and fpcmake are needed. + (zero? (system* "tar" "xvf" binary-tarball + compiler-tarball + fpcmake-tarball)) + (zero? (system* "tar" "xvf" compiler-tarball "-C..")) + (zero? (system* "tar" "xvf" fpcmake-tarball "-C.."))))))) + (replace 'configure + (lambda* (#:key inputs outputs #:allow-other-keys) + (substitute* "fpcsrc/compiler/systems/t_linux.pas" + ;; Point to the current glibc dynamic linker. + (("/lib/ld-linux.so.2") + (string-append (assoc-ref inputs "libc") + ,(glibc-dynamic-linker))) + (("/lib64/ld-linux-x86-64.so.2") + (string-append (assoc-ref inputs "libc") + ,(glibc-dynamic-linker))) + ;; Add glibc to ld's search path. + (("if \\(isdll\\) then") + (string-append + "Add('SEARCH_DIR(\"" + (assoc-ref inputs "libc") "/lib" + "\")');\n" + "if (isdll) then"))) + (substitute* "fpcsrc/compiler/options.pas" + (("exepath\\+'../etc'") + (string-append "'" (assoc-ref outputs "out") "/etc'"))) + #t)) + (replace 'build + (lambda* (#:key inputs #:allow-other-keys) + (let* ((fpc-bin (string-append fpc-bootstrap-path "/bin")) + (fpc (string-append fpc-bin "/fpc")) + (fpcmake (string-append fpc-bin "/fpcmake"))) + ;; The fpc binary needs to run the ppc[arch] binary (which + ;; does the actual compiling) in this directory. + (setenv "PATH" + (string-append (getenv "PATH") ":" + fpc-bootstrap-path + "/lib/fpc/" ,version)) + (setenv "FPC" fpc) + (and + ;; Specify target operating system using "-T" option + (zero? (system* fpcmake + (string-append "-T" ,arch "-linux"))) + (zero? (system* "make" "build" "NOGDB=1")))))) + (replace 'install + (lambda* (#:key outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + ;; This is the suffix of the ppc[arch] binary. + (suffix (if (string= ,arch "x86_64") + "x64" + "386")) + (ppc (string-append "ppc" suffix))) + (system* "make" "install" "NOGDB=1" + (string-append "INSTALL_PREFIX=" out)) + ;; Add a symlink to the ppc[arch] binary so fpc works. + (symlink (string-append out "/lib/fpc/" ,version "/" ppc) + (string-append out "/bin/" ppc)) + ;; Install the example configuration file. + (mkdir (string-append out "/etc")) + (zero? + (system* + (string-append out "/lib/fpc/" ,version "/samplecfg") + (string-append out "/lib/fpc/" ,version) + (string-append out "/etc")))))))))) + (home-page "http://www.freepascal.org") + (synopsis "The Free Pascal Compiler") + (description + "Free Pascal is a professional Object Pascal compiler. It supports the +Turbo Pascal 7.0, Delphi, and Mac Pascal dialects. Free Pascal also supports +many useful extensions to the Pascal programming language.") + ;; The majority of the software included is licensed under the GPLv2 + ;; or later. For more licensing details, see the appropriate files in + ;; the install/doc directory of the source distribution. + (license license:gpl2+)))) diff --git a/gnu/packages/patches/fpc-reproducibility.patch b/gnu/packages/patches/fpc-reproducibility.patch new file mode 100644 index 000000000..133c1d7e8 --- /dev/null +++ b/gnu/packages/patches/fpc-reproducibility.patch @@ -0,0 +1,39 @@ +Remove/patch metadata timestamps for reproducibility. + +diff -ur fpcbuild-3.0.0.old/fpcsrc/packages/fpmkunit/src/fpmkunit.pp fpcbuild-3.0.0/fpcsrc/packages/fpmkunit/src/fpmkunit.pp +--- fpcbuild-3.0.0.old/fpcsrc/packages/fpmkunit/src/fpmkunit.pp 2015-11-04 16:17:00.000000000 -0500 ++++ fpcbuild-3.0.0/fpcsrc/packages/fpmkunit/src/fpmkunit.pp 2017-01-26 16:25:29.327339282 -0500 +@@ -3779,7 +3779,7 @@ + Values[KeyName]:=Name; + Values[KeyVersion]:=Version; + // TODO Generate checksum based on PPUs +- InstalledChecksum:=DateTimeToFileDate(Now); ++ InstalledChecksum:=0; + Values[KeyChecksum]:=IntToStr(InstalledChecksum); + Values[KeyCPU]:=CPUToString(ACPU); + Values[KeyOS]:=OSToString(AOS); +diff -ur fpcbuild-3.0.0.old/fpcsrc/utils/fpcmkcfg/fpcmkcfg.pp fpcbuild-3.0.0/fpcsrc/utils/fpcmkcfg/fpcmkcfg.pp +--- fpcbuild-3.0.0.old/fpcsrc/utils/fpcmkcfg/fpcmkcfg.pp 2013-06-01 18:27:16.000000000 -0400 ++++ fpcbuild-3.0.0/fpcsrc/utils/fpcmkcfg/fpcmkcfg.pp 2017-01-26 16:24:22.949044903 -0500 +@@ -234,8 +234,8 @@ + TemplateParser.Values['FPCTARGETOS'] := BuildOSTarget; + TemplateParser.Values['FPCBIN'] := 'fpc'; + TemplateParser.Values['PWD'] := GetCurrentDir; +- TemplateParser.Values['BUILDDATE'] := DateToStr(Date); +- TemplateParser.Values['BUILDTIME'] := TimeToStr(Time); ++ TemplateParser.Values['BUILDDATE'] := ''; ++ TemplateParser.Values['BUILDTIME'] := ''; + + TemplateParser.Values['LOCALREPOSITORY'] := GetDefaultLocalRepository; + TemplateParser.Values['LOCALBASEPATH'] := GetDefaultLocalBasepath; +diff -ur fpcbuild-3.0.0.old/install/man/Makefile fpcbuild-3.0.0/install/man/Makefile +--- fpcbuild-3.0.0.old/install/man/Makefile 2011-06-19 14:40:37.000000000 -0400 ++++ fpcbuild-3.0.0/install/man/Makefile 2017-01-26 16:25:55.024227566 -0500 +@@ -31,5 +31,5 @@ + $(GINSTALL) -d -m 755 $(INSTALL_MANDIR)/man5 + $(GINSTALL) -c -m 644 man1/*.1 $(INSTALL_MANDIR)/man1 + $(GINSTALL) -c -m 644 man5/*.5 $(INSTALL_MANDIR)/man5 +- find man1/*.1 -exec gzip -9f $(INSTALL_MANDIR)/'{}' \; +- find man5/*.5 -exec gzip -9f $(INSTALL_MANDIR)/'{}' \; ++ find man1/*.1 -exec gzip -9fn $(INSTALL_MANDIR)/'{}' \; ++ find man5/*.5 -exec gzip -9fn $(INSTALL_MANDIR)/'{}' \; -- 2.11.0