Subject: bug#26009: libpng-apng

From: Kei Kebreau <[email-masked]>
Date: Wed, 15 Mar 2017 09:46:57 -0400

ng0 <[email-masked]> writes:

> Kei Kebreau transcribed 1.9K bytes:
>> [email-masked] (Ludovic Courtès) writes:
>> 
>> > Kei Kebreau <[email-masked]> skribis:
>> >
>> >> Those tips helped quite a bit! Libpng-apng now builds reproducibly. Now
>> >> the only issues are the CVE patch name not beginning with
>> >> "libpng-apng"
>> >
>> > You can ignore this warning from ‘guix lint’.
>> >
>> >> and the sourceforge URL using "*.sourceforge.net/project" instead of
>> >> "*.sourceforge.net/projects" (this detail leads to a 404 Error while
>> >> linting).
>> >
>> > Can’t you change the URL as done in
>> > 998ac26a1e4f025ac75147c3497453615bb32d40?
>> 
>> Yes, but libpng is already using a "mirror://sourceforge" URL. Also, the
>> URL turned out not to be the actual issue. The real issue is that
>> version 1.6.25 of libpng isn't present at either of the given source
>> locations. I guess Guix has been using a local copy from my store or a
>> cache tarball to build libpng-apng from source!
>
> Can you share your additions to my patch? I'd like to apply last fixes
> and send a new version.
> When I packaged it, mirror:// did not work (or at least I assumed so,
> this was the second reason for my mirror addition patch), so I used the
> full url.
>

Sure thing! See the attached file.

>> > HTH!
>> > Ludo’.

From 76e4bec9f8313adc6a78d3ae571ccea489c97848 Mon Sep 17 00:00:00 2001
From: ng0 <[email-masked]>
Date: Tue, 10 Jan 2017 20:49:30 +0000
Subject: [PATCH] gnu: Add libpng-apng.
To: [email-masked]

* gnu/packages/image.scm (libpng-apng): New variable.

Signed-off-by: Kei Kebreau <[email-masked]>
---
 gnu/packages/image.scm | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/gnu/packages/image.scm b/gnu/packages/image.scm
index 53ed69a84..f348a61c9 100644
--- a/gnu/packages/image.scm
+++ b/gnu/packages/image.scm
@@ -14,6 +14,7 @@
 ;;; Copyright © 2016 Eric Bavier <[email-masked]>
 ;;; Copyright © 2016 Arun Isaac <[email-masked]>
 ;;; Copyright © 2016 Kei Kebreau <[email-masked]>
+;;; Copyright © 2017 ng0 <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -98,6 +99,57 @@ library.  It supports almost all PNG features and is extensible.")
         (inherit (package-source libpng))
         (patches (search-patches "libpng-CVE-2016-10087.patch"))))))
 
+(define-public libpng-apng
+  (package
+    (inherit libpng)
+    (replacement #f) ;libpng's replacement doesn't apply here
+    (name "libpng-apng")
+    (version (package-version libpng))
+    (source
+     (origin
+       (inherit (package-source libpng))
+       (patches (search-patches "libpng-CVE-2016-10087.patch"))))
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'patch-apng
+           (lambda* (#:key inputs #:allow-other-keys)
+             (define (apply-patch file)
+               (zero? (system* "patch" "-p1" "--force"
+                               "--input" file)))
+             (let ((apng.gz (assoc-ref inputs "apng")))
+               (format #t "Applying APNG patch '~a'...~%"
+                       apng.gz)
+               (system (string-append "gunzip < " apng.gz " > the-patch"))
+               (and (apply-patch "the-patch")
+                    (for-each apply-patch
+                              (find-files "\\.patch"))))
+           #t))
+         (add-before 'configure 'no-checks
+           (lambda _
+             (substitute* "Makefile.in"
+               (("^scripts/symbols.chk") "")
+               (("check: scripts/symbols.chk") ""))
+             (zero? (system* "libtool"))
+             #t)))))
+    (inputs
+     `(("apng" ,(origin
+                  (method url-fetch)
+                  (uri
+                   (string-append "mirror://sourceforge/libpng-apng/libpng16/"
+                                  version "/libpng-" version "-apng.patch.gz"))
+                  (sha256
+                   (base32
+                    "026r0gbkf6d6v54wca02cdxln8sj4m2c1yk62sj2aasv2ki2ffh5"))))))
+    (native-inputs
+     `(("libtool" ,libtool)))
+    (synopsis "APNG patch for libpng")
+    (description
+     "APNG (Animated Portable Network Graphics) is an unofficial
+extension of the APNG (Portable Network Graphics) format.
+APNG patch provides APNG support to libpng.")
+    (home-page "https://sourceforge.net/projects/libpng-apng/")))
+
 (define-public libpng-1.2
   (package
     (inherit libpng)
-- 
2.12.0