Subject: Re: [PATCH core-updates 2/4] gnu: cmake-minimal: Build with a minimal variant of cURL.
From: Marius Bakke <[email-masked]>
To: Jakub Kądziołka <[email-masked]>, [email-masked]
Date: Wed, 22 Jan 2020 19:46:00 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Jakub Kądziołka <[email-masked]> writes:

>> This is necessary to avoid a circular dependency in the next commit.
>> 
>> * gnu/packages/curl.scm (curl-minimal): New public variable.
>> * gnu/packages/cmake.scm (cmake-minimal)[inputs]: Change from CURL to 
>> CURL-MINIMAL.
>> (cmake)[inputs]: Do the opposite.
>
> Is there a reason this curl-minimal couldn't also be used for
> git-minimal? This would keep the updater working for rhash.

Good catch.  I did this initially, but found it simpler to not use
git-fetch for RHash.  I don't like inserting these 'magic' packages
around the graph.  It also means we need two graft two cURLs instead of
one.

But I don't feel strongly about it, and keeping the updater working is a
good argument.  So I was about to revert back, but then found out RHash
is available on sourceforge too:

https://sourceforge.net/projects/rhash/

Much better!

Since you made me reconsider, I also found a better solution for 2/4: we
can lose CMakes runtime dependency on 'curl-minimal' as well by using it
only once, to build libjpeg-turbo:

diff --git a/gnu/packages/cmake.scm b/gnu/packages/cmake.scm
index d053935a86..fcc6642280 100644
--- a/gnu/packages/cmake.scm
+++ b/gnu/packages/cmake.scm
@@ -152,7 +152,7 @@
              (apply invoke "./configure" configure-flags))))))
     (native-inputs
      `(("bzip2" ,bzip2)
-       ("curl" ,curl-minimal)
+       ("curl" ,curl)
        ("expat" ,expat)
        ("file" ,file)
        ("libarchive" ,libarchive)
@@ -235,6 +235,18 @@ and workspaces that can be used in the compiler environment of your choice.")
     (search-paths
      (package-native-search-paths cmake-minimal))))
 
+;; The purpose of this package is to solve a circular dependency between
+;; packages that use cmake-build-system and CMakes own dependencies.
+(define-public cmake-minimal-bootstrap
+  (package
+    (inherit cmake-minimal)
+    (name "cmake-minimal-bootstrap")
+    (native-inputs
+     `(;; cURL depends on ghostscript (via groff and OpenLDAP), which depends on
+       ;; 'cmake-build-system' through libtiff and ultimately libjpeg-turbo.
+       ("curl" ,curl-minimal)
+       ,@(alist-delete "curl" (package-native-inputs cmake-minimal))))))
+
 (define-public emacs-cmake-mode
   (package
     (inherit cmake)
diff --git a/gnu/packages/image.scm b/gnu/packages/image.scm
index 38efe61780..1b86f700e4 100644
--- a/gnu/packages/image.scm
+++ b/gnu/packages/image.scm
@@ -46,6 +46,7 @@
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages boost)
   #:use-module (gnu packages check)
+  #:use-module (gnu packages cmake)
   #:use-module (gnu packages curl)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages documentation)
@@ -1505,8 +1506,13 @@ is hereby granted."))))
     (native-inputs
      `(("nasm" ,nasm)))
     (arguments
-     '(#:configure-flags '("-DCMAKE_INSTALL_LIBDIR:PATH=lib"
-                           "-DENABLE_STATIC=0")))
+     `(#:configure-flags '("-DCMAKE_INSTALL_LIBDIR:PATH=lib"
+                           "-DENABLE_STATIC=0")
+       ,@(if (%current-target-system)
+             '()
+             ;; Use a special "bootstrap" CMake for the native build to work
+             ;; around a circular dependency between CMake and this package.
+             `(#:cmake ,cmake-minimal-bootstrap))))
     (home-page "https://libjpeg-turbo.org/")
     (synopsis "SIMD-accelerated JPEG image handling library")
     (description "libjpeg-turbo is a JPEG image codec that accelerates baseline

Thanks a lot for the feedback.  Will push this shortly.  :-)