Patchwork gnu: Add libjxr.

login
register
mail settings
Submitter Kei Yamashita
Date Oct. 30, 2016, 3:31 p.m.
Message ID <87ins94zwf.fsf@openmailbox.org>
Download mbox | patch
Permalink /patch/17022/
State New
Headers show

Comments

Kei Yamashita - Oct. 30, 2016, 3:31 p.m.
ludo@gnu.org (Ludovic Courtès) writes:

> Kei Kebreau <kei@openmailbox.org> skribis:
>
>> ludo@gnu.org (Ludovic Courtès) writes:
>>
>>> Leo Famulari <leo@famulari.name> skribis:
>>>
>>>> On Sat, Oct 22, 2016 at 04:33:18AM -0400, Kei Kebreau wrote:
>>>
>>> [...]
>>>
>>>>> >> diff --git a/gnu/packages/patches/libjxr-use-cmake.patch
>>>>> >> b/gnu/packages/patches/libjxr-use-cmake.patch
>>>>> >> new file mode 100644
>>>>> >> index 0000000..cb5919e
>>>>> >> --- /dev/null
>>>>> >> +++ b/gnu/packages/patches/libjxr-use-cmake.patch
>>>>> >> @@ -0,0 +1,143 @@
>>>>> >> +Description: Prefer a cmake based build system
>>>>> >> +Author: Mathieu Malaterre <malat@debian.org>
>>>>> >> +Forwarded: https://jxrlib.codeplex.com/discussions/440294
>>>>> >
>>>>> > Why doesn't upstream's build system work?
>>>>> 
>>>>> Upstream's build system simply doesn't have configuration or
>>>>> installation targets in the provided Makefile. Using the cmake patch
>>>>> makes the definition cleaner at the cost of relying on outside work
>>>>> [1]. If this is not acceptable, I can see about writing manual
>>>>> replacement phases to the best of my ability.
>>>>> 
>>>>> [1]: https://jxrlib.codeplex.com/discussions/440294
>>>>
>>>> Hm, not an ideal situation.
>>>>
>>>> If Debian is using this patch, we should link to it's source on Debian's
>>>> site instead of this message board. I don't know enough about CMake to
>>>> judge the patch but I'd be more comfortable if Debian was using it.
>>>>
>>>> What do others think?
>>>
>>> Regarding the choice between writing our own installation phase in
>>> Scheme and using this CMake thing instead, I think we should choose the
>>> most concise approach (in terms of lines of code).
>>>
>>> If the winner here is the CMake patch, then indeed, we should take the
>>> patch from Debian rather than from a message board (and include
>>> provenance information in the patch, as you wrote.)
>>>
>>> That said, I suspect an ‘install’ phase in Scheme would be more concise
>>> than this new CMakeLists.txt (134 lines).
>>>
>>> Kei: WDYT?
>>>
>>
>> I have been working on writing our own installation phase, and it looks
>> like it will be more concise.
>
> Cool, thanks!
>
>> However, the patches need to be in DOS format to apply. The patch
>> doesn't seem to carry these line returns, which leads me to believe
>> that a standard git configuration won't accept them. Is there way
>> around this?
>
> But that’s unrelated to removing the CMakeLists.txt patch and adding
> your own install phase, right?  :-)
>
> From the description I’m not sure exactly what the problem is, but
> perhaps the ‘--binary’ option of ‘patch’ can help?  You can specify it
> in ‘patch-flags’:
>
>   https://www.gnu.org/software/guix/manual/html_node/origin-Reference.html
>
> Ludo’.

I ended up using the '--binary' flag, but the libjxr patches still need
to be converted to DOS format to function properly. The current
procedure to get this patch running is:

$ git am 0001-gnu-Add-libjxr.patch
[whitespace complaints]
$ sed -i -e 's/\r*$/\r/' gnu/packages/patches/libjxr-fix-*
$ ./pre-inst-env guix build libjxr

The DOS formatting issue also keeps me from using 'substitute*' to patch
the Makefile to build both a shared and static version of the library.
The current package only builds a static version. Everything seems to
link properly for now, but I don't know if that will be required in the
future.
From 316a4f7a676bf6b8cc7a8f8795b74fa0ebab3e36 Mon Sep 17 00:00:00 2001
From: Kei Kebreau <kei@openmailbox.org>
Date: Sun, 30 Oct 2016 11:05:30 -0400
Subject: [PATCH] gnu: Add libjxr.

* gnu/packages/images.scm (libjxr): New variable.
* gnu/packages/patches/libjxr-fix-function-signature.patch: New file.
* gnu/packages/patches/libjxr-fix-typos.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register patches.
---
 gnu/local.mk                                       |  2 +
 gnu/packages/image.scm                             | 54 ++++++++++++++++++++++
 .../patches/libjxr-fix-function-signature.patch    | 16 +++++++
 gnu/packages/patches/libjxr-fix-typos.patch        | 29 ++++++++++++
 4 files changed, 101 insertions(+)
 create mode 100644 gnu/packages/patches/libjxr-fix-function-signature.patch
 create mode 100644 gnu/packages/patches/libjxr-fix-typos.patch
Ludovic Courtès - Nov. 3, 2016, 1:36 p.m.
Kei Kebreau <kei@openmailbox.org> skribis:

> From 316a4f7a676bf6b8cc7a8f8795b74fa0ebab3e36 Mon Sep 17 00:00:00 2001
> From: Kei Kebreau <kei@openmailbox.org>
> Date: Sun, 30 Oct 2016 11:05:30 -0400
> Subject: [PATCH] gnu: Add libjxr.
>
> * gnu/packages/images.scm (libjxr): New variable.
> * gnu/packages/patches/libjxr-fix-function-signature.patch: New file.
> * gnu/packages/patches/libjxr-fix-typos.patch: New file.
> * gnu/local.mk (dist_patch_DATA): Register patches.

[...]

> +(define-public libjxr
> +  (package
> +    (name "libjxr")
> +    (version "1.1")
> +    (source (origin
> +              (method url-fetch)
> +              (uri (string-append "mirror://debian/pool/main/j/jxrlib/jxrlib_"
> +                                  version ".orig.tar.gz"))

Please add a comment saying why we’re using the Debian-provided source.

> +                   (replace 'install
> +                     (lambda* (#:key outputs #:allow-other-keys)

… and a comment saying why we roll our own ‘install’ phase.

OK with these changes, thanks!

Ludo’.

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index a64b7ec..db9d436 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -639,6 +639,8 @@  dist_patch_DATA =						\
   %D%/packages/patches/libdrm-symbol-check.patch		\
   %D%/packages/patches/libevent-dns-tests.patch			\
   %D%/packages/patches/libextractor-ffmpeg-3.patch		\
+  %D%/packages/patches/libjxr-fix-function-signature.patch	\
+  %D%/packages/patches/libjxr-fix-typos.patch			\
   %D%/packages/patches/liboop-mips64-deplibs-fix.patch		\
   %D%/packages/patches/libotr-test-auth-fix.patch		\
   %D%/packages/patches/liblxqt-include.patch			\
diff --git a/gnu/packages/image.scm b/gnu/packages/image.scm
index 873a7f2..b4d0765 100644
--- a/gnu/packages/image.scm
+++ b/gnu/packages/image.scm
@@ -11,6 +11,7 @@ 
 ;;; Copyright © 2016 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2016 Eric Bavier <bavier@member.fsf.org>
 ;;; Copyright © 2016 Arun Isaac <arunisaac@systemreboot.net>
+;;; Copyright © 2016 Kei Kebreau <kei@openmailbox.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -129,6 +130,59 @@  image files in PBMPLUS PPM/PGM, GIF, BMP, and Targa file formats.")
             (sha256 (base32
                      "1cz0dy05mgxqdgjf52p54yxpyy95rgl30cnazdrfmw7hfca9n0h0"))))))
 
+(define-public libjxr
+  (package
+    (name "libjxr")
+    (version "1.1")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "mirror://debian/pool/main/j/jxrlib/jxrlib_"
+                                  version ".orig.tar.gz"))
+              (sha256
+               (base32
+                "00w3f3cmjsm3fiaxq5mxskmp5rl3mki8psrf9y8s1vqbg237na67"))
+              (patch-flags '("-p1" "--binary"))
+              (patches (search-patches "libjxr-fix-function-signature.patch"
+                                       "libjxr-fix-typos.patch"))))
+    (build-system gnu-build-system)
+    (arguments '(#:make-flags '("CC=gcc")
+                 #:tests? #f ; no check target
+                 #:phases
+                 (modify-phases %standard-phases
+                   (delete 'configure) ; no configure script
+                   (replace 'install
+                     (lambda* (#:key outputs #:allow-other-keys)
+                       (let* ((out (assoc-ref outputs "out"))
+                              (bin (string-append out "/bin"))
+                              (lib (string-append out "/lib"))
+                              (include (string-append out "/include/jxrlib")))
+                         (for-each (lambda (file)
+                                     (install-file file include)
+                                     (delete-file file))
+                                   (append
+                                    '("jxrgluelib/JXRGlue.h"
+                                      "jxrgluelib/JXRMeta.h"
+                                      "jxrtestlib/JXRTest.h"
+                                      "image/sys/windowsmediaphoto.h")
+                                    (find-files "common/include" "\\.h$")))
+                         (for-each (lambda (file)
+                                     (install-file file lib)
+                                     (delete-file file))
+                                   (find-files "." "\\.a$"))
+                         (for-each (lambda (file)
+                                     (install-file file bin)
+                                     (delete-file file))
+                                   '("JxrDecApp" "JxrEncApp")))
+                       #t)))))
+    (synopsis "Implementation of the JPEG XR standard")
+    (description "JPEG XR is an approved ISO/IEC International standard (its
+official designation is ISO/IEC 29199-2). This library is an implementation of that standard.")
+    (license
+     (license:non-copyleft
+      "file://Makefile"
+      "See the header of the Makefile in the distribution."))
+    (home-page "https://jxrlib.codeplex.com/")))
+
 (define-public jpegoptim
   (package
    (name "jpegoptim")
diff --git a/gnu/packages/patches/libjxr-fix-function-signature.patch b/gnu/packages/patches/libjxr-fix-function-signature.patch
new file mode 100644
index 0000000..32f5f64
--- /dev/null
+++ b/gnu/packages/patches/libjxr-fix-function-signature.patch
@@ -0,0 +1,16 @@ 
+Description: Fix function signature

+Author: Mathieu Malaterre <malat@debian.org>

+Origin: upstream, https://jxrlib.codeplex.com/SourceControl/changeset/04cf339385b8196f98025b43a366a0790deac994

+Bug-Debian: http://bugs.debian.org/748590

+

+--- jxrlib-1.1.orig/image/decode/JXRTranscode.c

++++ jxrlib-1.1/image/decode/JXRTranscode.c

+@@ -47,7 +47,7 @@ EXTERN_C Void FreeCodingContextDec(CWMIm

+ EXTERN_C Int StrEncInit(CWMImageStrCodec *);

+ EXTERN_C Void StrIOEncTerm(CWMImageStrCodec *);

+ EXTERN_C Void FreeCodingContextEnc(CWMImageStrCodec *);

+-EXTERN_C Void encodeMB(CWMImageStrCodec *, Int, Int);

++EXTERN_C Int encodeMB(CWMImageStrCodec *, Int, Int);

+ EXTERN_C Int  writeIndexTableNull(CWMImageStrCodec *);

+ EXTERN_C Void writePacketHeader(BitIOInfo *, U8, U8);

+ 

diff --git a/gnu/packages/patches/libjxr-fix-typos.patch b/gnu/packages/patches/libjxr-fix-typos.patch
new file mode 100644
index 0000000..819db34
--- /dev/null
+++ b/gnu/packages/patches/libjxr-fix-typos.patch
@@ -0,0 +1,29 @@ 
+Description: Fix typos and remove some warnings

+Author: Mathieu Malaterre <malat@debian.org>

+

+Index: jxrlib-1.1/jxrencoderdecoder/JxrEncApp.c

+===================================================================

+--- jxrlib-1.1.orig/jxrencoderdecoder/JxrEncApp.c

++++ jxrlib-1.1/jxrencoderdecoder/JxrEncApp.c

+@@ -578,7 +578,7 @@ main(int argc, char* argv[])

+ 

+     //================================

+     Call(PKCreateCodecFactory(&pCodecFactory, WMP_SDK_VERSION));

+-    Call(pCodecFactory->CreateCodec(&IID_PKImageWmpEncode, &pEncoder));

++    Call(pCodecFactory->CreateCodec(&IID_PKImageWmpEncode, (void**)&pEncoder));

+ 

+     //----------------------------------------------------------------

+     Call(PKCreateTestFactory(&pTestFactory, WMP_SDK_VERSION));

+Index: jxrlib-1.1/jxrgluelib/JXRMeta.h

+===================================================================

+--- jxrlib-1.1.orig/jxrgluelib/JXRMeta.h

++++ jxrlib-1.1/jxrgluelib/JXRMeta.h

+@@ -34,7 +34,7 @@

+ 

+ #ifndef UNREFERENCED_PARAMETER

+ #define UNREFERENCED_PARAMETER(P) { (P) = (P); }

+-#endif UNREFERENCED_PARAMETER

++#endif /*UNREFERENCED_PARAMETER*/

+ 

+ //================================================================

+ // Container