unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#38687] [PATCH] gnu: Add libtcod.
@ 2019-12-20 12:37 Giacomo Leidi
  2019-12-23 18:37 ` Ludovic Courtès
  2020-02-06 20:17 ` [bug#38687] [PATCH 1/2] gnu: Add lodepng Giacomo Leidi
  0 siblings, 2 replies; 12+ messages in thread
From: Giacomo Leidi @ 2019-12-20 12:37 UTC (permalink / raw)
  To: 38687; +Cc: Giacomo Leidi

* gnu/packages/game-development.scm (libtcod): New variable.
---
 gnu/packages/game-development.scm | 39 +++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/gnu/packages/game-development.scm b/gnu/packages/game-development.scm
index febe15fa57..b5c4ff9ca7 100644
--- a/gnu/packages/game-development.scm
+++ b/gnu/packages/game-development.scm
@@ -17,6 +17,7 @@
 ;;; Copyright © 2019 Pierre Neidhardt <mail@ambrevar.xyz>
 ;;; Copyright © 2019 Leo Prikler <leo.prikler@student.tugraz.at>
 ;;; Copyright © 2019 Jethro Cao <jethrocao@gmail.com>
+;;; Copyright © 2019 Giacomo Leidi <goodoldpaul@autistici.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1904,3 +1905,41 @@ projects.")
 hardware from multiple vendors without requiring that applications have
 specific knowledge of the hardware they are targeting.")
     (license license:bsd-3)))
+
+(define-public libtcod
+  (package
+    (name "libtcod")
+    (version "1.15.1")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/libtcod/libtcod.git")
+                    (commit version)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0pzr8ajmbqvh43ldjajx962xirj3rf8ayh344p6mqlrmb8gxrfr5"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'change-to-build-dir
+           (lambda _
+             (chdir "buildsys/autotools")
+             (patch-shebang "get_version.py")
+             #t)))))
+    (native-inputs
+     `(("autoconf" ,autoconf)
+       ("automake" ,automake)
+       ("libtool" ,libtool)
+       ("python" ,python)
+       ("pkg-config" ,pkg-config)
+       ("sdl2" ,sdl2)
+       ("zlib" ,zlib)))
+    (home-page "https://github.com/libtcod/libtcod")
+    (synopsis "Library specifically designed for writing roguelikes")
+    (description
+     "libtcod is a free, fast, portable and uncomplicated API for roguelike
+developers providing an advanced true color console, input, and lots of other
+utilities frequently used in roguelikes.")
+    (license license:bsd-3)))
-- 
2.24.1

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

* [bug#38687] [PATCH] gnu: Add libtcod.
  2019-12-20 12:37 [bug#38687] [PATCH] gnu: Add libtcod Giacomo Leidi
@ 2019-12-23 18:37 ` Ludovic Courtès
  2020-01-22 11:11   ` goodoldpaul
  2020-02-06 20:17 ` [bug#38687] [PATCH 1/2] gnu: Add lodepng Giacomo Leidi
  1 sibling, 1 reply; 12+ messages in thread
From: Ludovic Courtès @ 2019-12-23 18:37 UTC (permalink / raw)
  To: Giacomo Leidi; +Cc: 38687

Hi,

Giacomo Leidi <goodoldpaul@autistici.org> skribis:

> * gnu/packages/game-development.scm (libtcod): New variable.

Could you (1) add a ‘snippet’ that removes zlib and utf8proc from
src/vendor (assuming it doesn’t break the build system…), and (2) add
utf8proc as an input?

That way we’d make sure we don’t end up using bundled copies of these
packages.

Apart from that it LGTM, thanks!

Ludo’.

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

* [bug#38687] [PATCH] gnu: Add libtcod.
  2019-12-23 18:37 ` Ludovic Courtès
@ 2020-01-22 11:11   ` goodoldpaul
  2020-01-22 18:57     ` Marius Bakke
  0 siblings, 1 reply; 12+ messages in thread
From: goodoldpaul @ 2020-01-22 11:11 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 38687

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

On 2019-12-23 18:37, Ludovic Courtès wrote:
> Hi,
> 
> Giacomo Leidi <goodoldpaul@autistici.org> skribis:
> 
>> * gnu/packages/game-development.scm (libtcod): New variable.
> 
> Could you (1) add a ‘snippet’ that removes zlib and utf8proc from
> src/vendor (assuming it doesn’t break the build system…), and (2) add
> utf8proc as an input?
> 
> That way we’d make sure we don’t end up using bundled copies of these
> packages
> 
> Apart from that it LGTM, thanks!
> 
> Ludo’.

Hi Ludo',
Sorry for the delay. I checked and it seems that a lot of vendor library 
paths are hardcoded in the C headers.

I made a new patch with a snippet that deletes zlib sources, but I'm 
unsure about how to approach the hardcoded paths.

grepping for 'vendor' inside the source returns


src/libtcod/sys_sdl_img_png.cpp
41:#include "../vendor/lodepng.h"

src/libtcod/console/printing.cpp
54:#include "../../vendor/utf8proc/utf8proc.h"

src/libtcod/sdl2/gl2_ext_.h
36:#include "../../vendor/glad.h"

src/libtcod/color/canvas.cpp
39:#include "../../vendor/lodepng.h"

src/libtcod/tileset/truetype.cpp
43:#include "../../vendor/stb_truetype.h"

src/libtcod/tileset/tilesheet.cpp
34:#include "../../vendor/lodepng.h"


As far as I understood (I'm no C wizard) lodepng, glad and stb are 
libraries which are designed to be dropped inside a source tree and 
statically built in binaries. Right now I think those are secondary 
problems and the main deal is how to effectively replace the included 
utf8proc.

I'm not sure if replacing every "#include ../../vendor/something.h" with 
"#include <something.h>" ( by including a .patch file or with 
substitute* ? Food for thought :D) and then placing something.h inside a 
path known by the C linker is enough but it's the  I'm not really sure 
where to go from here.

Any advice is very welcome, thanks.

Giacomo

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-Add-libtcod.patch --]
[-- Type: text/x-diff; name=0001-gnu-Add-libtcod.patch, Size: 2959 bytes --]

From 01877f5f7a7beed2d52729c4ca5577cccc495a88 Mon Sep 17 00:00:00 2001
From: Giacomo Leidi <goodoldpaul@autistici.org>
Date: Sun, 19 Jan 2020 16:59:57 +0100
Subject: [PATCH] gnu: Add libtcod.

* gnu/packages/game-development.scm (libtcod): New variable.
---
 gnu/packages/game-development.scm | 45 +++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/gnu/packages/game-development.scm b/gnu/packages/game-development.scm
index ee8dea23b5..f03321281e 100644
--- a/gnu/packages/game-development.scm
+++ b/gnu/packages/game-development.scm
@@ -18,6 +18,7 @@
 ;;; Copyright © 2019, 2020 Leo Prikler <leo.prikler@student.tugraz.at>
 ;;; Copyright © 2019 Jethro Cao <jethrocao@gmail.com>
 ;;; Copyright © 2020 Nicolas Goaziou <mail@nicolasgoaziou.fr>
+;;; Copyright © 2020 Giacomo Leidi <goodoldpaul@autistici.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -86,6 +87,7 @@
   #:use-module (gnu packages sphinx)
   #:use-module (gnu packages stb)
   #:use-module (gnu packages texinfo)
+  #:use-module (gnu packages textutils)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages video)
   #:use-module (gnu packages xdisorg)
@@ -2049,3 +2051,46 @@ computer games, 3D authoring tools and simulation tools.")
     (description "Chipmunk is a simple, lightweight, fast and portable 2D
 rigid body physics library written in C.")
     (license license:expat)))
+
+(define-public libtcod
+  (package
+    (name "libtcod")
+    (version "1.15.1")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/libtcod/libtcod.git")
+                    (commit version)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0pzr8ajmbqvh43ldjajx962xirj3rf8ayh344p6mqlrmb8gxrfr5"))
+              (modules '((guix build utils)))
+              (snippet '(begin
+                          (delete-file-recursively "src/vendor/zlib")
+                          #t))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'change-to-build-dir
+           (lambda _
+             (chdir "buildsys/autotools")
+             (patch-shebang "get_version.py")
+             #t)))))
+    (native-inputs
+     `(("autoconf" ,autoconf)
+       ("automake" ,automake)
+       ("libtool" ,libtool)
+       ("python" ,python)
+       ("pkg-config" ,pkg-config)
+       ("sdl2" ,sdl2)))
+    (inputs
+     `(("zlib" ,zlib)))
+    (home-page "https://github.com/libtcod/libtcod")
+    (synopsis "Library specifically designed for writing roguelikes")
+    (description
+     "libtcod is a free, fast, portable and uncomplicated API for roguelike
+developers providing an advanced true color console, input, and lots of other
+utilities frequently used in roguelikes.")
+    (license license:bsd-3)))
-- 
2.25.0


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

* [bug#38687] [PATCH] gnu: Add libtcod.
  2020-01-22 11:11   ` goodoldpaul
@ 2020-01-22 18:57     ` Marius Bakke
  2020-02-06 20:16       ` goodoldpaul
  0 siblings, 1 reply; 12+ messages in thread
From: Marius Bakke @ 2020-01-22 18:57 UTC (permalink / raw)
  To: goodoldpaul, Ludovic Courtès; +Cc: 38687

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

goodoldpaul@autistici.org writes:

> As far as I understood (I'm no C wizard) lodepng, glad and stb are 
> libraries which are designed to be dropped inside a source tree and 
> statically built in binaries. Right now I think those are secondary 
> problems and the main deal is how to effectively replace the included 
> utf8proc.
>
> I'm not sure if replacing every "#include ../../vendor/something.h" with 
> "#include <something.h>" ( by including a .patch file or with 
> substitute* ? Food for thought :D) and then placing something.h inside a 
> path known by the C linker is enough but it's the  I'm not really sure 
> where to go from here.

Something like

(substitute* (find-files "src/libtcod" "\\.(h|cpp)$")
  (("\\.\\./\\.\\./vendor/") ""))

Would make all the header paths relative, i.e. looked up in the compiler
search path.  In practice you might need to narrow down the substitution
so that e.g. vendor/utf8proc is preserved, if it turns out to be
difficult to unbundle.

There is currently no stb-truetype package, but it should be trivial to
add it (see gnu/packages/stb.scm).  Lodepng looks fairly easy too.  :-)

Good luck!

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

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

* [bug#38687] [PATCH] gnu: Add libtcod.
  2020-01-22 18:57     ` Marius Bakke
@ 2020-02-06 20:16       ` goodoldpaul
  2020-02-10 21:10         ` Marius Bakke
  0 siblings, 1 reply; 12+ messages in thread
From: goodoldpaul @ 2020-02-06 20:16 UTC (permalink / raw)
  To: Marius Bakke; +Cc: Ludovic Courtès, 38687

Hi Marius and Ludo,
I managed to remove all vendored libraries except for glad.h which seems 
to be some kind of generated glue code for loading OpenGL 
(https://github.com/Dav1dde/glad). In the next two patches I'm adding 
libtcod and it's dependency lodepng.

Guix lint is warning me that lodepng could be affected by 
CVE-2019-17178, but taking a look at 
https://nvd.nist.gov/vuln/detail/CVE-2019-17178 and 
https://nvd.nist.gov/vuln/search/results?adv_search=true&cpe_version=cpe%3a%2fa%3alodev%3alodepng%3a2019-09-28 
seems to indicate that lodepng should  be *not* vulnerable since 
28/09/2019, did I understand correctly?

Please don't hesitate and tell me if anything should done w.r.t. the 
CVE.

Thanks for your patience reviewing this,

Giacomo

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

* [bug#38687] [PATCH 1/2] gnu: Add lodepng.
  2019-12-20 12:37 [bug#38687] [PATCH] gnu: Add libtcod Giacomo Leidi
  2019-12-23 18:37 ` Ludovic Courtès
@ 2020-02-06 20:17 ` Giacomo Leidi
  2020-02-06 20:17   ` [bug#38687] [PATCH 2/2] gnu: Add libtcod Giacomo Leidi
  2020-02-10 21:14   ` [bug#38687] [PATCH 1/2] gnu: Add lodepng Marius Bakke
  1 sibling, 2 replies; 12+ messages in thread
From: Giacomo Leidi @ 2020-02-06 20:17 UTC (permalink / raw)
  To: 38687; +Cc: Giacomo Leidi

* gnu/packages/image.scm (lodepng): New variable.
---
 gnu/packages/image.scm | 58 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/gnu/packages/image.scm b/gnu/packages/image.scm
index 45055858b4..18a51a8773 100644
--- a/gnu/packages/image.scm
+++ b/gnu/packages/image.scm
@@ -23,6 +23,7 @@
 ;;; Copyright © 2018 Pierre-Antoine Rouby <contact@parouby.fr>
 ;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
 ;;; Copyright © 2018 Rutger Helling <rhelling@mykolab.com>
+;;; Copyright © 2020 Giacomo Leidi <goodoldpaul@autistici.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1841,3 +1842,60 @@ using only text tools.
 SNG is implemented by a compiler/decompiler called sng that
 losslessly translates between SNG and PNG.")
     (license license:zlib)))
+
+(define-public lodepng
+  ;; The project doesn't seem to use any
+  ;; kind of meaningful versioning scheme.
+  (let ((commit "5a0dba103893e6b8084be13945a826663917d00a")
+        (revision "1")
+        (version "0.0.0"))
+    (package
+      (name "lodepng")
+      (version (git-version version revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/lvandeve/lodepng")
+                      (commit commit)))
+                (sha256
+                 (base32
+                  "0nvlba82mf4n7xfc3rz2g9wwgnrxpjw64p5dsjmj2r06g5m4l38a"))
+                (file-name (git-file-name name version))))
+      (build-system gnu-build-system)
+      (arguments
+       '(#:phases
+         (modify-phases %standard-phases
+           (delete 'configure)
+           (replace 'build
+             (lambda _
+               (setenv "CXXFLAGS" "-fPIC")
+               (invoke "make" "lodepng.o")
+               (invoke "make" "lodepng_util.o")
+               (invoke "ar" "rv" "liblodepng.a" "lodepng.o" "lodepng_util.o")
+               (invoke "g++" "-fPIC" "-O3"
+                       "-o" "liblodepng.so"
+                       "-shared" "lodepng.o" "lodepng_util.o")
+               #t))
+           (replace 'check
+             (lambda _
+               (invoke "make" "unittest")
+               (invoke "./unittest")
+               #t))
+           (replace 'install
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let* ((out (assoc-ref outputs "out"))
+                      (doc (string-append out "/share/doc"))
+                      (lib (string-append out "/lib"))
+                      (include (string-append out "/include")))
+                 (install-file "lodepng.h" include)
+                 (install-file "lodepng_util.h" include)
+                 (install-file "liblodepng.a" lib)
+                 (install-file "liblodepng.so" lib)
+                 (install-file "README.md" doc)
+                 #t))))))
+      (home-page "https://lodev.org/lodepng/")
+      (synopsis "PNG encoder and decoder in C and C++, without dependencies")
+      (description "LodePNG is a PNG image decoder and encoder, all in one,
+no dependency or linkage required.  It's made for C (ISO C90), and has a C++
+wrapper with a more convenient interface on top.")
+      (license license:zlib))))
-- 
2.25.0

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

* [bug#38687] [PATCH 2/2] gnu: Add libtcod.
  2020-02-06 20:17 ` [bug#38687] [PATCH 1/2] gnu: Add lodepng Giacomo Leidi
@ 2020-02-06 20:17   ` Giacomo Leidi
  2020-02-10 21:19     ` Marius Bakke
  2020-02-10 21:14   ` [bug#38687] [PATCH 1/2] gnu: Add lodepng Marius Bakke
  1 sibling, 1 reply; 12+ messages in thread
From: Giacomo Leidi @ 2020-02-06 20:17 UTC (permalink / raw)
  To: 38687; +Cc: Giacomo Leidi

* gnu/packages/game-development.scm (libtcod): New variable.
---
 gnu/packages/game-development.scm | 76 +++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)

diff --git a/gnu/packages/game-development.scm b/gnu/packages/game-development.scm
index 6fa4fed74f..ce25620773 100644
--- a/gnu/packages/game-development.scm
+++ b/gnu/packages/game-development.scm
@@ -19,6 +19,7 @@
 ;;; Copyright © 2019 Jethro Cao <jethrocao@gmail.com>
 ;;; Copyright © 2020 Nicolas Goaziou <mail@nicolasgoaziou.fr>
 ;;; Copyright © 2020 Timotej Lazar <timotej.lazar@araneo.si>
+;;; Copyright © 2020 Giacomo Leidi <goodoldpaul@autistici.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -88,6 +89,7 @@
   #:use-module (gnu packages sphinx)
   #:use-module (gnu packages stb)
   #:use-module (gnu packages texinfo)
+  #:use-module (gnu packages textutils)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages video)
   #:use-module (gnu packages web)
@@ -2086,3 +2088,77 @@ computer games, 3D authoring tools and simulation tools.")
     (description "Chipmunk is a simple, lightweight, fast and portable 2D
 rigid body physics library written in C.")
     (license license:expat)))
+
+(define-public libtcod
+  (package
+    (name "libtcod")
+    (version "1.15.1")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/libtcod/libtcod.git")
+                    (commit version)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0pzr8ajmbqvh43ldjajx962xirj3rf8ayh344p6mqlrmb8gxrfr5"))
+              (modules '((guix build utils)))
+              (snippet '(begin
+                          (delete-file-recursively "src/vendor/utf8proc")
+                          (delete-file-recursively "src/vendor/zlib")
+                          (delete-file "src/vendor/stb_truetype.h")
+                          (delete-file "src/vendor/stb_sprintf.h")
+                          (delete-file "src/vendor/lodepng.cpp")
+                          (delete-file "src/vendor/lodepng.h")
+                          #t))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:configure-flags '("--with-gnu-ld"
+                           "LIBS=-lutf8proc -llodepng")
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'change-to-build-dir
+           (lambda _
+             (chdir "buildsys/autotools")
+             (patch-shebang "get_version.py")
+             #t))
+         (add-before 'bootstrap 'remove-hardcoded-vendor-paths
+           (lambda _
+             (substitute* "sources.am"
+                 (("\\.\\./\\.\\./src/vendor/lodepng\\.cpp \\\\\n") "")
+                 (("\\.\\./\\.\\./src/vendor/stb\\.c \\\\")
+                  "../../src/vendor/stb.c")
+                 (("\\.\\./\\.\\./src/vendor/utf8proc/utf8proc\\.c") ""))
+
+               (substitute* "../../src/libtcod/sys_sdl_img_png.cpp"
+                 (("\\.\\./vendor/") ""))
+
+               (substitute* '("../../src/libtcod/color/canvas.cpp"
+                              "../../src/libtcod/sys_sdl_img_png.cpp"
+                              "../../src/libtcod/tileset/truetype.cpp"
+                              "../../src/libtcod/tileset/tilesheet.cpp")
+                 (("\\.\\./\\.\\./vendor/") ""))
+
+               (substitute* "../../src/libtcod/console/printing.cpp"
+                 (("\\.\\./\\.\\./vendor/utf8proc/") ""))
+               #t)))))
+    (native-inputs
+     `(("autoconf" ,autoconf)
+       ("automake" ,automake)
+       ("libtool" ,libtool)
+       ("lodepng" ,lodepng)
+       ("python" ,python)
+       ("pkg-config" ,pkg-config)
+       ("sdl2" ,sdl2)
+       ("stb-sprintf" ,stb-sprintf)
+       ("stb-truetype" ,stb-truetype)))
+    (inputs
+     `(("utf8proc" ,utf8proc)
+       ("zlib" ,zlib)))
+    (home-page "https://github.com/libtcod/libtcod")
+    (synopsis "Library specifically designed for writing roguelikes")
+    (description
+     "libtcod is a free, fast, portable and uncomplicated API for roguelike
+developers providing an advanced true color console, input, and lots of other
+utilities frequently used in roguelikes.")
+    (license license:bsd-3)))
-- 
2.25.0

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

* [bug#38687] [PATCH] gnu: Add libtcod.
  2020-02-06 20:16       ` goodoldpaul
@ 2020-02-10 21:10         ` Marius Bakke
  0 siblings, 0 replies; 12+ messages in thread
From: Marius Bakke @ 2020-02-10 21:10 UTC (permalink / raw)
  To: goodoldpaul; +Cc: Ludovic Courtès, 38687

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

goodoldpaul@autistici.org writes:

> Hi Marius and Ludo,
> I managed to remove all vendored libraries except for glad.h which seems 
> to be some kind of generated glue code for loading OpenGL 
> (https://github.com/Dav1dde/glad). In the next two patches I'm adding 
> libtcod and it's dependency lodepng.

Excellent, thanks for taking the time to get rid of the bundled
dependencies.

> Guix lint is warning me that lodepng could be affected by 
> CVE-2019-17178, but taking a look at 
> https://nvd.nist.gov/vuln/detail/CVE-2019-17178 and 
> https://nvd.nist.gov/vuln/search/results?adv_search=true&cpe_version=cpe%3a%2fa%3alodev%3alodepng%3a2019-09-28 
> seems to indicate that lodepng should  be *not* vulnerable since 
> 28/09/2019, did I understand correctly?
>
> Please don't hesitate and tell me if anything should done w.r.t. the 
> CVE.

The CVE entry points to this commit:

https://github.com/FreeRDP/FreeRDP/commit/9fee4ae076b1ec97b97efb79ece08d1dab4df29a

Which changes something in FreeRDP's bundled version of LodePNG.  The
changes in question do not seem to be in upstream LodePNG:

https://github.com/lvandeve/lodepng/blob/master/lodepng.cpp#L1079

It's not clear to me whether this is a problem with LodePNG, or just
improper use of its API.  It looks like the latter: tree->lengths is
checked just below the changed line, so FreeRDP must be catching the
83 return code and keep going to get the memory leak described in the
CVE entry.

We can either ignore it using the 'lint-hidden-cve' property, and add a
comment that this version of LodePNG should not be used with FreeRDP; or
take the patch from FreeRDP, as it looks innocent enough.  I don't
really have a strong opinion here, nor sufficient expertise, so I'd be
happy if others could chime in.

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

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

* [bug#38687] [PATCH 1/2] gnu: Add lodepng.
  2020-02-06 20:17 ` [bug#38687] [PATCH 1/2] gnu: Add lodepng Giacomo Leidi
  2020-02-06 20:17   ` [bug#38687] [PATCH 2/2] gnu: Add libtcod Giacomo Leidi
@ 2020-02-10 21:14   ` Marius Bakke
  1 sibling, 0 replies; 12+ messages in thread
From: Marius Bakke @ 2020-02-10 21:14 UTC (permalink / raw)
  To: Giacomo Leidi, 38687

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

Giacomo Leidi <goodoldpaul@autistici.org> writes:

> * gnu/packages/image.scm (lodepng): New variable.

[...]

> +(define-public lodepng
> +  ;; The project doesn't seem to use any
> +  ;; kind of meaningful versioning scheme.
> +  (let ((commit "5a0dba103893e6b8084be13945a826663917d00a")
> +        (revision "1")
> +        (version "0.0.0"))

There is a LODEPNG_VERSION_STRING in lodepng.cpp, can you set the
"version" variable here to that?

> +    (package
> +      (name "lodepng")
> +      (version (git-version version revision commit))
> +      (source (origin
> +                (method git-fetch)
> +                (uri (git-reference
> +                      (url "https://github.com/lvandeve/lodepng")
> +                      (commit commit)))
> +                (sha256
> +                 (base32
> +                  "0nvlba82mf4n7xfc3rz2g9wwgnrxpjw64p5dsjmj2r06g5m4l38a"))
> +                (file-name (git-file-name name version))))
> +      (build-system gnu-build-system)
> +      (arguments
> +       '(#:phases
> +         (modify-phases %standard-phases
> +           (delete 'configure)
> +           (replace 'build
> +             (lambda _
> +               (setenv "CXXFLAGS" "-fPIC")
> +               (invoke "make" "lodepng.o")
> +               (invoke "make" "lodepng_util.o")
> +               (invoke "ar" "rv" "liblodepng.a" "lodepng.o" "lodepng_util.o")
> +               (invoke "g++" "-fPIC" "-O3"
> +                       "-o" "liblodepng.so"
> +                       "-shared" "lodepng.o" "lodepng_util.o")
> +               #t))
> +           (replace 'check
> +             (lambda _
> +               (invoke "make" "unittest")
> +               (invoke "./unittest")
> +               #t))
> +           (replace 'install
> +             (lambda* (#:key outputs #:allow-other-keys)
> +               (let* ((out (assoc-ref outputs "out"))
> +                      (doc (string-append out "/share/doc"))
> +                      (lib (string-append out "/lib"))
> +                      (include (string-append out "/include")))
> +                 (install-file "lodepng.h" include)
> +                 (install-file "lodepng_util.h" include)
> +                 (install-file "liblodepng.a" lib)

We try to avoid static libraries in Guix, so no need to install this
file.

Otherwise LGTM.

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

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

* [bug#38687] [PATCH 2/2] gnu: Add libtcod.
  2020-02-06 20:17   ` [bug#38687] [PATCH 2/2] gnu: Add libtcod Giacomo Leidi
@ 2020-02-10 21:19     ` Marius Bakke
  2020-02-16 21:53       ` [bug#38687] " goodoldpaul
  0 siblings, 1 reply; 12+ messages in thread
From: Marius Bakke @ 2020-02-10 21:19 UTC (permalink / raw)
  To: Giacomo Leidi, 38687

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

Giacomo Leidi <goodoldpaul@autistici.org> writes:

> * gnu/packages/game-development.scm (libtcod): New variable.

[...]

> +         (add-before 'bootstrap 'remove-hardcoded-vendor-paths
> +           (lambda _
> +             (substitute* "sources.am"
> +                 (("\\.\\./\\.\\./src/vendor/lodepng\\.cpp \\\\\n") "")
> +                 (("\\.\\./\\.\\./src/vendor/stb\\.c \\\\")
> +                  "../../src/vendor/stb.c")
> +                 (("\\.\\./\\.\\./src/vendor/utf8proc/utf8proc\\.c") ""))
> +
> +               (substitute* "../../src/libtcod/sys_sdl_img_png.cpp"
> +                 (("\\.\\./vendor/") ""))
> +
> +               (substitute* '("../../src/libtcod/color/canvas.cpp"
> +                              "../../src/libtcod/sys_sdl_img_png.cpp"
> +                              "../../src/libtcod/tileset/truetype.cpp"
> +                              "../../src/libtcod/tileset/tilesheet.cpp")
> +                 (("\\.\\./\\.\\./vendor/") ""))
> +
> +               (substitute* "../../src/libtcod/console/printing.cpp"
> +                 (("\\.\\./\\.\\./vendor/utf8proc/") ""))
> +               #t)))))

Can you move the contents of this phase to the 'snippet' instead?  Since
they are related to the unbundling, and makes 'guix build --source
libtcod' easier to work with.

> +    (native-inputs
> +     `(("autoconf" ,autoconf)
> +       ("automake" ,automake)
> +       ("libtool" ,libtool)
> +       ("lodepng" ,lodepng)
> +       ("python" ,python)
> +       ("pkg-config" ,pkg-config)
> +       ("sdl2" ,sdl2)

sdl2 and lodepng should probably be regular inputs.

> +       ("stb-sprintf" ,stb-sprintf)
> +       ("stb-truetype" ,stb-truetype)))
> +    (inputs
> +     `(("utf8proc" ,utf8proc)
> +       ("zlib" ,zlib)))
> +    (home-page "https://github.com/libtcod/libtcod")
> +    (synopsis "Library specifically designed for writing roguelikes")
> +    (description
> +     "libtcod is a free, fast, portable and uncomplicated API for roguelike

s/free//  (everything in Guix is free software)

Otherwise LGTM!

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

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

* [bug#38687] gnu: Add libtcod.
  2020-02-10 21:19     ` Marius Bakke
@ 2020-02-16 21:53       ` goodoldpaul
  2020-02-24 20:56         ` bug#38687: " Marius Bakke
  0 siblings, 1 reply; 12+ messages in thread
From: goodoldpaul @ 2020-02-16 21:53 UTC (permalink / raw)
  To: Marius Bakke; +Cc: 38687

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

Hi Marius,
I updated the patches and upgrading lodepng led the warning from guix 
lint disappear so I guess it should be safe now. I'm sending an updated 
version.

Thank you again for your patience,

Giacomo

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-Add-lodepng.patch --]
[-- Type: text/x-diff; name=0001-gnu-Add-lodepng.patch, Size: 3247 bytes --]

From 4adeb293def87d4c19985b57b56cd3e39ccb3859 Mon Sep 17 00:00:00 2001
From: Giacomo Leidi <goodoldpaul@autistici.org>
Date: Sun, 16 Feb 2020 22:21:32 +0100
Subject: [PATCH 1/2] gnu: Add lodepng.

* gnu/packages/image.scm (lodepng): New variable.
---
 gnu/packages/image.scm | 54 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/gnu/packages/image.scm b/gnu/packages/image.scm
index f9da1e9e89..e14d5607fc 100644
--- a/gnu/packages/image.scm
+++ b/gnu/packages/image.scm
@@ -23,6 +23,7 @@
 ;;; Copyright © 2018 Pierre-Antoine Rouby <contact@parouby.fr>
 ;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
 ;;; Copyright © 2018 Rutger Helling <rhelling@mykolab.com>
+;;; Copyright © 2020 Giacomo Leidi <goodoldpaul@autistici.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1844,3 +1845,56 @@ using only text tools.
 SNG is implemented by a compiler/decompiler called sng that
 losslessly translates between SNG and PNG.")
     (license license:zlib)))
+
+(define-public lodepng
+  (let ((commit "48e5364ef48ec2408f44c727657ac1b6703185f8")
+        (revision "1")
+        (version "20200215"))
+    (package
+      (name "lodepng")
+      (version (git-version version revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/lvandeve/lodepng")
+                      (commit commit)))
+                (sha256
+                 (base32
+                  "1a1x8ag2scanzb2066jm9hg2y9kaa3wmpgmz10l1x9bkpik612lw"))
+                (file-name (git-file-name name version))))
+      (build-system gnu-build-system)
+      (arguments
+       '(#:phases
+         (modify-phases %standard-phases
+           (delete 'configure)
+           (replace 'build
+             (lambda _
+               (setenv "CXXFLAGS" "-fPIC")
+               (invoke "make" "lodepng.o")
+               (invoke "make" "lodepng_util.o")
+               (invoke "g++" "-fPIC" "-O3"
+                       "-o" "liblodepng.so"
+                       "-shared" "lodepng.o" "lodepng_util.o")
+               #t))
+           (replace 'check
+             (lambda _
+               (invoke "make" "unittest")
+               (invoke "./unittest")
+               #t))
+           (replace 'install
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let* ((out (assoc-ref outputs "out"))
+                      (doc (string-append out "/share/doc"))
+                      (lib (string-append out "/lib"))
+                      (include (string-append out "/include")))
+                 (install-file "lodepng.h" include)
+                 (install-file "lodepng_util.h" include)
+                 (install-file "liblodepng.so" lib)
+                 (install-file "README.md" doc)
+                 #t))))))
+      (home-page "https://lodev.org/lodepng/")
+      (synopsis "PNG encoder and decoder in C and C++, without dependencies")
+      (description "LodePNG is a PNG image decoder and encoder, all in one,
+no dependency or linkage required.  It's made for C (ISO C90), and has a C++
+wrapper with a more convenient interface on top.")
+      (license license:zlib))))
-- 
2.25.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-gnu-Add-libtcod.patch --]
[-- Type: text/x-diff; name=0002-gnu-Add-libtcod.patch, Size: 4539 bytes --]

From c88a0c12855c2ec82b5653ebe8137bc1245aa369 Mon Sep 17 00:00:00 2001
From: Giacomo Leidi <goodoldpaul@autistici.org>
Date: Sun, 16 Feb 2020 22:42:42 +0100
Subject: [PATCH 2/2] gnu: Add libtcod.

* gnu/packages/game-development.scm (libtcod): New variable.
---
 gnu/packages/game-development.scm | 74 +++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)

diff --git a/gnu/packages/game-development.scm b/gnu/packages/game-development.scm
index 6fa4fed74f..7241c0f8c7 100644
--- a/gnu/packages/game-development.scm
+++ b/gnu/packages/game-development.scm
@@ -19,6 +19,7 @@
 ;;; Copyright © 2019 Jethro Cao <jethrocao@gmail.com>
 ;;; Copyright © 2020 Nicolas Goaziou <mail@nicolasgoaziou.fr>
 ;;; Copyright © 2020 Timotej Lazar <timotej.lazar@araneo.si>
+;;; Copyright © 2020 Giacomo Leidi <goodoldpaul@autistici.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -88,6 +89,7 @@
   #:use-module (gnu packages sphinx)
   #:use-module (gnu packages stb)
   #:use-module (gnu packages texinfo)
+  #:use-module (gnu packages textutils)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages video)
   #:use-module (gnu packages web)
@@ -2086,3 +2088,75 @@ computer games, 3D authoring tools and simulation tools.")
     (description "Chipmunk is a simple, lightweight, fast and portable 2D
 rigid body physics library written in C.")
     (license license:expat)))
+
+(define-public libtcod
+  (package
+    (name "libtcod")
+    (version "1.15.1")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/libtcod/libtcod.git")
+                    (commit version)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0pzr8ajmbqvh43ldjajx962xirj3rf8ayh344p6mqlrmb8gxrfr5"))
+              (modules '((guix build utils)))
+              (snippet '(begin
+                          (delete-file-recursively "src/vendor/utf8proc")
+                          (delete-file-recursively "src/vendor/zlib")
+                          (delete-file "src/vendor/stb_truetype.h")
+                          (delete-file "src/vendor/stb_sprintf.h")
+                          (delete-file "src/vendor/lodepng.cpp")
+                          (delete-file "src/vendor/lodepng.h")
+
+                          (substitute* "buildsys/autotools/sources.am"
+                            (("\\.\\./\\.\\./src/vendor/lodepng\\.cpp \\\\\n") "")
+                            (("\\.\\./\\.\\./src/vendor/stb\\.c \\\\")
+                             "../../src/vendor/stb.c")
+                            (("\\.\\./\\.\\./src/vendor/utf8proc/utf8proc\\.c") ""))
+
+                          (substitute* "src/libtcod/sys_sdl_img_png.cpp"
+                            (("\\.\\./vendor/") ""))
+
+                          (substitute* '("src/libtcod/color/canvas.cpp"
+                                         "src/libtcod/sys_sdl_img_png.cpp"
+                                         "src/libtcod/tileset/truetype.cpp"
+                                         "src/libtcod/tileset/tilesheet.cpp")
+                            (("\\.\\./\\.\\./vendor/") ""))
+
+                          (substitute* "src/libtcod/console/printing.cpp"
+                            (("\\.\\./\\.\\./vendor/utf8proc/") ""))
+                          #t))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:configure-flags '("--with-gnu-ld"
+                           "LIBS=-lutf8proc -llodepng")
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'change-to-build-dir
+           (lambda _
+             (chdir "buildsys/autotools")
+             (patch-shebang "get_version.py")
+             #t)))))
+    (native-inputs
+     `(("autoconf" ,autoconf)
+       ("automake" ,automake)
+       ("libtool" ,libtool)
+       ("python" ,python)
+       ("pkg-config" ,pkg-config)
+       ("stb-sprintf" ,stb-sprintf)
+       ("stb-truetype" ,stb-truetype)))
+    (inputs
+     `(("lodepng" ,lodepng)
+       ("sdl2" ,sdl2)
+       ("utf8proc" ,utf8proc)
+       ("zlib" ,zlib)))
+    (home-page "https://github.com/libtcod/libtcod")
+    (synopsis "Library specifically designed for writing roguelikes")
+    (description
+     "libtcod is a fast, portable and uncomplicated API for roguelike
+developers providing an advanced true color console, input, and lots of other
+utilities frequently used in roguelikes.")
+    (license license:bsd-3)))
-- 
2.25.0


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

* bug#38687: gnu: Add libtcod.
  2020-02-16 21:53       ` [bug#38687] " goodoldpaul
@ 2020-02-24 20:56         ` Marius Bakke
  0 siblings, 0 replies; 12+ messages in thread
From: Marius Bakke @ 2020-02-24 20:56 UTC (permalink / raw)
  To: goodoldpaul; +Cc: 38687-done

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

goodoldpaul@autistici.org writes:

> Hi Marius,
> I updated the patches and upgrading lodepng led the warning from guix 
> lint disappear so I guess it should be safe now. I'm sending an updated 
> version.

Thanks!  I applied both patches, and added a comment about the lodepng
version number for our future selves.  :-)

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

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

end of thread, other threads:[~2020-02-24 20:57 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-20 12:37 [bug#38687] [PATCH] gnu: Add libtcod Giacomo Leidi
2019-12-23 18:37 ` Ludovic Courtès
2020-01-22 11:11   ` goodoldpaul
2020-01-22 18:57     ` Marius Bakke
2020-02-06 20:16       ` goodoldpaul
2020-02-10 21:10         ` Marius Bakke
2020-02-06 20:17 ` [bug#38687] [PATCH 1/2] gnu: Add lodepng Giacomo Leidi
2020-02-06 20:17   ` [bug#38687] [PATCH 2/2] gnu: Add libtcod Giacomo Leidi
2020-02-10 21:19     ` Marius Bakke
2020-02-16 21:53       ` [bug#38687] " goodoldpaul
2020-02-24 20:56         ` bug#38687: " Marius Bakke
2020-02-10 21:14   ` [bug#38687] [PATCH 1/2] gnu: Add lodepng Marius Bakke

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).