Subject: [bug#47274] Linphone Packages

From: Maxim Cournoyer <[email-masked]>
Date: Sun, 28 Mar 2021 00:01:33 -0400

Hi!

Raghav Gururajan <[email-masked]> writes:

> [39. text/x-patch; 0038-gnu-Add-build.patch]...

I had an old package of build from 2020 with a more fleshed out
description, so I've pushed that version instead as commit 65719505b8.

> From c6e27b74e1f90985513167b52cd0e0f9cc54aa73 Mon Sep 17 00:00:00 2001
> From: Raghav Gururajan <[email-masked]>
> Date: Thu, 18 Mar 2021 13:57:53 -0400
> Subject: [PATCH 39/53] gnu: Add libcutl.
>
> * gnu/packages/codesynthesis.scm (libcutl): New variable.
> ---
>  gnu/packages/codesynthesis.scm | 44 ++++++++++++++++++++++++++++++++++
>  1 file changed, 44 insertions(+)
>
> diff --git a/gnu/packages/codesynthesis.scm b/gnu/packages/codesynthesis.scm
> index 7cb9a427a5..a264692c19 100644
> --- a/gnu/packages/codesynthesis.scm
> +++ b/gnu/packages/codesynthesis.scm
> @@ -19,6 +19,8 @@
>
>  (define-module (gnu packages codesynthesis)
>    #:use-module (gnu packages)
> +  #:use-module (gnu packages pkg-config)

pkg-config turned out not to be needed.

> +  #:use-module (gnu packages xml)
>    #:use-module ((guix licenses) #:prefix license:)
>    #:use-module (guix packages)
>    #:use-module (guix download)
> @@ -53,3 +55,45 @@
>  implemented on top of GNU make.")
>      (home-page "https://www.codesynthesis.com/projects/libxsd-frontend/")
>      (license license:gpl2+)))
> +
> +(define-public libcutl
> +  (package
> +    (name "libcutl")
> +    (version "1.10.0")
> +    (source
> +     (origin
> +       (method url-fetch)
> +       (uri (string-append "https://www.codesynthesis.com/download/libcutl/"
> +                           (version-major+minor version)
> +                           "/libcutl-" version ".tar.bz2"))
> +       (sha256
> +        (base32 "070j2x02m4gm1fn7gnymrkbdxflgzxwl7m96aryv8wp3f3366l8j"))
> +       (modules '((guix build utils)))
> +       (snippet
> +        `(begin
> +           ;; Remove bundled sources.
> +           (with-directory-excursion "cutl/details"
> +             (for-each delete-file-recursively
> +                       ;; FIXME: Boost_RegEx isn't being detected.
> +                       (list
> +                        ;; "boost"
> +                        "expat")))
> +           #t))))

I removed the trailing #t.

> +    (build-system gnu-build-system)
> +    (arguments
> +     `(#:configure-flags
> +       (list
> +        "--disable-static"
> +        ;; "--with-external-boost"
> +        "--with-external-expat")))
> +    (native-inputs
> +     `(("pkg-config" ,pkg-config)))

Removed the native-inputs field.

> +    (inputs
> +     `(;; ("boost" ,boost)
> +       ("expat" ,expat)))
> +    (synopsis "C++ utility library")
> +    (description "@package{libcutl} is a C++ utility library.  It contains a
> +collection of generic and independent components such as meta-programming tests,
> +smart pointers, containers, compiler building blocks, etc.")
> +    (home-page "https://www.codesynthesis.com/projects/libcutl/")
> +    (license license:expat)))
> --
> 2.31.0

And pushed as ae479f1834.

> From e3abe6dbfcbd6bfb352694fd5efcb9db9da6dce6 Mon Sep 17 00:00:00 2001
> From: Raghav Gururajan <[email-masked]>
> Date: Thu, 18 Mar 2021 14:00:13 -0400
> Subject: [PATCH 40/53] gnu: Add libxsd-frontend.
>
> * gnu/packages/codesynthesis.scm (libxsd-frontend): New variable.
> ---
>  gnu/packages/codesynthesis.scm | 54 ++++++++++++++++++++++++++++++++++
>  1 file changed, 54 insertions(+)
>
> diff --git a/gnu/packages/codesynthesis.scm b/gnu/packages/codesynthesis.scm
> index a264692c19..f24fb760de 100644
> --- a/gnu/packages/codesynthesis.scm
> +++ b/gnu/packages/codesynthesis.scm
> @@ -97,3 +97,57 @@ collection of generic and independent components such as meta-programming tests,
>  smart pointers, containers, compiler building blocks, etc.")
>      (home-page "https://www.codesynthesis.com/projects/libcutl/")
>      (license license:expat)))
> +
> +(define-public libxsd-frontend
> +  (package
> +    (name "libxsd-frontend")
> +    (version "2.0.0")
> +    (source
> +     (origin
> +       (method url-fetch)
> +       (uri (string-append "https://www.codesynthesis.com/download/"
> +                           "libxsd-frontend/" (version-major+minor version)
> +                           "/libxsd-frontend-" version ".tar.bz2"))
> +       (sha256
> +        (base32 "1nmzchsvwvn66jpmcx18anzyl1a3l309x1ld4zllrg37ijc31fim"))))
> +    (build-system gnu-build-system)
> +    (arguments
> +     `(#:test-target "test"
> +       #:imported-modules
> +       ((guix build copy-build-system)
> +        ,@%gnu-build-system-modules)
> +       #:modules
> +       (((guix build copy-build-system)
> +         #:prefix copy:)
> +        (guix build gnu-build-system)
> +        (guix build utils))
> +       #:phases
> +       (modify-phases %standard-phases
> +         (add-after 'unpack 'patch
> +           (lambda _
> +             (substitute* (find-files "." "\\.make$")
> +               (("build-0\\.3")
> +                (string-append (assoc-ref %build-inputs "build") "/include/build-0.3")))
> +             #t))

I could turn this patch phase into a make flag:

--8<---------------cut here---------------start------------->8---
        #:modules (((guix build copy-build-system) #:prefix copy:)
                   (guix build gnu-build-system)
                   (guix build utils))
+       #:make-flags (list (string-append "--include-dir="
+                                         (assoc-ref %build-inputs "build")
+                                         "/include/"))
        #:phases
        (modify-phases %standard-phases
-         (add-after 'unpack 'patch
-           (lambda _
-             (substitute* (find-files "." "\\.make$")
-               (("build-0\\.3")
-                (string-append (assoc-ref %build-inputs "build")
-                               "/include/build-0.3")))))
          (delete 'configure)
          (replace 'install
--8<---------------cut here---------------end--------------->8---

> +         (delete 'configure)
> +         (replace 'install
> +           (lambda args
> +             (apply (assoc-ref copy:%standard-phases 'install)
> +                    #:install-plan
> +                    '(("xsd-frontend" "include/xsd-frontend"
> +                       #:include-regexp ("\\.?xx$"))
> +                      ("xsd-frontend" "lib"
> +                       #:include-regexp ("\\.so$")))
> +                    args))))))
> +    (native-inputs
> +     `(("build" ,build)
> +       ("pkg-config" ,pkg-config)))

Removed pkg-config, which was not needed.

> +    (inputs
> +     `(("libcutl" ,libcutl)
> +       ("libxerces-c" ,xerces-c)))
> +    (synopsis "XSD Front-end")
> +    (description "@package{libxsd-frontend} is a compiler frontend
> for the W3C

Replaced @package by @code, as the former is not valid Texinfo markup.

> +XML Schema definition language.  It includes a parser, semantic graph types and
> +a traversal mechanism.")
> +    (home-page "https://www.codesynthesis.com/projects/libxsd-frontend/")
> +    (license license:gpl2+)))
> --
> 2.31.0

And pushed as 111004cc58.

>
> From 2c1e262e549b928a624513e2c91b059b88b8e822 Mon Sep 17 00:00:00 2001
> From: Raghav Gururajan <[email-masked]>
> Date: Thu, 18 Mar 2021 14:33:34 -0400
> Subject: [PATCH 41/53] gnu: Add cli.
>
> * gnu/packages/codesynthesis.scm (cli): New variable.
> ---
>  gnu/packages/codesynthesis.scm | 45 ++++++++++++++++++++++++++++++++++
>  1 file changed, 45 insertions(+)
>
> diff --git a/gnu/packages/codesynthesis.scm b/gnu/packages/codesynthesis.scm
> index f24fb760de..b70e53cd7c 100644
> --- a/gnu/packages/codesynthesis.scm
> +++ b/gnu/packages/codesynthesis.scm
> @@ -151,3 +151,48 @@ XML Schema definition language.  It includes a parser, semantic graph types and
>  a traversal mechanism.")
>      (home-page "https://www.codesynthesis.com/projects/libxsd-frontend/")
>      (license license:gpl2+)))
> +
> +(define-public cli
> +  (package
> +    (name "cli")
> +    (version "1.1.0")
> +    (source
> +     (origin
> +       (method url-fetch)
> +       (uri (string-append "https://www.codesynthesis.com/download/"
> +                           "cli/" (version-major+minor version)
> +                           "/cli-" version ".tar.bz2"))
> +       (sha256
> +        (base32 "0bg0nsai2q4h3mldpnj0jz4iy4svs0bcfvmq0v0c9cdyknny606g"))))
> +    (build-system gnu-build-system)
> +    (arguments
> +     `(#:test-target "test"
> +       #:make-flags
> +       (list
> +        (string-append "install_prefix=" (assoc-ref %outputs "out")))
> +       #:phases
> +       (modify-phases %standard-phases
> +         (add-after 'unpack 'patch
> +           (lambda _
> +             (substitute* (find-files "." "\\.make$")
> +               (("build-0\\.3")
> +                (string-append (assoc-ref %build-inputs "build")
> +                               "/include/build-0.3")))

I used the same --include-dir make flag trick here.

> +             (substitute* (find-files "." "\\.?xx$")
> +               (("add \\(typeid \\(type\\), \\*this\\);")
> +                "traverser_map<B>::add (typeid (type), *this);")
> +               (("iterate_and_dispatch \\(s\\.names_begin \\(\\), s\\.names_end \\(\\), d\\);")
> +                "edge_dispatcher::iterate_and_dispatch (s.names_begin (), s.names_end (), d);"))
> +             #t))

Dropped the #t, added a comment and added the prefix to the default
regexp group bound to 'all', like this:

+             ;; Add the namespace prefix, to avoid errors such as "error:
+             ;; ‘iterate_and_dispatch’ was not declared in this scope".
+             (substitute* (find-files "." "\\.?xx$")
+               (("add \\(typeid \\(type\\), \\*this\\);" all)
+                (string-append "traverser_map<B>::" all))
+               (("iterate_and_dispatch \\(s\\.names_begin.*;" all)
+                (string-append "edge_dispatcher::" all)))))

> +         (delete 'configure))))
> +    (native-inputs
> +     `(("build" ,build)
> +       ("pkg-config" ,pkg-config)))

Removed pkg-config, which was not needed.

> +    (inputs
> +     `(("libcutl" ,libcutl)))
> +    (synopsis "Command Line Interface (CLI) definition language")
> +    (description "@package{cli} is a domain-specific language (DSL)
> for defining

s/@package/@code/, as for the previous package.

> +command line interfaces of C++ programs.  It allows you to describe the options
> +that your program supports, their types, default values, and documentation.")
> +    (home-page "https://codesynthesis.com/projects/cli/")
> +    (license license:expat)))
> --
> 2.31.0

And pushed as commit f649a0a557.

>
> From d46ed1d4bd1d85ad5c89d2c713f387714f152358 Mon Sep 17 00:00:00 2001
> From: Raghav Gururajan <[email-masked]>
> Date: Thu, 18 Mar 2021 15:51:18 -0400
> Subject: [PATCH 42/53] gnu: Add xsd.
>
> * gnu/packages/codesynthesis.scm (xsd): New variable.
> ---
>  gnu/packages/codesynthesis.scm | 48 ++++++++++++++++++++++++++++++++++
>  1 file changed, 48 insertions(+)
>
> diff --git a/gnu/packages/codesynthesis.scm b/gnu/packages/codesynthesis.scm
> index b70e53cd7c..58f4fa9301 100644
> --- a/gnu/packages/codesynthesis.scm
> +++ b/gnu/packages/codesynthesis.scm
> @@ -19,6 +19,7 @@
>
>  (define-module (gnu packages codesynthesis)
>    #:use-module (gnu packages)
> +  #:use-module (gnu packages onc-rpc)
>    #:use-module (gnu packages pkg-config)
>    #:use-module (gnu packages xml)
>    #:use-module ((guix licenses) #:prefix license:)
> @@ -196,3 +197,50 @@ command line interfaces of C++ programs.  It allows you to describe the options
>  that your program supports, their types, default values, and documentation.")
>      (home-page "https://codesynthesis.com/projects/cli/")
>      (license license:expat)))
> +
> +(define-public xsd
> +  (package
> +    (name "xsd")
> +    (version "4.0.0")
> +    (source
> +     (origin
> +       (method url-fetch)
> +       (uri (string-append "https://www.codesynthesis.com/download/"
> +                           "xsd/" (version-major+minor version)
> +                           "/xsd-" version ".tar.bz2"))
> +       (sha256
> +        (base32 "1hi9ppxd34np8ydv1h0vgc2qpdmgcd1cdzgk30aidv670xjg91fx"))))
> +    (build-system gnu-build-system)
> +    (arguments
> +     `(#:test-target "test"
> +       #:make-flags
> +       (list
> +        (string-append "install_prefix=" (assoc-ref %outputs "out")))
> +       #:phases
> +       (modify-phases %standard-phases
> +         (add-after 'unpack 'patch
> +           (lambda _
> +             (substitute* (find-files "." "\\.make$")
> +               (("build-0\\.3")
> +                (string-append (assoc-ref %build-inputs "build")
> +                               "/include/build-0.3")))
> +             #t))

I added a doc output to hold the multi-megabyte documentation and
examples and used the same make flag trick to allow finding build-0.3
files:

+    (outputs '("out" "doc"))            ;3.8 MiB of doc and examples
+    (arguments
+     `(#:test-target "test"
+       #:make-flags (list (string-append "--include-dir="
+                                         (assoc-ref %build-inputs "build")
+                                         "/include/")
+                          (string-append "install_prefix="
+                                         (assoc-ref %outputs "out")))
+       #:phases (modify-phases %standard-phases
+                  (add-after 'install 'move-doc
+                    (lambda* (#:key outputs #:allow-other-keys)
+                      (let ((out (assoc-ref outputs "out"))
+                            (doc (assoc-ref outputs "doc")))
+                        (mkdir-p (string-append doc "/share/doc"))
+                        (rename-file (string-append out "/share/doc/xsd")
+                                     (string-append doc "/share/doc/xsd-"
+                                                    ,version)))))
+                  (delete 'configure))))

> +         (delete 'configure))))
> +    (native-inputs
> +     `(("build" ,build)
> +       ("cli" ,cli)
> +       ("pkg-config" ,pkg-config)))

Dropped pkg-config here as well.

> +    (inputs
> +     `(("libcutl" ,libcutl)
> +       ("libnsl" ,libnsl)
> +       ("libxsd-frontend" ,libxsd-frontend)))
> +    (propagated-inputs
> +     `(("libexpat" ,expat)
> +       ("libxerces-c" ,xerces-c)))

I removed expat from propagated-inputs, as the xsd generated code
default to using xerces-c.  Someone wanting to use expat could add it
manually.  I've also added a comment like this, as it was not clear to
me initially why propagation was useful:

    (propagated-inputs
     ;; The code XSD generates requires the following library at run time;
     ;; propagate it for convenience.
     `(("xerces-c" ,xerces-c)))

> +    (synopsis "XML Schema to C++ translator")
> +    (description "@package{xsd} is a W3C XML Schema to C++ translator.  It
> +generates vocabulary-specific, statically-typed C++ mappings/bindings from XML
> +Schema definitions.  It supports two C++ mappings: in-memory C++/Tree and
> +event-driven C++/Parser.")
> +    (home-page "https://codesynthesis.com/projects/xsd/")
> +    (license license:gpl2+)))

For this package, I also had an unfinished version locally; the
description was slightly more accurate, with an extra comment for the
license:

+    (synopsis "XML Data Binding for C++")
+    (description "CodeSynthesis XSD (also known as libxsd or xsdcxx) is an XML
+Schema to C++ data binding compiler.  Provided with an XML instance
+specification (XML Schema), it generates C++ classes that represent the given
+vocabulary as well as XML parsing and serialization code.  The data stored in
+XML can then be accessed using types and functions that semantically
+correspond to an application domain rather than dealing with the intricacies
+of reading and writing XML.")
+    (home-page "https://codesynthesis.com/projects/xsd/")
+    ;; Exceptions are made to allow using the generated source files as well
+    ;; as the libxsd library in free software projects whose license is
+    ;; incompatible with the GPL v2.  Refer to the file named FLOSSE for the
+    ;; details.

So I've used those parts and pushed as commit 510e24f973.

Phew.  I've now reached the core bits of the review, to be continued.

Thanks :-)

Maxim