Subject: [bug#47274] Linphone Packages

From: Maxim Cournoyer <[email-masked]>
Date: Wed, 24 Mar 2021 21:55:30 -0400

Hi,

Raghav Gururajan <[email-masked]> writes:

> * gnu/packages/linphone.scm (bctoolbox) [arguments]<#:phases>['patch-source]: Modify.
> [inputs]: Add libdecaf.
> ---
>  gnu/packages/linphone.scm | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/gnu/packages/linphone.scm b/gnu/packages/linphone.scm
> index 9d54b1b874..1a83105334 100644
> --- a/gnu/packages/linphone.scm
> +++ b/gnu/packages/linphone.scm
> @@ -25,6 +25,7 @@
>    #:use-module (gnu packages audio)
>    #:use-module (gnu packages base)
>    #:use-module (gnu packages compression)
> +  #:use-module (gnu packages crypto)
>    #:use-module (gnu packages documentation)
>    #:use-module (gnu packages gettext)
>    #:use-module (gnu packages gl)
> @@ -151,7 +152,16 @@ administering, and running unit tests in C.")
>         #:phases
>         (modify-phases %standard-phases
>           (add-after 'unpack 'patch-source
> -           (lambda _
> +           (lambda* (#:key inputs #:allow-other-keys)
> +             ;; Fix decaf dependency.
> +             (let* ((decaf (assoc-ref inputs "decaf")))
> +               (substitute* (find-files "." "CMakeLists.txt")
> +                 (("find_package\\(Decaf CONFIG\\)")
> +                  "set(DECAF_FOUND 1)")
> +                 (("\\$\\{DECAF_INCLUDE_DIRS\\}")
> +                  (string-append decaf "/include/decaf"))
> +                 (("\\$\\{DECAF_TARGETNAME\\}")
> +                  "decaf")))
>               ;; Disable failing tests.
>               (substitute* "tester/port.c"
>                 (("[ \t]*TEST_NO_TAG\\(\"Addrinfo sort\", bctbx_addrinfo_sort_test\\)")
> @@ -164,6 +174,7 @@ administering, and running unit tests in C.")
>               #t)))))
>      (inputs
>       `(("bcunit" ,bcunit)
> +       ("decaf" ,libdecaf)
>         ("mbedtls" ,mbedtls-apache)))
>      (synopsis "Belledonne Communications Tool Box")
>      (description "BcToolBox is an utilities library used by Belledonne

I've squashed the 3 bctoolbox commits together, adjusted the commit
message as below:

gnu: bctoolbox: Update to 4.4.34 and enable libdecaf, tests.

* gnu/packages/linphone.scm (bctoolbox)[version]: Update to 4.4.34.
[source]: Switch to git repository.
[arguments]: Remove tests? argument, enabling tests.
[phases]{patch-source}: New phase.
{check}: Override phase.
[inputs]: Add libdecaf.
[license]: Update to GPLv3+.

Signed-off-by: Maxim Cournoyer <[email-masked]>

1 file changed, 33 insertions(+), 10 deletions(-)
gnu/packages/linphone.scm | 43 +++++++++++++++++++++++++++++++++----------

modified   gnu/packages/linphone.scm
@@ -25,6 +25,7 @@
   #:use-module (gnu packages audio)
   #:use-module (gnu packages base)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages crypto)
   #:use-module (gnu packages documentation)
   #:use-module (gnu packages gettext)
   #:use-module (gnu packages gl)
@@ -127,28 +128,50 @@ writing, administering, and running unit tests in C.")
 (define-public bctoolbox
   (package
     (name "bctoolbox")
-    (version "0.6.0")
+    (version "4.4.34")
     (source
      (origin
-       (method url-fetch)
-       (uri
-        (string-append "https://www.linphone.org/releases/sources/" name
-                       "/" name "-" version ".tar.gz"))
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://gitlab.linphone.org/BC/public/bctoolbox.git")
+             (commit version)))

Used their HTTPS GitLab git here as its browsable;

+       (file-name (git-file-name name version))
        (sha256
-        (base32 "1a1i70pb4hhnykkwyhhc7fv67q556l8kprny8xzgfqpj1nby2ms6"))))
+        (base32 "0bfswwvvdshaahg4jd2j10f0sci8809s4khajd0m6b059zwc7y25"))))
     (build-system cmake-build-system)
     (arguments
-     '(#:tests? #f                      ; No test target
-       #:configure-flags
-       (list "-DENABLE_STATIC=OFF")))   ; Not required
+     `(#:configure-flags '("-DENABLE_STATIC=OFF")
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'patch-source
+           (lambda* (#:key inputs #:allow-other-keys)
+             ;; Fix decaf dependency (see:
+             ;; https://gitlab.linphone.org/BC/public/bctoolbox/-/issues/3).

Added an issue upstream for the problem worked around here.

+             (let* ((decaf (assoc-ref inputs "decaf")))
+               (substitute* (find-files "." "CMakeLists.txt")
+                 (("find_package\\(Decaf CONFIG\\)")
+                  "set(DECAF_FOUND 1)")
+                 (("\\$\\{DECAF_INCLUDE_DIRS\\}")
+                  (string-append decaf "/include/decaf"))
+                 (("\\$\\{DECAF_TARGETNAME\\}")
+                  "decaf")))
+             ;; The following test relies on networking; disable it.

Mentioned this had to do with networking, which is inherent to the
absence of networking in the Guix build container (otherwise it'd had
been good to report the test failure upstream).

+             (substitute* "tester/port.c"
+               (("[ \t]*TEST_NO_TAG.*bctbx_addrinfo_sort_test\\)")

Used .* to shorten the line below 80 chars ;-)

+                ""))))
+         (replace 'check
+           (lambda _
+             (with-directory-excursion "tester"
+               (invoke "./bctoolbox_tester")))))))
     (inputs
      `(("bcunit" ,bcunit)
+       ("decaf" ,libdecaf)
        ("mbedtls" ,mbedtls-apache)))
     (synopsis "Belledonne Communications Tool Box")
     (description "BcToolBox is an utilities library used by Belledonne
 Communications software like belle-sip, mediastreamer2 and linphone.")
     (home-page "https://gitlab.linphone.org/BC/public/bctoolbox")
-    (license license:gpl2+)))
+    (license license:gpl3+)))
 
Can't be pushed yet as it breaks stuff.

Maxim