Subject: substitute* decoding-error
From: nee <[email-masked]>
To: [email-masked]
Date: Sat, 13 Jan 2018 03:25:35 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello, attached is a package definition that fails because substitute*
throws an error. The file I try to substitute* on has some names with
special signs like ë and é that might be related?
I also included a sed workaround which can be uncommented and works
perfectly fine, so the itself file is not too broken to be edited and
this is a bug with substitute*.

The file in question is: src/main.cc from
https://sourceforge.net/projects/eureka-editor/files/Eureka/1.21/eureka-121-source.tar.gz/download

I tested this on the latest guix master. git log says:

commit 7c0926ea7c6f0d0fa291251017704dfb6fb21924 (origin/master,
origin/HEAD, eureka)
Author: Ludovic Courtès <[email-masked]>
Date:   Sat Jan 13 00:57:52 2018 +0100

From c92de18c559dac1be48f05ed39acbcd15120c0b6 Mon Sep 17 00:00:00 2001
From: nee <[email-masked]>
Date: Sat, 13 Jan 2018 02:49:32 +0100
Subject: [PATCH] demonstrate substitute* bug in eureka package

---
 gnu/packages/game-development.scm | 70 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 69 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/game-development.scm b/gnu/packages/game-development.scm
index 363d9a253..1937d0a59 100644
--- a/gnu/packages/game-development.scm
+++ b/gnu/packages/game-development.scm
@@ -45,6 +45,7 @@
   #:use-module (gnu packages curl)
   #:use-module (gnu packages databases)
   #:use-module (gnu packages documentation)
+  #:use-module (gnu packages fltk)
   #:use-module (gnu packages fonts)
   #:use-module (gnu packages fontutils)
   #:use-module (gnu packages freedesktop)
@@ -78,7 +79,9 @@
   #:use-module (gnu packages lua)
   #:use-module (gnu packages mp3)
   #:use-module (gnu packages xml)
-  #:use-module (gnu packages tls))
+  #:use-module (gnu packages tls)
+  ;; TODO remove
+  #:use-module (gnu packages base))
 
 (define-public bullet
   (package
@@ -1150,3 +1153,68 @@ features design tools such as a visual editor, can import 3D models and
 provide high-quality 3D rendering, it contains an animation editor, and can be
 scripted in a Python-like language.")
     (license license:expat)))
+
+(define-public eureka
+  (package
+    (name "eureka")
+    (version "1.21")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "mirror://sourceforge/eureka-editor/Eureka/"
+                                  version "/eureka-"
+                                  ;; version without dots e.g 1.21 => 121
+                                  (string-join (string-split version #\.) "")
+                                  "-source.tar.gz"))
+              (sha256
+               (base32
+                "1a7pf7xi56fcz7jc8layih5gq5m66g2ss4x5j61kzgip07j6rkir"))))
+    (build-system gnu-build-system)
+    (arguments
+     '(#:tests?
+       #f
+       #:make-flags
+       (let ((out (assoc-ref %outputs "out")))
+         (list (string-append "PREFIX=" out)))
+       #:phases
+       (modify-phases
+           %standard-phases
+         (delete 'configure)
+         (add-before
+             'build 'prepare-install-directories
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (mkdir-p (string-append out "/bin"))
+               (mkdir-p (string-append out "/share"))
+
+            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+               ;; FIXME substitute* crashes because of an accent in the name of someone
+               ;; (system* (which "sed")
+               ;;          "-i" (string-append "s|/usr/local|" out "|")
+               ;;          "src/main.cc")
+               (substitute*
+                   "./src/main.cc"
+                 (("/usr/local")
+                  out))
+            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+               (substitute*
+                   "Makefile"
+                 (("-o root")
+                  ""))))))))
+    (inputs `(("mesa" ,mesa)
+              ("libxft" ,libxft)
+              ("libxinerama" ,libxinerama)
+              ("libfontconfig" ,fontconfig)
+              ("libjpeg" ,libjpeg)
+              ("libpng" ,libpng)
+              ("fltk" ,fltk)
+              ("zlib" ,zlib)))
+    (native-inputs `(("pkg-config" ,pkg-config)
+                     ("xdg-utils" ,xdg-utils)
+                     ;; TODO remove when substitute* is fixed
+                     ("sed" ,sed)
+                     ("which" ,which)))
+    (synopsis "gzdoom")
+    (description "gzdoom")
+    (home-page "https://zdoom.org/")
+    (license license:gpl3+)))
-- 
2.15.1