'substitute*' fails to patch a binary and returns the following error

[...]

starting phase `pre-configure'
Backtrace:
In ice-9/boot-9.scm:
2320: 19 [save-module-excursion #<procedure 8e81de0 at ice-9/boot-9.scm:3961:3 
()>]
3966: 18 [#<procedure 8e81de0 at ice-9/boot-9.scm:3961:3 ()>]
1645: 17 [%start-stack load-stack ...]
1650: 16 [#<procedure 8e84df8 ()>]
In unknown file:
   ?: 15 [primitive-load 
"/nix/store/rcjkvdqp28dnp7igksnf3lzgwzxqvadb-ghc-bin-7.0.1-guile-builder"]
In ice-9/eval.scm:
 387: 14 [eval # ()]
In srfi/srfi-1.scm:
 830: 13 [every1 #<procedure 9090f10 at 
/nix/store/04z6assixr4ms2fmvm2m42aw1a8k07x5-module-import/guix/build/gnu-build-system.scm:364:9
 (expr)> ...]
In 
/nix/store/04z6assixr4ms2fmvm2m42aw1a8k07x5-module-import/guix/build/gnu-build-system.scm:
 368: 12 [#<procedure 9090f10 at 
/nix/store/04z6assixr4ms2fmvm2m42aw1a8k07x5-module-import/guix/build/gnu-build-system.scm:364:9
 (expr)> #]
In ice-9/eval.scm:
 432: 11 [eval # #]
In srfi/srfi-1.scm:
 616: 10 [for-each #<procedure 9097a98 at ice-9/eval.scm:416:20 (a)> #]
In ice-9/boot-9.scm:
 171: 9 [with-throw-handler #t ...]
 793: 8 [call-with-input-file "inplace/bin/ghc-cabal" ...]
In 
/nix/store/04z6assixr4ms2fmvm2m42aw1a8k07x5-module-import/guix/build/utils.scm:
 336: 7 [#<procedure 908b4e0 at 
/nix/store/04z6assixr4ms2fmvm2m42aw1a8k07x5-module-import/guix/build/utils.scm:335:10
 (in)> #<input: inplace/bin/ghc-cabal 11>]
 361: 6 [#<procedure 9320fc0 at 
/nix/store/04z6assixr4ms2fmvm2m42aw1a8k07x5-module-import/guix/build/utils.scm:357:6
 (in out)> #<input: inplace/bin/ghc-cabal 11> ...]
In srfi/srfi-1.scm:
 465: 5 [fold #<procedure 9026f40 at 
/nix/store/04z6assixr4ms2fmvm2m42aw1a8k07x5-module-import/guix/build/utils.scm:361:32
 (r+p line)> ...]
In 
/nix/store/04z6assixr4ms2fmvm2m42aw1a8k07x5-module-import/guix/build/utils.scm:
 364: 4 [#<procedure 9026f40 at 
/nix/store/04z6assixr4ms2fmvm2m42aw1a8k07x5-module-import/guix/build/utils.scm:361:32
 (r+p line)> # ...]
In ice-9/regex.scm:
 189: 3 [list-matches # ...]
 176: 2 [fold-matches # ...]
In unknown file:
   ?: 1 [regexp-exec # ...]
In ice-9/boot-9.scm:
 106: 0 [#<procedure 908b500 at ice-9/boot-9.scm:97:6 (thrown-k . args)> 
misc-error ...]

ice-9/boot-9.scm:106:20: In procedure #<procedure 908b500 at 
ice-9/boot-9.scm:97:6 (thrown-k . args)>:
ice-9/boot-9.scm:106:20: string contains #\nul character:

[...]

diff --git a/gnu/packages/ghc.scm b/gnu/packages/ghc.scm
new file mode 100644
index 0000000..1a3d308
--- /dev/null
+++ b/gnu/packages/ghc.scm
@@ -0,0 +1,114 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2013 Nikita Karetnikov <nik...@karetnikov.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 ghc)
+  #:use-module ((guix licenses) #:select (bsd-style))
+  #:use-module (guix packages)
+  #:use-module (guix download)
+  #:use-module (guix build-system gnu)
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages bootstrap)
+  #:use-module (gnu packages libffi)
+  #:use-module (gnu packages multiprecision)
+  #:use-module (gnu packages ncurses)
+  #:use-module (gnu packages patchelf)
+  #:use-module (gnu packages perl))
+
+(define-public ghc-7.0.1-bin
+  (package
+    (name "ghc-bin")
+    ;; 7.0.2--7.6.3
+    (version "7.0.1")
+    (source
+     (origin
+      (method url-fetch)
+      ;; XXX: Support other platforms.
+      (uri (string-append "http://www.haskell.org/ghc/dist/";
+                          version "/ghc-" version
+                          "-i386-unknown-linux.tar.bz2"))
+      (sha256
+       (base32
+        "1cc9ih3h804gj53vf1xabg4155m6bz5r468mjsv54kckmabgsmav"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:modules ((guix build gnu-build-system)
+                  (guix build utils)
+                  (srfi srfi-1))
+       #:phases (alist-cons-before
+                 'configure 'pre-configure
+                 (lambda _
+                   (let ((gmp (string-append (assoc-ref %build-inputs "gmp")
+                                             "/lib"))
+                         (linker (string-append
+                                  (assoc-ref %build-inputs "libc")
+                                  ,(glibc-dynamic-linker)))
+                         (libffi (string-append
+                                  (assoc-ref %build-inputs "libffi")
+                                  "/lib"))
+                         (ncurses (string-append
+                                   (assoc-ref %build-inputs "ncurses")
+                                   "/lib"))
+                         (patchelf (which "patchelf"))
+                         (pwd (which "pwd"))
+                         (sh (which "sh")))
+                     (begin (substitute* '("configure"
+                                           "mk/config.mk.in"
+                                           "utils/ghc-pkg/ghc.mk"
+
+                                           ;; Fails with a "string contains
+                                           ;; #\nul character" error.
+                                           "inplace/bin/ghc-cabal"
+
+                                           "inplace/bin/mkdirhier"
+                                           "utils/ghc-pkg/ghc.mk")
+                              (("/bin/sh") sh)
+                              (("/usr/local/bin/bash") sh)
+                              (("utils/ghc-pwd/ghc-pwd") pwd))
+
+                            (every (lambda (file)
+                                     (zero?
+                                      (system* patchelf
+                                               "--set-interpreter" linker
+                                               "--set-rpath"
+                                               (string-append gmp ":" ncurses)
+                                               file)))
+                                   (filter executable-file?
+                                           (find-files "utils" "")))
+
+                            (zero? (system* patchelf
+                                            "--set-interpreter" linker
+                                            "--set-rpath"
+                                            (string-append gmp ":" libffi)
+                                            "inplace/bin/ghc-cabal")))))
+
+                 (alist-delete 'build %standard-phases))
+       #:tests? #f))
+    (inputs
+     `(("gmp" ,gmp-4.3)
+       ("libc" ,glibc)
+       ("libffi" ,libffi-3.0)
+       ("ncurses" ,ncurses)
+       ("patchelf" ,patchelf)
+       ("perl" ,perl)))
+    (home-page "http://www.haskell.org/ghc/";)
+    (synopsis "Haskell compiler and interactive environment")
+    (description
+     "This is a binary distribution of GHC, a compiler and interactive
+environment for the Haskell functional programming language.")
+    (license (bsd-style "file://LICENSE"
+                        "See LICENSE in the distribution."))))
diff --git a/gnu/packages/libffi.scm b/gnu/packages/libffi.scm
index e4a2761..dbc41c3 100644
--- a/gnu/packages/libffi.scm
+++ b/gnu/packages/libffi.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013 Ludovic Courtès <l...@gnu.org>
+;;; Copyright © 2013 Nikita Karetnikov <nik...@karetnikov.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -71,3 +72,16 @@ conversions for values passed between the two languages.")
     ;; See <http://github.com/atgreen/libffi/blob/master/LICENSE>.
     (license expat))))
 
+(define-public libffi-3.0
+  (package (inherit libffi)
+    (name "libffi")
+    (version "3.0.10")
+    (source
+     (origin
+      (method url-fetch)
+      (uri
+       (string-append "ftp://sourceware.org/pub/libffi/";
+                      name "-" version ".tar.gz"))
+      (sha256
+       (base32 "0bs97dgvqrbzc9zv9y2ff5flfvbmfyc68dpnxvm6mdcygq1bj7ph"))))
+    (arguments `(#:phases (alist-delete 'post-install %standard-phases)))))
diff --git a/gnu/packages/multiprecision.scm b/gnu/packages/multiprecision.scm
index 16383d1..f8553c8 100644
--- a/gnu/packages/multiprecision.scm
+++ b/gnu/packages/multiprecision.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013 Ludovic Courtès <l...@gnu.org>
+;;; Copyright © 2013 Nikita Karetnikov <nik...@karetnikov.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -65,9 +66,20 @@ emphasis on speed.
 GMP is faster than any other bignum library.  The advantage for GMP increases
 with the operand sizes for many operations, since GMP uses asymptotically
 faster algorithms.")
-   (license lgpl3+)
+   (license (list gpl3+ lgpl3+))
    (home-page "http://gmplib.org/";)))
 
+(define-public gmp-4.3
+  (package (inherit gmp)
+   (version "4.3.2")
+   (source
+    (origin
+     (method url-fetch)
+     (uri
+      (string-append "mirror://gnu/gmp/gmp-" version ".tar.bz2"))
+     (sha256
+      (base32 "0x8prpqi9amfcmi7r4zrza609ai9529pjaq0h4aw51i867064qck"))))))
+
 (define-public mpfr
   (package
    (name "mpfr")

Attachment: pgpr28Inio4Xz.pgp
Description: PGP signature

Reply via email to