unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] gnu: Add fpc.
@ 2017-01-26 22:44 Kei Kebreau
  2017-01-27  4:01 ` [PATCH] gnu: Add fpc. (version 2) Kei Kebreau
  0 siblings, 1 reply; 15+ messages in thread
From: Kei Kebreau @ 2017-01-26 22:44 UTC (permalink / raw)
  To: guix-devel


[-- Attachment #1.1: Type: text/plain, Size: 135 bytes --]

This is a patch that adds a package for the Free Pascal Compiler.
Can someone verify that this builds reproducibly on an i386 machine?

[-- Attachment #1.2: 0001-gnu-Add-fpc.patch --]
[-- Type: text/plain, Size: 13334 bytes --]

From 5352fa71ccba41acf104512bbfeb5311ddd97ab9 Mon Sep 17 00:00:00 2001
From: Kei Kebreau <kei@openmailbox.org>
Date: Thu, 26 Jan 2017 17:36: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                        | 173 +++++++++++++++++++++++++
 gnu/packages/patches/fpc-reproducibility.patch |  39 ++++++
 3 files changed, 215 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 <mthl@gnu.org>
 # Copyright © 2013, 2014, 2015, 2016 Mark H Weaver <mhw@netris.org>
 # Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
-# Copyright © 2016 Kei Kebreau <kei@openmailbox.org>
+# Copyright © 2016, 2017 Kei Kebreau <kei@openmailbox.org>
 # Copyright © 2016 Rene Saavedra <rennes@openmailbox.org>
 # Copyright © 2016 Adonay "adfeno" Felipe Nogueira <https://libreplanet.org/wiki/User:Adfeno> <adfeno@openmailbox.org>
 # Copyright © 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
@@ -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..7b9b6aa5c
--- /dev/null
+++ b/gnu/packages/pascal.scm
@@ -0,0 +1,173 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Kei Kebreau <kei@openmailbox.org>
+;;;
+;;; 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 <http://www.gnu.org/licenses/>.
+
+(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 #: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")))
+                 #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


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH] gnu: Add fpc. (version 2)
  2017-01-26 22:44 [PATCH] gnu: Add fpc Kei Kebreau
@ 2017-01-27  4:01 ` Kei Kebreau
  2017-01-27  4:52   ` Kei Kebreau
  0 siblings, 1 reply; 15+ messages in thread
From: Kei Kebreau @ 2017-01-27  4:01 UTC (permalink / raw)
  To: guix-devel


[-- Attachment #1.1: Type: text/plain, Size: 247 bytes --]

Kei Kebreau <kei@openmailbox.org> writes:

> This is a patch that adds a package for the Free Pascal Compiler.
> Can someone verify that this builds reproducibly on an i386 machine?

This update allows the compiler to find its configuration file.

[-- Attachment #1.2: 0001-gnu-Add-fpc.patch --]
[-- Type: text/plain, Size: 13334 bytes --]

From 10b52891b6fd522231081e5735ce5287060dff21 Mon Sep 17 00:00:00 2001
From: Kei Kebreau <kei@openmailbox.org>
Date: Thu, 26 Jan 2017 22:58:22 -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                        | 173 +++++++++++++++++++++++++
 gnu/packages/patches/fpc-reproducibility.patch |  39 ++++++
 3 files changed, 215 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 <mthl@gnu.org>
 # Copyright © 2013, 2014, 2015, 2016 Mark H Weaver <mhw@netris.org>
 # Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
-# Copyright © 2016 Kei Kebreau <kei@openmailbox.org>
+# Copyright © 2016, 2017 Kei Kebreau <kei@openmailbox.org>
 # Copyright © 2016 Rene Saavedra <rennes@openmailbox.org>
 # Copyright © 2016 Adonay "adfeno" Felipe Nogueira <https://libreplanet.org/wiki/User:Adfeno> <adfeno@openmailbox.org>
 # Copyright © 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
@@ -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..7b9b6aa5c
--- /dev/null
+++ b/gnu/packages/pascal.scm
@@ -0,0 +1,173 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Kei Kebreau <kei@openmailbox.org>
+;;;
+;;; 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 <http://www.gnu.org/licenses/>.
+
+(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 #: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")))
+                 #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


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH] gnu: Add fpc. (version 2)
  2017-01-27  4:01 ` [PATCH] gnu: Add fpc. (version 2) Kei Kebreau
@ 2017-01-27  4:52   ` Kei Kebreau
  2017-01-27  6:00     ` Kei Kebreau
  0 siblings, 1 reply; 15+ messages in thread
From: Kei Kebreau @ 2017-01-27  4:52 UTC (permalink / raw)
  To: guix-devel


[-- Attachment #1.1: Type: text/plain, Size: 418 bytes --]

Kei Kebreau <kei@openmailbox.org> writes:

> Kei Kebreau <kei@openmailbox.org> writes:
>
>> This is a patch that adds a package for the Free Pascal Compiler.
>> Can someone verify that this builds reproducibly on an i386 machine?
>
> This update allows the compiler to find its configuration file.

My apologies, the former upload was missing the crucial changes in the
configure phase. Please use this patch instead.

[-- Attachment #1.2: 0001-gnu-Add-fpc.patch --]
[-- Type: text/plain, Size: 13527 bytes --]

From e5c2e4b67a05f6ddf1b5db917ea6da924cfe0bc6 Mon Sep 17 00:00:00 2001
From: Kei Kebreau <kei@openmailbox.org>
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 <mthl@gnu.org>
 # Copyright © 2013, 2014, 2015, 2016 Mark H Weaver <mhw@netris.org>
 # Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
-# Copyright © 2016 Kei Kebreau <kei@openmailbox.org>
+# Copyright © 2016, 2017 Kei Kebreau <kei@openmailbox.org>
 # Copyright © 2016 Rene Saavedra <rennes@openmailbox.org>
 # Copyright © 2016 Adonay "adfeno" Felipe Nogueira <https://libreplanet.org/wiki/User:Adfeno> <adfeno@openmailbox.org>
 # Copyright © 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
@@ -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 <kei@openmailbox.org>
+;;;
+;;; 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 <http://www.gnu.org/licenses/>.
+
+(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


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH] gnu: Add fpc. (version 2)
  2017-01-27  4:52   ` Kei Kebreau
@ 2017-01-27  6:00     ` Kei Kebreau
  2017-03-12 12:47       ` Danny Milosavljevic
  2017-03-14 21:45       ` Danny Milosavljevic
  0 siblings, 2 replies; 15+ messages in thread
From: Kei Kebreau @ 2017-01-27  6:00 UTC (permalink / raw)
  To: guix-devel


[-- Attachment #1.1: Type: text/plain, Size: 611 bytes --]

Kei Kebreau <kei@openmailbox.org> writes:

> Kei Kebreau <kei@openmailbox.org> writes:
>
>> Kei Kebreau <kei@openmailbox.org> writes:
>>
>>> This is a patch that adds a package for the Free Pascal Compiler.
>>> Can someone verify that this builds reproducibly on an i386 machine?
>>
>> This update allows the compiler to find its configuration file.
>
> My apologies, the former upload was missing the crucial changes in the
> configure phase. Please use this patch instead.

Third time's a charm! Forgot a slash in one of the regex substitutions.
I can confirm that this compiles Pascal programs successfully.

[-- Attachment #1.2: 0001-gnu-Add-fpc.patch --]
[-- Type: text/plain, Size: 13528 bytes --]

From e5f92d59faecf2be251375f01df0a1601f4990d4 Mon Sep 17 00:00:00 2001
From: Kei Kebreau <kei@openmailbox.org>
Date: Fri, 27 Jan 2017 00:18:45 -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 <mthl@gnu.org>
 # Copyright © 2013, 2014, 2015, 2016 Mark H Weaver <mhw@netris.org>
 # Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
-# Copyright © 2016 Kei Kebreau <kei@openmailbox.org>
+# Copyright © 2016, 2017 Kei Kebreau <kei@openmailbox.org>
 # Copyright © 2016 Rene Saavedra <rennes@openmailbox.org>
 # Copyright © 2016 Adonay "adfeno" Felipe Nogueira <https://libreplanet.org/wiki/User:Adfeno> <adfeno@openmailbox.org>
 # Copyright © 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
@@ -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..0e7b9f3ab
--- /dev/null
+++ b/gnu/packages/pascal.scm
@@ -0,0 +1,176 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Kei Kebreau <kei@openmailbox.org>
+;;;
+;;; 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 <http://www.gnu.org/licenses/>.
+
+(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


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH] gnu: Add fpc. (version 2)
  2017-01-27  6:00     ` Kei Kebreau
@ 2017-03-12 12:47       ` Danny Milosavljevic
  2017-03-13 21:22         ` Kei Kebreau
  2017-03-14 21:45       ` Danny Milosavljevic
  1 sibling, 1 reply; 15+ messages in thread
From: Danny Milosavljevic @ 2017-03-12 12:47 UTC (permalink / raw)
  To: Kei Kebreau; +Cc: guix-devel

Hi Kei,

is anything holding this up?

I've tested it and can confirm it works fine.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] gnu: Add fpc. (version 2)
  2017-03-12 12:47       ` Danny Milosavljevic
@ 2017-03-13 21:22         ` Kei Kebreau
  0 siblings, 0 replies; 15+ messages in thread
From: Kei Kebreau @ 2017-03-13 21:22 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 320 bytes --]

Danny Milosavljevic <dannym@scratchpost.org> writes:

> Hi Kei,
>
> is anything holding this up?
>
> I've tested it and can confirm it works fine.

Not that I can remember. I believe it was just waiting for review. If
this counts as a positive review I can see about tidying it up if
necessary and pushing it to master.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] gnu: Add fpc. (version 2)
  2017-01-27  6:00     ` Kei Kebreau
  2017-03-12 12:47       ` Danny Milosavljevic
@ 2017-03-14 21:45       ` Danny Milosavljevic
  2017-03-20 15:02         ` Kei Kebreau
  2017-03-20 19:59         ` Ricardo Wurmus
  1 sibling, 2 replies; 15+ messages in thread
From: Danny Milosavljevic @ 2017-03-14 21:45 UTC (permalink / raw)
  To: Kei Kebreau; +Cc: guix-devel

Hi,

>+                   (copy-file (assoc-ref inputs "fpc-binary")
>+                              "fpc-bin.tar")
>+                   (zero? (system* "tar" "xvf" "fpc-bin.tar")))))

Why the copy-file and then untar ? Can't it be untarred immediately from where it is? If it is useful, maybe add a comment about the reason.

Also, it might be easier to have a fpc-bootstrap package with the bootstrap binaries that installs the binaries required to build fpc normally and to make a fpc package depend on fpc-bootstrap as native-inputs.  What do you think?  I myself don't have a strong preference about it - but some other packages do it that way.

About the fpc-reproducibility.patch , it might make sense to file bugs upstream about it so they add it on their side.

Also, these existing bootstrap compilers on sourceforge do not produce bit reproducible executables, right?  Should they also have the same patch applied upstream in the future ?

Overall LGTM!

fpc supports armhf and usually so do we - although not here.  We can add armhf support in a future patch, though.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] gnu: Add fpc. (version 2)
  2017-03-14 21:45       ` Danny Milosavljevic
@ 2017-03-20 15:02         ` Kei Kebreau
  2017-03-20 19:59         ` Ricardo Wurmus
  1 sibling, 0 replies; 15+ messages in thread
From: Kei Kebreau @ 2017-03-20 15:02 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 2195 bytes --]

Danny Milosavljevic <dannym@scratchpost.org> writes:

> Hi,
>
>>+                   (copy-file (assoc-ref inputs "fpc-binary")
>>+                              "fpc-bin.tar")
>>+                   (zero? (system* "tar" "xvf" "fpc-bin.tar")))))
>
> Why the copy-file and then untar ? Can't it be untarred immediately from where it is? If it is useful, maybe add a comment about the reason.
>

It turns out that this wasn't useful. I can't remember what I wanted to
accomplish by copying the file first, so I've removed the unnecessary call.

> Also, it might be easier to have a fpc-bootstrap package with the
> bootstrap binaries that installs the binaries required to build fpc
> normally and to make a fpc package depend on fpc-bootstrap as
> native-inputs.  What do you think?  I myself don't have a strong
> preference about it - but some other packages do it that way.
>

This is how I have fpc set up to build right now, unless I'm missing
something. I've defined the bootstrap binaries for the i386 and x86_64
architectures, and the FPC package definition builds the source using
the appropriate binaries depending on the architecture of the build
target. 

> About the fpc-reproducibility.patch , it might make sense to file bugs upstream about it so they add it on their side.
>

I'll bring it up to them.

> Also, these existing bootstrap compilers on sourceforge do not produce
> bit reproducible executables, right?  Should they also have the same
> patch applied upstream in the future ?
>

The existing bootstrap compilers can produce bit reproducible
executables when they are provided with a program without
environment-dependent variables (time, hostname, etc.). As an example,
the FPC source itself builds reproducibly using the bootstrap FPC binaries.

> Overall LGTM!
>

Thanks for the review!

> fpc supports armhf and usually so do we - although not here.  We can add armhf support in a future patch, though.

You know, the FPC has released new binaries for its version 3.0.2
release. Now there are bootstrap binaries available for mips,
arm-eabihf and powerpc as well. I can see about adding those and trying
them out.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] gnu: Add fpc. (version 2)
  2017-03-14 21:45       ` Danny Milosavljevic
  2017-03-20 15:02         ` Kei Kebreau
@ 2017-03-20 19:59         ` Ricardo Wurmus
  2017-03-20 22:54           ` Kei Kebreau
  2017-06-05 13:20           ` Danny Milosavljevic
  1 sibling, 2 replies; 15+ messages in thread
From: Ricardo Wurmus @ 2017-03-20 19:59 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: guix-devel


Danny Milosavljevic <dannym@scratchpost.org> writes:

> Hi,
>
>>+                   (copy-file (assoc-ref inputs "fpc-binary")
>>+                              "fpc-bin.tar")
>>+                   (zero? (system* "tar" "xvf" "fpc-bin.tar")))))
>
> Why the copy-file and then untar ? Can't it be untarred immediately from where it is? If it is useful, maybe add a comment about the reason.
>
> Also, it might be easier to have a fpc-bootstrap package with the bootstrap binaries that installs the binaries required to build fpc normally and to make a fpc package depend on fpc-bootstrap as native-inputs.  What do you think?  I myself don't have a strong preference about it - but some other packages do it that way.

It’s not so nice to depend on a binary bootstrap.  Can this be avoided?
I tried packaging a version of the GNU Pascal compiler, which is
unmaintained, in an effort to bootstrap a version of FPC from source.

Have you attempted this?

--
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] gnu: Add fpc. (version 2)
  2017-03-20 19:59         ` Ricardo Wurmus
@ 2017-03-20 22:54           ` Kei Kebreau
  2017-06-05 13:20           ` Danny Milosavljevic
  1 sibling, 0 replies; 15+ messages in thread
From: Kei Kebreau @ 2017-03-20 22:54 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1384 bytes --]

Ricardo Wurmus <rekado@elephly.net> writes:

> Danny Milosavljevic <dannym@scratchpost.org> writes:
>
>> Hi,
>>
>>>+                   (copy-file (assoc-ref inputs "fpc-binary")
>>>+                              "fpc-bin.tar")
>>>+                   (zero? (system* "tar" "xvf" "fpc-bin.tar")))))
>>
>> Why the copy-file and then untar ? Can't it be untarred immediately from where it is? If it is useful, maybe add a comment about the reason.
>>
>> Also, it might be easier to have a fpc-bootstrap package with the
>> bootstrap binaries that installs the binaries required to build fpc
>> normally and to make a fpc package depend on fpc-bootstrap as
>> native-inputs.  What do you think?  I myself don't have a strong
>> preference about it - but some other packages do it that way.
>
> It’s not so nice to depend on a binary bootstrap.  Can this be avoided?
> I tried packaging a version of the GNU Pascal compiler, which is
> unmaintained, in an effort to bootstrap a version of FPC from source.
>
> Have you attempted this?
>

Though I would prefer a source bootstrap, I haven't attempted this. I
anticipate that it would be no small feat getting the GNU Pascal
compiler to work. Were you using a recent version of GCC to try to
bootstrap FPC?

> --
> Ricardo
>
> GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
> https://elephly.net

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] gnu: Add fpc. (version 2)
  2017-03-20 19:59         ` Ricardo Wurmus
  2017-03-20 22:54           ` Kei Kebreau
@ 2017-06-05 13:20           ` Danny Milosavljevic
  2017-06-05 13:33             ` Marius Bakke
  2017-06-05 19:55             ` Ricardo Wurmus
  1 sibling, 2 replies; 15+ messages in thread
From: Danny Milosavljevic @ 2017-06-05 13:20 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel

Hi,

to experiment, I tried this:

(define-module (wip pascal)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix hg-download)
  #:use-module (guix utils)
  #:use-module (guix build-system python)
  #:use-module (guix build-system gnu)
  #:use-module (guix gexp)
  #:use-module (gnu packages)
  #:use-module (gnu packages base)
  #:use-module (gnu packages gcc)
  #:use-module (gnu packages pkg-config))

(define-public gpc
  (let ((base (custom-gccx gcc-4.7 "gpc" '("pascal"))))
    (package
      (inherit base)
      (name "gpc")
      (native-inputs
       `(("tar" ,tar)
; REQUIRED: bash, bzip2, GNU sed, GNU awk, GNU m4, bison (at least version 2.0), flex (version 2.5.27), autoconf (version 2.12), texinfo (at least version 4.2), help2man.
; ENV before configure:
;          FLEX=/path/to/flex
;          LEX=/path/to/flex
;          BISON=/path/to/bison
;          YACC=/path/to/bison
;          INTLBISON=/path/to/bison
         ("gpc"
          ,(origin
             (method url-fetch)
             (uri "http://www.gnu-pascal.de/alpha/gpc-20060325.tar.bz2")
             (sha256
              (base32
               "1vadkpwm0087knb2lx48fk7mkv646ivwm84iy42qjw8z7svdrz8q"))))
          ,@(package-native-inputs base)))
      (arguments
       (substitute-keyword-arguments (package-arguments base)
        ((#:phases phases)
         `(modify-phases ,phases
           (add-after 'unpack 'unpack-submodule-sources
            (lambda* (#:key inputs #:allow-other-keys)
             (let ((unpack (lambda (source target)
                             (with-directory-excursion target
                               (zero? (system* "tar" "xvf"
                                               (assoc-ref inputs source)
                                               "--strip-components=1"))))))
              (unpack "gpc" "gcc")))))))))))

... and this ...

$ git diff gnu/packages/gcc.scm
diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm
index 866f8478f..8370a54c9 100644
--- a/gnu/packages/gcc.scm
+++ b/gnu/packages/gcc.scm
@@ -512,6 +512,8 @@ as the 'native-search-paths' field."
                                      ".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc.*)"))
                #t))))))))
 
+(define-public custom-gccx custom-gcc)
+
 (define %generic-search-paths
   ;; This is the language-neutral search path for GCC.  Entries in $CPATH are
   ;; not considered "system headers", which means GCC can raise warnings for

... but it turns out that gpc patches gcc parts - and the most recent patch is for gcc 4.0.3 - which we don't carry.

The patch contains:
- Turns walk_subtrees off for functions (WTF).
- Adds debugging info for (bit)sets and array bounds with a floating-point expression (WTF).
- Adds support for bitstrings (latter is in gcc/stor-layout.c and used in gcc/expr.c).  (OK)
- ! static GTY(()) unsigned int tmp_var_id_num = 155419; (WTF)

It may be that these kinds of bitstrings are integrated in gcc proper already - I don't know.

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH] gnu: Add fpc. (version 2)
  2017-06-05 13:20           ` Danny Milosavljevic
@ 2017-06-05 13:33             ` Marius Bakke
  2017-06-05 13:42               ` Marius Bakke
  2017-06-05 19:55             ` Ricardo Wurmus
  1 sibling, 1 reply; 15+ messages in thread
From: Marius Bakke @ 2017-06-05 13:33 UTC (permalink / raw)
  To: Danny Milosavljevic, Ricardo Wurmus; +Cc: guix-devel


[-- Attachment #1.1: Type: text/plain, Size: 129 bytes --]

Just to piggy-back on this discussion, I'm attempting to package
"Hedgewars" and needed this patch to get fpc working properly:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-gnu-fpc-Make-sure-it-finds-gcc-and-ld-at-runtime.patch --]
[-- Type: text/x-patch, Size: 2355 bytes --]

From 4f76fb12f031652e11063c0fb37949229caa45cc Mon Sep 17 00:00:00 2001
From: Marius Bakke <mbakke@fastmail.com>
Date: Tue, 25 Apr 2017 15:39:30 +0200
Subject: [PATCH] gnu: fpc: Make sure it finds gcc and ld at runtime.

* gnu/packages/fpc.scm (fpc)[inputs]: Add GCC and LD-WRAPPER.
[arguments]: Add 'wrap' phase.
---
 gnu/packages/pascal.scm | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/pascal.scm b/gnu/packages/pascal.scm
index a343ddcd6..fbb5b1d10 100644
--- a/gnu/packages/pascal.scm
+++ b/gnu/packages/pascal.scm
@@ -24,7 +24,9 @@
   #:use-module (gnu packages)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bootstrap)
+  #:use-module (gnu packages commencement)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages gcc)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages xml))
 
@@ -67,6 +69,8 @@
       (supported-systems '("i686-linux" "x86_64-linux"))
       (inputs
        `(("expat" ,expat)
+         ("glibc" ,glibc/linux)
+         ("ld-wrapper" ,ld-wrapper)
          ("ncurses" ,ncurses)
          ("zlib" ,zlib)))
       (native-inputs
@@ -168,7 +172,19 @@
                     (system*
                      (string-append out "/lib/fpc/" ,version "/samplecfg")
                      (string-append out "/lib/fpc/" ,version)
-                     (string-append out "/etc"))))))))))
+                     (string-append out "/etc"))))))
+             (add-after 'install 'wrap
+               (lambda* (#:key inputs outputs #:allow-other-keys)
+                 (let* ((out (assoc-ref outputs "out"))
+                        (fpc (string-append out "/bin/fpc"))
+                        (ld (assoc-ref inputs "ld-wrapper"))
+                        (glibc (assoc-ref inputs "glibc")))
+                   (wrap-program fpc
+                     `("PATH" ":" prefix (,(string-append ld "/bin")))
+                     `("LIBRARY_PATH" ":" prefix (,(string-append glibc "/lib"))))
+                   #t)))))))
+      ;; fpc invokes gcc, so make sure LIBRARY_PATH et.al are set.
+      ;(native-search-paths (package-native-search-paths gcc))
       (home-page "http://www.freepascal.org")
       (synopsis "The Free Pascal Compiler")
       (description
-- 
2.13.1


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH] gnu: Add fpc. (version 2)
  2017-06-05 13:33             ` Marius Bakke
@ 2017-06-05 13:42               ` Marius Bakke
  2017-06-09  1:30                 ` Kei Kebreau
  0 siblings, 1 reply; 15+ messages in thread
From: Marius Bakke @ 2017-06-05 13:42 UTC (permalink / raw)
  To: Danny Milosavljevic, Ricardo Wurmus; +Cc: guix-devel


[-- Attachment #1.1: Type: text/plain, Size: 281 bytes --]

Marius Bakke <mbakke@fastmail.com> writes:

> Just to piggy-back on this discussion, I'm attempting to package
> "Hedgewars" and needed this patch to get fpc working properly:

Oops, found one more patch in that old branch. @Kei, feel free to squash
this into the original patch:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-gnu-fpc-Patch-bin-sh-reference.patch --]
[-- Type: text/x-patch, Size: 1225 bytes --]

From cb94a2c4c697541183cb912039399df54ece5ec3 Mon Sep 17 00:00:00 2001
From: Marius Bakke <mbakke@fastmail.com>
Date: Mon, 24 Apr 2017 21:37:13 +0200
Subject: [PATCH] gnu: fpc: Patch /bin/sh reference.

* gnu/packages/pascal.scm (fpc)[arguments]<#:phases>: Add new
'patch-inline-shebangs' phase.
---
 gnu/packages/pascal.scm | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gnu/packages/pascal.scm b/gnu/packages/pascal.scm
index 0e7b9f3ab..a343ddcd6 100644
--- a/gnu/packages/pascal.scm
+++ b/gnu/packages/pascal.scm
@@ -106,6 +106,11 @@
                                       fpcmake-tarball))
                       (zero? (system* "tar" "xvf" compiler-tarball "-C.."))
                       (zero? (system* "tar" "xvf" fpcmake-tarball "-C..")))))))
+             (add-after 'patch-source-shebangs 'patch-inline-shebangs
+               (lambda _
+                 (substitute* "fpcsrc/compiler/script.pas"
+                   (("#!/bin/sh") (string-append "#!" (which "sh"))))
+                 #t))
              (replace 'configure
                (lambda* (#:key inputs outputs #:allow-other-keys)
                  (substitute* "fpcsrc/compiler/systems/t_linux.pas"
-- 
2.13.1


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH] gnu: Add fpc. (version 2)
  2017-06-05 13:20           ` Danny Milosavljevic
  2017-06-05 13:33             ` Marius Bakke
@ 2017-06-05 19:55             ` Ricardo Wurmus
  1 sibling, 0 replies; 15+ messages in thread
From: Ricardo Wurmus @ 2017-06-05 19:55 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: guix-devel


Danny Milosavljevic <dannym@scratchpost.org> writes:

> ... but it turns out that gpc patches gcc parts - and the most recent
> patch is for gcc 4.0.3 - which we don't carry.

Actually, the most recent patch is for 4.3, which is why I’ve packaged gcc-4.3:

--8<---------------cut here---------------start------------->8---
commit cd40a5a8cf241dd5a7944f93296d6e8c71c072b0
Author: Ricardo Wurmus <rekado@elephly.net>
Date:   Sat Oct 15 14:55:36 2016 +0200

    WIP gcc-4.3 for gcp for freepascal bootstrap

diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm
index 866f8478f..810f58174 100644
--- a/gnu/packages/gcc.scm
+++ b/gnu/packages/gcc.scm
@@ -342,6 +342,39 @@ Go.  It also includes runtime support libraries for these languages.")
       (license gpl3+)
       (home-page "https://gcc.gnu.org/"))))

+;; The GNU Pascal compiler gpc inherits from this package.
+(define-public gcc-4.3
+  (package (inherit gcc-4.7)
+    (version "4.3.5")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "mirror://gnu/gcc/gcc-"
+                                  version "/gcc-" version ".tar.bz2"))
+              (sha256
+               (base32
+                "0svy81i6yfm1r5jydmylv5djrd9wc3ishsx1rx8ckgcxqd2ygihh"))))
+    (arguments
+     (substitute-keyword-arguments (package-arguments gcc-4.7)
+       ((#:phases phases)
+        `(modify-phases ,phases
+           (add-before 'pre-configure 'modernize
+             (lambda* (#:key inputs outputs #:allow-other-keys)
+               ;; FIXME: this is a hack needed to be able to reuse the build
+               ;; phases of gcc-4.7.
+               (mkdir-p "libstdc++-v3/python/")
+               (zero? (system* "touch" "libstdc++-v3/python/Makefile.in"))
+
+               ;; This is to avoid searching for headers in the libc package's
+               ;; "/usr/include" directory.
+               (let ((libc (assoc-ref %build-inputs "libc")))
+                 (substitute* '("gcc/configure"
+                                "gcc/Makefile.in")
+                   (("/usr/include")
+                    (string-append libc "/include"))))
+               #t))))))
+    ;; Use older texinfo because it's more tolerant
+    (native-inputs `(("texinfo" ,texinfo-4)))))
+
 (define-public gcc-4.8
   (package (inherit gcc-4.7)
     (version "4.8.5")
--8<---------------cut here---------------end--------------->8---

I took the GCC diff from https://github.com/hebisch/gpc.git, which is
the main author’s repository.  I almost got GPC to build, but it fails
some time during stage 2 or so IIRC.  The error did not seem to be a
problem with GPC itself, but with how we do things in Guix.

I don’t have my branch in order right now, but if you’re interested I
could share a bit more of my work.

(I started this only because I also wanted to package Hedgewars.)

--
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH] gnu: Add fpc. (version 2)
  2017-06-05 13:42               ` Marius Bakke
@ 2017-06-09  1:30                 ` Kei Kebreau
  0 siblings, 0 replies; 15+ messages in thread
From: Kei Kebreau @ 2017-06-09  1:30 UTC (permalink / raw)
  To: Marius Bakke; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 353 bytes --]

Marius Bakke <mbakke@fastmail.com> writes:

> Marius Bakke <mbakke@fastmail.com> writes:
>
>> Just to piggy-back on this discussion, I'm attempting to package
>> "Hedgewars" and needed this patch to get fpc working properly:
>
> Oops, found one more patch in that old branch. @Kei, feel free to squash
> this into the original patch:

Patch "squashed"!

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2017-06-09  1:30 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-26 22:44 [PATCH] gnu: Add fpc Kei Kebreau
2017-01-27  4:01 ` [PATCH] gnu: Add fpc. (version 2) Kei Kebreau
2017-01-27  4:52   ` Kei Kebreau
2017-01-27  6:00     ` Kei Kebreau
2017-03-12 12:47       ` Danny Milosavljevic
2017-03-13 21:22         ` Kei Kebreau
2017-03-14 21:45       ` Danny Milosavljevic
2017-03-20 15:02         ` Kei Kebreau
2017-03-20 19:59         ` Ricardo Wurmus
2017-03-20 22:54           ` Kei Kebreau
2017-06-05 13:20           ` Danny Milosavljevic
2017-06-05 13:33             ` Marius Bakke
2017-06-05 13:42               ` Marius Bakke
2017-06-09  1:30                 ` Kei Kebreau
2017-06-05 19:55             ` Ricardo Wurmus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).